Completed
Branch FET/your-org-country-input (f14f74)
by
unknown
36:41 queued 16s
created
admin_pages/general_settings/General_Settings_Admin_Page.core.php 1 patch
Indentation   +1328 added lines, -1328 removed lines patch added patch discarded remove patch
@@ -21,1343 +21,1343 @@
 block discarded – undo
21 21
 {
22 22
 
23 23
 
24
-    /**
25
-     * _question_group
26
-     * holds the specific question group object for the question group details screen
27
-     *
28
-     * @var object
29
-     */
30
-    protected $_question_group;
31
-
32
-
33
-    /**
34
-     * Initialize basic properties.
35
-     */
36
-    protected function _init_page_props()
37
-    {
38
-        $this->page_slug = GEN_SET_PG_SLUG;
39
-        $this->page_label = GEN_SET_LABEL;
40
-        $this->_admin_base_url = GEN_SET_ADMIN_URL;
41
-        $this->_admin_base_path = GEN_SET_ADMIN;
42
-    }
43
-
44
-
45
-    /**
46
-     * Set ajax hooks
47
-     */
48
-    protected function _ajax_hooks()
49
-    {
50
-        add_action('wp_ajax_espresso_display_country_settings', array($this, 'display_country_settings'));
51
-        add_action('wp_ajax_espresso_display_country_states', array($this, 'display_country_states'));
52
-        add_action('wp_ajax_espresso_delete_state', array($this, 'delete_state'), 10, 3);
53
-        add_action('wp_ajax_espresso_add_new_state', array($this, 'add_new_state'));
54
-    }
55
-
56
-
57
-    /**
58
-     * More page properties initialization.
59
-     */
60
-    protected function _define_page_props()
61
-    {
62
-        $this->_admin_page_title = GEN_SET_LABEL;
63
-        $this->_labels = array(
64
-            'publishbox' => __('Update Settings', 'event_espresso'),
65
-        );
66
-    }
67
-
68
-
69
-    /**
70
-     * Set page routes property.
71
-     */
72
-    protected function _set_page_routes()
73
-    {
74
-        $this->_page_routes = array(
75
-
76
-            'critical_pages'                => array(
77
-                'func'       => '_espresso_page_settings',
78
-                'capability' => 'manage_options',
79
-            ),
80
-            'update_espresso_page_settings' => array(
81
-                'func'       => '_update_espresso_page_settings',
82
-                'capability' => 'manage_options',
83
-                'noheader'   => true,
84
-            ),
85
-            'default'                       => array(
86
-                'func'       => '_your_organization_settings',
87
-                'capability' => 'manage_options',
88
-            ),
89
-
90
-            'update_your_organization_settings' => array(
91
-                'func'       => '_update_your_organization_settings',
92
-                'capability' => 'manage_options',
93
-                'noheader'   => true,
94
-            ),
95
-
96
-            'admin_option_settings' => array(
97
-                'func'       => '_admin_option_settings',
98
-                'capability' => 'manage_options',
99
-            ),
100
-
101
-            'update_admin_option_settings' => array(
102
-                'func'       => '_update_admin_option_settings',
103
-                'capability' => 'manage_options',
104
-                'noheader'   => true,
105
-            ),
106
-
107
-            'country_settings' => array(
108
-                'func'       => '_country_settings',
109
-                'capability' => 'manage_options',
110
-            ),
111
-
112
-            'update_country_settings' => array(
113
-                'func'       => '_update_country_settings',
114
-                'capability' => 'manage_options',
115
-                'noheader'   => true,
116
-            ),
117
-
118
-            'display_country_settings' => array(
119
-                'func'       => 'display_country_settings',
120
-                'capability' => 'manage_options',
121
-                'noheader'   => true,
122
-            ),
123
-
124
-            'add_new_state' => array(
125
-                'func'       => 'add_new_state',
126
-                'capability' => 'manage_options',
127
-                'noheader'   => true,
128
-            ),
129
-
130
-            'delete_state' => array(
131
-                'func'       => 'delete_state',
132
-                'capability' => 'manage_options',
133
-                'noheader'   => true,
134
-            ),
135
-            'privacy_settings' => array(
136
-                'func' => 'privacySettings',
137
-                'capability' => 'manage_options',
138
-            ),
139
-            'update_privacy_settings' => array(
140
-                'func' => 'updatePrivacySettings',
141
-                'capability' => 'manage_options',
142
-                'noheader' => true,
143
-                'headers_sent_route' => 'privacy_settings'
144
-            )
145
-        );
146
-    }
147
-
148
-
149
-    /**
150
-     * Set page configuration property
151
-     */
152
-    protected function _set_page_config()
153
-    {
154
-        $this->_page_config = array(
155
-            'critical_pages'        => array(
156
-                'nav'           => array(
157
-                    'label' => __('Critical Pages', 'event_espresso'),
158
-                    'order' => 50,
159
-                ),
160
-                'metaboxes'     => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')),
161
-                'help_tabs'     => array(
162
-                    'general_settings_critical_pages_help_tab' => array(
163
-                        'title'    => __('Critical Pages', 'event_espresso'),
164
-                        'filename' => 'general_settings_critical_pages',
165
-                    ),
166
-                ),
167
-                'help_tour'     => array('Critical_Pages_Help_Tour'),
168
-                'require_nonce' => false,
169
-            ),
170
-            'default'               => array(
171
-                'nav'           => array(
172
-                    'label' => __('Your Organization', 'event_espresso'),
173
-                    'order' => 20,
174
-                ),
175
-                'help_tabs'     => array(
176
-                    'general_settings_your_organization_help_tab' => array(
177
-                        'title'    => __('Your Organization', 'event_espresso'),
178
-                        'filename' => 'general_settings_your_organization',
179
-                    ),
180
-                ),
181
-                'help_tour'     => array('Your_Organization_Help_Tour'),
182
-                'metaboxes'     => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')),
183
-                'require_nonce' => false,
184
-            ),
185
-            'admin_option_settings' => array(
186
-                'nav'           => array(
187
-                    'label' => __('Admin Options', 'event_espresso'),
188
-                    'order' => 60,
189
-                ),
190
-                'metaboxes'     => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')),
191
-                'help_tabs'     => array(
192
-                    'general_settings_admin_options_help_tab' => array(
193
-                        'title'    => __('Admin Options', 'event_espresso'),
194
-                        'filename' => 'general_settings_admin_options',
195
-                    ),
196
-                ),
197
-                'help_tour'     => array('Admin_Options_Help_Tour'),
198
-                'require_nonce' => false,
199
-            ),
200
-            'country_settings'      => array(
201
-                'nav'           => array(
202
-                    'label' => __('Countries', 'event_espresso'),
203
-                    'order' => 70,
204
-                ),
205
-                'help_tabs'     => array(
206
-                    'general_settings_countries_help_tab' => array(
207
-                        'title'    => __('Countries', 'event_espresso'),
208
-                        'filename' => 'general_settings_countries',
209
-                    ),
210
-                ),
211
-                'help_tour'     => array('Countries_Help_Tour'),
212
-                'require_nonce' => false,
213
-            ),
214
-            'privacy_settings' => array(
215
-                'nav' => array(
216
-                    'label' => esc_html__('Privacy', 'event_espresso'),
217
-                    'order' => 80
218
-                ),
219
-                'metaboxes'     => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')),
220
-                'require_nonce' => false
221
-            )
222
-        );
223
-    }
224
-
225
-
226
-    protected function _add_screen_options()
227
-    {
228
-    }
229
-
230
-    protected function _add_feature_pointers()
231
-    {
232
-    }
233
-
234
-
235
-    /**
236
-     * Enqueue global scripts and styles for all routes in the General Settings Admin Pages.
237
-     */
238
-    public function load_scripts_styles()
239
-    {
240
-        // styles
241
-        wp_enqueue_style('espresso-ui-theme');
242
-        // scripts
243
-        wp_enqueue_script('ee_admin_js');
244
-    }
245
-
246
-
247
-    /**
248
-     * Execute logic running on `admin_init`
249
-     */
250
-    public function admin_init()
251
-    {
252
-        EE_Registry::$i18n_js_strings['invalid_server_response'] = __(
253
-            '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.',
254
-            'event_espresso'
255
-        );
256
-        EE_Registry::$i18n_js_strings['error_occurred'] = __(
257
-            'An error occurred! Please refresh the page and try again.',
258
-            'event_espresso'
259
-        );
260
-        EE_Registry::$i18n_js_strings['confirm_delete_state'] = __(
261
-            'Are you sure you want to delete this State / Province?',
262
-            'event_espresso'
263
-        );
264
-        $protocol = isset($_SERVER['HTTPS']) ? 'https://' : 'http://';
265
-        EE_Registry::$i18n_js_strings['ajax_url'] = admin_url(
266
-            'admin-ajax.php?page=espresso_general_settings',
267
-            $protocol
268
-        );
269
-    }
270
-
271
-    public function admin_notices()
272
-    {
273
-    }
274
-
275
-    public function admin_footer_scripts()
276
-    {
277
-    }
278
-
279
-
280
-    /**
281
-     * Enqueue scripts and styles for the default route.
282
-     */
283
-    public function load_scripts_styles_default()
284
-    {
285
-        // styles
286
-        wp_enqueue_style('thickbox');
287
-        // scripts
288
-        wp_enqueue_script('media-upload');
289
-        wp_enqueue_script('thickbox');
290
-        wp_register_script(
291
-            'organization_settings',
292
-            GEN_SET_ASSETS_URL . 'your_organization_settings.js',
293
-            array('jquery', 'media-upload', 'thickbox'),
294
-            EVENT_ESPRESSO_VERSION,
295
-            true
296
-        );
297
-        wp_register_style('organization-css', GEN_SET_ASSETS_URL . 'organization.css', array(), EVENT_ESPRESSO_VERSION);
298
-        wp_enqueue_script('organization_settings');
299
-        wp_enqueue_style('organization-css');
300
-        $confirm_image_delete = array(
301
-            'text' => __(
302
-                'Do you really want to delete this image? Please remember to save your settings to complete the removal.',
303
-                'event_espresso'
304
-            ),
305
-        );
306
-        wp_localize_script('organization_settings', 'confirm_image_delete', $confirm_image_delete);
307
-    }
308
-
309
-
310
-    /**
311
-     * Enqueue scripts and styles for the country settings route.
312
-     */
313
-    public function load_scripts_styles_country_settings()
314
-    {
315
-        // scripts
316
-        wp_register_script(
317
-            'gen_settings_countries',
318
-            GEN_SET_ASSETS_URL . 'gen_settings_countries.js',
319
-            array('ee_admin_js'),
320
-            EVENT_ESPRESSO_VERSION,
321
-            true
322
-        );
323
-        wp_register_style('organization-css', GEN_SET_ASSETS_URL . 'organization.css', array(), EVENT_ESPRESSO_VERSION);
324
-        wp_enqueue_script('gen_settings_countries');
325
-        wp_enqueue_style('organization-css');
326
-    }
327
-
328
-
329
-    /*************        Espresso Pages        *************/
330
-    /**
331
-     * _espresso_page_settings
332
-     *
333
-     * @throws \EE_Error
334
-     * @throws DomainException
335
-     * @throws DomainException
336
-     * @throws InvalidDataTypeException
337
-     * @throws InvalidArgumentException
338
-     */
339
-    protected function _espresso_page_settings()
340
-    {
341
-        // Check to make sure all of the main pages are setup properly,
342
-        // if not create the default pages and display an admin notice
343
-        EEH_Activation::verify_default_pages_exist();
344
-        $this->_transient_garbage_collection();
345
-        $this->_template_args['values'] = $this->_yes_no_values;
346
-        $this->_template_args['reg_page_id'] = isset(EE_Registry::instance()->CFG->core->reg_page_id)
347
-            ? EE_Registry::instance()->CFG->core->reg_page_id
348
-            : null;
349
-        $this->_template_args['reg_page_obj'] = isset(EE_Registry::instance()->CFG->core->reg_page_id)
350
-            ? get_page(EE_Registry::instance()->CFG->core->reg_page_id)
351
-            : false;
352
-        $this->_template_args['txn_page_id'] = isset(EE_Registry::instance()->CFG->core->txn_page_id)
353
-            ? EE_Registry::instance()->CFG->core->txn_page_id
354
-            : null;
355
-        $this->_template_args['txn_page_obj'] = isset(EE_Registry::instance()->CFG->core->txn_page_id)
356
-            ? get_page(EE_Registry::instance()->CFG->core->txn_page_id)
357
-            : false;
358
-        $this->_template_args['thank_you_page_id'] = isset(EE_Registry::instance()->CFG->core->thank_you_page_id)
359
-            ? EE_Registry::instance()->CFG->core->thank_you_page_id
360
-            : null;
361
-        $this->_template_args['thank_you_page_obj'] = isset(EE_Registry::instance()->CFG->core->thank_you_page_id)
362
-            ? get_page(EE_Registry::instance()->CFG->core->thank_you_page_id)
363
-            : false;
364
-        $this->_template_args['cancel_page_id'] = isset(EE_Registry::instance()->CFG->core->cancel_page_id)
365
-            ? EE_Registry::instance()->CFG->core->cancel_page_id
366
-            : null;
367
-        $this->_template_args['cancel_page_obj'] = isset(EE_Registry::instance()->CFG->core->cancel_page_id)
368
-            ? get_page(EE_Registry::instance()->CFG->core->cancel_page_id)
369
-            : false;
370
-        $this->_set_add_edit_form_tags('update_espresso_page_settings');
371
-        $this->_set_publish_post_box_vars(null, false, false, null, false);
372
-        $this->_template_args['admin_page_content'] = EEH_Template::display_template(
373
-            GEN_SET_TEMPLATE_PATH . 'espresso_page_settings.template.php',
374
-            $this->_template_args,
375
-            true
376
-        );
377
-        $this->display_admin_page_with_sidebar();
378
-    }
379
-
380
-
381
-    /**
382
-     * Handler for updating espresso page settings.
383
-     *
384
-     * @throws EE_Error
385
-     */
386
-    protected function _update_espresso_page_settings()
387
-    {
388
-        // capture incoming request data && set page IDs
389
-        EE_Registry::instance()->CFG->core->reg_page_id = isset($this->_req_data['reg_page_id'])
390
-            ? absint($this->_req_data['reg_page_id'])
391
-            : EE_Registry::instance()->CFG->core->reg_page_id;
392
-        EE_Registry::instance()->CFG->core->txn_page_id = isset($this->_req_data['txn_page_id'])
393
-            ? absint($this->_req_data['txn_page_id'])
394
-            : EE_Registry::instance()->CFG->core->txn_page_id;
395
-        EE_Registry::instance()->CFG->core->thank_you_page_id = isset($this->_req_data['thank_you_page_id'])
396
-            ? absint($this->_req_data['thank_you_page_id'])
397
-            : EE_Registry::instance()->CFG->core->thank_you_page_id;
398
-        EE_Registry::instance()->CFG->core->cancel_page_id = isset($this->_req_data['cancel_page_id'])
399
-            ? absint($this->_req_data['cancel_page_id'])
400
-            : EE_Registry::instance()->CFG->core->cancel_page_id;
401
-
402
-        EE_Registry::instance()->CFG->core = apply_filters(
403
-            'FHEE__General_Settings_Admin_Page___update_espresso_page_settings__CFG_core',
404
-            EE_Registry::instance()->CFG->core,
405
-            $this->_req_data
406
-        );
407
-        $what = __('Critical Pages & Shortcodes', 'event_espresso');
408
-        $this->_redirect_after_action(
409
-            $this->_update_espresso_configuration(
410
-                $what,
411
-                EE_Registry::instance()->CFG->core,
412
-                __FILE__,
413
-                __FUNCTION__,
414
-                __LINE__
415
-            ),
416
-            $what,
417
-            '',
418
-            array(
419
-                'action' => 'critical_pages',
420
-            ),
421
-            true
422
-        );
423
-    }
424
-
425
-
426
-    /*************        Your Organization        *************/
427
-
428
-
429
-    /**
430
-     * @throws DomainException
431
-     * @throws EE_Error
432
-     * @throws InvalidArgumentException
433
-     * @throws InvalidDataTypeException
434
-     * @throws InvalidInterfaceException
435
-     */
436
-    protected function _your_organization_settings()
437
-    {
438
-        $this->_template_args['admin_page_content'] = '';
439
-        try {
440
-            /** @var EventEspresso\admin_pages\general_settings\OrganizationSettings $organization_settings_form */
441
-            $organization_settings_form = $this->loader->getShared(
442
-                'EventEspresso\admin_pages\general_settings\OrganizationSettings'
443
-            );
444
-            $this->_template_args['admin_page_content'] = $organization_settings_form->display();
445
-        } catch (Exception $e) {
446
-            EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__);
447
-        }
448
-        $this->_set_add_edit_form_tags('update_your_organization_settings');
449
-        $this->_set_publish_post_box_vars(null, false, false, null, false);
450
-        $this->display_admin_page_with_sidebar();
451
-    }
452
-
453
-
454
-
455
-    /**
456
-     * Handler for updating organization settings.
457
-     *
458
-     * @throws EE_Error
459
-     */
460
-    protected function _update_your_organization_settings()
461
-    {
462
-        try {
463
-            /** @var EventEspresso\admin_pages\general_settings\OrganizationSettings $organization_settings_form */
464
-            $organization_settings_form = $this->loader->getShared(
465
-                'EventEspresso\admin_pages\general_settings\OrganizationSettings'
466
-            );
467
-            $success = $organization_settings_form->process($this->_req_data);
468
-            EE_Registry::instance()->CFG = apply_filters(
469
-                'FHEE__General_Settings_Admin_Page___update_your_organization_settings__CFG',
470
-                EE_Registry::instance()->CFG
471
-            );
472
-        } catch (Exception $e) {
473
-            EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__);
474
-            $success = false;
475
-        }
476
-
477
-        if ($success) {
478
-            $success = $this->_update_espresso_configuration(
479
-                esc_html__('Your Organization Settings', 'event_espresso'),
480
-                EE_Registry::instance()->CFG,
481
-                __FILE__,
482
-                __FUNCTION__,
483
-                __LINE__
484
-            );
485
-        }
486
-
487
-        $this->_redirect_after_action($success, '', '', array('action' => 'default'), true);
488
-    }
489
-
490
-
491
-
492
-    /*************        Admin Options        *************/
493
-
494
-
495
-    /**
496
-     * _admin_option_settings
497
-     *
498
-     * @throws \EE_Error
499
-     * @throws \LogicException
500
-     */
501
-    protected function _admin_option_settings()
502
-    {
503
-        $this->_template_args['admin_page_content'] = '';
504
-        try {
505
-            $admin_options_settings_form = new AdminOptionsSettings(EE_Registry::instance());
506
-            // still need this for the old school form in Extend_General_Settings_Admin_Page
507
-            $this->_template_args['values'] = $this->_yes_no_values;
508
-            // also need to account for the do_action that was in the old template
509
-            $admin_options_settings_form->setTemplateArgs($this->_template_args);
510
-            $this->_template_args['admin_page_content'] = $admin_options_settings_form->display();
511
-        } catch (Exception $e) {
512
-            EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__);
513
-        }
514
-        $this->_set_add_edit_form_tags('update_admin_option_settings');
515
-        $this->_set_publish_post_box_vars(null, false, false, null, false);
516
-        $this->display_admin_page_with_sidebar();
517
-    }
518
-
519
-
520
-    /**
521
-     * _update_admin_option_settings
522
-     *
523
-     * @throws \EE_Error
524
-     * @throws InvalidDataTypeException
525
-     * @throws \EventEspresso\core\exceptions\InvalidFormSubmissionException
526
-     * @throws \InvalidArgumentException
527
-     * @throws \LogicException
528
-     */
529
-    protected function _update_admin_option_settings()
530
-    {
531
-        try {
532
-            $admin_options_settings_form = new AdminOptionsSettings(EE_Registry::instance());
533
-            $admin_options_settings_form->process($this->_req_data[ $admin_options_settings_form->slug() ]);
534
-            EE_Registry::instance()->CFG->admin = apply_filters(
535
-                'FHEE__General_Settings_Admin_Page___update_admin_option_settings__CFG_admin',
536
-                EE_Registry::instance()->CFG->admin
537
-            );
538
-        } catch (Exception $e) {
539
-            EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__);
540
-        }
541
-        $this->_redirect_after_action(
542
-            apply_filters(
543
-                'FHEE__General_Settings_Admin_Page___update_admin_option_settings__success',
544
-                $this->_update_espresso_configuration(
545
-                    'Admin Options',
546
-                    EE_Registry::instance()->CFG->admin,
547
-                    __FILE__,
548
-                    __FUNCTION__,
549
-                    __LINE__
550
-                )
551
-            ),
552
-            'Admin Options',
553
-            'updated',
554
-            array('action' => 'admin_option_settings')
555
-        );
556
-    }
557
-
558
-
559
-    /*************        Countries        *************/
560
-
561
-
562
-    /**
563
-     * @return string
564
-     */
565
-    protected function getCountryIsoForSite()
566
-    {
567
-        return ! empty(EE_Registry::instance()->CFG->organization->CNT_ISO)
568
-            ? EE_Registry::instance()->CFG->organization->CNT_ISO
569
-            : 'US';
570
-    }
571
-
572
-
573
-
574
-    /**
575
-     * Output Country Settings view.
576
-     *
577
-     * @throws DomainException
578
-     * @throws EE_Error
579
-     */
580
-    protected function _country_settings()
581
-    {
582
-        $CNT_ISO_for_site = $this->getCountryIsoForSite();
583
-        $CNT_ISO = isset($this->_req_data['country'])
584
-            ? strtoupper(sanitize_text_field($this->_req_data['country']))
585
-            : $CNT_ISO_for_site;
586
-
587
-        // load field generator helper
588
-
589
-        $this->_template_args['values'] = $this->_yes_no_values;
590
-
591
-        $this->_template_args['countries'] = new EE_Question_Form_Input(
592
-            EE_Question::new_instance(
593
-                array(
594
-                    'QST_ID'           => 0,
595
-                    'QST_display_text' => __('Select Country', 'event_espresso'),
596
-                    'QST_system'       => 'admin-country',
597
-                )
598
-            ),
599
-            EE_Answer::new_instance(
600
-                array(
601
-                    'ANS_ID'    => 0,
602
-                    'ANS_value' => $CNT_ISO,
603
-                )
604
-            ),
605
-            array(
606
-                'input_id'       => 'country',
607
-                'input_name'     => 'country',
608
-                'input_prefix'   => '',
609
-                'append_qstn_id' => false,
610
-            )
611
-        );
612
-
613
-        add_filter('FHEE__EEH_Form_Fields__label_html', array($this, 'country_form_field_label_wrap'), 10, 2);
614
-        add_filter('FHEE__EEH_Form_Fields__input_html', array($this, 'country_form_field_input__wrap'), 10, 2);
615
-        $this->_template_args['country_details_settings'] = $this->display_country_settings();
616
-        $this->_template_args['country_states_settings'] = $this->display_country_states();
617
-        $this->_template_args['CNT_name_for_site'] = EEM_Country::instance()->get_one_by_ID($CNT_ISO_for_site)
618
-                                                                            ->name();
619
-
620
-        $this->_set_add_edit_form_tags('update_country_settings');
621
-        $this->_set_publish_post_box_vars(null, false, false, null, false);
622
-        $this->_template_args['admin_page_content'] = EEH_Template::display_template(
623
-            GEN_SET_TEMPLATE_PATH . 'countries_settings.template.php',
624
-            $this->_template_args,
625
-            true
626
-        );
627
-        $this->display_admin_page_with_no_sidebar();
628
-    }
629
-
630
-
631
-    /**
632
-     *        display_country_settings
633
-     *
634
-     * @access    public
635
-     * @param    string $CNT_ISO
636
-     * @return mixed string | array
637
-     * @throws DomainException
638
-     */
639
-    public function display_country_settings($CNT_ISO = '')
640
-    {
641
-        $CNT_ISO_for_site = $this->getCountryIsoForSite();
642
-
643
-        $CNT_ISO = isset($this->_req_data['country'])
644
-            ? strtoupper(sanitize_text_field($this->_req_data['country']))
645
-            : $CNT_ISO;
646
-        if (! $CNT_ISO) {
647
-            return '';
648
-        }
649
-
650
-        // for ajax
651
-        remove_all_filters('FHEE__EEH_Form_Fields__label_html');
652
-        remove_all_filters('FHEE__EEH_Form_Fields__input_html');
653
-        add_filter('FHEE__EEH_Form_Fields__label_html', array($this, 'country_form_field_label_wrap'), 10, 2);
654
-        add_filter('FHEE__EEH_Form_Fields__input_html', array($this, 'country_form_field_input__wrap'), 10, 2);
655
-        /** @var EE_Country $country */
656
-        $country = EEM_Country::instance()->get_one_by_ID($CNT_ISO);
657
-
658
-        $CNT_cur_disabled = $CNT_ISO !== $CNT_ISO_for_site;
659
-        $this->_template_args['CNT_cur_disabled'] = $CNT_cur_disabled;
660
-
661
-        $country_input_types = array(
662
-            'CNT_active'      => array(
663
-                'type'             => 'RADIO_BTN',
664
-                'input_name'       => 'cntry[' . $CNT_ISO . ']',
665
-                'class'            => '',
666
-                'options'          => $this->_yes_no_values,
667
-                'use_desc_4_label' => true,
668
-            ),
669
-            'CNT_ISO'         => array(
670
-                'type'       => 'TEXT',
671
-                'input_name' => 'cntry[' . $CNT_ISO . ']',
672
-                'class'      => 'small-text',
673
-            ),
674
-            'CNT_ISO3'        => array(
675
-                'type'       => 'TEXT',
676
-                'input_name' => 'cntry[' . $CNT_ISO . ']',
677
-                'class'      => 'small-text',
678
-            ),
679
-            'RGN_ID'          => array(
680
-                'type'       => 'TEXT',
681
-                'input_name' => 'cntry[' . $CNT_ISO . ']',
682
-                'class'      => 'small-text',
683
-            ),
684
-            'CNT_name'        => array(
685
-                'type'       => 'TEXT',
686
-                'input_name' => 'cntry[' . $CNT_ISO . ']',
687
-                'class'      => 'regular-text',
688
-            ),
689
-            'CNT_cur_code'    => array(
690
-                'type'       => 'TEXT',
691
-                'input_name' => 'cntry[' . $CNT_ISO . ']',
692
-                'class'      => 'small-text',
693
-                'disabled'   => $CNT_cur_disabled
694
-            ),
695
-            'CNT_cur_single'  => array(
696
-                'type'       => 'TEXT',
697
-                'input_name' => 'cntry[' . $CNT_ISO . ']',
698
-                'class'      => 'medium-text',
699
-                'disabled' => $CNT_cur_disabled
700
-            ),
701
-            'CNT_cur_plural'  => array(
702
-                'type'       => 'TEXT',
703
-                'input_name' => 'cntry[' . $CNT_ISO . ']',
704
-                'class'      => 'medium-text',
705
-                'disabled' => $CNT_cur_disabled
706
-            ),
707
-            'CNT_cur_sign'    => array(
708
-                'type'         => 'TEXT',
709
-                'input_name'   => 'cntry[' . $CNT_ISO . ']',
710
-                'class'        => 'small-text',
711
-                'htmlentities' => false,
712
-                'disabled' => $CNT_cur_disabled
713
-            ),
714
-            'CNT_cur_sign_b4' => array(
715
-                'type'             => 'RADIO_BTN',
716
-                'input_name'       => 'cntry[' . $CNT_ISO . ']',
717
-                'class'            => '',
718
-                'options'          => $this->_yes_no_values,
719
-                'use_desc_4_label' => true,
720
-                'disabled' => $CNT_cur_disabled
721
-            ),
722
-            'CNT_cur_dec_plc' => array(
723
-                'type'       => 'RADIO_BTN',
724
-                'input_name' => 'cntry[' . $CNT_ISO . ']',
725
-                'class'      => '',
726
-                'options'    => array(
727
-                    array('id' => 0, 'text' => ''),
728
-                    array('id' => 1, 'text' => ''),
729
-                    array('id' => 2, 'text' => ''),
730
-                    array('id' => 3, 'text' => ''),
731
-                ),
732
-                'disabled' => $CNT_cur_disabled
733
-            ),
734
-            'CNT_cur_dec_mrk' => array(
735
-                'type'             => 'RADIO_BTN',
736
-                'input_name'       => 'cntry[' . $CNT_ISO . ']',
737
-                'class'            => '',
738
-                'options'          => array(
739
-                    array(
740
-                        'id'   => ',',
741
-                        'text' => __(', (comma)', 'event_espresso'),
742
-                    ),
743
-                    array('id' => '.', 'text' => __('. (decimal)', 'event_espresso')),
744
-                ),
745
-                'use_desc_4_label' => true,
746
-                'disabled' => $CNT_cur_disabled
747
-            ),
748
-            'CNT_cur_thsnds'  => array(
749
-                'type'             => 'RADIO_BTN',
750
-                'input_name'       => 'cntry[' . $CNT_ISO . ']',
751
-                'class'            => '',
752
-                'options'          => array(
753
-                    array(
754
-                        'id'   => ',',
755
-                        'text' => __(', (comma)', 'event_espresso'),
756
-                    ),
757
-                    array('id' => '.', 'text' => __('. (decimal)', 'event_espresso')),
758
-                ),
759
-                'use_desc_4_label' => true,
760
-                'disabled' => $CNT_cur_disabled
761
-            ),
762
-            'CNT_tel_code'    => array(
763
-                'type'       => 'TEXT',
764
-                'input_name' => 'cntry[' . $CNT_ISO . ']',
765
-                'class'      => 'small-text',
766
-            ),
767
-            'CNT_is_EU'       => array(
768
-                'type'             => 'RADIO_BTN',
769
-                'input_name'       => 'cntry[' . $CNT_ISO . ']',
770
-                'class'            => '',
771
-                'options'          => $this->_yes_no_values,
772
-                'use_desc_4_label' => true,
773
-            ),
774
-        );
775
-        $this->_template_args['inputs'] = EE_Question_Form_Input::generate_question_form_inputs_for_object(
776
-            $country,
777
-            $country_input_types
778
-        );
779
-        $country_details_settings = EEH_Template::display_template(
780
-            GEN_SET_TEMPLATE_PATH . 'country_details_settings.template.php',
781
-            $this->_template_args,
782
-            true
783
-        );
784
-
785
-        if (defined('DOING_AJAX')) {
786
-            $notices = EE_Error::get_notices(false, false, false);
787
-            echo wp_json_encode(
788
-                array(
789
-                    'return_data' => $country_details_settings,
790
-                    'success'     => $notices['success'],
791
-                    'errors'      => $notices['errors'],
792
-                )
793
-            );
794
-            die();
795
-        } else {
796
-            return $country_details_settings;
797
-        }
798
-    }
799
-
800
-
801
-    /**
802
-     *        display_country_states
803
-     *
804
-     * @access    public
805
-     * @param    string $CNT_ISO
806
-     * @return string
807
-     * @throws DomainException
808
-     */
809
-    public function display_country_states($CNT_ISO = '')
810
-    {
811
-
812
-        $CNT_ISO = isset($this->_req_data['country']) ? sanitize_text_field($this->_req_data['country']) : $CNT_ISO;
813
-
814
-        if (! $CNT_ISO) {
815
-            return '';
816
-        }
817
-        // for ajax
818
-        remove_all_filters('FHEE__EEH_Form_Fields__label_html');
819
-        remove_all_filters('FHEE__EEH_Form_Fields__input_html');
820
-        add_filter('FHEE__EEH_Form_Fields__label_html', array($this, 'state_form_field_label_wrap'), 10, 2);
821
-        add_filter('FHEE__EEH_Form_Fields__input_html', array($this, 'state_form_field_input__wrap'), 10, 2);
822
-        $states = EEM_State::instance()->get_all_states_for_these_countries(array($CNT_ISO => $CNT_ISO));
823
-
824
-        if ($states) {
825
-            foreach ($states as $STA_ID => $state) {
826
-                if ($state instanceof EE_State) {
827
-                    // STA_abbrev    STA_name    STA_active
828
-                    $state_input_types = array(
829
-                        'STA_abbrev' => array(
830
-                            'type'       => 'TEXT',
831
-                            'input_name' => 'states[' . $STA_ID . ']',
832
-                            'class'      => 'mid-text',
833
-                        ),
834
-                        'STA_name'   => array(
835
-                            'type'       => 'TEXT',
836
-                            'input_name' => 'states[' . $STA_ID . ']',
837
-                            'class'      => 'regular-text',
838
-                        ),
839
-                        'STA_active' => array(
840
-                            'type'             => 'RADIO_BTN',
841
-                            'input_name'       => 'states[' . $STA_ID . ']',
842
-                            'options'          => $this->_yes_no_values,
843
-                            'use_desc_4_label' => true,
844
-                        ),
845
-                    );
846
-                    $this->_template_args['states'][ $STA_ID ]['inputs'] =
847
-                        EE_Question_Form_Input::generate_question_form_inputs_for_object(
848
-                            $state,
849
-                            $state_input_types
850
-                        );
851
-                    $query_args = array(
852
-                        'action'     => 'delete_state',
853
-                        'STA_ID'     => $STA_ID,
854
-                        'CNT_ISO'    => $CNT_ISO,
855
-                        'STA_abbrev' => $state->abbrev(),
856
-                    );
857
-                    $this->_template_args['states'][ $STA_ID ]['delete_state_url'] =
858
-                        EE_Admin_Page::add_query_args_and_nonce(
859
-                            $query_args,
860
-                            GEN_SET_ADMIN_URL
861
-                        );
862
-                }
863
-            }
864
-        } else {
865
-            $this->_template_args['states'] = false;
866
-        }
867
-
868
-        $this->_template_args['add_new_state_url'] = EE_Admin_Page::add_query_args_and_nonce(
869
-            array('action' => 'add_new_state'),
870
-            GEN_SET_ADMIN_URL
871
-        );
872
-
873
-        $state_details_settings = EEH_Template::display_template(
874
-            GEN_SET_TEMPLATE_PATH . 'state_details_settings.template.php',
875
-            $this->_template_args,
876
-            true
877
-        );
878
-
879
-        if (defined('DOING_AJAX')) {
880
-            $notices = EE_Error::get_notices(false, false, false);
881
-            echo wp_json_encode(
882
-                array(
883
-                    'return_data' => $state_details_settings,
884
-                    'success'     => $notices['success'],
885
-                    'errors'      => $notices['errors'],
886
-                )
887
-            );
888
-            die();
889
-        } else {
890
-            return $state_details_settings;
891
-        }
892
-    }
893
-
894
-
895
-    /**
896
-     *        add_new_state
897
-     *
898
-     * @access    public
899
-     * @return void
900
-     * @throws EE_Error
901
-     */
902
-    public function add_new_state()
903
-    {
904
-
905
-        $success = true;
906
-
907
-        $CNT_ISO = isset($this->_req_data['CNT_ISO'])
908
-            ? strtoupper(sanitize_text_field($this->_req_data['CNT_ISO']))
909
-            : false;
910
-        if (! $CNT_ISO) {
911
-            EE_Error::add_error(
912
-                __('No Country ISO code or an invalid Country ISO code was received.', 'event_espresso'),
913
-                __FILE__,
914
-                __FUNCTION__,
915
-                __LINE__
916
-            );
917
-            $success = false;
918
-        }
919
-        $STA_abbrev = isset($this->_req_data['STA_abbrev'])
920
-            ? sanitize_text_field($this->_req_data['STA_abbrev'])
921
-            : false;
922
-        if (! $STA_abbrev) {
923
-            EE_Error::add_error(
924
-                __('No State ISO code or an invalid State ISO code was received.', 'event_espresso'),
925
-                __FILE__,
926
-                __FUNCTION__,
927
-                __LINE__
928
-            );
929
-            $success = false;
930
-        }
931
-        $STA_name = isset($this->_req_data['STA_name'])
932
-            ? sanitize_text_field($this->_req_data['STA_name'])
933
-            : false;
934
-        if (! $STA_name) {
935
-            EE_Error::add_error(
936
-                __('No State name or an invalid State name was received.', 'event_espresso'),
937
-                __FILE__,
938
-                __FUNCTION__,
939
-                __LINE__
940
-            );
941
-            $success = false;
942
-        }
943
-
944
-        if ($success) {
945
-            $cols_n_values = array(
946
-                'CNT_ISO'    => $CNT_ISO,
947
-                'STA_abbrev' => $STA_abbrev,
948
-                'STA_name'   => $STA_name,
949
-                'STA_active' => true,
950
-            );
951
-            $success = EEM_State::instance()->insert($cols_n_values);
952
-            EE_Error::add_success(__('The State was added successfully.', 'event_espresso'));
953
-        }
954
-
955
-        if (defined('DOING_AJAX')) {
956
-            $notices = EE_Error::get_notices(false, false, false);
957
-            echo wp_json_encode(array_merge($notices, array('return_data' => $CNT_ISO)));
958
-            die();
959
-        } else {
960
-            $this->_redirect_after_action($success, 'State', 'added', array('action' => 'country_settings'));
961
-        }
962
-    }
963
-
964
-
965
-    /**
966
-     *        delete_state
967
-     *
968
-     * @access    public
969
-     * @return        boolean
970
-     * @throws EE_Error
971
-     * @throws EE_Error
972
-     */
973
-    public function delete_state()
974
-    {
975
-        $CNT_ISO = isset($this->_req_data['CNT_ISO'])
976
-            ? strtoupper(sanitize_text_field($this->_req_data['CNT_ISO']))
977
-            : false;
978
-        $STA_ID = isset($this->_req_data['STA_ID'])
979
-            ? sanitize_text_field($this->_req_data['STA_ID'])
980
-            : false;
981
-        $STA_abbrev = isset($this->_req_data['STA_abbrev'])
982
-            ? sanitize_text_field($this->_req_data['STA_abbrev'])
983
-            : false;
984
-        if (! $STA_ID) {
985
-            EE_Error::add_error(
986
-                __('No State ID or an invalid State ID was received.', 'event_espresso'),
987
-                __FILE__,
988
-                __FUNCTION__,
989
-                __LINE__
990
-            );
991
-            return false;
992
-        }
993
-
994
-        $success = EEM_State::instance()->delete_by_ID($STA_ID);
995
-        if ($success !== false) {
996
-            do_action(
997
-                'AHEE__General_Settings_Admin_Page__delete_state__state_deleted',
998
-                $CNT_ISO,
999
-                $STA_ID,
1000
-                array('STA_abbrev' => $STA_abbrev)
1001
-            );
1002
-            EE_Error::add_success(__('The State was deleted successfully.', 'event_espresso'));
1003
-        }
1004
-        if (defined('DOING_AJAX')) {
1005
-            $notices = EE_Error::get_notices(false, false);
1006
-            $notices['return_data'] = true;
1007
-            echo wp_json_encode($notices);
1008
-            die();
1009
-        } else {
1010
-            $this->_redirect_after_action(
1011
-                $success,
1012
-                'State',
1013
-                'deleted',
1014
-                array('action' => 'country_settings')
1015
-            );
1016
-        }
1017
-    }
1018
-
1019
-
1020
-    /**
1021
-     *        _update_country_settings
1022
-     *
1023
-     * @access    protected
1024
-     * @return void
1025
-     * @throws EE_Error
1026
-     */
1027
-    protected function _update_country_settings()
1028
-    {
1029
-        // grab the country ISO code
1030
-        $CNT_ISO = isset($this->_req_data['country'])
1031
-            ? strtoupper(sanitize_text_field($this->_req_data['country']))
1032
-            : false;
1033
-        if (! $CNT_ISO) {
1034
-            EE_Error::add_error(
1035
-                __('No Country ISO code or an invalid Country ISO code was received.', 'event_espresso'),
1036
-                __FILE__,
1037
-                __FUNCTION__,
1038
-                __LINE__
1039
-            );
1040
-
1041
-            return;
1042
-        }
1043
-        $cols_n_values = array();
1044
-        $cols_n_values['CNT_ISO3'] = isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_ISO3'])
1045
-            ? strtoupper(sanitize_text_field($this->_req_data['cntry'][ $CNT_ISO ]['CNT_ISO3']))
1046
-            : false;
1047
-        $cols_n_values['RGN_ID'] = isset($this->_req_data['cntry'][ $CNT_ISO ]['RGN_ID'])
1048
-            ? absint($this->_req_data['cntry'][ $CNT_ISO ]['RGN_ID'])
1049
-            : null;
1050
-        $cols_n_values['CNT_name'] = isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_name'])
1051
-            ? sanitize_text_field($this->_req_data['cntry'][ $CNT_ISO ]['CNT_name'])
1052
-            : null;
1053
-        if (isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_code'])) {
1054
-            $cols_n_values['CNT_cur_code'] = strtoupper(
1055
-                sanitize_text_field($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_code'])
1056
-            );
1057
-        }
1058
-        if (isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_single'])) {
1059
-            $cols_n_values['CNT_cur_single'] = sanitize_text_field(
1060
-                $this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_single']
1061
-            );
1062
-        }
1063
-        if (isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_plural'])) {
1064
-            $cols_n_values['CNT_cur_plural'] = sanitize_text_field(
1065
-                $this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_plural']
1066
-            );
1067
-        }
1068
-        if (isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_sign'])) {
1069
-            $cols_n_values['CNT_cur_sign'] = sanitize_text_field(
1070
-                $this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_sign']
1071
-            );
1072
-        }
1073
-        if (isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_sign_b4'])) {
1074
-            $cols_n_values['CNT_cur_sign_b4'] = absint(
1075
-                $this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_sign_b4']
1076
-            );
1077
-        }
1078
-        if (isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_dec_plc'])) {
1079
-            $cols_n_values['CNT_cur_dec_plc'] = absint(
1080
-                $this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_dec_plc']
1081
-            );
1082
-        }
1083
-        if (isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_dec_mrk'])) {
1084
-            $cols_n_values['CNT_cur_dec_mrk'] = sanitize_text_field(
1085
-                $this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_dec_mrk']
1086
-            );
1087
-        }
1088
-        if (isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_thsnds'])) {
1089
-            $cols_n_values['CNT_cur_thsnds'] = sanitize_text_field(
1090
-                $this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_thsnds']
1091
-            );
1092
-        }
1093
-        $cols_n_values['CNT_tel_code'] = isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_tel_code'])
1094
-            ? sanitize_text_field($this->_req_data['cntry'][ $CNT_ISO ]['CNT_tel_code'])
1095
-            : null;
1096
-        $cols_n_values['CNT_is_EU'] = isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_is_EU'])
1097
-            ? absint($this->_req_data['cntry'][ $CNT_ISO ]['CNT_is_EU'])
1098
-            : false;
1099
-        $cols_n_values['CNT_active'] = isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_active'])
1100
-            ? absint($this->_req_data['cntry'][ $CNT_ISO ]['CNT_active'])
1101
-            : false;
1102
-        // allow filtering of country data
1103
-        $cols_n_values = apply_filters(
1104
-            'FHEE__General_Settings_Admin_Page___update_country_settings__cols_n_values',
1105
-            $cols_n_values
1106
-        );
1107
-
1108
-        // where values
1109
-        $where_cols_n_values = array(array('CNT_ISO' => $CNT_ISO));
1110
-        // run the update
1111
-        $success = EEM_Country::instance()->update($cols_n_values, $where_cols_n_values);
1112
-
1113
-        if (isset($this->_req_data['states']) && is_array($this->_req_data['states']) && $success !== false) {
1114
-            // allow filtering of states data
1115
-            $states = apply_filters(
1116
-                'FHEE__General_Settings_Admin_Page___update_country_settings__states',
1117
-                $this->_req_data['states']
1118
-            );
1119
-
1120
-            // loop thru state data ( looks like : states[75][STA_name] )
1121
-            foreach ($states as $STA_ID => $state) {
1122
-                $cols_n_values = array(
1123
-                    'CNT_ISO'    => $CNT_ISO,
1124
-                    'STA_abbrev' => sanitize_text_field($state['STA_abbrev']),
1125
-                    'STA_name'   => sanitize_text_field($state['STA_name']),
1126
-                    'STA_active' => (bool) absint($state['STA_active']),
1127
-                );
1128
-                // where values
1129
-                $where_cols_n_values = array(array('STA_ID' => $STA_ID));
1130
-                // run the update
1131
-                $success = EEM_State::instance()->update($cols_n_values, $where_cols_n_values);
1132
-                if ($success !== false) {
1133
-                    do_action(
1134
-                        'AHEE__General_Settings_Admin_Page__update_country_settings__state_saved',
1135
-                        $CNT_ISO,
1136
-                        $STA_ID,
1137
-                        $cols_n_values
1138
-                    );
1139
-                }
1140
-            }
1141
-        }
1142
-        // check if country being edited matches org option country, and if so, then  update EE_Config with new settings
1143
-        if (isset(EE_Registry::instance()->CFG->organization->CNT_ISO)
1144
-            && $CNT_ISO == EE_Registry::instance()->CFG->organization->CNT_ISO
1145
-        ) {
1146
-            EE_Registry::instance()->CFG->currency = new EE_Currency_Config($CNT_ISO);
1147
-            EE_Registry::instance()->CFG->update_espresso_config();
1148
-        }
1149
-
1150
-        if ($success !== false) {
1151
-            EE_Error::add_success(
1152
-                esc_html__('Country Settings updated successfully.', 'event_espresso')
1153
-            );
1154
-        }
1155
-        $this->_redirect_after_action(
1156
-            $success,
1157
-            '',
1158
-            '',
1159
-            array('action' => 'country_settings', 'country' => $CNT_ISO),
1160
-            true
1161
-        );
1162
-    }
1163
-
1164
-
1165
-    /**
1166
-     *        form_form_field_label_wrap
1167
-     *
1168
-     * @access        public
1169
-     * @param        string $label
1170
-     * @return        string
1171
-     */
1172
-    public function country_form_field_label_wrap($label, $required_text)
1173
-    {
1174
-        return '
24
+	/**
25
+	 * _question_group
26
+	 * holds the specific question group object for the question group details screen
27
+	 *
28
+	 * @var object
29
+	 */
30
+	protected $_question_group;
31
+
32
+
33
+	/**
34
+	 * Initialize basic properties.
35
+	 */
36
+	protected function _init_page_props()
37
+	{
38
+		$this->page_slug = GEN_SET_PG_SLUG;
39
+		$this->page_label = GEN_SET_LABEL;
40
+		$this->_admin_base_url = GEN_SET_ADMIN_URL;
41
+		$this->_admin_base_path = GEN_SET_ADMIN;
42
+	}
43
+
44
+
45
+	/**
46
+	 * Set ajax hooks
47
+	 */
48
+	protected function _ajax_hooks()
49
+	{
50
+		add_action('wp_ajax_espresso_display_country_settings', array($this, 'display_country_settings'));
51
+		add_action('wp_ajax_espresso_display_country_states', array($this, 'display_country_states'));
52
+		add_action('wp_ajax_espresso_delete_state', array($this, 'delete_state'), 10, 3);
53
+		add_action('wp_ajax_espresso_add_new_state', array($this, 'add_new_state'));
54
+	}
55
+
56
+
57
+	/**
58
+	 * More page properties initialization.
59
+	 */
60
+	protected function _define_page_props()
61
+	{
62
+		$this->_admin_page_title = GEN_SET_LABEL;
63
+		$this->_labels = array(
64
+			'publishbox' => __('Update Settings', 'event_espresso'),
65
+		);
66
+	}
67
+
68
+
69
+	/**
70
+	 * Set page routes property.
71
+	 */
72
+	protected function _set_page_routes()
73
+	{
74
+		$this->_page_routes = array(
75
+
76
+			'critical_pages'                => array(
77
+				'func'       => '_espresso_page_settings',
78
+				'capability' => 'manage_options',
79
+			),
80
+			'update_espresso_page_settings' => array(
81
+				'func'       => '_update_espresso_page_settings',
82
+				'capability' => 'manage_options',
83
+				'noheader'   => true,
84
+			),
85
+			'default'                       => array(
86
+				'func'       => '_your_organization_settings',
87
+				'capability' => 'manage_options',
88
+			),
89
+
90
+			'update_your_organization_settings' => array(
91
+				'func'       => '_update_your_organization_settings',
92
+				'capability' => 'manage_options',
93
+				'noheader'   => true,
94
+			),
95
+
96
+			'admin_option_settings' => array(
97
+				'func'       => '_admin_option_settings',
98
+				'capability' => 'manage_options',
99
+			),
100
+
101
+			'update_admin_option_settings' => array(
102
+				'func'       => '_update_admin_option_settings',
103
+				'capability' => 'manage_options',
104
+				'noheader'   => true,
105
+			),
106
+
107
+			'country_settings' => array(
108
+				'func'       => '_country_settings',
109
+				'capability' => 'manage_options',
110
+			),
111
+
112
+			'update_country_settings' => array(
113
+				'func'       => '_update_country_settings',
114
+				'capability' => 'manage_options',
115
+				'noheader'   => true,
116
+			),
117
+
118
+			'display_country_settings' => array(
119
+				'func'       => 'display_country_settings',
120
+				'capability' => 'manage_options',
121
+				'noheader'   => true,
122
+			),
123
+
124
+			'add_new_state' => array(
125
+				'func'       => 'add_new_state',
126
+				'capability' => 'manage_options',
127
+				'noheader'   => true,
128
+			),
129
+
130
+			'delete_state' => array(
131
+				'func'       => 'delete_state',
132
+				'capability' => 'manage_options',
133
+				'noheader'   => true,
134
+			),
135
+			'privacy_settings' => array(
136
+				'func' => 'privacySettings',
137
+				'capability' => 'manage_options',
138
+			),
139
+			'update_privacy_settings' => array(
140
+				'func' => 'updatePrivacySettings',
141
+				'capability' => 'manage_options',
142
+				'noheader' => true,
143
+				'headers_sent_route' => 'privacy_settings'
144
+			)
145
+		);
146
+	}
147
+
148
+
149
+	/**
150
+	 * Set page configuration property
151
+	 */
152
+	protected function _set_page_config()
153
+	{
154
+		$this->_page_config = array(
155
+			'critical_pages'        => array(
156
+				'nav'           => array(
157
+					'label' => __('Critical Pages', 'event_espresso'),
158
+					'order' => 50,
159
+				),
160
+				'metaboxes'     => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')),
161
+				'help_tabs'     => array(
162
+					'general_settings_critical_pages_help_tab' => array(
163
+						'title'    => __('Critical Pages', 'event_espresso'),
164
+						'filename' => 'general_settings_critical_pages',
165
+					),
166
+				),
167
+				'help_tour'     => array('Critical_Pages_Help_Tour'),
168
+				'require_nonce' => false,
169
+			),
170
+			'default'               => array(
171
+				'nav'           => array(
172
+					'label' => __('Your Organization', 'event_espresso'),
173
+					'order' => 20,
174
+				),
175
+				'help_tabs'     => array(
176
+					'general_settings_your_organization_help_tab' => array(
177
+						'title'    => __('Your Organization', 'event_espresso'),
178
+						'filename' => 'general_settings_your_organization',
179
+					),
180
+				),
181
+				'help_tour'     => array('Your_Organization_Help_Tour'),
182
+				'metaboxes'     => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')),
183
+				'require_nonce' => false,
184
+			),
185
+			'admin_option_settings' => array(
186
+				'nav'           => array(
187
+					'label' => __('Admin Options', 'event_espresso'),
188
+					'order' => 60,
189
+				),
190
+				'metaboxes'     => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')),
191
+				'help_tabs'     => array(
192
+					'general_settings_admin_options_help_tab' => array(
193
+						'title'    => __('Admin Options', 'event_espresso'),
194
+						'filename' => 'general_settings_admin_options',
195
+					),
196
+				),
197
+				'help_tour'     => array('Admin_Options_Help_Tour'),
198
+				'require_nonce' => false,
199
+			),
200
+			'country_settings'      => array(
201
+				'nav'           => array(
202
+					'label' => __('Countries', 'event_espresso'),
203
+					'order' => 70,
204
+				),
205
+				'help_tabs'     => array(
206
+					'general_settings_countries_help_tab' => array(
207
+						'title'    => __('Countries', 'event_espresso'),
208
+						'filename' => 'general_settings_countries',
209
+					),
210
+				),
211
+				'help_tour'     => array('Countries_Help_Tour'),
212
+				'require_nonce' => false,
213
+			),
214
+			'privacy_settings' => array(
215
+				'nav' => array(
216
+					'label' => esc_html__('Privacy', 'event_espresso'),
217
+					'order' => 80
218
+				),
219
+				'metaboxes'     => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')),
220
+				'require_nonce' => false
221
+			)
222
+		);
223
+	}
224
+
225
+
226
+	protected function _add_screen_options()
227
+	{
228
+	}
229
+
230
+	protected function _add_feature_pointers()
231
+	{
232
+	}
233
+
234
+
235
+	/**
236
+	 * Enqueue global scripts and styles for all routes in the General Settings Admin Pages.
237
+	 */
238
+	public function load_scripts_styles()
239
+	{
240
+		// styles
241
+		wp_enqueue_style('espresso-ui-theme');
242
+		// scripts
243
+		wp_enqueue_script('ee_admin_js');
244
+	}
245
+
246
+
247
+	/**
248
+	 * Execute logic running on `admin_init`
249
+	 */
250
+	public function admin_init()
251
+	{
252
+		EE_Registry::$i18n_js_strings['invalid_server_response'] = __(
253
+			'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.',
254
+			'event_espresso'
255
+		);
256
+		EE_Registry::$i18n_js_strings['error_occurred'] = __(
257
+			'An error occurred! Please refresh the page and try again.',
258
+			'event_espresso'
259
+		);
260
+		EE_Registry::$i18n_js_strings['confirm_delete_state'] = __(
261
+			'Are you sure you want to delete this State / Province?',
262
+			'event_espresso'
263
+		);
264
+		$protocol = isset($_SERVER['HTTPS']) ? 'https://' : 'http://';
265
+		EE_Registry::$i18n_js_strings['ajax_url'] = admin_url(
266
+			'admin-ajax.php?page=espresso_general_settings',
267
+			$protocol
268
+		);
269
+	}
270
+
271
+	public function admin_notices()
272
+	{
273
+	}
274
+
275
+	public function admin_footer_scripts()
276
+	{
277
+	}
278
+
279
+
280
+	/**
281
+	 * Enqueue scripts and styles for the default route.
282
+	 */
283
+	public function load_scripts_styles_default()
284
+	{
285
+		// styles
286
+		wp_enqueue_style('thickbox');
287
+		// scripts
288
+		wp_enqueue_script('media-upload');
289
+		wp_enqueue_script('thickbox');
290
+		wp_register_script(
291
+			'organization_settings',
292
+			GEN_SET_ASSETS_URL . 'your_organization_settings.js',
293
+			array('jquery', 'media-upload', 'thickbox'),
294
+			EVENT_ESPRESSO_VERSION,
295
+			true
296
+		);
297
+		wp_register_style('organization-css', GEN_SET_ASSETS_URL . 'organization.css', array(), EVENT_ESPRESSO_VERSION);
298
+		wp_enqueue_script('organization_settings');
299
+		wp_enqueue_style('organization-css');
300
+		$confirm_image_delete = array(
301
+			'text' => __(
302
+				'Do you really want to delete this image? Please remember to save your settings to complete the removal.',
303
+				'event_espresso'
304
+			),
305
+		);
306
+		wp_localize_script('organization_settings', 'confirm_image_delete', $confirm_image_delete);
307
+	}
308
+
309
+
310
+	/**
311
+	 * Enqueue scripts and styles for the country settings route.
312
+	 */
313
+	public function load_scripts_styles_country_settings()
314
+	{
315
+		// scripts
316
+		wp_register_script(
317
+			'gen_settings_countries',
318
+			GEN_SET_ASSETS_URL . 'gen_settings_countries.js',
319
+			array('ee_admin_js'),
320
+			EVENT_ESPRESSO_VERSION,
321
+			true
322
+		);
323
+		wp_register_style('organization-css', GEN_SET_ASSETS_URL . 'organization.css', array(), EVENT_ESPRESSO_VERSION);
324
+		wp_enqueue_script('gen_settings_countries');
325
+		wp_enqueue_style('organization-css');
326
+	}
327
+
328
+
329
+	/*************        Espresso Pages        *************/
330
+	/**
331
+	 * _espresso_page_settings
332
+	 *
333
+	 * @throws \EE_Error
334
+	 * @throws DomainException
335
+	 * @throws DomainException
336
+	 * @throws InvalidDataTypeException
337
+	 * @throws InvalidArgumentException
338
+	 */
339
+	protected function _espresso_page_settings()
340
+	{
341
+		// Check to make sure all of the main pages are setup properly,
342
+		// if not create the default pages and display an admin notice
343
+		EEH_Activation::verify_default_pages_exist();
344
+		$this->_transient_garbage_collection();
345
+		$this->_template_args['values'] = $this->_yes_no_values;
346
+		$this->_template_args['reg_page_id'] = isset(EE_Registry::instance()->CFG->core->reg_page_id)
347
+			? EE_Registry::instance()->CFG->core->reg_page_id
348
+			: null;
349
+		$this->_template_args['reg_page_obj'] = isset(EE_Registry::instance()->CFG->core->reg_page_id)
350
+			? get_page(EE_Registry::instance()->CFG->core->reg_page_id)
351
+			: false;
352
+		$this->_template_args['txn_page_id'] = isset(EE_Registry::instance()->CFG->core->txn_page_id)
353
+			? EE_Registry::instance()->CFG->core->txn_page_id
354
+			: null;
355
+		$this->_template_args['txn_page_obj'] = isset(EE_Registry::instance()->CFG->core->txn_page_id)
356
+			? get_page(EE_Registry::instance()->CFG->core->txn_page_id)
357
+			: false;
358
+		$this->_template_args['thank_you_page_id'] = isset(EE_Registry::instance()->CFG->core->thank_you_page_id)
359
+			? EE_Registry::instance()->CFG->core->thank_you_page_id
360
+			: null;
361
+		$this->_template_args['thank_you_page_obj'] = isset(EE_Registry::instance()->CFG->core->thank_you_page_id)
362
+			? get_page(EE_Registry::instance()->CFG->core->thank_you_page_id)
363
+			: false;
364
+		$this->_template_args['cancel_page_id'] = isset(EE_Registry::instance()->CFG->core->cancel_page_id)
365
+			? EE_Registry::instance()->CFG->core->cancel_page_id
366
+			: null;
367
+		$this->_template_args['cancel_page_obj'] = isset(EE_Registry::instance()->CFG->core->cancel_page_id)
368
+			? get_page(EE_Registry::instance()->CFG->core->cancel_page_id)
369
+			: false;
370
+		$this->_set_add_edit_form_tags('update_espresso_page_settings');
371
+		$this->_set_publish_post_box_vars(null, false, false, null, false);
372
+		$this->_template_args['admin_page_content'] = EEH_Template::display_template(
373
+			GEN_SET_TEMPLATE_PATH . 'espresso_page_settings.template.php',
374
+			$this->_template_args,
375
+			true
376
+		);
377
+		$this->display_admin_page_with_sidebar();
378
+	}
379
+
380
+
381
+	/**
382
+	 * Handler for updating espresso page settings.
383
+	 *
384
+	 * @throws EE_Error
385
+	 */
386
+	protected function _update_espresso_page_settings()
387
+	{
388
+		// capture incoming request data && set page IDs
389
+		EE_Registry::instance()->CFG->core->reg_page_id = isset($this->_req_data['reg_page_id'])
390
+			? absint($this->_req_data['reg_page_id'])
391
+			: EE_Registry::instance()->CFG->core->reg_page_id;
392
+		EE_Registry::instance()->CFG->core->txn_page_id = isset($this->_req_data['txn_page_id'])
393
+			? absint($this->_req_data['txn_page_id'])
394
+			: EE_Registry::instance()->CFG->core->txn_page_id;
395
+		EE_Registry::instance()->CFG->core->thank_you_page_id = isset($this->_req_data['thank_you_page_id'])
396
+			? absint($this->_req_data['thank_you_page_id'])
397
+			: EE_Registry::instance()->CFG->core->thank_you_page_id;
398
+		EE_Registry::instance()->CFG->core->cancel_page_id = isset($this->_req_data['cancel_page_id'])
399
+			? absint($this->_req_data['cancel_page_id'])
400
+			: EE_Registry::instance()->CFG->core->cancel_page_id;
401
+
402
+		EE_Registry::instance()->CFG->core = apply_filters(
403
+			'FHEE__General_Settings_Admin_Page___update_espresso_page_settings__CFG_core',
404
+			EE_Registry::instance()->CFG->core,
405
+			$this->_req_data
406
+		);
407
+		$what = __('Critical Pages & Shortcodes', 'event_espresso');
408
+		$this->_redirect_after_action(
409
+			$this->_update_espresso_configuration(
410
+				$what,
411
+				EE_Registry::instance()->CFG->core,
412
+				__FILE__,
413
+				__FUNCTION__,
414
+				__LINE__
415
+			),
416
+			$what,
417
+			'',
418
+			array(
419
+				'action' => 'critical_pages',
420
+			),
421
+			true
422
+		);
423
+	}
424
+
425
+
426
+	/*************        Your Organization        *************/
427
+
428
+
429
+	/**
430
+	 * @throws DomainException
431
+	 * @throws EE_Error
432
+	 * @throws InvalidArgumentException
433
+	 * @throws InvalidDataTypeException
434
+	 * @throws InvalidInterfaceException
435
+	 */
436
+	protected function _your_organization_settings()
437
+	{
438
+		$this->_template_args['admin_page_content'] = '';
439
+		try {
440
+			/** @var EventEspresso\admin_pages\general_settings\OrganizationSettings $organization_settings_form */
441
+			$organization_settings_form = $this->loader->getShared(
442
+				'EventEspresso\admin_pages\general_settings\OrganizationSettings'
443
+			);
444
+			$this->_template_args['admin_page_content'] = $organization_settings_form->display();
445
+		} catch (Exception $e) {
446
+			EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__);
447
+		}
448
+		$this->_set_add_edit_form_tags('update_your_organization_settings');
449
+		$this->_set_publish_post_box_vars(null, false, false, null, false);
450
+		$this->display_admin_page_with_sidebar();
451
+	}
452
+
453
+
454
+
455
+	/**
456
+	 * Handler for updating organization settings.
457
+	 *
458
+	 * @throws EE_Error
459
+	 */
460
+	protected function _update_your_organization_settings()
461
+	{
462
+		try {
463
+			/** @var EventEspresso\admin_pages\general_settings\OrganizationSettings $organization_settings_form */
464
+			$organization_settings_form = $this->loader->getShared(
465
+				'EventEspresso\admin_pages\general_settings\OrganizationSettings'
466
+			);
467
+			$success = $organization_settings_form->process($this->_req_data);
468
+			EE_Registry::instance()->CFG = apply_filters(
469
+				'FHEE__General_Settings_Admin_Page___update_your_organization_settings__CFG',
470
+				EE_Registry::instance()->CFG
471
+			);
472
+		} catch (Exception $e) {
473
+			EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__);
474
+			$success = false;
475
+		}
476
+
477
+		if ($success) {
478
+			$success = $this->_update_espresso_configuration(
479
+				esc_html__('Your Organization Settings', 'event_espresso'),
480
+				EE_Registry::instance()->CFG,
481
+				__FILE__,
482
+				__FUNCTION__,
483
+				__LINE__
484
+			);
485
+		}
486
+
487
+		$this->_redirect_after_action($success, '', '', array('action' => 'default'), true);
488
+	}
489
+
490
+
491
+
492
+	/*************        Admin Options        *************/
493
+
494
+
495
+	/**
496
+	 * _admin_option_settings
497
+	 *
498
+	 * @throws \EE_Error
499
+	 * @throws \LogicException
500
+	 */
501
+	protected function _admin_option_settings()
502
+	{
503
+		$this->_template_args['admin_page_content'] = '';
504
+		try {
505
+			$admin_options_settings_form = new AdminOptionsSettings(EE_Registry::instance());
506
+			// still need this for the old school form in Extend_General_Settings_Admin_Page
507
+			$this->_template_args['values'] = $this->_yes_no_values;
508
+			// also need to account for the do_action that was in the old template
509
+			$admin_options_settings_form->setTemplateArgs($this->_template_args);
510
+			$this->_template_args['admin_page_content'] = $admin_options_settings_form->display();
511
+		} catch (Exception $e) {
512
+			EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__);
513
+		}
514
+		$this->_set_add_edit_form_tags('update_admin_option_settings');
515
+		$this->_set_publish_post_box_vars(null, false, false, null, false);
516
+		$this->display_admin_page_with_sidebar();
517
+	}
518
+
519
+
520
+	/**
521
+	 * _update_admin_option_settings
522
+	 *
523
+	 * @throws \EE_Error
524
+	 * @throws InvalidDataTypeException
525
+	 * @throws \EventEspresso\core\exceptions\InvalidFormSubmissionException
526
+	 * @throws \InvalidArgumentException
527
+	 * @throws \LogicException
528
+	 */
529
+	protected function _update_admin_option_settings()
530
+	{
531
+		try {
532
+			$admin_options_settings_form = new AdminOptionsSettings(EE_Registry::instance());
533
+			$admin_options_settings_form->process($this->_req_data[ $admin_options_settings_form->slug() ]);
534
+			EE_Registry::instance()->CFG->admin = apply_filters(
535
+				'FHEE__General_Settings_Admin_Page___update_admin_option_settings__CFG_admin',
536
+				EE_Registry::instance()->CFG->admin
537
+			);
538
+		} catch (Exception $e) {
539
+			EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__);
540
+		}
541
+		$this->_redirect_after_action(
542
+			apply_filters(
543
+				'FHEE__General_Settings_Admin_Page___update_admin_option_settings__success',
544
+				$this->_update_espresso_configuration(
545
+					'Admin Options',
546
+					EE_Registry::instance()->CFG->admin,
547
+					__FILE__,
548
+					__FUNCTION__,
549
+					__LINE__
550
+				)
551
+			),
552
+			'Admin Options',
553
+			'updated',
554
+			array('action' => 'admin_option_settings')
555
+		);
556
+	}
557
+
558
+
559
+	/*************        Countries        *************/
560
+
561
+
562
+	/**
563
+	 * @return string
564
+	 */
565
+	protected function getCountryIsoForSite()
566
+	{
567
+		return ! empty(EE_Registry::instance()->CFG->organization->CNT_ISO)
568
+			? EE_Registry::instance()->CFG->organization->CNT_ISO
569
+			: 'US';
570
+	}
571
+
572
+
573
+
574
+	/**
575
+	 * Output Country Settings view.
576
+	 *
577
+	 * @throws DomainException
578
+	 * @throws EE_Error
579
+	 */
580
+	protected function _country_settings()
581
+	{
582
+		$CNT_ISO_for_site = $this->getCountryIsoForSite();
583
+		$CNT_ISO = isset($this->_req_data['country'])
584
+			? strtoupper(sanitize_text_field($this->_req_data['country']))
585
+			: $CNT_ISO_for_site;
586
+
587
+		// load field generator helper
588
+
589
+		$this->_template_args['values'] = $this->_yes_no_values;
590
+
591
+		$this->_template_args['countries'] = new EE_Question_Form_Input(
592
+			EE_Question::new_instance(
593
+				array(
594
+					'QST_ID'           => 0,
595
+					'QST_display_text' => __('Select Country', 'event_espresso'),
596
+					'QST_system'       => 'admin-country',
597
+				)
598
+			),
599
+			EE_Answer::new_instance(
600
+				array(
601
+					'ANS_ID'    => 0,
602
+					'ANS_value' => $CNT_ISO,
603
+				)
604
+			),
605
+			array(
606
+				'input_id'       => 'country',
607
+				'input_name'     => 'country',
608
+				'input_prefix'   => '',
609
+				'append_qstn_id' => false,
610
+			)
611
+		);
612
+
613
+		add_filter('FHEE__EEH_Form_Fields__label_html', array($this, 'country_form_field_label_wrap'), 10, 2);
614
+		add_filter('FHEE__EEH_Form_Fields__input_html', array($this, 'country_form_field_input__wrap'), 10, 2);
615
+		$this->_template_args['country_details_settings'] = $this->display_country_settings();
616
+		$this->_template_args['country_states_settings'] = $this->display_country_states();
617
+		$this->_template_args['CNT_name_for_site'] = EEM_Country::instance()->get_one_by_ID($CNT_ISO_for_site)
618
+																			->name();
619
+
620
+		$this->_set_add_edit_form_tags('update_country_settings');
621
+		$this->_set_publish_post_box_vars(null, false, false, null, false);
622
+		$this->_template_args['admin_page_content'] = EEH_Template::display_template(
623
+			GEN_SET_TEMPLATE_PATH . 'countries_settings.template.php',
624
+			$this->_template_args,
625
+			true
626
+		);
627
+		$this->display_admin_page_with_no_sidebar();
628
+	}
629
+
630
+
631
+	/**
632
+	 *        display_country_settings
633
+	 *
634
+	 * @access    public
635
+	 * @param    string $CNT_ISO
636
+	 * @return mixed string | array
637
+	 * @throws DomainException
638
+	 */
639
+	public function display_country_settings($CNT_ISO = '')
640
+	{
641
+		$CNT_ISO_for_site = $this->getCountryIsoForSite();
642
+
643
+		$CNT_ISO = isset($this->_req_data['country'])
644
+			? strtoupper(sanitize_text_field($this->_req_data['country']))
645
+			: $CNT_ISO;
646
+		if (! $CNT_ISO) {
647
+			return '';
648
+		}
649
+
650
+		// for ajax
651
+		remove_all_filters('FHEE__EEH_Form_Fields__label_html');
652
+		remove_all_filters('FHEE__EEH_Form_Fields__input_html');
653
+		add_filter('FHEE__EEH_Form_Fields__label_html', array($this, 'country_form_field_label_wrap'), 10, 2);
654
+		add_filter('FHEE__EEH_Form_Fields__input_html', array($this, 'country_form_field_input__wrap'), 10, 2);
655
+		/** @var EE_Country $country */
656
+		$country = EEM_Country::instance()->get_one_by_ID($CNT_ISO);
657
+
658
+		$CNT_cur_disabled = $CNT_ISO !== $CNT_ISO_for_site;
659
+		$this->_template_args['CNT_cur_disabled'] = $CNT_cur_disabled;
660
+
661
+		$country_input_types = array(
662
+			'CNT_active'      => array(
663
+				'type'             => 'RADIO_BTN',
664
+				'input_name'       => 'cntry[' . $CNT_ISO . ']',
665
+				'class'            => '',
666
+				'options'          => $this->_yes_no_values,
667
+				'use_desc_4_label' => true,
668
+			),
669
+			'CNT_ISO'         => array(
670
+				'type'       => 'TEXT',
671
+				'input_name' => 'cntry[' . $CNT_ISO . ']',
672
+				'class'      => 'small-text',
673
+			),
674
+			'CNT_ISO3'        => array(
675
+				'type'       => 'TEXT',
676
+				'input_name' => 'cntry[' . $CNT_ISO . ']',
677
+				'class'      => 'small-text',
678
+			),
679
+			'RGN_ID'          => array(
680
+				'type'       => 'TEXT',
681
+				'input_name' => 'cntry[' . $CNT_ISO . ']',
682
+				'class'      => 'small-text',
683
+			),
684
+			'CNT_name'        => array(
685
+				'type'       => 'TEXT',
686
+				'input_name' => 'cntry[' . $CNT_ISO . ']',
687
+				'class'      => 'regular-text',
688
+			),
689
+			'CNT_cur_code'    => array(
690
+				'type'       => 'TEXT',
691
+				'input_name' => 'cntry[' . $CNT_ISO . ']',
692
+				'class'      => 'small-text',
693
+				'disabled'   => $CNT_cur_disabled
694
+			),
695
+			'CNT_cur_single'  => array(
696
+				'type'       => 'TEXT',
697
+				'input_name' => 'cntry[' . $CNT_ISO . ']',
698
+				'class'      => 'medium-text',
699
+				'disabled' => $CNT_cur_disabled
700
+			),
701
+			'CNT_cur_plural'  => array(
702
+				'type'       => 'TEXT',
703
+				'input_name' => 'cntry[' . $CNT_ISO . ']',
704
+				'class'      => 'medium-text',
705
+				'disabled' => $CNT_cur_disabled
706
+			),
707
+			'CNT_cur_sign'    => array(
708
+				'type'         => 'TEXT',
709
+				'input_name'   => 'cntry[' . $CNT_ISO . ']',
710
+				'class'        => 'small-text',
711
+				'htmlentities' => false,
712
+				'disabled' => $CNT_cur_disabled
713
+			),
714
+			'CNT_cur_sign_b4' => array(
715
+				'type'             => 'RADIO_BTN',
716
+				'input_name'       => 'cntry[' . $CNT_ISO . ']',
717
+				'class'            => '',
718
+				'options'          => $this->_yes_no_values,
719
+				'use_desc_4_label' => true,
720
+				'disabled' => $CNT_cur_disabled
721
+			),
722
+			'CNT_cur_dec_plc' => array(
723
+				'type'       => 'RADIO_BTN',
724
+				'input_name' => 'cntry[' . $CNT_ISO . ']',
725
+				'class'      => '',
726
+				'options'    => array(
727
+					array('id' => 0, 'text' => ''),
728
+					array('id' => 1, 'text' => ''),
729
+					array('id' => 2, 'text' => ''),
730
+					array('id' => 3, 'text' => ''),
731
+				),
732
+				'disabled' => $CNT_cur_disabled
733
+			),
734
+			'CNT_cur_dec_mrk' => array(
735
+				'type'             => 'RADIO_BTN',
736
+				'input_name'       => 'cntry[' . $CNT_ISO . ']',
737
+				'class'            => '',
738
+				'options'          => array(
739
+					array(
740
+						'id'   => ',',
741
+						'text' => __(', (comma)', 'event_espresso'),
742
+					),
743
+					array('id' => '.', 'text' => __('. (decimal)', 'event_espresso')),
744
+				),
745
+				'use_desc_4_label' => true,
746
+				'disabled' => $CNT_cur_disabled
747
+			),
748
+			'CNT_cur_thsnds'  => array(
749
+				'type'             => 'RADIO_BTN',
750
+				'input_name'       => 'cntry[' . $CNT_ISO . ']',
751
+				'class'            => '',
752
+				'options'          => array(
753
+					array(
754
+						'id'   => ',',
755
+						'text' => __(', (comma)', 'event_espresso'),
756
+					),
757
+					array('id' => '.', 'text' => __('. (decimal)', 'event_espresso')),
758
+				),
759
+				'use_desc_4_label' => true,
760
+				'disabled' => $CNT_cur_disabled
761
+			),
762
+			'CNT_tel_code'    => array(
763
+				'type'       => 'TEXT',
764
+				'input_name' => 'cntry[' . $CNT_ISO . ']',
765
+				'class'      => 'small-text',
766
+			),
767
+			'CNT_is_EU'       => array(
768
+				'type'             => 'RADIO_BTN',
769
+				'input_name'       => 'cntry[' . $CNT_ISO . ']',
770
+				'class'            => '',
771
+				'options'          => $this->_yes_no_values,
772
+				'use_desc_4_label' => true,
773
+			),
774
+		);
775
+		$this->_template_args['inputs'] = EE_Question_Form_Input::generate_question_form_inputs_for_object(
776
+			$country,
777
+			$country_input_types
778
+		);
779
+		$country_details_settings = EEH_Template::display_template(
780
+			GEN_SET_TEMPLATE_PATH . 'country_details_settings.template.php',
781
+			$this->_template_args,
782
+			true
783
+		);
784
+
785
+		if (defined('DOING_AJAX')) {
786
+			$notices = EE_Error::get_notices(false, false, false);
787
+			echo wp_json_encode(
788
+				array(
789
+					'return_data' => $country_details_settings,
790
+					'success'     => $notices['success'],
791
+					'errors'      => $notices['errors'],
792
+				)
793
+			);
794
+			die();
795
+		} else {
796
+			return $country_details_settings;
797
+		}
798
+	}
799
+
800
+
801
+	/**
802
+	 *        display_country_states
803
+	 *
804
+	 * @access    public
805
+	 * @param    string $CNT_ISO
806
+	 * @return string
807
+	 * @throws DomainException
808
+	 */
809
+	public function display_country_states($CNT_ISO = '')
810
+	{
811
+
812
+		$CNT_ISO = isset($this->_req_data['country']) ? sanitize_text_field($this->_req_data['country']) : $CNT_ISO;
813
+
814
+		if (! $CNT_ISO) {
815
+			return '';
816
+		}
817
+		// for ajax
818
+		remove_all_filters('FHEE__EEH_Form_Fields__label_html');
819
+		remove_all_filters('FHEE__EEH_Form_Fields__input_html');
820
+		add_filter('FHEE__EEH_Form_Fields__label_html', array($this, 'state_form_field_label_wrap'), 10, 2);
821
+		add_filter('FHEE__EEH_Form_Fields__input_html', array($this, 'state_form_field_input__wrap'), 10, 2);
822
+		$states = EEM_State::instance()->get_all_states_for_these_countries(array($CNT_ISO => $CNT_ISO));
823
+
824
+		if ($states) {
825
+			foreach ($states as $STA_ID => $state) {
826
+				if ($state instanceof EE_State) {
827
+					// STA_abbrev    STA_name    STA_active
828
+					$state_input_types = array(
829
+						'STA_abbrev' => array(
830
+							'type'       => 'TEXT',
831
+							'input_name' => 'states[' . $STA_ID . ']',
832
+							'class'      => 'mid-text',
833
+						),
834
+						'STA_name'   => array(
835
+							'type'       => 'TEXT',
836
+							'input_name' => 'states[' . $STA_ID . ']',
837
+							'class'      => 'regular-text',
838
+						),
839
+						'STA_active' => array(
840
+							'type'             => 'RADIO_BTN',
841
+							'input_name'       => 'states[' . $STA_ID . ']',
842
+							'options'          => $this->_yes_no_values,
843
+							'use_desc_4_label' => true,
844
+						),
845
+					);
846
+					$this->_template_args['states'][ $STA_ID ]['inputs'] =
847
+						EE_Question_Form_Input::generate_question_form_inputs_for_object(
848
+							$state,
849
+							$state_input_types
850
+						);
851
+					$query_args = array(
852
+						'action'     => 'delete_state',
853
+						'STA_ID'     => $STA_ID,
854
+						'CNT_ISO'    => $CNT_ISO,
855
+						'STA_abbrev' => $state->abbrev(),
856
+					);
857
+					$this->_template_args['states'][ $STA_ID ]['delete_state_url'] =
858
+						EE_Admin_Page::add_query_args_and_nonce(
859
+							$query_args,
860
+							GEN_SET_ADMIN_URL
861
+						);
862
+				}
863
+			}
864
+		} else {
865
+			$this->_template_args['states'] = false;
866
+		}
867
+
868
+		$this->_template_args['add_new_state_url'] = EE_Admin_Page::add_query_args_and_nonce(
869
+			array('action' => 'add_new_state'),
870
+			GEN_SET_ADMIN_URL
871
+		);
872
+
873
+		$state_details_settings = EEH_Template::display_template(
874
+			GEN_SET_TEMPLATE_PATH . 'state_details_settings.template.php',
875
+			$this->_template_args,
876
+			true
877
+		);
878
+
879
+		if (defined('DOING_AJAX')) {
880
+			$notices = EE_Error::get_notices(false, false, false);
881
+			echo wp_json_encode(
882
+				array(
883
+					'return_data' => $state_details_settings,
884
+					'success'     => $notices['success'],
885
+					'errors'      => $notices['errors'],
886
+				)
887
+			);
888
+			die();
889
+		} else {
890
+			return $state_details_settings;
891
+		}
892
+	}
893
+
894
+
895
+	/**
896
+	 *        add_new_state
897
+	 *
898
+	 * @access    public
899
+	 * @return void
900
+	 * @throws EE_Error
901
+	 */
902
+	public function add_new_state()
903
+	{
904
+
905
+		$success = true;
906
+
907
+		$CNT_ISO = isset($this->_req_data['CNT_ISO'])
908
+			? strtoupper(sanitize_text_field($this->_req_data['CNT_ISO']))
909
+			: false;
910
+		if (! $CNT_ISO) {
911
+			EE_Error::add_error(
912
+				__('No Country ISO code or an invalid Country ISO code was received.', 'event_espresso'),
913
+				__FILE__,
914
+				__FUNCTION__,
915
+				__LINE__
916
+			);
917
+			$success = false;
918
+		}
919
+		$STA_abbrev = isset($this->_req_data['STA_abbrev'])
920
+			? sanitize_text_field($this->_req_data['STA_abbrev'])
921
+			: false;
922
+		if (! $STA_abbrev) {
923
+			EE_Error::add_error(
924
+				__('No State ISO code or an invalid State ISO code was received.', 'event_espresso'),
925
+				__FILE__,
926
+				__FUNCTION__,
927
+				__LINE__
928
+			);
929
+			$success = false;
930
+		}
931
+		$STA_name = isset($this->_req_data['STA_name'])
932
+			? sanitize_text_field($this->_req_data['STA_name'])
933
+			: false;
934
+		if (! $STA_name) {
935
+			EE_Error::add_error(
936
+				__('No State name or an invalid State name was received.', 'event_espresso'),
937
+				__FILE__,
938
+				__FUNCTION__,
939
+				__LINE__
940
+			);
941
+			$success = false;
942
+		}
943
+
944
+		if ($success) {
945
+			$cols_n_values = array(
946
+				'CNT_ISO'    => $CNT_ISO,
947
+				'STA_abbrev' => $STA_abbrev,
948
+				'STA_name'   => $STA_name,
949
+				'STA_active' => true,
950
+			);
951
+			$success = EEM_State::instance()->insert($cols_n_values);
952
+			EE_Error::add_success(__('The State was added successfully.', 'event_espresso'));
953
+		}
954
+
955
+		if (defined('DOING_AJAX')) {
956
+			$notices = EE_Error::get_notices(false, false, false);
957
+			echo wp_json_encode(array_merge($notices, array('return_data' => $CNT_ISO)));
958
+			die();
959
+		} else {
960
+			$this->_redirect_after_action($success, 'State', 'added', array('action' => 'country_settings'));
961
+		}
962
+	}
963
+
964
+
965
+	/**
966
+	 *        delete_state
967
+	 *
968
+	 * @access    public
969
+	 * @return        boolean
970
+	 * @throws EE_Error
971
+	 * @throws EE_Error
972
+	 */
973
+	public function delete_state()
974
+	{
975
+		$CNT_ISO = isset($this->_req_data['CNT_ISO'])
976
+			? strtoupper(sanitize_text_field($this->_req_data['CNT_ISO']))
977
+			: false;
978
+		$STA_ID = isset($this->_req_data['STA_ID'])
979
+			? sanitize_text_field($this->_req_data['STA_ID'])
980
+			: false;
981
+		$STA_abbrev = isset($this->_req_data['STA_abbrev'])
982
+			? sanitize_text_field($this->_req_data['STA_abbrev'])
983
+			: false;
984
+		if (! $STA_ID) {
985
+			EE_Error::add_error(
986
+				__('No State ID or an invalid State ID was received.', 'event_espresso'),
987
+				__FILE__,
988
+				__FUNCTION__,
989
+				__LINE__
990
+			);
991
+			return false;
992
+		}
993
+
994
+		$success = EEM_State::instance()->delete_by_ID($STA_ID);
995
+		if ($success !== false) {
996
+			do_action(
997
+				'AHEE__General_Settings_Admin_Page__delete_state__state_deleted',
998
+				$CNT_ISO,
999
+				$STA_ID,
1000
+				array('STA_abbrev' => $STA_abbrev)
1001
+			);
1002
+			EE_Error::add_success(__('The State was deleted successfully.', 'event_espresso'));
1003
+		}
1004
+		if (defined('DOING_AJAX')) {
1005
+			$notices = EE_Error::get_notices(false, false);
1006
+			$notices['return_data'] = true;
1007
+			echo wp_json_encode($notices);
1008
+			die();
1009
+		} else {
1010
+			$this->_redirect_after_action(
1011
+				$success,
1012
+				'State',
1013
+				'deleted',
1014
+				array('action' => 'country_settings')
1015
+			);
1016
+		}
1017
+	}
1018
+
1019
+
1020
+	/**
1021
+	 *        _update_country_settings
1022
+	 *
1023
+	 * @access    protected
1024
+	 * @return void
1025
+	 * @throws EE_Error
1026
+	 */
1027
+	protected function _update_country_settings()
1028
+	{
1029
+		// grab the country ISO code
1030
+		$CNT_ISO = isset($this->_req_data['country'])
1031
+			? strtoupper(sanitize_text_field($this->_req_data['country']))
1032
+			: false;
1033
+		if (! $CNT_ISO) {
1034
+			EE_Error::add_error(
1035
+				__('No Country ISO code or an invalid Country ISO code was received.', 'event_espresso'),
1036
+				__FILE__,
1037
+				__FUNCTION__,
1038
+				__LINE__
1039
+			);
1040
+
1041
+			return;
1042
+		}
1043
+		$cols_n_values = array();
1044
+		$cols_n_values['CNT_ISO3'] = isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_ISO3'])
1045
+			? strtoupper(sanitize_text_field($this->_req_data['cntry'][ $CNT_ISO ]['CNT_ISO3']))
1046
+			: false;
1047
+		$cols_n_values['RGN_ID'] = isset($this->_req_data['cntry'][ $CNT_ISO ]['RGN_ID'])
1048
+			? absint($this->_req_data['cntry'][ $CNT_ISO ]['RGN_ID'])
1049
+			: null;
1050
+		$cols_n_values['CNT_name'] = isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_name'])
1051
+			? sanitize_text_field($this->_req_data['cntry'][ $CNT_ISO ]['CNT_name'])
1052
+			: null;
1053
+		if (isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_code'])) {
1054
+			$cols_n_values['CNT_cur_code'] = strtoupper(
1055
+				sanitize_text_field($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_code'])
1056
+			);
1057
+		}
1058
+		if (isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_single'])) {
1059
+			$cols_n_values['CNT_cur_single'] = sanitize_text_field(
1060
+				$this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_single']
1061
+			);
1062
+		}
1063
+		if (isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_plural'])) {
1064
+			$cols_n_values['CNT_cur_plural'] = sanitize_text_field(
1065
+				$this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_plural']
1066
+			);
1067
+		}
1068
+		if (isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_sign'])) {
1069
+			$cols_n_values['CNT_cur_sign'] = sanitize_text_field(
1070
+				$this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_sign']
1071
+			);
1072
+		}
1073
+		if (isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_sign_b4'])) {
1074
+			$cols_n_values['CNT_cur_sign_b4'] = absint(
1075
+				$this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_sign_b4']
1076
+			);
1077
+		}
1078
+		if (isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_dec_plc'])) {
1079
+			$cols_n_values['CNT_cur_dec_plc'] = absint(
1080
+				$this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_dec_plc']
1081
+			);
1082
+		}
1083
+		if (isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_dec_mrk'])) {
1084
+			$cols_n_values['CNT_cur_dec_mrk'] = sanitize_text_field(
1085
+				$this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_dec_mrk']
1086
+			);
1087
+		}
1088
+		if (isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_thsnds'])) {
1089
+			$cols_n_values['CNT_cur_thsnds'] = sanitize_text_field(
1090
+				$this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_thsnds']
1091
+			);
1092
+		}
1093
+		$cols_n_values['CNT_tel_code'] = isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_tel_code'])
1094
+			? sanitize_text_field($this->_req_data['cntry'][ $CNT_ISO ]['CNT_tel_code'])
1095
+			: null;
1096
+		$cols_n_values['CNT_is_EU'] = isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_is_EU'])
1097
+			? absint($this->_req_data['cntry'][ $CNT_ISO ]['CNT_is_EU'])
1098
+			: false;
1099
+		$cols_n_values['CNT_active'] = isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_active'])
1100
+			? absint($this->_req_data['cntry'][ $CNT_ISO ]['CNT_active'])
1101
+			: false;
1102
+		// allow filtering of country data
1103
+		$cols_n_values = apply_filters(
1104
+			'FHEE__General_Settings_Admin_Page___update_country_settings__cols_n_values',
1105
+			$cols_n_values
1106
+		);
1107
+
1108
+		// where values
1109
+		$where_cols_n_values = array(array('CNT_ISO' => $CNT_ISO));
1110
+		// run the update
1111
+		$success = EEM_Country::instance()->update($cols_n_values, $where_cols_n_values);
1112
+
1113
+		if (isset($this->_req_data['states']) && is_array($this->_req_data['states']) && $success !== false) {
1114
+			// allow filtering of states data
1115
+			$states = apply_filters(
1116
+				'FHEE__General_Settings_Admin_Page___update_country_settings__states',
1117
+				$this->_req_data['states']
1118
+			);
1119
+
1120
+			// loop thru state data ( looks like : states[75][STA_name] )
1121
+			foreach ($states as $STA_ID => $state) {
1122
+				$cols_n_values = array(
1123
+					'CNT_ISO'    => $CNT_ISO,
1124
+					'STA_abbrev' => sanitize_text_field($state['STA_abbrev']),
1125
+					'STA_name'   => sanitize_text_field($state['STA_name']),
1126
+					'STA_active' => (bool) absint($state['STA_active']),
1127
+				);
1128
+				// where values
1129
+				$where_cols_n_values = array(array('STA_ID' => $STA_ID));
1130
+				// run the update
1131
+				$success = EEM_State::instance()->update($cols_n_values, $where_cols_n_values);
1132
+				if ($success !== false) {
1133
+					do_action(
1134
+						'AHEE__General_Settings_Admin_Page__update_country_settings__state_saved',
1135
+						$CNT_ISO,
1136
+						$STA_ID,
1137
+						$cols_n_values
1138
+					);
1139
+				}
1140
+			}
1141
+		}
1142
+		// check if country being edited matches org option country, and if so, then  update EE_Config with new settings
1143
+		if (isset(EE_Registry::instance()->CFG->organization->CNT_ISO)
1144
+			&& $CNT_ISO == EE_Registry::instance()->CFG->organization->CNT_ISO
1145
+		) {
1146
+			EE_Registry::instance()->CFG->currency = new EE_Currency_Config($CNT_ISO);
1147
+			EE_Registry::instance()->CFG->update_espresso_config();
1148
+		}
1149
+
1150
+		if ($success !== false) {
1151
+			EE_Error::add_success(
1152
+				esc_html__('Country Settings updated successfully.', 'event_espresso')
1153
+			);
1154
+		}
1155
+		$this->_redirect_after_action(
1156
+			$success,
1157
+			'',
1158
+			'',
1159
+			array('action' => 'country_settings', 'country' => $CNT_ISO),
1160
+			true
1161
+		);
1162
+	}
1163
+
1164
+
1165
+	/**
1166
+	 *        form_form_field_label_wrap
1167
+	 *
1168
+	 * @access        public
1169
+	 * @param        string $label
1170
+	 * @return        string
1171
+	 */
1172
+	public function country_form_field_label_wrap($label, $required_text)
1173
+	{
1174
+		return '
1175 1175
 			<tr>
1176 1176
 				<th>
1177 1177
 					' . $label . '
1178 1178
 				</th>';
1179
-    }
1180
-
1181
-
1182
-    /**
1183
-     *        form_form_field_input__wrap
1184
-     *
1185
-     * @access        public
1186
-     * @param        string $label
1187
-     * @return        string
1188
-     */
1189
-    public function country_form_field_input__wrap($input, $label)
1190
-    {
1191
-        return '
1179
+	}
1180
+
1181
+
1182
+	/**
1183
+	 *        form_form_field_input__wrap
1184
+	 *
1185
+	 * @access        public
1186
+	 * @param        string $label
1187
+	 * @return        string
1188
+	 */
1189
+	public function country_form_field_input__wrap($input, $label)
1190
+	{
1191
+		return '
1192 1192
 				<td class="general-settings-country-input-td">
1193 1193
 					' . $input . '
1194 1194
 				</td>
1195 1195
 			</tr>';
1196
-    }
1197
-
1198
-
1199
-    /**
1200
-     *        form_form_field_label_wrap
1201
-     *
1202
-     * @access        public
1203
-     * @param        string $label
1204
-     * @param        string $required_text
1205
-     * @return        string
1206
-     */
1207
-    public function state_form_field_label_wrap($label, $required_text)
1208
-    {
1209
-        return $required_text;
1210
-    }
1211
-
1212
-
1213
-    /**
1214
-     *        form_form_field_input__wrap
1215
-     *
1216
-     * @access        public
1217
-     * @param        string $label
1218
-     * @return        string
1219
-     */
1220
-    public function state_form_field_input__wrap($input, $label)
1221
-    {
1222
-        return '
1196
+	}
1197
+
1198
+
1199
+	/**
1200
+	 *        form_form_field_label_wrap
1201
+	 *
1202
+	 * @access        public
1203
+	 * @param        string $label
1204
+	 * @param        string $required_text
1205
+	 * @return        string
1206
+	 */
1207
+	public function state_form_field_label_wrap($label, $required_text)
1208
+	{
1209
+		return $required_text;
1210
+	}
1211
+
1212
+
1213
+	/**
1214
+	 *        form_form_field_input__wrap
1215
+	 *
1216
+	 * @access        public
1217
+	 * @param        string $label
1218
+	 * @return        string
1219
+	 */
1220
+	public function state_form_field_input__wrap($input, $label)
1221
+	{
1222
+		return '
1223 1223
 				<td class="general-settings-country-state-input-td">
1224 1224
 					' . $input . '
1225 1225
 				</td>';
1226
-    }
1227
-
1228
-
1229
-    /***********/
1230
-
1231
-
1232
-    /**
1233
-     * displays edit and view links for critical EE pages
1234
-     *
1235
-     * @access public
1236
-     * @param int $ee_page_id
1237
-     * @return string
1238
-     */
1239
-    public static function edit_view_links($ee_page_id)
1240
-    {
1241
-        $links = '<a href="'
1242
-                 . add_query_arg(
1243
-                     array('post' => $ee_page_id, 'action' => 'edit'),
1244
-                     admin_url('post.php')
1245
-                 )
1246
-                 . '" >'
1247
-                 . __('Edit', 'event_espresso')
1248
-                 . '</a>';
1249
-        $links .= ' &nbsp;|&nbsp; ';
1250
-        $links .= '<a href="' . get_permalink($ee_page_id) . '" >' . __('View', 'event_espresso') . '</a>';
1251
-
1252
-        return $links;
1253
-    }
1254
-
1255
-
1256
-    /**
1257
-     * displays page and shortcode status for critical EE pages
1258
-     *
1259
-     * @param WP page object $ee_page
1260
-     * @return string
1261
-     */
1262
-    public static function page_and_shortcode_status($ee_page, $shortcode)
1263
-    {
1264
-
1265
-        // page status
1266
-        if (isset($ee_page->post_status) && $ee_page->post_status == 'publish') {
1267
-            $pg_colour = 'green';
1268
-            $pg_status = sprintf(__('Page%sStatus%sOK', 'event_espresso'), '&nbsp;', '&nbsp;');
1269
-        } else {
1270
-            $pg_colour = 'red';
1271
-            $pg_status = sprintf(__('Page%sVisibility%sProblem', 'event_espresso'), '&nbsp;', '&nbsp;');
1272
-        }
1273
-
1274
-        // shortcode status
1275
-        if (isset($ee_page->post_content) && strpos($ee_page->post_content, $shortcode) !== false) {
1276
-            $sc_colour = 'green';
1277
-            $sc_status = sprintf(__('Shortcode%sOK', 'event_espresso'), '&nbsp;');
1278
-        } else {
1279
-            $sc_colour = 'red';
1280
-            $sc_status = sprintf(__('Shortcode%sProblem', 'event_espresso'), '&nbsp;');
1281
-        }
1282
-
1283
-        return '<span style="color:' . $pg_colour . '; margin-right:2em;"><strong>'
1284
-               . $pg_status
1285
-               . '</strong></span><span style="color:' . $sc_colour . '"><strong>' . $sc_status . '</strong></span>';
1286
-    }
1287
-
1288
-
1289
-    /**
1290
-     * generates a dropdown of all parent pages - copied from WP core
1291
-     *
1292
-     * @param int $default
1293
-     * @param int $parent
1294
-     * @param int $level
1295
-     */
1296
-    public static function page_settings_dropdown($default = 0, $parent = 0, $level = 0)
1297
-    {
1298
-        global $wpdb;
1299
-        $items = $wpdb->get_results(
1300
-            $wpdb->prepare(
1301
-                "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",
1302
-                $parent
1303
-            )
1304
-        );
1305
-
1306
-        if ($items) {
1307
-            foreach ($items as $item) {
1308
-                $pad = str_repeat('&nbsp;', $level * 3);
1309
-                if ($item->ID == $default) {
1310
-                    $current = ' selected="selected"';
1311
-                } else {
1312
-                    $current = '';
1313
-                }
1314
-
1315
-                echo "\n\t<option class='level-$level' value='$item->ID'$current>$pad "
1316
-                     . esc_html($item->post_title)
1317
-                     . "</option>";
1318
-                parent_dropdown($default, $item->ID, $level + 1);
1319
-            }
1320
-        }
1321
-    }
1322
-
1323
-
1324
-    /**
1325
-     * Loads the scripts for the privacy settings form
1326
-     */
1327
-    public function load_scripts_styles_privacy_settings()
1328
-    {
1329
-        $form_handler = $this->loader->getShared('EventEspresso\core\domain\services\admin\privacy\forms\PrivacySettingsFormHandler');
1330
-        $form_handler->enqueueStylesAndScripts();
1331
-    }
1332
-
1333
-
1334
-    /**
1335
-     * display the privacy settings form
1336
-     */
1337
-    public function privacySettings()
1338
-    {
1339
-        $this->_set_add_edit_form_tags('update_privacy_settings');
1340
-        $this->_set_publish_post_box_vars(null, false, false, null, false);
1341
-        $form_handler = $this->loader->getShared('EventEspresso\core\domain\services\admin\privacy\forms\PrivacySettingsFormHandler');
1342
-        $this->_template_args['admin_page_content'] = $form_handler->display();
1343
-        $this->display_admin_page_with_sidebar();
1344
-    }
1345
-
1346
-
1347
-    /**
1348
-     * Update the privacy settings from form data
1349
-     *
1350
-     * @throws EE_Error
1351
-     */
1352
-    public function updatePrivacySettings()
1353
-    {
1354
-        $form_handler = $this->loader->getShared('EventEspresso\core\domain\services\admin\privacy\forms\PrivacySettingsFormHandler');
1355
-        $success = $form_handler->process($this->get_request_data());
1356
-        $this->_redirect_after_action(
1357
-            $success,
1358
-            esc_html__('Registration Form Options', 'event_espresso'),
1359
-            'updated',
1360
-            array('action' => 'privacy_settings')
1361
-        );
1362
-    }
1226
+	}
1227
+
1228
+
1229
+	/***********/
1230
+
1231
+
1232
+	/**
1233
+	 * displays edit and view links for critical EE pages
1234
+	 *
1235
+	 * @access public
1236
+	 * @param int $ee_page_id
1237
+	 * @return string
1238
+	 */
1239
+	public static function edit_view_links($ee_page_id)
1240
+	{
1241
+		$links = '<a href="'
1242
+				 . add_query_arg(
1243
+					 array('post' => $ee_page_id, 'action' => 'edit'),
1244
+					 admin_url('post.php')
1245
+				 )
1246
+				 . '" >'
1247
+				 . __('Edit', 'event_espresso')
1248
+				 . '</a>';
1249
+		$links .= ' &nbsp;|&nbsp; ';
1250
+		$links .= '<a href="' . get_permalink($ee_page_id) . '" >' . __('View', 'event_espresso') . '</a>';
1251
+
1252
+		return $links;
1253
+	}
1254
+
1255
+
1256
+	/**
1257
+	 * displays page and shortcode status for critical EE pages
1258
+	 *
1259
+	 * @param WP page object $ee_page
1260
+	 * @return string
1261
+	 */
1262
+	public static function page_and_shortcode_status($ee_page, $shortcode)
1263
+	{
1264
+
1265
+		// page status
1266
+		if (isset($ee_page->post_status) && $ee_page->post_status == 'publish') {
1267
+			$pg_colour = 'green';
1268
+			$pg_status = sprintf(__('Page%sStatus%sOK', 'event_espresso'), '&nbsp;', '&nbsp;');
1269
+		} else {
1270
+			$pg_colour = 'red';
1271
+			$pg_status = sprintf(__('Page%sVisibility%sProblem', 'event_espresso'), '&nbsp;', '&nbsp;');
1272
+		}
1273
+
1274
+		// shortcode status
1275
+		if (isset($ee_page->post_content) && strpos($ee_page->post_content, $shortcode) !== false) {
1276
+			$sc_colour = 'green';
1277
+			$sc_status = sprintf(__('Shortcode%sOK', 'event_espresso'), '&nbsp;');
1278
+		} else {
1279
+			$sc_colour = 'red';
1280
+			$sc_status = sprintf(__('Shortcode%sProblem', 'event_espresso'), '&nbsp;');
1281
+		}
1282
+
1283
+		return '<span style="color:' . $pg_colour . '; margin-right:2em;"><strong>'
1284
+			   . $pg_status
1285
+			   . '</strong></span><span style="color:' . $sc_colour . '"><strong>' . $sc_status . '</strong></span>';
1286
+	}
1287
+
1288
+
1289
+	/**
1290
+	 * generates a dropdown of all parent pages - copied from WP core
1291
+	 *
1292
+	 * @param int $default
1293
+	 * @param int $parent
1294
+	 * @param int $level
1295
+	 */
1296
+	public static function page_settings_dropdown($default = 0, $parent = 0, $level = 0)
1297
+	{
1298
+		global $wpdb;
1299
+		$items = $wpdb->get_results(
1300
+			$wpdb->prepare(
1301
+				"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",
1302
+				$parent
1303
+			)
1304
+		);
1305
+
1306
+		if ($items) {
1307
+			foreach ($items as $item) {
1308
+				$pad = str_repeat('&nbsp;', $level * 3);
1309
+				if ($item->ID == $default) {
1310
+					$current = ' selected="selected"';
1311
+				} else {
1312
+					$current = '';
1313
+				}
1314
+
1315
+				echo "\n\t<option class='level-$level' value='$item->ID'$current>$pad "
1316
+					 . esc_html($item->post_title)
1317
+					 . "</option>";
1318
+				parent_dropdown($default, $item->ID, $level + 1);
1319
+			}
1320
+		}
1321
+	}
1322
+
1323
+
1324
+	/**
1325
+	 * Loads the scripts for the privacy settings form
1326
+	 */
1327
+	public function load_scripts_styles_privacy_settings()
1328
+	{
1329
+		$form_handler = $this->loader->getShared('EventEspresso\core\domain\services\admin\privacy\forms\PrivacySettingsFormHandler');
1330
+		$form_handler->enqueueStylesAndScripts();
1331
+	}
1332
+
1333
+
1334
+	/**
1335
+	 * display the privacy settings form
1336
+	 */
1337
+	public function privacySettings()
1338
+	{
1339
+		$this->_set_add_edit_form_tags('update_privacy_settings');
1340
+		$this->_set_publish_post_box_vars(null, false, false, null, false);
1341
+		$form_handler = $this->loader->getShared('EventEspresso\core\domain\services\admin\privacy\forms\PrivacySettingsFormHandler');
1342
+		$this->_template_args['admin_page_content'] = $form_handler->display();
1343
+		$this->display_admin_page_with_sidebar();
1344
+	}
1345
+
1346
+
1347
+	/**
1348
+	 * Update the privacy settings from form data
1349
+	 *
1350
+	 * @throws EE_Error
1351
+	 */
1352
+	public function updatePrivacySettings()
1353
+	{
1354
+		$form_handler = $this->loader->getShared('EventEspresso\core\domain\services\admin\privacy\forms\PrivacySettingsFormHandler');
1355
+		$success = $form_handler->process($this->get_request_data());
1356
+		$this->_redirect_after_action(
1357
+			$success,
1358
+			esc_html__('Registration Form Options', 'event_espresso'),
1359
+			'updated',
1360
+			array('action' => 'privacy_settings')
1361
+		);
1362
+	}
1363 1363
 }
Please login to merge, or discard this patch.