Completed
Branch BUG/country-settings-fatal (a3d5d1)
by
unknown
162:41 queued 09:26
created
admin_pages/general_settings/General_Settings_Admin_Page.core.php 1 patch
Indentation   +1332 added lines, -1332 removed lines patch added patch discarded remove patch
@@ -21,1347 +21,1347 @@
 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
-            $organization_settings_form = new OrganizationSettings(
441
-                EE_Registry::instance(),
442
-                EE_Registry::instance()->CFG->organization,
443
-                EE_Registry::instance()->CFG->core,
444
-                EE_Registry::instance()->NET_CFG->core
445
-            );
446
-            $this->_template_args['admin_page_content'] = $organization_settings_form->display();
447
-        } catch (Exception $e) {
448
-            EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__);
449
-        }
450
-        $this->_set_add_edit_form_tags('update_your_organization_settings');
451
-        $this->_set_publish_post_box_vars(null, false, false, null, false);
452
-        $this->display_admin_page_with_sidebar();
453
-    }
454
-
455
-
456
-
457
-    /**
458
-     * Handler for updating organization settings.
459
-     *
460
-     * @throws EE_Error
461
-     */
462
-    protected function _update_your_organization_settings()
463
-    {
464
-        try {
465
-            $organization_settings_form = new OrganizationSettings(
466
-                EE_Registry::instance(),
467
-                EE_Registry::instance()->CFG->organization,
468
-                EE_Registry::instance()->CFG->core,
469
-                EE_Registry::instance()->NET_CFG->core
470
-            );
471
-            $success = $organization_settings_form->process($this->_req_data);
472
-            EE_Registry::instance()->CFG = apply_filters(
473
-                'FHEE__General_Settings_Admin_Page___update_your_organization_settings__CFG',
474
-                EE_Registry::instance()->CFG
475
-            );
476
-        } catch (Exception $e) {
477
-            EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__);
478
-            $success = false;
479
-        }
480
-
481
-        if ($success) {
482
-            $success = $this->_update_espresso_configuration(
483
-                esc_html__('Your Organization Settings', 'event_espresso'),
484
-                EE_Registry::instance()->CFG,
485
-                __FILE__,
486
-                __FUNCTION__,
487
-                __LINE__
488
-            );
489
-        }
490
-
491
-        $this->_redirect_after_action($success, '', '', array('action' => 'default'), true);
492
-    }
493
-
494
-
495
-
496
-    /*************        Admin Options        *************/
497
-
498
-
499
-    /**
500
-     * _admin_option_settings
501
-     *
502
-     * @throws \EE_Error
503
-     * @throws \LogicException
504
-     */
505
-    protected function _admin_option_settings()
506
-    {
507
-        $this->_template_args['admin_page_content'] = '';
508
-        try {
509
-            $admin_options_settings_form = new AdminOptionsSettings(EE_Registry::instance());
510
-            // still need this for the old school form in Extend_General_Settings_Admin_Page
511
-            $this->_template_args['values'] = $this->_yes_no_values;
512
-            // also need to account for the do_action that was in the old template
513
-            $admin_options_settings_form->setTemplateArgs($this->_template_args);
514
-            $this->_template_args['admin_page_content'] = $admin_options_settings_form->display();
515
-        } catch (Exception $e) {
516
-            EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__);
517
-        }
518
-        $this->_set_add_edit_form_tags('update_admin_option_settings');
519
-        $this->_set_publish_post_box_vars(null, false, false, null, false);
520
-        $this->display_admin_page_with_sidebar();
521
-    }
522
-
523
-
524
-    /**
525
-     * _update_admin_option_settings
526
-     *
527
-     * @throws \EE_Error
528
-     * @throws InvalidDataTypeException
529
-     * @throws \EventEspresso\core\exceptions\InvalidFormSubmissionException
530
-     * @throws \InvalidArgumentException
531
-     * @throws \LogicException
532
-     */
533
-    protected function _update_admin_option_settings()
534
-    {
535
-        try {
536
-            $admin_options_settings_form = new AdminOptionsSettings(EE_Registry::instance());
537
-            $admin_options_settings_form->process($this->_req_data[ $admin_options_settings_form->slug() ]);
538
-            EE_Registry::instance()->CFG->admin = apply_filters(
539
-                'FHEE__General_Settings_Admin_Page___update_admin_option_settings__CFG_admin',
540
-                EE_Registry::instance()->CFG->admin
541
-            );
542
-        } catch (Exception $e) {
543
-            EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__);
544
-        }
545
-        $this->_redirect_after_action(
546
-            apply_filters(
547
-                'FHEE__General_Settings_Admin_Page___update_admin_option_settings__success',
548
-                $this->_update_espresso_configuration(
549
-                    'Admin Options',
550
-                    EE_Registry::instance()->CFG->admin,
551
-                    __FILE__,
552
-                    __FUNCTION__,
553
-                    __LINE__
554
-                )
555
-            ),
556
-            'Admin Options',
557
-            'updated',
558
-            array('action' => 'admin_option_settings')
559
-        );
560
-    }
561
-
562
-
563
-    /*************        Countries        *************/
564
-
565
-
566
-    /**
567
-     * @return string
568
-     */
569
-    protected function getCountryIsoForSite()
570
-    {
571
-        return ! empty(EE_Registry::instance()->CFG->organization->CNT_ISO)
572
-            ? EE_Registry::instance()->CFG->organization->CNT_ISO
573
-            : 'US';
574
-    }
575
-
576
-
577
-
578
-    /**
579
-     * Output Country Settings view.
580
-     *
581
-     * @throws DomainException
582
-     * @throws EE_Error
583
-     */
584
-    protected function _country_settings()
585
-    {
586
-        $CNT_ISO_for_site = $this->getCountryIsoForSite();
587
-        $CNT_ISO = isset($this->_req_data['country'])
588
-            ? strtoupper(sanitize_text_field($this->_req_data['country']))
589
-            : $CNT_ISO_for_site;
590
-
591
-        // load field generator helper
592
-
593
-        $this->_template_args['values'] = $this->_yes_no_values;
594
-
595
-        $this->_template_args['countries'] = new EE_Question_Form_Input(
596
-            EE_Question::new_instance(
597
-                array(
598
-                    'QST_ID'           => 0,
599
-                    'QST_display_text' => __('Select Country', 'event_espresso'),
600
-                    'QST_system'       => 'admin-country',
601
-                )
602
-            ),
603
-            EE_Answer::new_instance(
604
-                array(
605
-                    'ANS_ID'    => 0,
606
-                    'ANS_value' => $CNT_ISO,
607
-                )
608
-            ),
609
-            array(
610
-                'input_id'       => 'country',
611
-                'input_name'     => 'country',
612
-                'input_prefix'   => '',
613
-                'append_qstn_id' => false,
614
-            )
615
-        );
616
-
617
-        add_filter('FHEE__EEH_Form_Fields__label_html', array($this, 'country_form_field_label_wrap'), 10, 2);
618
-        add_filter('FHEE__EEH_Form_Fields__input_html', array($this, 'country_form_field_input__wrap'), 10, 2);
619
-        $this->_template_args['country_details_settings'] = $this->display_country_settings();
620
-        $this->_template_args['country_states_settings'] = $this->display_country_states();
621
-        $this->_template_args['CNT_name_for_site'] = EEM_Country::instance()->get_one_by_ID($CNT_ISO_for_site)
622
-                                                                            ->name();
623
-
624
-        $this->_set_add_edit_form_tags('update_country_settings');
625
-        $this->_set_publish_post_box_vars(null, false, false, null, false);
626
-        $this->_template_args['admin_page_content'] = EEH_Template::display_template(
627
-            GEN_SET_TEMPLATE_PATH . 'countries_settings.template.php',
628
-            $this->_template_args,
629
-            true
630
-        );
631
-        $this->display_admin_page_with_no_sidebar();
632
-    }
633
-
634
-
635
-    /**
636
-     *        display_country_settings
637
-     *
638
-     * @access    public
639
-     * @param    string $CNT_ISO
640
-     * @return mixed string | array
641
-     * @throws DomainException
642
-     */
643
-    public function display_country_settings($CNT_ISO = '')
644
-    {
645
-        $CNT_ISO_for_site = $this->getCountryIsoForSite();
646
-
647
-        $CNT_ISO = isset($this->_req_data['country'])
648
-            ? strtoupper(sanitize_text_field($this->_req_data['country']))
649
-            : $CNT_ISO;
650
-        if (! $CNT_ISO) {
651
-            return '';
652
-        }
653
-
654
-        // for ajax
655
-        remove_all_filters('FHEE__EEH_Form_Fields__label_html');
656
-        remove_all_filters('FHEE__EEH_Form_Fields__input_html');
657
-        add_filter('FHEE__EEH_Form_Fields__label_html', array($this, 'country_form_field_label_wrap'), 10, 2);
658
-        add_filter('FHEE__EEH_Form_Fields__input_html', array($this, 'country_form_field_input__wrap'), 10, 2);
659
-        /** @var EE_Country $country */
660
-        $country = EEM_Country::instance()->get_one_by_ID($CNT_ISO);
661
-
662
-        $CNT_cur_disabled = $CNT_ISO !== $CNT_ISO_for_site;
663
-        $this->_template_args['CNT_cur_disabled'] = $CNT_cur_disabled;
664
-
665
-        $country_input_types = array(
666
-            'CNT_active'      => array(
667
-                'type'             => 'RADIO_BTN',
668
-                'input_name'       => 'cntry[' . $CNT_ISO . ']',
669
-                'class'            => '',
670
-                'options'          => $this->_yes_no_values,
671
-                'use_desc_4_label' => true,
672
-            ),
673
-            'CNT_ISO'         => array(
674
-                'type'       => 'TEXT',
675
-                'input_name' => 'cntry[' . $CNT_ISO . ']',
676
-                'class'      => 'small-text',
677
-            ),
678
-            'CNT_ISO3'        => array(
679
-                'type'       => 'TEXT',
680
-                'input_name' => 'cntry[' . $CNT_ISO . ']',
681
-                'class'      => 'small-text',
682
-            ),
683
-            'RGN_ID'          => array(
684
-                'type'       => 'TEXT',
685
-                'input_name' => 'cntry[' . $CNT_ISO . ']',
686
-                'class'      => 'small-text',
687
-            ),
688
-            'CNT_name'        => array(
689
-                'type'       => 'TEXT',
690
-                'input_name' => 'cntry[' . $CNT_ISO . ']',
691
-                'class'      => 'regular-text',
692
-            ),
693
-            'CNT_cur_code'    => array(
694
-                'type'       => 'TEXT',
695
-                'input_name' => 'cntry[' . $CNT_ISO . ']',
696
-                'class'      => 'small-text',
697
-                'disabled'   => $CNT_cur_disabled
698
-            ),
699
-            'CNT_cur_single'  => array(
700
-                'type'       => 'TEXT',
701
-                'input_name' => 'cntry[' . $CNT_ISO . ']',
702
-                'class'      => 'medium-text',
703
-                'disabled' => $CNT_cur_disabled
704
-            ),
705
-            'CNT_cur_plural'  => array(
706
-                'type'       => 'TEXT',
707
-                'input_name' => 'cntry[' . $CNT_ISO . ']',
708
-                'class'      => 'medium-text',
709
-                'disabled' => $CNT_cur_disabled
710
-            ),
711
-            'CNT_cur_sign'    => array(
712
-                'type'         => 'TEXT',
713
-                'input_name'   => 'cntry[' . $CNT_ISO . ']',
714
-                'class'        => 'small-text',
715
-                'htmlentities' => false,
716
-                'disabled' => $CNT_cur_disabled
717
-            ),
718
-            'CNT_cur_sign_b4' => array(
719
-                'type'             => 'RADIO_BTN',
720
-                'input_name'       => 'cntry[' . $CNT_ISO . ']',
721
-                'class'            => '',
722
-                'options'          => $this->_yes_no_values,
723
-                'use_desc_4_label' => true,
724
-                'disabled' => $CNT_cur_disabled
725
-            ),
726
-            'CNT_cur_dec_plc' => array(
727
-                'type'       => 'RADIO_BTN',
728
-                'input_name' => 'cntry[' . $CNT_ISO . ']',
729
-                'class'      => '',
730
-                'options'    => array(
731
-                    array('id' => 0, 'text' => ''),
732
-                    array('id' => 1, 'text' => ''),
733
-                    array('id' => 2, 'text' => ''),
734
-                    array('id' => 3, 'text' => ''),
735
-                ),
736
-                'disabled' => $CNT_cur_disabled
737
-            ),
738
-            'CNT_cur_dec_mrk' => array(
739
-                'type'             => 'RADIO_BTN',
740
-                'input_name'       => 'cntry[' . $CNT_ISO . ']',
741
-                'class'            => '',
742
-                'options'          => array(
743
-                    array(
744
-                        'id'   => ',',
745
-                        'text' => __(', (comma)', 'event_espresso'),
746
-                    ),
747
-                    array('id' => '.', 'text' => __('. (decimal)', 'event_espresso')),
748
-                ),
749
-                'use_desc_4_label' => true,
750
-                'disabled' => $CNT_cur_disabled
751
-            ),
752
-            'CNT_cur_thsnds'  => array(
753
-                'type'             => 'RADIO_BTN',
754
-                'input_name'       => 'cntry[' . $CNT_ISO . ']',
755
-                'class'            => '',
756
-                'options'          => array(
757
-                    array(
758
-                        'id'   => ',',
759
-                        'text' => __(', (comma)', 'event_espresso'),
760
-                    ),
761
-                    array('id' => '.', 'text' => __('. (decimal)', 'event_espresso')),
762
-                ),
763
-                'use_desc_4_label' => true,
764
-                'disabled' => $CNT_cur_disabled
765
-            ),
766
-            'CNT_tel_code'    => array(
767
-                'type'       => 'TEXT',
768
-                'input_name' => 'cntry[' . $CNT_ISO . ']',
769
-                'class'      => 'small-text',
770
-            ),
771
-            'CNT_is_EU'       => array(
772
-                'type'             => 'RADIO_BTN',
773
-                'input_name'       => 'cntry[' . $CNT_ISO . ']',
774
-                'class'            => '',
775
-                'options'          => $this->_yes_no_values,
776
-                'use_desc_4_label' => true,
777
-            ),
778
-        );
779
-        $this->_template_args['inputs'] = EE_Question_Form_Input::generate_question_form_inputs_for_object(
780
-            $country,
781
-            $country_input_types
782
-        );
783
-        $country_details_settings = EEH_Template::display_template(
784
-            GEN_SET_TEMPLATE_PATH . 'country_details_settings.template.php',
785
-            $this->_template_args,
786
-            true
787
-        );
788
-
789
-        if (defined('DOING_AJAX')) {
790
-            $notices = EE_Error::get_notices(false, false, false);
791
-            echo wp_json_encode(
792
-                array(
793
-                    'return_data' => $country_details_settings,
794
-                    'success'     => $notices['success'],
795
-                    'errors'      => $notices['errors'],
796
-                )
797
-            );
798
-            die();
799
-        } else {
800
-            return $country_details_settings;
801
-        }
802
-    }
803
-
804
-
805
-    /**
806
-     *        display_country_states
807
-     *
808
-     * @access    public
809
-     * @param    string $CNT_ISO
810
-     * @return string
811
-     * @throws DomainException
812
-     */
813
-    public function display_country_states($CNT_ISO = '')
814
-    {
815
-
816
-        $CNT_ISO = isset($this->_req_data['country']) ? sanitize_text_field($this->_req_data['country']) : $CNT_ISO;
817
-
818
-        if (! $CNT_ISO) {
819
-            return '';
820
-        }
821
-        // for ajax
822
-        remove_all_filters('FHEE__EEH_Form_Fields__label_html');
823
-        remove_all_filters('FHEE__EEH_Form_Fields__input_html');
824
-        add_filter('FHEE__EEH_Form_Fields__label_html', array($this, 'state_form_field_label_wrap'), 10, 2);
825
-        add_filter('FHEE__EEH_Form_Fields__input_html', array($this, 'state_form_field_input__wrap'), 10, 2);
826
-        $states = EEM_State::instance()->get_all_states_for_these_countries(array($CNT_ISO => $CNT_ISO));
827
-
828
-        if ($states) {
829
-            foreach ($states as $STA_ID => $state) {
830
-                if ($state instanceof EE_State) {
831
-                    // STA_abbrev    STA_name    STA_active
832
-                    $state_input_types = array(
833
-                        'STA_abbrev' => array(
834
-                            'type'       => 'TEXT',
835
-                            'input_name' => 'states[' . $STA_ID . ']',
836
-                            'class'      => 'mid-text',
837
-                        ),
838
-                        'STA_name'   => array(
839
-                            'type'       => 'TEXT',
840
-                            'input_name' => 'states[' . $STA_ID . ']',
841
-                            'class'      => 'regular-text',
842
-                        ),
843
-                        'STA_active' => array(
844
-                            'type'             => 'RADIO_BTN',
845
-                            'input_name'       => 'states[' . $STA_ID . ']',
846
-                            'options'          => $this->_yes_no_values,
847
-                            'use_desc_4_label' => true,
848
-                        ),
849
-                    );
850
-                    $this->_template_args['states'][ $STA_ID ]['inputs'] =
851
-                        EE_Question_Form_Input::generate_question_form_inputs_for_object(
852
-                            $state,
853
-                            $state_input_types
854
-                        );
855
-                    $query_args = array(
856
-                        'action'     => 'delete_state',
857
-                        'STA_ID'     => $STA_ID,
858
-                        'CNT_ISO'    => $CNT_ISO,
859
-                        'STA_abbrev' => $state->abbrev(),
860
-                    );
861
-                    $this->_template_args['states'][ $STA_ID ]['delete_state_url'] =
862
-                        EE_Admin_Page::add_query_args_and_nonce(
863
-                            $query_args,
864
-                            GEN_SET_ADMIN_URL
865
-                        );
866
-                }
867
-            }
868
-        } else {
869
-            $this->_template_args['states'] = false;
870
-        }
871
-
872
-        $this->_template_args['add_new_state_url'] = EE_Admin_Page::add_query_args_and_nonce(
873
-            array('action' => 'add_new_state'),
874
-            GEN_SET_ADMIN_URL
875
-        );
876
-
877
-        $state_details_settings = EEH_Template::display_template(
878
-            GEN_SET_TEMPLATE_PATH . 'state_details_settings.template.php',
879
-            $this->_template_args,
880
-            true
881
-        );
882
-
883
-        if (defined('DOING_AJAX')) {
884
-            $notices = EE_Error::get_notices(false, false, false);
885
-            echo wp_json_encode(
886
-                array(
887
-                    'return_data' => $state_details_settings,
888
-                    'success'     => $notices['success'],
889
-                    'errors'      => $notices['errors'],
890
-                )
891
-            );
892
-            die();
893
-        } else {
894
-            return $state_details_settings;
895
-        }
896
-    }
897
-
898
-
899
-    /**
900
-     *        add_new_state
901
-     *
902
-     * @access    public
903
-     * @return void
904
-     * @throws EE_Error
905
-     */
906
-    public function add_new_state()
907
-    {
908
-
909
-        $success = true;
910
-
911
-        $CNT_ISO = isset($this->_req_data['CNT_ISO'])
912
-            ? strtoupper(sanitize_text_field($this->_req_data['CNT_ISO']))
913
-            : false;
914
-        if (! $CNT_ISO) {
915
-            EE_Error::add_error(
916
-                __('No Country ISO code or an invalid Country ISO code was received.', 'event_espresso'),
917
-                __FILE__,
918
-                __FUNCTION__,
919
-                __LINE__
920
-            );
921
-            $success = false;
922
-        }
923
-        $STA_abbrev = isset($this->_req_data['STA_abbrev'])
924
-            ? sanitize_text_field($this->_req_data['STA_abbrev'])
925
-            : false;
926
-        if (! $STA_abbrev) {
927
-            EE_Error::add_error(
928
-                __('No State ISO code or an invalid State ISO code was received.', 'event_espresso'),
929
-                __FILE__,
930
-                __FUNCTION__,
931
-                __LINE__
932
-            );
933
-            $success = false;
934
-        }
935
-        $STA_name = isset($this->_req_data['STA_name'])
936
-            ? sanitize_text_field($this->_req_data['STA_name'])
937
-            : false;
938
-        if (! $STA_name) {
939
-            EE_Error::add_error(
940
-                __('No State name or an invalid State name was received.', 'event_espresso'),
941
-                __FILE__,
942
-                __FUNCTION__,
943
-                __LINE__
944
-            );
945
-            $success = false;
946
-        }
947
-
948
-        if ($success) {
949
-            $cols_n_values = array(
950
-                'CNT_ISO'    => $CNT_ISO,
951
-                'STA_abbrev' => $STA_abbrev,
952
-                'STA_name'   => $STA_name,
953
-                'STA_active' => true,
954
-            );
955
-            $success = EEM_State::instance()->insert($cols_n_values);
956
-            EE_Error::add_success(__('The State was added successfully.', 'event_espresso'));
957
-        }
958
-
959
-        if (defined('DOING_AJAX')) {
960
-            $notices = EE_Error::get_notices(false, false, false);
961
-            echo wp_json_encode(array_merge($notices, array('return_data' => $CNT_ISO)));
962
-            die();
963
-        } else {
964
-            $this->_redirect_after_action($success, 'State', 'added', array('action' => 'country_settings'));
965
-        }
966
-    }
967
-
968
-
969
-    /**
970
-     *        delete_state
971
-     *
972
-     * @access    public
973
-     * @return        boolean
974
-     * @throws EE_Error
975
-     * @throws EE_Error
976
-     */
977
-    public function delete_state()
978
-    {
979
-        $CNT_ISO = isset($this->_req_data['CNT_ISO'])
980
-            ? strtoupper(sanitize_text_field($this->_req_data['CNT_ISO']))
981
-            : false;
982
-        $STA_ID = isset($this->_req_data['STA_ID'])
983
-            ? sanitize_text_field($this->_req_data['STA_ID'])
984
-            : false;
985
-        $STA_abbrev = isset($this->_req_data['STA_abbrev'])
986
-            ? sanitize_text_field($this->_req_data['STA_abbrev'])
987
-            : false;
988
-        if (! $STA_ID) {
989
-            EE_Error::add_error(
990
-                __('No State ID or an invalid State ID was received.', 'event_espresso'),
991
-                __FILE__,
992
-                __FUNCTION__,
993
-                __LINE__
994
-            );
995
-            return false;
996
-        }
997
-
998
-        $success = EEM_State::instance()->delete_by_ID($STA_ID);
999
-        if ($success !== false) {
1000
-            do_action(
1001
-                'AHEE__General_Settings_Admin_Page__delete_state__state_deleted',
1002
-                $CNT_ISO,
1003
-                $STA_ID,
1004
-                array('STA_abbrev' => $STA_abbrev)
1005
-            );
1006
-            EE_Error::add_success(__('The State was deleted successfully.', 'event_espresso'));
1007
-        }
1008
-        if (defined('DOING_AJAX')) {
1009
-            $notices = EE_Error::get_notices(false, false);
1010
-            $notices['return_data'] = true;
1011
-            echo wp_json_encode($notices);
1012
-            die();
1013
-        } else {
1014
-            $this->_redirect_after_action(
1015
-                $success,
1016
-                'State',
1017
-                'deleted',
1018
-                array('action' => 'country_settings')
1019
-            );
1020
-        }
1021
-    }
1022
-
1023
-
1024
-    /**
1025
-     *        _update_country_settings
1026
-     *
1027
-     * @access    protected
1028
-     * @return void
1029
-     * @throws EE_Error
1030
-     */
1031
-    protected function _update_country_settings()
1032
-    {
1033
-        // grab the country ISO code
1034
-        $CNT_ISO = isset($this->_req_data['country'])
1035
-            ? strtoupper(sanitize_text_field($this->_req_data['country']))
1036
-            : false;
1037
-        if (! $CNT_ISO) {
1038
-            EE_Error::add_error(
1039
-                __('No Country ISO code or an invalid Country ISO code was received.', 'event_espresso'),
1040
-                __FILE__,
1041
-                __FUNCTION__,
1042
-                __LINE__
1043
-            );
1044
-
1045
-            return;
1046
-        }
1047
-        $cols_n_values = array();
1048
-        $cols_n_values['CNT_ISO3'] = isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_ISO3'])
1049
-            ? strtoupper(sanitize_text_field($this->_req_data['cntry'][ $CNT_ISO ]['CNT_ISO3']))
1050
-            : false;
1051
-        $cols_n_values['RGN_ID'] = isset($this->_req_data['cntry'][ $CNT_ISO ]['RGN_ID'])
1052
-            ? absint($this->_req_data['cntry'][ $CNT_ISO ]['RGN_ID'])
1053
-            : null;
1054
-        $cols_n_values['CNT_name'] = isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_name'])
1055
-            ? sanitize_text_field($this->_req_data['cntry'][ $CNT_ISO ]['CNT_name'])
1056
-            : null;
1057
-        if (isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_code'])) {
1058
-            $cols_n_values['CNT_cur_code'] = strtoupper(
1059
-                sanitize_text_field($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_code'])
1060
-            );
1061
-        }
1062
-        if (isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_single'])) {
1063
-            $cols_n_values['CNT_cur_single'] = sanitize_text_field(
1064
-                $this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_single']
1065
-            );
1066
-        }
1067
-        if (isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_plural'])) {
1068
-            $cols_n_values['CNT_cur_plural'] = sanitize_text_field(
1069
-                $this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_plural']
1070
-            );
1071
-        }
1072
-        if (isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_sign'])) {
1073
-            $cols_n_values['CNT_cur_sign'] = sanitize_text_field(
1074
-                $this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_sign']
1075
-            );
1076
-        }
1077
-        if (isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_sign_b4'])) {
1078
-            $cols_n_values['CNT_cur_sign_b4'] = absint(
1079
-                $this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_sign_b4']
1080
-            );
1081
-        }
1082
-        if (isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_dec_plc'])) {
1083
-            $cols_n_values['CNT_cur_dec_plc'] = absint(
1084
-                $this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_dec_plc']
1085
-            );
1086
-        }
1087
-        if (isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_dec_mrk'])) {
1088
-            $cols_n_values['CNT_cur_dec_mrk'] = sanitize_text_field(
1089
-                $this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_dec_mrk']
1090
-            );
1091
-        }
1092
-        if (isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_thsnds'])) {
1093
-            $cols_n_values['CNT_cur_thsnds'] = sanitize_text_field(
1094
-                $this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_thsnds']
1095
-            );
1096
-        }
1097
-        $cols_n_values['CNT_tel_code'] = isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_tel_code'])
1098
-            ? sanitize_text_field($this->_req_data['cntry'][ $CNT_ISO ]['CNT_tel_code'])
1099
-            : null;
1100
-        $cols_n_values['CNT_is_EU'] = isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_is_EU'])
1101
-            ? absint($this->_req_data['cntry'][ $CNT_ISO ]['CNT_is_EU'])
1102
-            : false;
1103
-        $cols_n_values['CNT_active'] = isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_active'])
1104
-            ? absint($this->_req_data['cntry'][ $CNT_ISO ]['CNT_active'])
1105
-            : false;
1106
-        // allow filtering of country data
1107
-        $cols_n_values = apply_filters(
1108
-            'FHEE__General_Settings_Admin_Page___update_country_settings__cols_n_values',
1109
-            $cols_n_values
1110
-        );
1111
-
1112
-        // where values
1113
-        $where_cols_n_values = array(array('CNT_ISO' => $CNT_ISO));
1114
-        // run the update
1115
-        $success = EEM_Country::instance()->update($cols_n_values, $where_cols_n_values);
1116
-
1117
-        if (isset($this->_req_data['states']) && is_array($this->_req_data['states']) && $success !== false) {
1118
-            // allow filtering of states data
1119
-            $states = apply_filters(
1120
-                'FHEE__General_Settings_Admin_Page___update_country_settings__states',
1121
-                $this->_req_data['states']
1122
-            );
1123
-
1124
-            // loop thru state data ( looks like : states[75][STA_name] )
1125
-            foreach ($states as $STA_ID => $state) {
1126
-                $cols_n_values = array(
1127
-                    'CNT_ISO'    => $CNT_ISO,
1128
-                    'STA_abbrev' => sanitize_text_field($state['STA_abbrev']),
1129
-                    'STA_name'   => sanitize_text_field($state['STA_name']),
1130
-                    'STA_active' => (bool) absint($state['STA_active']),
1131
-                );
1132
-                // where values
1133
-                $where_cols_n_values = array(array('STA_ID' => $STA_ID));
1134
-                // run the update
1135
-                $success = EEM_State::instance()->update($cols_n_values, $where_cols_n_values);
1136
-                if ($success !== false) {
1137
-                    do_action(
1138
-                        'AHEE__General_Settings_Admin_Page__update_country_settings__state_saved',
1139
-                        $CNT_ISO,
1140
-                        $STA_ID,
1141
-                        $cols_n_values
1142
-                    );
1143
-                }
1144
-            }
1145
-        }
1146
-        // check if country being edited matches org option country, and if so, then  update EE_Config with new settings
1147
-        if (isset(EE_Registry::instance()->CFG->organization->CNT_ISO)
1148
-            && $CNT_ISO == EE_Registry::instance()->CFG->organization->CNT_ISO
1149
-        ) {
1150
-            EE_Registry::instance()->CFG->currency = new EE_Currency_Config($CNT_ISO);
1151
-            EE_Registry::instance()->CFG->update_espresso_config();
1152
-        }
1153
-
1154
-        if ($success !== false) {
1155
-            EE_Error::add_success(
1156
-                esc_html__('Country Settings updated successfully.', 'event_espresso')
1157
-            );
1158
-        }
1159
-        $this->_redirect_after_action(
1160
-            $success,
1161
-            '',
1162
-            '',
1163
-            array('action' => 'country_settings', 'country' => $CNT_ISO),
1164
-            true
1165
-        );
1166
-    }
1167
-
1168
-
1169
-    /**
1170
-     *        form_form_field_label_wrap
1171
-     *
1172
-     * @access        public
1173
-     * @param        string $label
1174
-     * @return        string
1175
-     */
1176
-    public function country_form_field_label_wrap($label, $required_text)
1177
-    {
1178
-        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
+			$organization_settings_form = new OrganizationSettings(
441
+				EE_Registry::instance(),
442
+				EE_Registry::instance()->CFG->organization,
443
+				EE_Registry::instance()->CFG->core,
444
+				EE_Registry::instance()->NET_CFG->core
445
+			);
446
+			$this->_template_args['admin_page_content'] = $organization_settings_form->display();
447
+		} catch (Exception $e) {
448
+			EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__);
449
+		}
450
+		$this->_set_add_edit_form_tags('update_your_organization_settings');
451
+		$this->_set_publish_post_box_vars(null, false, false, null, false);
452
+		$this->display_admin_page_with_sidebar();
453
+	}
454
+
455
+
456
+
457
+	/**
458
+	 * Handler for updating organization settings.
459
+	 *
460
+	 * @throws EE_Error
461
+	 */
462
+	protected function _update_your_organization_settings()
463
+	{
464
+		try {
465
+			$organization_settings_form = new OrganizationSettings(
466
+				EE_Registry::instance(),
467
+				EE_Registry::instance()->CFG->organization,
468
+				EE_Registry::instance()->CFG->core,
469
+				EE_Registry::instance()->NET_CFG->core
470
+			);
471
+			$success = $organization_settings_form->process($this->_req_data);
472
+			EE_Registry::instance()->CFG = apply_filters(
473
+				'FHEE__General_Settings_Admin_Page___update_your_organization_settings__CFG',
474
+				EE_Registry::instance()->CFG
475
+			);
476
+		} catch (Exception $e) {
477
+			EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__);
478
+			$success = false;
479
+		}
480
+
481
+		if ($success) {
482
+			$success = $this->_update_espresso_configuration(
483
+				esc_html__('Your Organization Settings', 'event_espresso'),
484
+				EE_Registry::instance()->CFG,
485
+				__FILE__,
486
+				__FUNCTION__,
487
+				__LINE__
488
+			);
489
+		}
490
+
491
+		$this->_redirect_after_action($success, '', '', array('action' => 'default'), true);
492
+	}
493
+
494
+
495
+
496
+	/*************        Admin Options        *************/
497
+
498
+
499
+	/**
500
+	 * _admin_option_settings
501
+	 *
502
+	 * @throws \EE_Error
503
+	 * @throws \LogicException
504
+	 */
505
+	protected function _admin_option_settings()
506
+	{
507
+		$this->_template_args['admin_page_content'] = '';
508
+		try {
509
+			$admin_options_settings_form = new AdminOptionsSettings(EE_Registry::instance());
510
+			// still need this for the old school form in Extend_General_Settings_Admin_Page
511
+			$this->_template_args['values'] = $this->_yes_no_values;
512
+			// also need to account for the do_action that was in the old template
513
+			$admin_options_settings_form->setTemplateArgs($this->_template_args);
514
+			$this->_template_args['admin_page_content'] = $admin_options_settings_form->display();
515
+		} catch (Exception $e) {
516
+			EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__);
517
+		}
518
+		$this->_set_add_edit_form_tags('update_admin_option_settings');
519
+		$this->_set_publish_post_box_vars(null, false, false, null, false);
520
+		$this->display_admin_page_with_sidebar();
521
+	}
522
+
523
+
524
+	/**
525
+	 * _update_admin_option_settings
526
+	 *
527
+	 * @throws \EE_Error
528
+	 * @throws InvalidDataTypeException
529
+	 * @throws \EventEspresso\core\exceptions\InvalidFormSubmissionException
530
+	 * @throws \InvalidArgumentException
531
+	 * @throws \LogicException
532
+	 */
533
+	protected function _update_admin_option_settings()
534
+	{
535
+		try {
536
+			$admin_options_settings_form = new AdminOptionsSettings(EE_Registry::instance());
537
+			$admin_options_settings_form->process($this->_req_data[ $admin_options_settings_form->slug() ]);
538
+			EE_Registry::instance()->CFG->admin = apply_filters(
539
+				'FHEE__General_Settings_Admin_Page___update_admin_option_settings__CFG_admin',
540
+				EE_Registry::instance()->CFG->admin
541
+			);
542
+		} catch (Exception $e) {
543
+			EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__);
544
+		}
545
+		$this->_redirect_after_action(
546
+			apply_filters(
547
+				'FHEE__General_Settings_Admin_Page___update_admin_option_settings__success',
548
+				$this->_update_espresso_configuration(
549
+					'Admin Options',
550
+					EE_Registry::instance()->CFG->admin,
551
+					__FILE__,
552
+					__FUNCTION__,
553
+					__LINE__
554
+				)
555
+			),
556
+			'Admin Options',
557
+			'updated',
558
+			array('action' => 'admin_option_settings')
559
+		);
560
+	}
561
+
562
+
563
+	/*************        Countries        *************/
564
+
565
+
566
+	/**
567
+	 * @return string
568
+	 */
569
+	protected function getCountryIsoForSite()
570
+	{
571
+		return ! empty(EE_Registry::instance()->CFG->organization->CNT_ISO)
572
+			? EE_Registry::instance()->CFG->organization->CNT_ISO
573
+			: 'US';
574
+	}
575
+
576
+
577
+
578
+	/**
579
+	 * Output Country Settings view.
580
+	 *
581
+	 * @throws DomainException
582
+	 * @throws EE_Error
583
+	 */
584
+	protected function _country_settings()
585
+	{
586
+		$CNT_ISO_for_site = $this->getCountryIsoForSite();
587
+		$CNT_ISO = isset($this->_req_data['country'])
588
+			? strtoupper(sanitize_text_field($this->_req_data['country']))
589
+			: $CNT_ISO_for_site;
590
+
591
+		// load field generator helper
592
+
593
+		$this->_template_args['values'] = $this->_yes_no_values;
594
+
595
+		$this->_template_args['countries'] = new EE_Question_Form_Input(
596
+			EE_Question::new_instance(
597
+				array(
598
+					'QST_ID'           => 0,
599
+					'QST_display_text' => __('Select Country', 'event_espresso'),
600
+					'QST_system'       => 'admin-country',
601
+				)
602
+			),
603
+			EE_Answer::new_instance(
604
+				array(
605
+					'ANS_ID'    => 0,
606
+					'ANS_value' => $CNT_ISO,
607
+				)
608
+			),
609
+			array(
610
+				'input_id'       => 'country',
611
+				'input_name'     => 'country',
612
+				'input_prefix'   => '',
613
+				'append_qstn_id' => false,
614
+			)
615
+		);
616
+
617
+		add_filter('FHEE__EEH_Form_Fields__label_html', array($this, 'country_form_field_label_wrap'), 10, 2);
618
+		add_filter('FHEE__EEH_Form_Fields__input_html', array($this, 'country_form_field_input__wrap'), 10, 2);
619
+		$this->_template_args['country_details_settings'] = $this->display_country_settings();
620
+		$this->_template_args['country_states_settings'] = $this->display_country_states();
621
+		$this->_template_args['CNT_name_for_site'] = EEM_Country::instance()->get_one_by_ID($CNT_ISO_for_site)
622
+																			->name();
623
+
624
+		$this->_set_add_edit_form_tags('update_country_settings');
625
+		$this->_set_publish_post_box_vars(null, false, false, null, false);
626
+		$this->_template_args['admin_page_content'] = EEH_Template::display_template(
627
+			GEN_SET_TEMPLATE_PATH . 'countries_settings.template.php',
628
+			$this->_template_args,
629
+			true
630
+		);
631
+		$this->display_admin_page_with_no_sidebar();
632
+	}
633
+
634
+
635
+	/**
636
+	 *        display_country_settings
637
+	 *
638
+	 * @access    public
639
+	 * @param    string $CNT_ISO
640
+	 * @return mixed string | array
641
+	 * @throws DomainException
642
+	 */
643
+	public function display_country_settings($CNT_ISO = '')
644
+	{
645
+		$CNT_ISO_for_site = $this->getCountryIsoForSite();
646
+
647
+		$CNT_ISO = isset($this->_req_data['country'])
648
+			? strtoupper(sanitize_text_field($this->_req_data['country']))
649
+			: $CNT_ISO;
650
+		if (! $CNT_ISO) {
651
+			return '';
652
+		}
653
+
654
+		// for ajax
655
+		remove_all_filters('FHEE__EEH_Form_Fields__label_html');
656
+		remove_all_filters('FHEE__EEH_Form_Fields__input_html');
657
+		add_filter('FHEE__EEH_Form_Fields__label_html', array($this, 'country_form_field_label_wrap'), 10, 2);
658
+		add_filter('FHEE__EEH_Form_Fields__input_html', array($this, 'country_form_field_input__wrap'), 10, 2);
659
+		/** @var EE_Country $country */
660
+		$country = EEM_Country::instance()->get_one_by_ID($CNT_ISO);
661
+
662
+		$CNT_cur_disabled = $CNT_ISO !== $CNT_ISO_for_site;
663
+		$this->_template_args['CNT_cur_disabled'] = $CNT_cur_disabled;
664
+
665
+		$country_input_types = array(
666
+			'CNT_active'      => array(
667
+				'type'             => 'RADIO_BTN',
668
+				'input_name'       => 'cntry[' . $CNT_ISO . ']',
669
+				'class'            => '',
670
+				'options'          => $this->_yes_no_values,
671
+				'use_desc_4_label' => true,
672
+			),
673
+			'CNT_ISO'         => array(
674
+				'type'       => 'TEXT',
675
+				'input_name' => 'cntry[' . $CNT_ISO . ']',
676
+				'class'      => 'small-text',
677
+			),
678
+			'CNT_ISO3'        => array(
679
+				'type'       => 'TEXT',
680
+				'input_name' => 'cntry[' . $CNT_ISO . ']',
681
+				'class'      => 'small-text',
682
+			),
683
+			'RGN_ID'          => array(
684
+				'type'       => 'TEXT',
685
+				'input_name' => 'cntry[' . $CNT_ISO . ']',
686
+				'class'      => 'small-text',
687
+			),
688
+			'CNT_name'        => array(
689
+				'type'       => 'TEXT',
690
+				'input_name' => 'cntry[' . $CNT_ISO . ']',
691
+				'class'      => 'regular-text',
692
+			),
693
+			'CNT_cur_code'    => array(
694
+				'type'       => 'TEXT',
695
+				'input_name' => 'cntry[' . $CNT_ISO . ']',
696
+				'class'      => 'small-text',
697
+				'disabled'   => $CNT_cur_disabled
698
+			),
699
+			'CNT_cur_single'  => array(
700
+				'type'       => 'TEXT',
701
+				'input_name' => 'cntry[' . $CNT_ISO . ']',
702
+				'class'      => 'medium-text',
703
+				'disabled' => $CNT_cur_disabled
704
+			),
705
+			'CNT_cur_plural'  => array(
706
+				'type'       => 'TEXT',
707
+				'input_name' => 'cntry[' . $CNT_ISO . ']',
708
+				'class'      => 'medium-text',
709
+				'disabled' => $CNT_cur_disabled
710
+			),
711
+			'CNT_cur_sign'    => array(
712
+				'type'         => 'TEXT',
713
+				'input_name'   => 'cntry[' . $CNT_ISO . ']',
714
+				'class'        => 'small-text',
715
+				'htmlentities' => false,
716
+				'disabled' => $CNT_cur_disabled
717
+			),
718
+			'CNT_cur_sign_b4' => array(
719
+				'type'             => 'RADIO_BTN',
720
+				'input_name'       => 'cntry[' . $CNT_ISO . ']',
721
+				'class'            => '',
722
+				'options'          => $this->_yes_no_values,
723
+				'use_desc_4_label' => true,
724
+				'disabled' => $CNT_cur_disabled
725
+			),
726
+			'CNT_cur_dec_plc' => array(
727
+				'type'       => 'RADIO_BTN',
728
+				'input_name' => 'cntry[' . $CNT_ISO . ']',
729
+				'class'      => '',
730
+				'options'    => array(
731
+					array('id' => 0, 'text' => ''),
732
+					array('id' => 1, 'text' => ''),
733
+					array('id' => 2, 'text' => ''),
734
+					array('id' => 3, 'text' => ''),
735
+				),
736
+				'disabled' => $CNT_cur_disabled
737
+			),
738
+			'CNT_cur_dec_mrk' => array(
739
+				'type'             => 'RADIO_BTN',
740
+				'input_name'       => 'cntry[' . $CNT_ISO . ']',
741
+				'class'            => '',
742
+				'options'          => array(
743
+					array(
744
+						'id'   => ',',
745
+						'text' => __(', (comma)', 'event_espresso'),
746
+					),
747
+					array('id' => '.', 'text' => __('. (decimal)', 'event_espresso')),
748
+				),
749
+				'use_desc_4_label' => true,
750
+				'disabled' => $CNT_cur_disabled
751
+			),
752
+			'CNT_cur_thsnds'  => array(
753
+				'type'             => 'RADIO_BTN',
754
+				'input_name'       => 'cntry[' . $CNT_ISO . ']',
755
+				'class'            => '',
756
+				'options'          => array(
757
+					array(
758
+						'id'   => ',',
759
+						'text' => __(', (comma)', 'event_espresso'),
760
+					),
761
+					array('id' => '.', 'text' => __('. (decimal)', 'event_espresso')),
762
+				),
763
+				'use_desc_4_label' => true,
764
+				'disabled' => $CNT_cur_disabled
765
+			),
766
+			'CNT_tel_code'    => array(
767
+				'type'       => 'TEXT',
768
+				'input_name' => 'cntry[' . $CNT_ISO . ']',
769
+				'class'      => 'small-text',
770
+			),
771
+			'CNT_is_EU'       => array(
772
+				'type'             => 'RADIO_BTN',
773
+				'input_name'       => 'cntry[' . $CNT_ISO . ']',
774
+				'class'            => '',
775
+				'options'          => $this->_yes_no_values,
776
+				'use_desc_4_label' => true,
777
+			),
778
+		);
779
+		$this->_template_args['inputs'] = EE_Question_Form_Input::generate_question_form_inputs_for_object(
780
+			$country,
781
+			$country_input_types
782
+		);
783
+		$country_details_settings = EEH_Template::display_template(
784
+			GEN_SET_TEMPLATE_PATH . 'country_details_settings.template.php',
785
+			$this->_template_args,
786
+			true
787
+		);
788
+
789
+		if (defined('DOING_AJAX')) {
790
+			$notices = EE_Error::get_notices(false, false, false);
791
+			echo wp_json_encode(
792
+				array(
793
+					'return_data' => $country_details_settings,
794
+					'success'     => $notices['success'],
795
+					'errors'      => $notices['errors'],
796
+				)
797
+			);
798
+			die();
799
+		} else {
800
+			return $country_details_settings;
801
+		}
802
+	}
803
+
804
+
805
+	/**
806
+	 *        display_country_states
807
+	 *
808
+	 * @access    public
809
+	 * @param    string $CNT_ISO
810
+	 * @return string
811
+	 * @throws DomainException
812
+	 */
813
+	public function display_country_states($CNT_ISO = '')
814
+	{
815
+
816
+		$CNT_ISO = isset($this->_req_data['country']) ? sanitize_text_field($this->_req_data['country']) : $CNT_ISO;
817
+
818
+		if (! $CNT_ISO) {
819
+			return '';
820
+		}
821
+		// for ajax
822
+		remove_all_filters('FHEE__EEH_Form_Fields__label_html');
823
+		remove_all_filters('FHEE__EEH_Form_Fields__input_html');
824
+		add_filter('FHEE__EEH_Form_Fields__label_html', array($this, 'state_form_field_label_wrap'), 10, 2);
825
+		add_filter('FHEE__EEH_Form_Fields__input_html', array($this, 'state_form_field_input__wrap'), 10, 2);
826
+		$states = EEM_State::instance()->get_all_states_for_these_countries(array($CNT_ISO => $CNT_ISO));
827
+
828
+		if ($states) {
829
+			foreach ($states as $STA_ID => $state) {
830
+				if ($state instanceof EE_State) {
831
+					// STA_abbrev    STA_name    STA_active
832
+					$state_input_types = array(
833
+						'STA_abbrev' => array(
834
+							'type'       => 'TEXT',
835
+							'input_name' => 'states[' . $STA_ID . ']',
836
+							'class'      => 'mid-text',
837
+						),
838
+						'STA_name'   => array(
839
+							'type'       => 'TEXT',
840
+							'input_name' => 'states[' . $STA_ID . ']',
841
+							'class'      => 'regular-text',
842
+						),
843
+						'STA_active' => array(
844
+							'type'             => 'RADIO_BTN',
845
+							'input_name'       => 'states[' . $STA_ID . ']',
846
+							'options'          => $this->_yes_no_values,
847
+							'use_desc_4_label' => true,
848
+						),
849
+					);
850
+					$this->_template_args['states'][ $STA_ID ]['inputs'] =
851
+						EE_Question_Form_Input::generate_question_form_inputs_for_object(
852
+							$state,
853
+							$state_input_types
854
+						);
855
+					$query_args = array(
856
+						'action'     => 'delete_state',
857
+						'STA_ID'     => $STA_ID,
858
+						'CNT_ISO'    => $CNT_ISO,
859
+						'STA_abbrev' => $state->abbrev(),
860
+					);
861
+					$this->_template_args['states'][ $STA_ID ]['delete_state_url'] =
862
+						EE_Admin_Page::add_query_args_and_nonce(
863
+							$query_args,
864
+							GEN_SET_ADMIN_URL
865
+						);
866
+				}
867
+			}
868
+		} else {
869
+			$this->_template_args['states'] = false;
870
+		}
871
+
872
+		$this->_template_args['add_new_state_url'] = EE_Admin_Page::add_query_args_and_nonce(
873
+			array('action' => 'add_new_state'),
874
+			GEN_SET_ADMIN_URL
875
+		);
876
+
877
+		$state_details_settings = EEH_Template::display_template(
878
+			GEN_SET_TEMPLATE_PATH . 'state_details_settings.template.php',
879
+			$this->_template_args,
880
+			true
881
+		);
882
+
883
+		if (defined('DOING_AJAX')) {
884
+			$notices = EE_Error::get_notices(false, false, false);
885
+			echo wp_json_encode(
886
+				array(
887
+					'return_data' => $state_details_settings,
888
+					'success'     => $notices['success'],
889
+					'errors'      => $notices['errors'],
890
+				)
891
+			);
892
+			die();
893
+		} else {
894
+			return $state_details_settings;
895
+		}
896
+	}
897
+
898
+
899
+	/**
900
+	 *        add_new_state
901
+	 *
902
+	 * @access    public
903
+	 * @return void
904
+	 * @throws EE_Error
905
+	 */
906
+	public function add_new_state()
907
+	{
908
+
909
+		$success = true;
910
+
911
+		$CNT_ISO = isset($this->_req_data['CNT_ISO'])
912
+			? strtoupper(sanitize_text_field($this->_req_data['CNT_ISO']))
913
+			: false;
914
+		if (! $CNT_ISO) {
915
+			EE_Error::add_error(
916
+				__('No Country ISO code or an invalid Country ISO code was received.', 'event_espresso'),
917
+				__FILE__,
918
+				__FUNCTION__,
919
+				__LINE__
920
+			);
921
+			$success = false;
922
+		}
923
+		$STA_abbrev = isset($this->_req_data['STA_abbrev'])
924
+			? sanitize_text_field($this->_req_data['STA_abbrev'])
925
+			: false;
926
+		if (! $STA_abbrev) {
927
+			EE_Error::add_error(
928
+				__('No State ISO code or an invalid State ISO code was received.', 'event_espresso'),
929
+				__FILE__,
930
+				__FUNCTION__,
931
+				__LINE__
932
+			);
933
+			$success = false;
934
+		}
935
+		$STA_name = isset($this->_req_data['STA_name'])
936
+			? sanitize_text_field($this->_req_data['STA_name'])
937
+			: false;
938
+		if (! $STA_name) {
939
+			EE_Error::add_error(
940
+				__('No State name or an invalid State name was received.', 'event_espresso'),
941
+				__FILE__,
942
+				__FUNCTION__,
943
+				__LINE__
944
+			);
945
+			$success = false;
946
+		}
947
+
948
+		if ($success) {
949
+			$cols_n_values = array(
950
+				'CNT_ISO'    => $CNT_ISO,
951
+				'STA_abbrev' => $STA_abbrev,
952
+				'STA_name'   => $STA_name,
953
+				'STA_active' => true,
954
+			);
955
+			$success = EEM_State::instance()->insert($cols_n_values);
956
+			EE_Error::add_success(__('The State was added successfully.', 'event_espresso'));
957
+		}
958
+
959
+		if (defined('DOING_AJAX')) {
960
+			$notices = EE_Error::get_notices(false, false, false);
961
+			echo wp_json_encode(array_merge($notices, array('return_data' => $CNT_ISO)));
962
+			die();
963
+		} else {
964
+			$this->_redirect_after_action($success, 'State', 'added', array('action' => 'country_settings'));
965
+		}
966
+	}
967
+
968
+
969
+	/**
970
+	 *        delete_state
971
+	 *
972
+	 * @access    public
973
+	 * @return        boolean
974
+	 * @throws EE_Error
975
+	 * @throws EE_Error
976
+	 */
977
+	public function delete_state()
978
+	{
979
+		$CNT_ISO = isset($this->_req_data['CNT_ISO'])
980
+			? strtoupper(sanitize_text_field($this->_req_data['CNT_ISO']))
981
+			: false;
982
+		$STA_ID = isset($this->_req_data['STA_ID'])
983
+			? sanitize_text_field($this->_req_data['STA_ID'])
984
+			: false;
985
+		$STA_abbrev = isset($this->_req_data['STA_abbrev'])
986
+			? sanitize_text_field($this->_req_data['STA_abbrev'])
987
+			: false;
988
+		if (! $STA_ID) {
989
+			EE_Error::add_error(
990
+				__('No State ID or an invalid State ID was received.', 'event_espresso'),
991
+				__FILE__,
992
+				__FUNCTION__,
993
+				__LINE__
994
+			);
995
+			return false;
996
+		}
997
+
998
+		$success = EEM_State::instance()->delete_by_ID($STA_ID);
999
+		if ($success !== false) {
1000
+			do_action(
1001
+				'AHEE__General_Settings_Admin_Page__delete_state__state_deleted',
1002
+				$CNT_ISO,
1003
+				$STA_ID,
1004
+				array('STA_abbrev' => $STA_abbrev)
1005
+			);
1006
+			EE_Error::add_success(__('The State was deleted successfully.', 'event_espresso'));
1007
+		}
1008
+		if (defined('DOING_AJAX')) {
1009
+			$notices = EE_Error::get_notices(false, false);
1010
+			$notices['return_data'] = true;
1011
+			echo wp_json_encode($notices);
1012
+			die();
1013
+		} else {
1014
+			$this->_redirect_after_action(
1015
+				$success,
1016
+				'State',
1017
+				'deleted',
1018
+				array('action' => 'country_settings')
1019
+			);
1020
+		}
1021
+	}
1022
+
1023
+
1024
+	/**
1025
+	 *        _update_country_settings
1026
+	 *
1027
+	 * @access    protected
1028
+	 * @return void
1029
+	 * @throws EE_Error
1030
+	 */
1031
+	protected function _update_country_settings()
1032
+	{
1033
+		// grab the country ISO code
1034
+		$CNT_ISO = isset($this->_req_data['country'])
1035
+			? strtoupper(sanitize_text_field($this->_req_data['country']))
1036
+			: false;
1037
+		if (! $CNT_ISO) {
1038
+			EE_Error::add_error(
1039
+				__('No Country ISO code or an invalid Country ISO code was received.', 'event_espresso'),
1040
+				__FILE__,
1041
+				__FUNCTION__,
1042
+				__LINE__
1043
+			);
1044
+
1045
+			return;
1046
+		}
1047
+		$cols_n_values = array();
1048
+		$cols_n_values['CNT_ISO3'] = isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_ISO3'])
1049
+			? strtoupper(sanitize_text_field($this->_req_data['cntry'][ $CNT_ISO ]['CNT_ISO3']))
1050
+			: false;
1051
+		$cols_n_values['RGN_ID'] = isset($this->_req_data['cntry'][ $CNT_ISO ]['RGN_ID'])
1052
+			? absint($this->_req_data['cntry'][ $CNT_ISO ]['RGN_ID'])
1053
+			: null;
1054
+		$cols_n_values['CNT_name'] = isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_name'])
1055
+			? sanitize_text_field($this->_req_data['cntry'][ $CNT_ISO ]['CNT_name'])
1056
+			: null;
1057
+		if (isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_code'])) {
1058
+			$cols_n_values['CNT_cur_code'] = strtoupper(
1059
+				sanitize_text_field($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_code'])
1060
+			);
1061
+		}
1062
+		if (isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_single'])) {
1063
+			$cols_n_values['CNT_cur_single'] = sanitize_text_field(
1064
+				$this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_single']
1065
+			);
1066
+		}
1067
+		if (isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_plural'])) {
1068
+			$cols_n_values['CNT_cur_plural'] = sanitize_text_field(
1069
+				$this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_plural']
1070
+			);
1071
+		}
1072
+		if (isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_sign'])) {
1073
+			$cols_n_values['CNT_cur_sign'] = sanitize_text_field(
1074
+				$this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_sign']
1075
+			);
1076
+		}
1077
+		if (isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_sign_b4'])) {
1078
+			$cols_n_values['CNT_cur_sign_b4'] = absint(
1079
+				$this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_sign_b4']
1080
+			);
1081
+		}
1082
+		if (isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_dec_plc'])) {
1083
+			$cols_n_values['CNT_cur_dec_plc'] = absint(
1084
+				$this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_dec_plc']
1085
+			);
1086
+		}
1087
+		if (isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_dec_mrk'])) {
1088
+			$cols_n_values['CNT_cur_dec_mrk'] = sanitize_text_field(
1089
+				$this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_dec_mrk']
1090
+			);
1091
+		}
1092
+		if (isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_thsnds'])) {
1093
+			$cols_n_values['CNT_cur_thsnds'] = sanitize_text_field(
1094
+				$this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_thsnds']
1095
+			);
1096
+		}
1097
+		$cols_n_values['CNT_tel_code'] = isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_tel_code'])
1098
+			? sanitize_text_field($this->_req_data['cntry'][ $CNT_ISO ]['CNT_tel_code'])
1099
+			: null;
1100
+		$cols_n_values['CNT_is_EU'] = isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_is_EU'])
1101
+			? absint($this->_req_data['cntry'][ $CNT_ISO ]['CNT_is_EU'])
1102
+			: false;
1103
+		$cols_n_values['CNT_active'] = isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_active'])
1104
+			? absint($this->_req_data['cntry'][ $CNT_ISO ]['CNT_active'])
1105
+			: false;
1106
+		// allow filtering of country data
1107
+		$cols_n_values = apply_filters(
1108
+			'FHEE__General_Settings_Admin_Page___update_country_settings__cols_n_values',
1109
+			$cols_n_values
1110
+		);
1111
+
1112
+		// where values
1113
+		$where_cols_n_values = array(array('CNT_ISO' => $CNT_ISO));
1114
+		// run the update
1115
+		$success = EEM_Country::instance()->update($cols_n_values, $where_cols_n_values);
1116
+
1117
+		if (isset($this->_req_data['states']) && is_array($this->_req_data['states']) && $success !== false) {
1118
+			// allow filtering of states data
1119
+			$states = apply_filters(
1120
+				'FHEE__General_Settings_Admin_Page___update_country_settings__states',
1121
+				$this->_req_data['states']
1122
+			);
1123
+
1124
+			// loop thru state data ( looks like : states[75][STA_name] )
1125
+			foreach ($states as $STA_ID => $state) {
1126
+				$cols_n_values = array(
1127
+					'CNT_ISO'    => $CNT_ISO,
1128
+					'STA_abbrev' => sanitize_text_field($state['STA_abbrev']),
1129
+					'STA_name'   => sanitize_text_field($state['STA_name']),
1130
+					'STA_active' => (bool) absint($state['STA_active']),
1131
+				);
1132
+				// where values
1133
+				$where_cols_n_values = array(array('STA_ID' => $STA_ID));
1134
+				// run the update
1135
+				$success = EEM_State::instance()->update($cols_n_values, $where_cols_n_values);
1136
+				if ($success !== false) {
1137
+					do_action(
1138
+						'AHEE__General_Settings_Admin_Page__update_country_settings__state_saved',
1139
+						$CNT_ISO,
1140
+						$STA_ID,
1141
+						$cols_n_values
1142
+					);
1143
+				}
1144
+			}
1145
+		}
1146
+		// check if country being edited matches org option country, and if so, then  update EE_Config with new settings
1147
+		if (isset(EE_Registry::instance()->CFG->organization->CNT_ISO)
1148
+			&& $CNT_ISO == EE_Registry::instance()->CFG->organization->CNT_ISO
1149
+		) {
1150
+			EE_Registry::instance()->CFG->currency = new EE_Currency_Config($CNT_ISO);
1151
+			EE_Registry::instance()->CFG->update_espresso_config();
1152
+		}
1153
+
1154
+		if ($success !== false) {
1155
+			EE_Error::add_success(
1156
+				esc_html__('Country Settings updated successfully.', 'event_espresso')
1157
+			);
1158
+		}
1159
+		$this->_redirect_after_action(
1160
+			$success,
1161
+			'',
1162
+			'',
1163
+			array('action' => 'country_settings', 'country' => $CNT_ISO),
1164
+			true
1165
+		);
1166
+	}
1167
+
1168
+
1169
+	/**
1170
+	 *        form_form_field_label_wrap
1171
+	 *
1172
+	 * @access        public
1173
+	 * @param        string $label
1174
+	 * @return        string
1175
+	 */
1176
+	public function country_form_field_label_wrap($label, $required_text)
1177
+	{
1178
+		return '
1179 1179
 			<tr>
1180 1180
 				<th>
1181 1181
 					' . $label . '
1182 1182
 				</th>';
1183
-    }
1184
-
1185
-
1186
-    /**
1187
-     *        form_form_field_input__wrap
1188
-     *
1189
-     * @access        public
1190
-     * @param        string $label
1191
-     * @return        string
1192
-     */
1193
-    public function country_form_field_input__wrap($input, $label)
1194
-    {
1195
-        return '
1183
+	}
1184
+
1185
+
1186
+	/**
1187
+	 *        form_form_field_input__wrap
1188
+	 *
1189
+	 * @access        public
1190
+	 * @param        string $label
1191
+	 * @return        string
1192
+	 */
1193
+	public function country_form_field_input__wrap($input, $label)
1194
+	{
1195
+		return '
1196 1196
 				<td class="general-settings-country-input-td">
1197 1197
 					' . $input . '
1198 1198
 				</td>
1199 1199
 			</tr>';
1200
-    }
1201
-
1202
-
1203
-    /**
1204
-     *        form_form_field_label_wrap
1205
-     *
1206
-     * @access        public
1207
-     * @param        string $label
1208
-     * @param        string $required_text
1209
-     * @return        string
1210
-     */
1211
-    public function state_form_field_label_wrap($label, $required_text)
1212
-    {
1213
-        return $required_text;
1214
-    }
1215
-
1216
-
1217
-    /**
1218
-     *        form_form_field_input__wrap
1219
-     *
1220
-     * @access        public
1221
-     * @param        string $label
1222
-     * @return        string
1223
-     */
1224
-    public function state_form_field_input__wrap($input, $label)
1225
-    {
1226
-        return '
1200
+	}
1201
+
1202
+
1203
+	/**
1204
+	 *        form_form_field_label_wrap
1205
+	 *
1206
+	 * @access        public
1207
+	 * @param        string $label
1208
+	 * @param        string $required_text
1209
+	 * @return        string
1210
+	 */
1211
+	public function state_form_field_label_wrap($label, $required_text)
1212
+	{
1213
+		return $required_text;
1214
+	}
1215
+
1216
+
1217
+	/**
1218
+	 *        form_form_field_input__wrap
1219
+	 *
1220
+	 * @access        public
1221
+	 * @param        string $label
1222
+	 * @return        string
1223
+	 */
1224
+	public function state_form_field_input__wrap($input, $label)
1225
+	{
1226
+		return '
1227 1227
 				<td class="general-settings-country-state-input-td">
1228 1228
 					' . $input . '
1229 1229
 				</td>';
1230
-    }
1231
-
1232
-
1233
-    /***********/
1234
-
1235
-
1236
-    /**
1237
-     * displays edit and view links for critical EE pages
1238
-     *
1239
-     * @access public
1240
-     * @param int $ee_page_id
1241
-     * @return string
1242
-     */
1243
-    public static function edit_view_links($ee_page_id)
1244
-    {
1245
-        $links = '<a href="'
1246
-                 . add_query_arg(
1247
-                     array('post' => $ee_page_id, 'action' => 'edit'),
1248
-                     admin_url('post.php')
1249
-                 )
1250
-                 . '" >'
1251
-                 . __('Edit', 'event_espresso')
1252
-                 . '</a>';
1253
-        $links .= ' &nbsp;|&nbsp; ';
1254
-        $links .= '<a href="' . get_permalink($ee_page_id) . '" >' . __('View', 'event_espresso') . '</a>';
1255
-
1256
-        return $links;
1257
-    }
1258
-
1259
-
1260
-    /**
1261
-     * displays page and shortcode status for critical EE pages
1262
-     *
1263
-     * @param WP page object $ee_page
1264
-     * @return string
1265
-     */
1266
-    public static function page_and_shortcode_status($ee_page, $shortcode)
1267
-    {
1268
-
1269
-        // page status
1270
-        if (isset($ee_page->post_status) && $ee_page->post_status == 'publish') {
1271
-            $pg_colour = 'green';
1272
-            $pg_status = sprintf(__('Page%sStatus%sOK', 'event_espresso'), '&nbsp;', '&nbsp;');
1273
-        } else {
1274
-            $pg_colour = 'red';
1275
-            $pg_status = sprintf(__('Page%sVisibility%sProblem', 'event_espresso'), '&nbsp;', '&nbsp;');
1276
-        }
1277
-
1278
-        // shortcode status
1279
-        if (isset($ee_page->post_content) && strpos($ee_page->post_content, $shortcode) !== false) {
1280
-            $sc_colour = 'green';
1281
-            $sc_status = sprintf(__('Shortcode%sOK', 'event_espresso'), '&nbsp;');
1282
-        } else {
1283
-            $sc_colour = 'red';
1284
-            $sc_status = sprintf(__('Shortcode%sProblem', 'event_espresso'), '&nbsp;');
1285
-        }
1286
-
1287
-        return '<span style="color:' . $pg_colour . '; margin-right:2em;"><strong>'
1288
-               . $pg_status
1289
-               . '</strong></span><span style="color:' . $sc_colour . '"><strong>' . $sc_status . '</strong></span>';
1290
-    }
1291
-
1292
-
1293
-    /**
1294
-     * generates a dropdown of all parent pages - copied from WP core
1295
-     *
1296
-     * @param int $default
1297
-     * @param int $parent
1298
-     * @param int $level
1299
-     */
1300
-    public static function page_settings_dropdown($default = 0, $parent = 0, $level = 0)
1301
-    {
1302
-        global $wpdb;
1303
-        $items = $wpdb->get_results(
1304
-            $wpdb->prepare(
1305
-                "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",
1306
-                $parent
1307
-            )
1308
-        );
1309
-
1310
-        if ($items) {
1311
-            foreach ($items as $item) {
1312
-                $pad = str_repeat('&nbsp;', $level * 3);
1313
-                if ($item->ID == $default) {
1314
-                    $current = ' selected="selected"';
1315
-                } else {
1316
-                    $current = '';
1317
-                }
1318
-
1319
-                echo "\n\t<option class='level-$level' value='$item->ID'$current>$pad "
1320
-                     . esc_html($item->post_title)
1321
-                     . "</option>";
1322
-                parent_dropdown($default, $item->ID, $level + 1);
1323
-            }
1324
-        }
1325
-    }
1326
-
1327
-
1328
-    /**
1329
-     * Loads the scripts for the privacy settings form
1330
-     */
1331
-    public function load_scripts_styles_privacy_settings()
1332
-    {
1333
-        $form_handler = LoaderFactory::getLoader()->getShared('EventEspresso\core\domain\services\admin\privacy\forms\PrivacySettingsFormHandler');
1334
-        $form_handler->enqueueStylesAndScripts();
1335
-    }
1336
-
1337
-
1338
-    /**
1339
-     * display the privacy settings form
1340
-     */
1341
-    public function privacySettings()
1342
-    {
1343
-        $this->_set_add_edit_form_tags('update_privacy_settings');
1344
-        $this->_set_publish_post_box_vars(null, false, false, null, false);
1345
-        $form_handler = LoaderFactory::getLoader()->getShared('EventEspresso\core\domain\services\admin\privacy\forms\PrivacySettingsFormHandler');
1346
-        $this->_template_args['admin_page_content'] = $form_handler->display();
1347
-        $this->display_admin_page_with_sidebar();
1348
-    }
1349
-
1350
-
1351
-    /**
1352
-     * Update the privacy settings from form data
1353
-     *
1354
-     * @throws EE_Error
1355
-     */
1356
-    public function updatePrivacySettings()
1357
-    {
1358
-        $form_handler = LoaderFactory::getLoader()->getShared('EventEspresso\core\domain\services\admin\privacy\forms\PrivacySettingsFormHandler');
1359
-        $success = $form_handler->process($this->get_request_data());
1360
-        $this->_redirect_after_action(
1361
-            $success,
1362
-            esc_html__('Registration Form Options', 'event_espresso'),
1363
-            'updated',
1364
-            array('action' => 'privacy_settings')
1365
-        );
1366
-    }
1230
+	}
1231
+
1232
+
1233
+	/***********/
1234
+
1235
+
1236
+	/**
1237
+	 * displays edit and view links for critical EE pages
1238
+	 *
1239
+	 * @access public
1240
+	 * @param int $ee_page_id
1241
+	 * @return string
1242
+	 */
1243
+	public static function edit_view_links($ee_page_id)
1244
+	{
1245
+		$links = '<a href="'
1246
+				 . add_query_arg(
1247
+					 array('post' => $ee_page_id, 'action' => 'edit'),
1248
+					 admin_url('post.php')
1249
+				 )
1250
+				 . '" >'
1251
+				 . __('Edit', 'event_espresso')
1252
+				 . '</a>';
1253
+		$links .= ' &nbsp;|&nbsp; ';
1254
+		$links .= '<a href="' . get_permalink($ee_page_id) . '" >' . __('View', 'event_espresso') . '</a>';
1255
+
1256
+		return $links;
1257
+	}
1258
+
1259
+
1260
+	/**
1261
+	 * displays page and shortcode status for critical EE pages
1262
+	 *
1263
+	 * @param WP page object $ee_page
1264
+	 * @return string
1265
+	 */
1266
+	public static function page_and_shortcode_status($ee_page, $shortcode)
1267
+	{
1268
+
1269
+		// page status
1270
+		if (isset($ee_page->post_status) && $ee_page->post_status == 'publish') {
1271
+			$pg_colour = 'green';
1272
+			$pg_status = sprintf(__('Page%sStatus%sOK', 'event_espresso'), '&nbsp;', '&nbsp;');
1273
+		} else {
1274
+			$pg_colour = 'red';
1275
+			$pg_status = sprintf(__('Page%sVisibility%sProblem', 'event_espresso'), '&nbsp;', '&nbsp;');
1276
+		}
1277
+
1278
+		// shortcode status
1279
+		if (isset($ee_page->post_content) && strpos($ee_page->post_content, $shortcode) !== false) {
1280
+			$sc_colour = 'green';
1281
+			$sc_status = sprintf(__('Shortcode%sOK', 'event_espresso'), '&nbsp;');
1282
+		} else {
1283
+			$sc_colour = 'red';
1284
+			$sc_status = sprintf(__('Shortcode%sProblem', 'event_espresso'), '&nbsp;');
1285
+		}
1286
+
1287
+		return '<span style="color:' . $pg_colour . '; margin-right:2em;"><strong>'
1288
+			   . $pg_status
1289
+			   . '</strong></span><span style="color:' . $sc_colour . '"><strong>' . $sc_status . '</strong></span>';
1290
+	}
1291
+
1292
+
1293
+	/**
1294
+	 * generates a dropdown of all parent pages - copied from WP core
1295
+	 *
1296
+	 * @param int $default
1297
+	 * @param int $parent
1298
+	 * @param int $level
1299
+	 */
1300
+	public static function page_settings_dropdown($default = 0, $parent = 0, $level = 0)
1301
+	{
1302
+		global $wpdb;
1303
+		$items = $wpdb->get_results(
1304
+			$wpdb->prepare(
1305
+				"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",
1306
+				$parent
1307
+			)
1308
+		);
1309
+
1310
+		if ($items) {
1311
+			foreach ($items as $item) {
1312
+				$pad = str_repeat('&nbsp;', $level * 3);
1313
+				if ($item->ID == $default) {
1314
+					$current = ' selected="selected"';
1315
+				} else {
1316
+					$current = '';
1317
+				}
1318
+
1319
+				echo "\n\t<option class='level-$level' value='$item->ID'$current>$pad "
1320
+					 . esc_html($item->post_title)
1321
+					 . "</option>";
1322
+				parent_dropdown($default, $item->ID, $level + 1);
1323
+			}
1324
+		}
1325
+	}
1326
+
1327
+
1328
+	/**
1329
+	 * Loads the scripts for the privacy settings form
1330
+	 */
1331
+	public function load_scripts_styles_privacy_settings()
1332
+	{
1333
+		$form_handler = LoaderFactory::getLoader()->getShared('EventEspresso\core\domain\services\admin\privacy\forms\PrivacySettingsFormHandler');
1334
+		$form_handler->enqueueStylesAndScripts();
1335
+	}
1336
+
1337
+
1338
+	/**
1339
+	 * display the privacy settings form
1340
+	 */
1341
+	public function privacySettings()
1342
+	{
1343
+		$this->_set_add_edit_form_tags('update_privacy_settings');
1344
+		$this->_set_publish_post_box_vars(null, false, false, null, false);
1345
+		$form_handler = LoaderFactory::getLoader()->getShared('EventEspresso\core\domain\services\admin\privacy\forms\PrivacySettingsFormHandler');
1346
+		$this->_template_args['admin_page_content'] = $form_handler->display();
1347
+		$this->display_admin_page_with_sidebar();
1348
+	}
1349
+
1350
+
1351
+	/**
1352
+	 * Update the privacy settings from form data
1353
+	 *
1354
+	 * @throws EE_Error
1355
+	 */
1356
+	public function updatePrivacySettings()
1357
+	{
1358
+		$form_handler = LoaderFactory::getLoader()->getShared('EventEspresso\core\domain\services\admin\privacy\forms\PrivacySettingsFormHandler');
1359
+		$success = $form_handler->process($this->get_request_data());
1360
+		$this->_redirect_after_action(
1361
+			$success,
1362
+			esc_html__('Registration Form Options', 'event_espresso'),
1363
+			'updated',
1364
+			array('action' => 'privacy_settings')
1365
+		);
1366
+	}
1367 1367
 }
Please login to merge, or discard this patch.