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