Completed
Branch EDTR/input-labels (73d1b5)
by
unknown
11:26 queued 01:08
created
venues/templates/event_venues_metabox_content_from_manager.template.php 1 patch
Indentation   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -5,14 +5,14 @@  discard block
 block discarded – undo
5 5
             <?php echo $venue_selector; ?>
6 6
             <?php echo $new_venue_link; ?>
7 7
             <?php foreach ($venues as $venue) :
8
-                $selected = $evt_venue_id == $venue->ID() ? '' : ' style="display:none;"';
9
-                $edit_url = EE_Admin_Page::add_query_args_and_nonce(
10
-                    array('action' => 'edit', 'post' => $venue->ID()),
11
-                    EE_VENUES_ADMIN_URL
12
-                );
13
-                $state_name = is_object($venue->state_obj()) ? $venue->state_obj()->name() : null;
14
-                $country_name = is_object($venue->country_obj()) ? $venue->country_obj()->name() : null;
15
-                ?>
8
+				$selected = $evt_venue_id == $venue->ID() ? '' : ' style="display:none;"';
9
+				$edit_url = EE_Admin_Page::add_query_args_and_nonce(
10
+					array('action' => 'edit', 'post' => $venue->ID()),
11
+					EE_VENUES_ADMIN_URL
12
+				);
13
+				$state_name = is_object($venue->state_obj()) ? $venue->state_obj()->name() : null;
14
+				$country_name = is_object($venue->country_obj()) ? $venue->country_obj()->name() : null;
15
+				?>
16 16
                 <fieldset id="eebox_<?php echo $venue->ID(); ?>" class="eebox"<?php echo $selected; ?>>
17 17
                     <ul class="address-view">
18 18
                         <li>
@@ -27,9 +27,9 @@  discard block
 block discarded – undo
27 27
                                 <br/></p>
28 28
                             <a href="<?php echo $edit_url; ?>" target="_blank">
29 29
                                 <?php _e(
30
-                                    'Edit this Venue',
31
-                                    'event_espresso'
32
-                                ); ?></a>
30
+									'Edit this Venue',
31
+									'event_espresso'
32
+								); ?></a>
33 33
                         </li>
34 34
                     </ul>
35 35
                 </fieldset>
Please login to merge, or discard this patch.
core/CPTs/EE_CPT_Strategy.core.php 2 patches
Indentation   +443 added lines, -443 removed lines patch added patch discarded remove patch
@@ -16,447 +16,447 @@
 block discarded – undo
16 16
 class EE_CPT_Strategy extends EE_Base
17 17
 {
18 18
 
19
-    /**
20
-     * @var EE_CPT_Strategy $_instance
21
-     */
22
-    private static $_instance;
23
-
24
-    /**
25
-     * the current page, if it utilizes CPTs
26
-     *
27
-     * @var array $CPT
28
-     */
29
-    protected $CPT;
30
-
31
-    /**
32
-     * return value from CustomPostTypeDefinitions::getDefinitions()
33
-     *
34
-     * @var array $_CPTs
35
-     */
36
-    protected $_CPTs = array();
37
-
38
-    /**
39
-     * @var array $_CPT_taxonomies
40
-     */
41
-    protected $_CPT_taxonomies = array();
42
-
43
-    /**
44
-     * @var array $_CPT_terms
45
-     */
46
-    protected $_CPT_terms = array();
47
-
48
-    /**
49
-     * @var array $_CPT_endpoints
50
-     */
51
-    protected $_CPT_endpoints = array();
52
-
53
-    /**
54
-     * @var EEM_Base $CPT_model
55
-     */
56
-    protected $CPT_model;
57
-
58
-    /**
59
-     * @var EventEspresso\Core\CPTs\CptQueryModifier $query_modifier
60
-     */
61
-    protected $query_modifier;
62
-
63
-
64
-    /**
65
-     * @singleton method used to instantiate class object
66
-     * @param CustomPostTypeDefinitions|null $custom_post_types
67
-     * @param CustomTaxonomyDefinitions|null $taxonomies
68
-     * @return EE_CPT_Strategy
69
-     */
70
-    public static function instance(
71
-        CustomPostTypeDefinitions $custom_post_types = null,
72
-        CustomTaxonomyDefinitions $taxonomies = null
73
-    ) {
74
-        // check if class object is instantiated
75
-        if (! self::$_instance instanceof EE_CPT_Strategy
76
-            && $custom_post_types instanceof CustomPostTypeDefinitions
77
-            && $taxonomies instanceof CustomTaxonomyDefinitions
78
-        ) {
79
-            self::$_instance = new self($custom_post_types, $taxonomies);
80
-        }
81
-        return self::$_instance;
82
-    }
83
-
84
-
85
-    /**
86
-     * @param CustomPostTypeDefinitions $custom_post_types
87
-     * @param CustomTaxonomyDefinitions $taxonomies
88
-     */
89
-    protected function __construct(
90
-        CustomPostTypeDefinitions $custom_post_types,
91
-        CustomTaxonomyDefinitions $taxonomies
92
-    ) {
93
-        // get CPT data
94
-        $this->_CPTs = $custom_post_types->getDefinitions();
95
-        $this->_CPT_endpoints = $this->_set_CPT_endpoints();
96
-        $this->_CPT_taxonomies = $taxonomies->getCustomTaxonomyDefinitions();
97
-        add_action('pre_get_posts', array($this, 'pre_get_posts'), 5);
98
-    }
99
-
100
-
101
-    /**
102
-     * @return array
103
-     */
104
-    public function get_CPT_endpoints()
105
-    {
106
-        return $this->_CPT_endpoints;
107
-    }
108
-
109
-
110
-    /**
111
-     * @return array
112
-     */
113
-    public function get_CPT_taxonomies()
114
-    {
115
-        return $this->_CPT_taxonomies;
116
-    }
117
-
118
-
119
-    /**
120
-     * add CPT "slugs" to array of default espresso "pages"
121
-     *
122
-     * @return array
123
-     */
124
-    private function _set_CPT_endpoints()
125
-    {
126
-        $_CPT_endpoints = array();
127
-        if (is_array($this->_CPTs)) {
128
-            foreach ($this->_CPTs as $CPT_type => $CPT) {
129
-                if (isset($CPT['plural_slug'])) {
130
-                    $_CPT_endpoints [ (string) $CPT['plural_slug'] ] = $CPT_type;
131
-                }
132
-            }
133
-        }
134
-        return $_CPT_endpoints;
135
-    }
136
-
137
-
138
-    /**
139
-     * If this query (not just "main" queries (ie, for WP's infamous "loop")) is for an EE CPT, then we want to
140
-     * supercharge the get_posts query to add our EE stuff (like joining to our tables, selecting extra columns, and
141
-     * adding EE objects to the post to facilitate further querying of related data etc)
142
-     *
143
-     * @param WP_Query $WP_Query
144
-     * @return void
145
-     * @throws \EE_Error
146
-     * @throws \InvalidArgumentException
147
-     * @throws \EventEspresso\core\exceptions\InvalidInterfaceException
148
-     * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
149
-     */
150
-    public function pre_get_posts($WP_Query)
151
-    {
152
-        // check that post-type is set
153
-        if (! $WP_Query instanceof WP_Query) {
154
-            return;
155
-        }
156
-        // add our conditionals
157
-        $this->_set_EE_tags_on_WP_Query($WP_Query);
158
-        // check for terms
159
-        $this->_set_post_type_for_terms($WP_Query);
160
-        // make sure paging is always set
161
-        $this->_set_paging($WP_Query);
162
-        // is a taxonomy set ?
163
-        $this->_set_CPT_taxonomies_on_WP_Query($WP_Query);
164
-        // loop thru post_types if set
165
-        $this->_process_WP_Query_post_types($WP_Query);
166
-    }
167
-
168
-
169
-    /**
170
-     * @param WP_Query $WP_Query
171
-     * @return void
172
-     */
173
-    private function _set_EE_tags_on_WP_Query(WP_Query $WP_Query)
174
-    {
175
-        $WP_Query->is_espresso_event_single = false;
176
-        $WP_Query->is_espresso_event_archive = false;
177
-        $WP_Query->is_espresso_event_taxonomy = false;
178
-        $WP_Query->is_espresso_venue_single = false;
179
-        $WP_Query->is_espresso_venue_archive = false;
180
-        $WP_Query->is_espresso_venue_taxonomy = false;
181
-    }
182
-
183
-
184
-    /**
185
-     * @return void
186
-     * @throws EE_Error
187
-     * @throws InvalidArgumentException
188
-     * @throws InvalidDataTypeException
189
-     * @throws InvalidInterfaceException
190
-     */
191
-    private function _set_CPT_terms()
192
-    {
193
-        if (empty($this->_CPT_terms)) {
194
-            $terms = EEM_Term::instance()->get_all_CPT_post_tags();
195
-            foreach ($terms as $term) {
196
-                if ($term instanceof EE_Term) {
197
-                    $this->_CPT_terms[ $term->slug() ] = $term;
198
-                }
199
-            }
200
-        }
201
-    }
202
-
203
-
204
-    /**
205
-     * @param WP_Query $WP_Query
206
-     * @return void
207
-     * @throws EE_Error
208
-     * @throws InvalidArgumentException
209
-     * @throws InvalidDataTypeException
210
-     * @throws InvalidInterfaceException
211
-     */
212
-    private function _set_post_type_for_terms(WP_Query $WP_Query)
213
-    {
214
-        // is a tag set ?
215
-        if (isset($WP_Query->query['tag'])) {
216
-            // get term for tag
217
-            $term = EEM_Term::instance()->get_post_tag_for_event_or_venue($WP_Query->query['tag']);
218
-            // verify the term
219
-            if ($term instanceof EE_Term) {
220
-                $term->post_type = array_merge(array('post', 'page'), (array) $term->post_type);
221
-                $term->post_type = apply_filters(
222
-                    'FHEE__EE_CPT_Strategy___set_post_type_for_terms__term_post_type',
223
-                    $term->post_type,
224
-                    $term
225
-                );
226
-                // if a post type is already set
227
-                if (isset($WP_Query->query_vars['post_type'])) {
228
-                    // add to existing array
229
-                    $term->post_type = array_merge((array) $WP_Query->query_vars['post_type'], $term->post_type);
230
-                }
231
-                // just set post_type to our CPT
232
-                $WP_Query->set('post_type', array_unique($term->post_type));
233
-            }
234
-        }
235
-    }
236
-
237
-
238
-    /**
239
-     * @param WP_Query $WP_Query
240
-     * @return void
241
-     */
242
-    public function _set_paging($WP_Query)
243
-    {
244
-        if ($WP_Query->is_main_query() && apply_filters('FHEE__EE_CPT_Strategy___set_paging', true)) {
245
-            $page = get_query_var('page') ? get_query_var('page') : null;
246
-            $paged = get_query_var('paged') ? get_query_var('paged') : $page;
247
-            $WP_Query->set('paged', $paged);
248
-        }
249
-    }
250
-
251
-
252
-    /**
253
-     * @param \WP_Query $WP_Query
254
-     */
255
-    protected function _set_CPT_taxonomies_on_WP_Query(WP_Query $WP_Query)
256
-    {
257
-        // is a taxonomy set ?
258
-        if ($WP_Query->is_tax) {
259
-            // loop thru our taxonomies
260
-            foreach ($this->_CPT_taxonomies as $CPT_taxonomy => $CPT_taxonomy_details) {
261
-                // check if one of our taxonomies is set as a query var
262
-                if (isset($WP_Query->query[ $CPT_taxonomy ])) {
263
-                    // but which CPT does that correspond to??? hmmm... guess we gotta go looping
264
-                    foreach ($this->_CPTs as $post_type => $CPT) {
265
-                        // verify our CPT has args, is public and has taxonomies set
266
-                        if (isset($CPT['args']['public'])
267
-                            && $CPT['args']['public']
268
-                            && ! empty($CPT['args']['taxonomies'])
269
-                            && in_array($CPT_taxonomy, $CPT['args']['taxonomies'], true)
270
-                        ) {
271
-                            // if so, then add this CPT post_type to the current query's array of post_types'
272
-                            $WP_Query->query_vars['post_type'] = isset($WP_Query->query_vars['post_type'])
273
-                                ? (array) $WP_Query->query_vars['post_type']
274
-                                : array();
275
-                            $WP_Query->query_vars['post_type'][] = $post_type;
276
-                            switch ($post_type) {
277
-                                case 'espresso_events':
278
-                                    $WP_Query->is_espresso_event_taxonomy = true;
279
-                                    break;
280
-                                case 'espresso_venues':
281
-                                    $WP_Query->is_espresso_venue_taxonomy = true;
282
-                                    break;
283
-                                default:
284
-                                    do_action(
285
-                                        'AHEE__EE_CPT_Strategy___set_CPT_taxonomies_on_WP_Query__for_' . $post_type . '_post_type',
286
-                                        $WP_Query,
287
-                                        $this
288
-                                    );
289
-                            }
290
-                        }
291
-                    }
292
-                }
293
-            }
294
-        }
295
-    }
296
-
297
-
298
-    /**
299
-     * @param \WP_Query $WP_Query
300
-     * @throws InvalidArgumentException
301
-     * @throws InvalidDataTypeException
302
-     * @throws InvalidInterfaceException
303
-     */
304
-    protected function _process_WP_Query_post_types(WP_Query $WP_Query)
305
-    {
306
-        if (isset($WP_Query->query_vars['post_type'])) {
307
-            // loop thru post_types as array
308
-            foreach ((array) $WP_Query->query_vars['post_type'] as $post_type) {
309
-                // is current query for an EE CPT ?
310
-                if (isset($this->_CPTs[ $post_type ])) {
311
-                    // is EE on or off ?
312
-                    if (EE_Maintenance_Mode::instance()->level()) {
313
-                        // reroute CPT template view to maintenance_mode.template.php
314
-                        if (! has_filter('template_include', array('EE_Maintenance_Mode', 'template_include'))) {
315
-                            add_filter('template_include', array('EE_Maintenance_Mode', 'template_include'), 99999);
316
-                        }
317
-                        if (has_filter('the_content', array(EE_Maintenance_Mode::instance(), 'the_content'))) {
318
-                            add_filter('the_content', array($this, 'inject_EE_shortcode_placeholder'), 1);
319
-                        }
320
-                        return;
321
-                    }
322
-                    $this->_generate_CptQueryModifier($WP_Query, $post_type);
323
-                }
324
-            }
325
-        }
326
-    }
327
-
328
-
329
-    /**
330
-     * @param \WP_Query $WP_Query
331
-     * @param string    $post_type
332
-     * @throws InvalidArgumentException
333
-     * @throws InvalidDataTypeException
334
-     * @throws InvalidInterfaceException
335
-     */
336
-    protected function _generate_CptQueryModifier(WP_Query $WP_Query, $post_type)
337
-    {
338
-        $this->query_modifier = LoaderFactory::getLoader()->getShared(
339
-            'EventEspresso\core\CPTs\CptQueryModifier',
340
-            array(
341
-                $post_type,
342
-                $this->_CPTs[ $post_type ],
343
-                $WP_Query,
344
-            )
345
-        );
346
-        $this->_CPT_taxonomies = $this->query_modifier->taxonomies();
347
-    }
348
-
349
-
350
-    /**
351
-     * inject_EE_shortcode_placeholder
352
-     * in order to display the M-Mode notice on our CPT routes,
353
-     * we need to first inject what looks like one of our shortcodes,
354
-     * so that it can be replaced with the actual M-Mode notice
355
-     *
356
-     * @return string
357
-     */
358
-    public function inject_EE_shortcode_placeholder()
359
-    {
360
-        return '[ESPRESSO_';
361
-    }
362
-
363
-
364
-    /**
365
-     * @deprecated
366
-     * @since  4.8.41
367
-     * @return void
368
-     */
369
-    public function _possibly_set_ee_request_var()
370
-    {
371
-        $this->query_modifier->setRequestVarsIfCpt();
372
-    }
373
-
374
-
375
-    /**
376
-     * @deprecated
377
-     * @since  4.8.41
378
-     * @param  $SQL
379
-     * @return string
380
-     */
381
-    public function posts_fields($SQL)
382
-    {
383
-        if ($this->query_modifier instanceof EventEspresso\Core\CPTs\CptQueryModifier) {
384
-            return $this->query_modifier->postsFields($SQL);
385
-        }
386
-        return $SQL;
387
-    }
388
-
389
-
390
-    /**
391
-     * @deprecated
392
-     * @since  4.8.41
393
-     * @param  $SQL
394
-     * @return string
395
-     */
396
-    public function posts_join($SQL)
397
-    {
398
-        if ($this->query_modifier instanceof EventEspresso\Core\CPTs\CptQueryModifier) {
399
-            return $this->query_modifier->postsJoin($SQL);
400
-        }
401
-        return $SQL;
402
-    }
403
-
404
-
405
-    /**
406
-     * @deprecated
407
-     * @since  4.8.41
408
-     * @param  \WP_Post[] $posts
409
-     * @return \WP_Post[]
410
-     */
411
-    public function the_posts($posts)
412
-    {
413
-        if ($this->query_modifier instanceof EventEspresso\Core\CPTs\CptQueryModifier) {
414
-            $this->query_modifier->thePosts($posts);
415
-        }
416
-        return $posts;
417
-    }
418
-
419
-
420
-    /**
421
-     * @deprecated
422
-     * @since  4.8.41
423
-     * @param $url
424
-     * @param $ID
425
-     * @return string
426
-     */
427
-    public function get_edit_post_link($url, $ID)
428
-    {
429
-        if ($this->query_modifier instanceof EventEspresso\Core\CPTs\CptQueryModifier) {
430
-            return $this->query_modifier->getEditPostLink($url, $ID);
431
-        }
432
-        return '';
433
-    }
434
-
435
-
436
-    /**
437
-     * @deprecated
438
-     * @since  4.8.41
439
-     * @param null $WP_Query
440
-     */
441
-    protected function _do_template_filters($WP_Query = null)
442
-    {
443
-        if ($this->query_modifier instanceof EventEspresso\Core\CPTs\CptQueryModifier) {
444
-            $this->query_modifier->addTemplateFilters();
445
-        }
446
-    }
447
-
448
-
449
-    /**
450
-     * @deprecated
451
-     * @since  4.8.41
452
-     * @param string $current_template Existing default template path derived for this page call.
453
-     * @return string the path to the full template file.
454
-     */
455
-    public function single_cpt_template($current_template)
456
-    {
457
-        if ($this->query_modifier instanceof EventEspresso\Core\CPTs\CptQueryModifier) {
458
-            return $this->query_modifier->singleCptTemplate($current_template);
459
-        }
460
-        return $current_template;
461
-    }
19
+	/**
20
+	 * @var EE_CPT_Strategy $_instance
21
+	 */
22
+	private static $_instance;
23
+
24
+	/**
25
+	 * the current page, if it utilizes CPTs
26
+	 *
27
+	 * @var array $CPT
28
+	 */
29
+	protected $CPT;
30
+
31
+	/**
32
+	 * return value from CustomPostTypeDefinitions::getDefinitions()
33
+	 *
34
+	 * @var array $_CPTs
35
+	 */
36
+	protected $_CPTs = array();
37
+
38
+	/**
39
+	 * @var array $_CPT_taxonomies
40
+	 */
41
+	protected $_CPT_taxonomies = array();
42
+
43
+	/**
44
+	 * @var array $_CPT_terms
45
+	 */
46
+	protected $_CPT_terms = array();
47
+
48
+	/**
49
+	 * @var array $_CPT_endpoints
50
+	 */
51
+	protected $_CPT_endpoints = array();
52
+
53
+	/**
54
+	 * @var EEM_Base $CPT_model
55
+	 */
56
+	protected $CPT_model;
57
+
58
+	/**
59
+	 * @var EventEspresso\Core\CPTs\CptQueryModifier $query_modifier
60
+	 */
61
+	protected $query_modifier;
62
+
63
+
64
+	/**
65
+	 * @singleton method used to instantiate class object
66
+	 * @param CustomPostTypeDefinitions|null $custom_post_types
67
+	 * @param CustomTaxonomyDefinitions|null $taxonomies
68
+	 * @return EE_CPT_Strategy
69
+	 */
70
+	public static function instance(
71
+		CustomPostTypeDefinitions $custom_post_types = null,
72
+		CustomTaxonomyDefinitions $taxonomies = null
73
+	) {
74
+		// check if class object is instantiated
75
+		if (! self::$_instance instanceof EE_CPT_Strategy
76
+			&& $custom_post_types instanceof CustomPostTypeDefinitions
77
+			&& $taxonomies instanceof CustomTaxonomyDefinitions
78
+		) {
79
+			self::$_instance = new self($custom_post_types, $taxonomies);
80
+		}
81
+		return self::$_instance;
82
+	}
83
+
84
+
85
+	/**
86
+	 * @param CustomPostTypeDefinitions $custom_post_types
87
+	 * @param CustomTaxonomyDefinitions $taxonomies
88
+	 */
89
+	protected function __construct(
90
+		CustomPostTypeDefinitions $custom_post_types,
91
+		CustomTaxonomyDefinitions $taxonomies
92
+	) {
93
+		// get CPT data
94
+		$this->_CPTs = $custom_post_types->getDefinitions();
95
+		$this->_CPT_endpoints = $this->_set_CPT_endpoints();
96
+		$this->_CPT_taxonomies = $taxonomies->getCustomTaxonomyDefinitions();
97
+		add_action('pre_get_posts', array($this, 'pre_get_posts'), 5);
98
+	}
99
+
100
+
101
+	/**
102
+	 * @return array
103
+	 */
104
+	public function get_CPT_endpoints()
105
+	{
106
+		return $this->_CPT_endpoints;
107
+	}
108
+
109
+
110
+	/**
111
+	 * @return array
112
+	 */
113
+	public function get_CPT_taxonomies()
114
+	{
115
+		return $this->_CPT_taxonomies;
116
+	}
117
+
118
+
119
+	/**
120
+	 * add CPT "slugs" to array of default espresso "pages"
121
+	 *
122
+	 * @return array
123
+	 */
124
+	private function _set_CPT_endpoints()
125
+	{
126
+		$_CPT_endpoints = array();
127
+		if (is_array($this->_CPTs)) {
128
+			foreach ($this->_CPTs as $CPT_type => $CPT) {
129
+				if (isset($CPT['plural_slug'])) {
130
+					$_CPT_endpoints [ (string) $CPT['plural_slug'] ] = $CPT_type;
131
+				}
132
+			}
133
+		}
134
+		return $_CPT_endpoints;
135
+	}
136
+
137
+
138
+	/**
139
+	 * If this query (not just "main" queries (ie, for WP's infamous "loop")) is for an EE CPT, then we want to
140
+	 * supercharge the get_posts query to add our EE stuff (like joining to our tables, selecting extra columns, and
141
+	 * adding EE objects to the post to facilitate further querying of related data etc)
142
+	 *
143
+	 * @param WP_Query $WP_Query
144
+	 * @return void
145
+	 * @throws \EE_Error
146
+	 * @throws \InvalidArgumentException
147
+	 * @throws \EventEspresso\core\exceptions\InvalidInterfaceException
148
+	 * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
149
+	 */
150
+	public function pre_get_posts($WP_Query)
151
+	{
152
+		// check that post-type is set
153
+		if (! $WP_Query instanceof WP_Query) {
154
+			return;
155
+		}
156
+		// add our conditionals
157
+		$this->_set_EE_tags_on_WP_Query($WP_Query);
158
+		// check for terms
159
+		$this->_set_post_type_for_terms($WP_Query);
160
+		// make sure paging is always set
161
+		$this->_set_paging($WP_Query);
162
+		// is a taxonomy set ?
163
+		$this->_set_CPT_taxonomies_on_WP_Query($WP_Query);
164
+		// loop thru post_types if set
165
+		$this->_process_WP_Query_post_types($WP_Query);
166
+	}
167
+
168
+
169
+	/**
170
+	 * @param WP_Query $WP_Query
171
+	 * @return void
172
+	 */
173
+	private function _set_EE_tags_on_WP_Query(WP_Query $WP_Query)
174
+	{
175
+		$WP_Query->is_espresso_event_single = false;
176
+		$WP_Query->is_espresso_event_archive = false;
177
+		$WP_Query->is_espresso_event_taxonomy = false;
178
+		$WP_Query->is_espresso_venue_single = false;
179
+		$WP_Query->is_espresso_venue_archive = false;
180
+		$WP_Query->is_espresso_venue_taxonomy = false;
181
+	}
182
+
183
+
184
+	/**
185
+	 * @return void
186
+	 * @throws EE_Error
187
+	 * @throws InvalidArgumentException
188
+	 * @throws InvalidDataTypeException
189
+	 * @throws InvalidInterfaceException
190
+	 */
191
+	private function _set_CPT_terms()
192
+	{
193
+		if (empty($this->_CPT_terms)) {
194
+			$terms = EEM_Term::instance()->get_all_CPT_post_tags();
195
+			foreach ($terms as $term) {
196
+				if ($term instanceof EE_Term) {
197
+					$this->_CPT_terms[ $term->slug() ] = $term;
198
+				}
199
+			}
200
+		}
201
+	}
202
+
203
+
204
+	/**
205
+	 * @param WP_Query $WP_Query
206
+	 * @return void
207
+	 * @throws EE_Error
208
+	 * @throws InvalidArgumentException
209
+	 * @throws InvalidDataTypeException
210
+	 * @throws InvalidInterfaceException
211
+	 */
212
+	private function _set_post_type_for_terms(WP_Query $WP_Query)
213
+	{
214
+		// is a tag set ?
215
+		if (isset($WP_Query->query['tag'])) {
216
+			// get term for tag
217
+			$term = EEM_Term::instance()->get_post_tag_for_event_or_venue($WP_Query->query['tag']);
218
+			// verify the term
219
+			if ($term instanceof EE_Term) {
220
+				$term->post_type = array_merge(array('post', 'page'), (array) $term->post_type);
221
+				$term->post_type = apply_filters(
222
+					'FHEE__EE_CPT_Strategy___set_post_type_for_terms__term_post_type',
223
+					$term->post_type,
224
+					$term
225
+				);
226
+				// if a post type is already set
227
+				if (isset($WP_Query->query_vars['post_type'])) {
228
+					// add to existing array
229
+					$term->post_type = array_merge((array) $WP_Query->query_vars['post_type'], $term->post_type);
230
+				}
231
+				// just set post_type to our CPT
232
+				$WP_Query->set('post_type', array_unique($term->post_type));
233
+			}
234
+		}
235
+	}
236
+
237
+
238
+	/**
239
+	 * @param WP_Query $WP_Query
240
+	 * @return void
241
+	 */
242
+	public function _set_paging($WP_Query)
243
+	{
244
+		if ($WP_Query->is_main_query() && apply_filters('FHEE__EE_CPT_Strategy___set_paging', true)) {
245
+			$page = get_query_var('page') ? get_query_var('page') : null;
246
+			$paged = get_query_var('paged') ? get_query_var('paged') : $page;
247
+			$WP_Query->set('paged', $paged);
248
+		}
249
+	}
250
+
251
+
252
+	/**
253
+	 * @param \WP_Query $WP_Query
254
+	 */
255
+	protected function _set_CPT_taxonomies_on_WP_Query(WP_Query $WP_Query)
256
+	{
257
+		// is a taxonomy set ?
258
+		if ($WP_Query->is_tax) {
259
+			// loop thru our taxonomies
260
+			foreach ($this->_CPT_taxonomies as $CPT_taxonomy => $CPT_taxonomy_details) {
261
+				// check if one of our taxonomies is set as a query var
262
+				if (isset($WP_Query->query[ $CPT_taxonomy ])) {
263
+					// but which CPT does that correspond to??? hmmm... guess we gotta go looping
264
+					foreach ($this->_CPTs as $post_type => $CPT) {
265
+						// verify our CPT has args, is public and has taxonomies set
266
+						if (isset($CPT['args']['public'])
267
+							&& $CPT['args']['public']
268
+							&& ! empty($CPT['args']['taxonomies'])
269
+							&& in_array($CPT_taxonomy, $CPT['args']['taxonomies'], true)
270
+						) {
271
+							// if so, then add this CPT post_type to the current query's array of post_types'
272
+							$WP_Query->query_vars['post_type'] = isset($WP_Query->query_vars['post_type'])
273
+								? (array) $WP_Query->query_vars['post_type']
274
+								: array();
275
+							$WP_Query->query_vars['post_type'][] = $post_type;
276
+							switch ($post_type) {
277
+								case 'espresso_events':
278
+									$WP_Query->is_espresso_event_taxonomy = true;
279
+									break;
280
+								case 'espresso_venues':
281
+									$WP_Query->is_espresso_venue_taxonomy = true;
282
+									break;
283
+								default:
284
+									do_action(
285
+										'AHEE__EE_CPT_Strategy___set_CPT_taxonomies_on_WP_Query__for_' . $post_type . '_post_type',
286
+										$WP_Query,
287
+										$this
288
+									);
289
+							}
290
+						}
291
+					}
292
+				}
293
+			}
294
+		}
295
+	}
296
+
297
+
298
+	/**
299
+	 * @param \WP_Query $WP_Query
300
+	 * @throws InvalidArgumentException
301
+	 * @throws InvalidDataTypeException
302
+	 * @throws InvalidInterfaceException
303
+	 */
304
+	protected function _process_WP_Query_post_types(WP_Query $WP_Query)
305
+	{
306
+		if (isset($WP_Query->query_vars['post_type'])) {
307
+			// loop thru post_types as array
308
+			foreach ((array) $WP_Query->query_vars['post_type'] as $post_type) {
309
+				// is current query for an EE CPT ?
310
+				if (isset($this->_CPTs[ $post_type ])) {
311
+					// is EE on or off ?
312
+					if (EE_Maintenance_Mode::instance()->level()) {
313
+						// reroute CPT template view to maintenance_mode.template.php
314
+						if (! has_filter('template_include', array('EE_Maintenance_Mode', 'template_include'))) {
315
+							add_filter('template_include', array('EE_Maintenance_Mode', 'template_include'), 99999);
316
+						}
317
+						if (has_filter('the_content', array(EE_Maintenance_Mode::instance(), 'the_content'))) {
318
+							add_filter('the_content', array($this, 'inject_EE_shortcode_placeholder'), 1);
319
+						}
320
+						return;
321
+					}
322
+					$this->_generate_CptQueryModifier($WP_Query, $post_type);
323
+				}
324
+			}
325
+		}
326
+	}
327
+
328
+
329
+	/**
330
+	 * @param \WP_Query $WP_Query
331
+	 * @param string    $post_type
332
+	 * @throws InvalidArgumentException
333
+	 * @throws InvalidDataTypeException
334
+	 * @throws InvalidInterfaceException
335
+	 */
336
+	protected function _generate_CptQueryModifier(WP_Query $WP_Query, $post_type)
337
+	{
338
+		$this->query_modifier = LoaderFactory::getLoader()->getShared(
339
+			'EventEspresso\core\CPTs\CptQueryModifier',
340
+			array(
341
+				$post_type,
342
+				$this->_CPTs[ $post_type ],
343
+				$WP_Query,
344
+			)
345
+		);
346
+		$this->_CPT_taxonomies = $this->query_modifier->taxonomies();
347
+	}
348
+
349
+
350
+	/**
351
+	 * inject_EE_shortcode_placeholder
352
+	 * in order to display the M-Mode notice on our CPT routes,
353
+	 * we need to first inject what looks like one of our shortcodes,
354
+	 * so that it can be replaced with the actual M-Mode notice
355
+	 *
356
+	 * @return string
357
+	 */
358
+	public function inject_EE_shortcode_placeholder()
359
+	{
360
+		return '[ESPRESSO_';
361
+	}
362
+
363
+
364
+	/**
365
+	 * @deprecated
366
+	 * @since  4.8.41
367
+	 * @return void
368
+	 */
369
+	public function _possibly_set_ee_request_var()
370
+	{
371
+		$this->query_modifier->setRequestVarsIfCpt();
372
+	}
373
+
374
+
375
+	/**
376
+	 * @deprecated
377
+	 * @since  4.8.41
378
+	 * @param  $SQL
379
+	 * @return string
380
+	 */
381
+	public function posts_fields($SQL)
382
+	{
383
+		if ($this->query_modifier instanceof EventEspresso\Core\CPTs\CptQueryModifier) {
384
+			return $this->query_modifier->postsFields($SQL);
385
+		}
386
+		return $SQL;
387
+	}
388
+
389
+
390
+	/**
391
+	 * @deprecated
392
+	 * @since  4.8.41
393
+	 * @param  $SQL
394
+	 * @return string
395
+	 */
396
+	public function posts_join($SQL)
397
+	{
398
+		if ($this->query_modifier instanceof EventEspresso\Core\CPTs\CptQueryModifier) {
399
+			return $this->query_modifier->postsJoin($SQL);
400
+		}
401
+		return $SQL;
402
+	}
403
+
404
+
405
+	/**
406
+	 * @deprecated
407
+	 * @since  4.8.41
408
+	 * @param  \WP_Post[] $posts
409
+	 * @return \WP_Post[]
410
+	 */
411
+	public function the_posts($posts)
412
+	{
413
+		if ($this->query_modifier instanceof EventEspresso\Core\CPTs\CptQueryModifier) {
414
+			$this->query_modifier->thePosts($posts);
415
+		}
416
+		return $posts;
417
+	}
418
+
419
+
420
+	/**
421
+	 * @deprecated
422
+	 * @since  4.8.41
423
+	 * @param $url
424
+	 * @param $ID
425
+	 * @return string
426
+	 */
427
+	public function get_edit_post_link($url, $ID)
428
+	{
429
+		if ($this->query_modifier instanceof EventEspresso\Core\CPTs\CptQueryModifier) {
430
+			return $this->query_modifier->getEditPostLink($url, $ID);
431
+		}
432
+		return '';
433
+	}
434
+
435
+
436
+	/**
437
+	 * @deprecated
438
+	 * @since  4.8.41
439
+	 * @param null $WP_Query
440
+	 */
441
+	protected function _do_template_filters($WP_Query = null)
442
+	{
443
+		if ($this->query_modifier instanceof EventEspresso\Core\CPTs\CptQueryModifier) {
444
+			$this->query_modifier->addTemplateFilters();
445
+		}
446
+	}
447
+
448
+
449
+	/**
450
+	 * @deprecated
451
+	 * @since  4.8.41
452
+	 * @param string $current_template Existing default template path derived for this page call.
453
+	 * @return string the path to the full template file.
454
+	 */
455
+	public function single_cpt_template($current_template)
456
+	{
457
+		if ($this->query_modifier instanceof EventEspresso\Core\CPTs\CptQueryModifier) {
458
+			return $this->query_modifier->singleCptTemplate($current_template);
459
+		}
460
+		return $current_template;
461
+	}
462 462
 }
Please login to merge, or discard this patch.
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -72,7 +72,7 @@  discard block
 block discarded – undo
72 72
         CustomTaxonomyDefinitions $taxonomies = null
73 73
     ) {
74 74
         // check if class object is instantiated
75
-        if (! self::$_instance instanceof EE_CPT_Strategy
75
+        if ( ! self::$_instance instanceof EE_CPT_Strategy
76 76
             && $custom_post_types instanceof CustomPostTypeDefinitions
77 77
             && $taxonomies instanceof CustomTaxonomyDefinitions
78 78
         ) {
@@ -127,7 +127,7 @@  discard block
 block discarded – undo
127 127
         if (is_array($this->_CPTs)) {
128 128
             foreach ($this->_CPTs as $CPT_type => $CPT) {
129 129
                 if (isset($CPT['plural_slug'])) {
130
-                    $_CPT_endpoints [ (string) $CPT['plural_slug'] ] = $CPT_type;
130
+                    $_CPT_endpoints [(string) $CPT['plural_slug']] = $CPT_type;
131 131
                 }
132 132
             }
133 133
         }
@@ -150,7 +150,7 @@  discard block
 block discarded – undo
150 150
     public function pre_get_posts($WP_Query)
151 151
     {
152 152
         // check that post-type is set
153
-        if (! $WP_Query instanceof WP_Query) {
153
+        if ( ! $WP_Query instanceof WP_Query) {
154 154
             return;
155 155
         }
156 156
         // add our conditionals
@@ -194,7 +194,7 @@  discard block
 block discarded – undo
194 194
             $terms = EEM_Term::instance()->get_all_CPT_post_tags();
195 195
             foreach ($terms as $term) {
196 196
                 if ($term instanceof EE_Term) {
197
-                    $this->_CPT_terms[ $term->slug() ] = $term;
197
+                    $this->_CPT_terms[$term->slug()] = $term;
198 198
                 }
199 199
             }
200 200
         }
@@ -259,7 +259,7 @@  discard block
 block discarded – undo
259 259
             // loop thru our taxonomies
260 260
             foreach ($this->_CPT_taxonomies as $CPT_taxonomy => $CPT_taxonomy_details) {
261 261
                 // check if one of our taxonomies is set as a query var
262
-                if (isset($WP_Query->query[ $CPT_taxonomy ])) {
262
+                if (isset($WP_Query->query[$CPT_taxonomy])) {
263 263
                     // but which CPT does that correspond to??? hmmm... guess we gotta go looping
264 264
                     foreach ($this->_CPTs as $post_type => $CPT) {
265 265
                         // verify our CPT has args, is public and has taxonomies set
@@ -282,7 +282,7 @@  discard block
 block discarded – undo
282 282
                                     break;
283 283
                                 default:
284 284
                                     do_action(
285
-                                        'AHEE__EE_CPT_Strategy___set_CPT_taxonomies_on_WP_Query__for_' . $post_type . '_post_type',
285
+                                        'AHEE__EE_CPT_Strategy___set_CPT_taxonomies_on_WP_Query__for_'.$post_type.'_post_type',
286 286
                                         $WP_Query,
287 287
                                         $this
288 288
                                     );
@@ -307,11 +307,11 @@  discard block
 block discarded – undo
307 307
             // loop thru post_types as array
308 308
             foreach ((array) $WP_Query->query_vars['post_type'] as $post_type) {
309 309
                 // is current query for an EE CPT ?
310
-                if (isset($this->_CPTs[ $post_type ])) {
310
+                if (isset($this->_CPTs[$post_type])) {
311 311
                     // is EE on or off ?
312 312
                     if (EE_Maintenance_Mode::instance()->level()) {
313 313
                         // reroute CPT template view to maintenance_mode.template.php
314
-                        if (! has_filter('template_include', array('EE_Maintenance_Mode', 'template_include'))) {
314
+                        if ( ! has_filter('template_include', array('EE_Maintenance_Mode', 'template_include'))) {
315 315
                             add_filter('template_include', array('EE_Maintenance_Mode', 'template_include'), 99999);
316 316
                         }
317 317
                         if (has_filter('the_content', array(EE_Maintenance_Mode::instance(), 'the_content'))) {
@@ -339,7 +339,7 @@  discard block
 block discarded – undo
339 339
             'EventEspresso\core\CPTs\CptQueryModifier',
340 340
             array(
341 341
                 $post_type,
342
-                $this->_CPTs[ $post_type ],
342
+                $this->_CPTs[$post_type],
343 343
                 $WP_Query,
344 344
             )
345 345
         );
Please login to merge, or discard this patch.
core/services/request/Request.php 3 patches
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -174,7 +174,7 @@  discard block
 block discarded – undo
174 174
      *
175 175
      * @param       $key
176 176
      * @param null  $default
177
-     * @return mixed
177
+     * @return integer
178 178
      */
179 179
     public function getRequestParam($key, $default = null)
180 180
     {
@@ -287,7 +287,7 @@  discard block
 block discarded – undo
287 287
      * would return true if default parameters were set
288 288
      *
289 289
      * @param string $callback
290
-     * @param        $key
290
+     * @param        string $key
291 291
      * @param null   $default
292 292
      * @param array  $request_params
293 293
      * @return bool|mixed|null
Please login to merge, or discard this patch.
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -182,7 +182,7 @@  discard block
 block discarded – undo
182 182
             || ($key === 'ee' && empty($this->request['ee']))
183 183
             || ($key === 'ee' && ! empty($this->request['ee']) && $override_ee)
184 184
         ) {
185
-            $this->request[ $key ] = $value;
185
+            $this->request[$key] = $value;
186 186
         }
187 187
     }
188 188
 
@@ -273,10 +273,10 @@  discard block
 block discarded – undo
273 273
             preg_quote($pattern, '/')
274 274
         );
275 275
         foreach ($request_params as $key => $request_param) {
276
-            if (preg_match('/^' . $pattern . '$/is', $key)) {
276
+            if (preg_match('/^'.$pattern.'$/is', $key)) {
277 277
                 // return value for request param
278 278
                 if ($return === 'value') {
279
-                    return $request_params[ $key ];
279
+                    return $request_params[$key];
280 280
                 }
281 281
                 // or actual key or true just to indicate it was found
282 282
                 return $return === 'key' ? $key : true;
@@ -333,29 +333,29 @@  discard block
 block discarded – undo
333 333
                 $key = $real_key ? $real_key : $key;
334 334
             }
335 335
             // check if top level key exists
336
-            if (isset($request_params[ $key ])) {
336
+            if (isset($request_params[$key])) {
337 337
                 // build a new key to pass along like: 'second[third]'
338 338
                 // or just 'second' depending on depth of keys
339 339
                 $key_string = array_shift($keys);
340
-                if (! empty($keys)) {
341
-                    $key_string .= '[' . implode('][', $keys) . ']';
340
+                if ( ! empty($keys)) {
341
+                    $key_string .= '['.implode('][', $keys).']';
342 342
                 }
343 343
                 return $this->requestParameterDrillDown(
344 344
                     $key_string,
345 345
                     $default,
346 346
                     $callback,
347
-                    $request_params[ $key ]
347
+                    $request_params[$key]
348 348
                 );
349 349
             }
350 350
         }
351 351
         if ($callback === 'is_set') {
352
-            return isset($request_params[ $key ]);
352
+            return isset($request_params[$key]);
353 353
         }
354 354
         if ($callback === 'match') {
355 355
             return $this->match($key, $request_params, $default);
356 356
         }
357
-        return isset($request_params[ $key ])
358
-            ? $request_params[ $key ]
357
+        return isset($request_params[$key])
358
+            ? $request_params[$key]
359 359
             : $default;
360 360
     }
361 361
 
@@ -369,10 +369,10 @@  discard block
 block discarded – undo
369 369
     public function unSetRequestParam($key, $unset_from_global_too = false)
370 370
     {
371 371
         // because unset may not actually remove var
372
-        $this->request[ $key ] = null;
373
-        unset($this->request[ $key ]);
372
+        $this->request[$key] = null;
373
+        unset($this->request[$key]);
374 374
         if ($unset_from_global_too) {
375
-            unset($_REQUEST[ $key ]);
375
+            unset($_REQUEST[$key]);
376 376
         }
377 377
     }
378 378
 
@@ -420,8 +420,8 @@  discard block
 block discarded – undo
420 420
             'REMOTE_ADDR',
421 421
         );
422 422
         foreach ($server_keys as $key) {
423
-            if (isset($this->server[ $key ])) {
424
-                foreach (array_map('trim', explode(',', $this->server[ $key ])) as $ip) {
423
+            if (isset($this->server[$key])) {
424
+                foreach (array_map('trim', explode(',', $this->server[$key])) as $ip) {
425 425
                     if ($ip === '127.0.0.1' || filter_var($ip, FILTER_VALIDATE_IP) !== false) {
426 426
                         $visitor_ip = $ip;
427 427
                     }
Please login to merge, or discard this patch.
Indentation   +671 added lines, -671 removed lines patch added patch discarded remove patch
@@ -17,675 +17,675 @@
 block discarded – undo
17 17
 class Request implements InterminableInterface, RequestInterface, ReservedInstanceInterface
18 18
 {
19 19
 
20
-    /**
21
-     * $_GET parameters
22
-     *
23
-     * @var array $get
24
-     */
25
-    private $get;
26
-
27
-    /**
28
-     * $_POST parameters
29
-     *
30
-     * @var array $post
31
-     */
32
-    private $post;
33
-
34
-    /**
35
-     * $_COOKIE parameters
36
-     *
37
-     * @var array $cookie
38
-     */
39
-    private $cookie;
40
-
41
-    /**
42
-     * $_SERVER parameters
43
-     *
44
-     * @var array $server
45
-     */
46
-    private $server;
47
-
48
-    /**
49
-     * $_FILES parameters
50
-     *
51
-     * @var array $files
52
-     */
53
-    private $files;
54
-
55
-    /**
56
-     * $_REQUEST parameters
57
-     *
58
-     * @var array $request
59
-     */
60
-    private $request;
61
-
62
-    /**
63
-     * @var RequestTypeContextCheckerInterface
64
-     */
65
-    private $request_type;
66
-
67
-    /**
68
-     * IP address for request
69
-     *
70
-     * @var string $ip_address
71
-     */
72
-    private $ip_address;
73
-
74
-    /**
75
-     * @var string $user_agent
76
-     */
77
-    private $user_agent;
78
-
79
-    /**
80
-     * true if current user appears to be some kind of bot
81
-     *
82
-     * @var bool $is_bot
83
-     */
84
-    private $is_bot;
85
-
86
-
87
-    /**
88
-     * @param array $get
89
-     * @param array $post
90
-     * @param array $cookie
91
-     * @param array $server
92
-     * @param array $files
93
-     */
94
-    public function __construct(array $get, array $post, array $cookie, array $server, array $files = array())
95
-    {
96
-        // grab request vars
97
-        $this->get = $get;
98
-        $this->post = $post;
99
-        $this->cookie = $cookie;
100
-        $this->server = $server;
101
-        $this->files = $files;
102
-        $this->request = array_merge($this->get, $this->post);
103
-        $this->ip_address = $this->visitorIp();
104
-    }
105
-
106
-
107
-    /**
108
-     * @param RequestTypeContextCheckerInterface $type
109
-     */
110
-    public function setRequestTypeContextChecker(RequestTypeContextCheckerInterface $type)
111
-    {
112
-        $this->request_type = $type;
113
-    }
114
-
115
-
116
-    /**
117
-     * @return array
118
-     */
119
-    public function getParams()
120
-    {
121
-        return $this->get;
122
-    }
123
-
124
-
125
-    /**
126
-     * @return array
127
-     */
128
-    public function postParams()
129
-    {
130
-        return $this->post;
131
-    }
132
-
133
-
134
-    /**
135
-     * @return array
136
-     */
137
-    public function cookieParams()
138
-    {
139
-        return $this->cookie;
140
-    }
141
-
142
-
143
-    /**
144
-     * @return array
145
-     */
146
-    public function serverParams()
147
-    {
148
-        return $this->server;
149
-    }
150
-
151
-
152
-    /**
153
-     * @return array
154
-     */
155
-    public function filesParams()
156
-    {
157
-        return $this->files;
158
-    }
159
-
160
-
161
-    /**
162
-     * returns contents of $_REQUEST
163
-     *
164
-     * @return array
165
-     */
166
-    public function requestParams()
167
-    {
168
-        return $this->request;
169
-    }
170
-
171
-
172
-    /**
173
-     * @param      $key
174
-     * @param      $value
175
-     * @param bool $override_ee
176
-     * @return    void
177
-     */
178
-    public function setRequestParam($key, $value, $override_ee = false)
179
-    {
180
-        // don't allow "ee" to be overwritten unless explicitly instructed to do so
181
-        if ($key !== 'ee'
182
-            || ($key === 'ee' && empty($this->request['ee']))
183
-            || ($key === 'ee' && ! empty($this->request['ee']) && $override_ee)
184
-        ) {
185
-            $this->request[ $key ] = $value;
186
-        }
187
-    }
188
-
189
-
190
-    /**
191
-     * returns   the value for a request param if the given key exists
192
-     *
193
-     * @param       $key
194
-     * @param null  $default
195
-     * @return mixed
196
-     */
197
-    public function getRequestParam($key, $default = null)
198
-    {
199
-        return $this->requestParameterDrillDown($key, $default, 'get');
200
-    }
201
-
202
-
203
-    /**
204
-     * check if param exists
205
-     *
206
-     * @param       $key
207
-     * @return bool
208
-     */
209
-    public function requestParamIsSet($key)
210
-    {
211
-        return $this->requestParameterDrillDown($key);
212
-    }
213
-
214
-
215
-    /**
216
-     * check if a request parameter exists whose key that matches the supplied wildcard pattern
217
-     * and return the value for the first match found
218
-     * wildcards can be either of the following:
219
-     *      ? to represent a single character of any type
220
-     *      * to represent one or more characters of any type
221
-     *
222
-     * @param string     $pattern
223
-     * @param null|mixed $default
224
-     * @return mixed
225
-     */
226
-    public function getMatch($pattern, $default = null)
227
-    {
228
-        return $this->requestParameterDrillDown($pattern, $default, 'match');
229
-    }
230
-
231
-
232
-    /**
233
-     * check if a request parameter exists whose key matches the supplied wildcard pattern
234
-     * wildcards can be either of the following:
235
-     *      ? to represent a single character of any type
236
-     *      * to represent one or more characters of any type
237
-     * returns true if a match is found or false if not
238
-     *
239
-     * @param string $pattern
240
-     * @return bool
241
-     */
242
-    public function matches($pattern)
243
-    {
244
-        return $this->requestParameterDrillDown($pattern, null, 'match') !== null;
245
-    }
246
-
247
-
248
-    /**
249
-     * @see https://stackoverflow.com/questions/6163055/php-string-matching-with-wildcard
250
-     * @param string $pattern               A string including wildcards to be converted to a regex pattern
251
-     *                                      and used to search through the current request's parameter keys
252
-     * @param array  $request_params        The array of request parameters to search through
253
-     * @param mixed  $default               [optional] The value to be returned if no match is found.
254
-     *                                      Default is null
255
-     * @param string $return                [optional] Controls what kind of value is returned.
256
-     *                                      Options are:
257
-     *                                      'bool' will return true or false if match is found or not
258
-     *                                      'key' will return the first key found that matches the supplied pattern
259
-     *                                      'value' will return the value for the first request parameter
260
-     *                                      whose key matches the supplied pattern
261
-     *                                      Default is 'value'
262
-     * @return boolean|string
263
-     */
264
-    private function match($pattern, array $request_params, $default = null, $return = 'value')
265
-    {
266
-        $return = in_array($return, array('bool', 'key', 'value'), true)
267
-            ? $return
268
-            : 'is_set';
269
-        // replace wildcard chars with regex chars
270
-        $pattern = str_replace(
271
-            array("\*", "\?"),
272
-            array('.*', '.'),
273
-            preg_quote($pattern, '/')
274
-        );
275
-        foreach ($request_params as $key => $request_param) {
276
-            if (preg_match('/^' . $pattern . '$/is', $key)) {
277
-                // return value for request param
278
-                if ($return === 'value') {
279
-                    return $request_params[ $key ];
280
-                }
281
-                // or actual key or true just to indicate it was found
282
-                return $return === 'key' ? $key : true;
283
-            }
284
-        }
285
-        // match not found so return default value or false
286
-        return $return === 'value' ? $default : false;
287
-    }
288
-
289
-
290
-    /**
291
-     * the supplied key can be a simple string to represent a "top-level" request parameter
292
-     * or represent a key for a request parameter that is nested deeper within the request parameter array,
293
-     * by using square brackets to surround keys for deeper array elements.
294
-     * For example :
295
-     * if the supplied $key was: "first[second][third]"
296
-     * then this will attempt to drill down into the request parameter array to find a value.
297
-     * Given the following request parameters:
298
-     *  array(
299
-     *      'first' => array(
300
-     *          'second' => array(
301
-     *              'third' => 'has a value'
302
-     *          )
303
-     *      )
304
-     *  )
305
-     * would return true if default parameters were set
306
-     *
307
-     * @param string $callback
308
-     * @param        $key
309
-     * @param null   $default
310
-     * @param array  $request_params
311
-     * @return bool|mixed|null
312
-     */
313
-    private function requestParameterDrillDown(
314
-        $key,
315
-        $default = null,
316
-        $callback = 'is_set',
317
-        array $request_params = array()
318
-    ) {
319
-        $callback = in_array($callback, array('is_set', 'get', 'match'), true)
320
-            ? $callback
321
-            : 'is_set';
322
-        $request_params = ! empty($request_params)
323
-            ? $request_params
324
-            : $this->request;
325
-        // does incoming key represent an array like 'first[second][third]'  ?
326
-        if (strpos($key, '[') !== false) {
327
-            // turn it into an actual array
328
-            $key = str_replace(']', '', $key);
329
-            $keys = explode('[', $key);
330
-            $key = array_shift($keys);
331
-            if ($callback === 'match') {
332
-                $real_key = $this->match($key, $request_params, $default, 'key');
333
-                $key = $real_key ? $real_key : $key;
334
-            }
335
-            // check if top level key exists
336
-            if (isset($request_params[ $key ])) {
337
-                // build a new key to pass along like: 'second[third]'
338
-                // or just 'second' depending on depth of keys
339
-                $key_string = array_shift($keys);
340
-                if (! empty($keys)) {
341
-                    $key_string .= '[' . implode('][', $keys) . ']';
342
-                }
343
-                return $this->requestParameterDrillDown(
344
-                    $key_string,
345
-                    $default,
346
-                    $callback,
347
-                    $request_params[ $key ]
348
-                );
349
-            }
350
-        }
351
-        if ($callback === 'is_set') {
352
-            return isset($request_params[ $key ]);
353
-        }
354
-        if ($callback === 'match') {
355
-            return $this->match($key, $request_params, $default);
356
-        }
357
-        return isset($request_params[ $key ])
358
-            ? $request_params[ $key ]
359
-            : $default;
360
-    }
361
-
362
-
363
-    /**
364
-     * remove param
365
-     *
366
-     * @param      $key
367
-     * @param bool $unset_from_global_too
368
-     */
369
-    public function unSetRequestParam($key, $unset_from_global_too = false)
370
-    {
371
-        // because unset may not actually remove var
372
-        $this->request[ $key ] = null;
373
-        unset($this->request[ $key ]);
374
-        if ($unset_from_global_too) {
375
-            unset($_REQUEST[ $key ]);
376
-        }
377
-    }
378
-
379
-
380
-    /**
381
-     * remove params
382
-     *
383
-     * @param array $keys
384
-     * @param bool  $unset_from_global_too
385
-     */
386
-    public function unSetRequestParams(array $keys, $unset_from_global_too = false)
387
-    {
388
-        foreach ($keys as $key) {
389
-            $this->unSetRequestParam($key, $unset_from_global_too);
390
-        }
391
-    }
392
-
393
-
394
-    /**
395
-     * @return string
396
-     */
397
-    public function ipAddress()
398
-    {
399
-        return $this->ip_address;
400
-    }
401
-
402
-
403
-    /**
404
-     * attempt to get IP address of current visitor from server
405
-     * plz see: http://stackoverflow.com/a/2031935/1475279
406
-     *
407
-     * @access public
408
-     * @return string
409
-     */
410
-    private function visitorIp()
411
-    {
412
-        $visitor_ip = '0.0.0.0';
413
-        $server_keys = array(
414
-            'HTTP_CLIENT_IP',
415
-            'HTTP_X_FORWARDED_FOR',
416
-            'HTTP_X_FORWARDED',
417
-            'HTTP_X_CLUSTER_CLIENT_IP',
418
-            'HTTP_FORWARDED_FOR',
419
-            'HTTP_FORWARDED',
420
-            'REMOTE_ADDR',
421
-        );
422
-        foreach ($server_keys as $key) {
423
-            if (isset($this->server[ $key ])) {
424
-                foreach (array_map('trim', explode(',', $this->server[ $key ])) as $ip) {
425
-                    if ($ip === '127.0.0.1' || filter_var($ip, FILTER_VALIDATE_IP) !== false) {
426
-                        $visitor_ip = $ip;
427
-                    }
428
-                }
429
-            }
430
-        }
431
-        return $visitor_ip;
432
-    }
433
-
434
-
435
-    /**
436
-     * Gets the request's literal URI. Related to `requestUriAfterSiteHomeUri`, see its description for a comparison.
437
-     * @param boolean $relativeToWpRoot If home_url() is "http://mysite.com/wp/", and a request comes to
438
-     *                                  "http://mysite.com/wp/wp-json", setting $relativeToWpRoot=true will return
439
-     *                                  "/wp-json", whereas $relativeToWpRoot=false will return "/wp/wp-json/".
440
-     * @return string
441
-     */
442
-    public function requestUri($relativeToWpRoot = false)
443
-    {
444
-        $request_uri = filter_input(
445
-            INPUT_SERVER,
446
-            'REQUEST_URI',
447
-            FILTER_SANITIZE_URL,
448
-            FILTER_NULL_ON_FAILURE
449
-        );
450
-        if (empty($request_uri)) {
451
-            // fallback sanitization if the above fails
452
-            $request_uri = wp_sanitize_redirect($this->server['REQUEST_URI']);
453
-        }
454
-        if ($relativeToWpRoot) {
455
-            $home_path = untrailingslashit(
456
-                parse_url(
457
-                    home_url(),
458
-                    PHP_URL_PATH
459
-                )
460
-            );
461
-            $request_uri = str_replace(
462
-                $home_path,
463
-                '',
464
-                $request_uri
465
-            );
466
-        }
467
-        return $request_uri;
468
-    }
469
-
470
-    /**
471
-     * @return string
472
-     */
473
-    public function userAgent()
474
-    {
475
-        return $this->user_agent;
476
-    }
477
-
478
-
479
-    /**
480
-     * @param string $user_agent
481
-     */
482
-    public function setUserAgent($user_agent = '')
483
-    {
484
-        if ($user_agent === '' || ! is_string($user_agent)) {
485
-            $user_agent = isset($_SERVER['HTTP_USER_AGENT']) ? (string) esc_attr($_SERVER['HTTP_USER_AGENT']) : '';
486
-        }
487
-        $this->user_agent = $user_agent;
488
-    }
489
-
490
-
491
-    /**
492
-     * @return bool
493
-     */
494
-    public function isBot()
495
-    {
496
-        return $this->is_bot;
497
-    }
498
-
499
-
500
-    /**
501
-     * @param bool $is_bot
502
-     */
503
-    public function setIsBot($is_bot)
504
-    {
505
-        $this->is_bot = filter_var($is_bot, FILTER_VALIDATE_BOOLEAN);
506
-    }
507
-
508
-
509
-    /**
510
-     * @return bool
511
-     */
512
-    public function isActivation()
513
-    {
514
-        return $this->request_type->isActivation();
515
-    }
516
-
517
-
518
-    /**
519
-     * @param $is_activation
520
-     * @return bool
521
-     */
522
-    public function setIsActivation($is_activation)
523
-    {
524
-        return $this->request_type->setIsActivation($is_activation);
525
-    }
526
-
527
-
528
-    /**
529
-     * @return bool
530
-     */
531
-    public function isAdmin()
532
-    {
533
-        return $this->request_type->isAdmin();
534
-    }
535
-
536
-
537
-    /**
538
-     * @return bool
539
-     */
540
-    public function isAdminAjax()
541
-    {
542
-        return $this->request_type->isAdminAjax();
543
-    }
544
-
545
-
546
-    /**
547
-     * @return bool
548
-     */
549
-    public function isAjax()
550
-    {
551
-        return $this->request_type->isAjax();
552
-    }
553
-
554
-
555
-    /**
556
-     * @return bool
557
-     */
558
-    public function isEeAjax()
559
-    {
560
-        return $this->request_type->isEeAjax();
561
-    }
562
-
563
-
564
-    /**
565
-     * @return bool
566
-     */
567
-    public function isOtherAjax()
568
-    {
569
-        return $this->request_type->isOtherAjax();
570
-    }
571
-
572
-
573
-    /**
574
-     * @return bool
575
-     */
576
-    public function isApi()
577
-    {
578
-        return $this->request_type->isApi();
579
-    }
580
-
581
-
582
-    /**
583
-     * @return bool
584
-     */
585
-    public function isCli()
586
-    {
587
-        return $this->request_type->isCli();
588
-    }
589
-
590
-
591
-    /**
592
-     * @return bool
593
-     */
594
-    public function isCron()
595
-    {
596
-        return $this->request_type->isCron();
597
-    }
598
-
599
-
600
-    /**
601
-     * @return bool
602
-     */
603
-    public function isFeed()
604
-    {
605
-        return $this->request_type->isFeed();
606
-    }
607
-
608
-
609
-    /**
610
-     * @return bool
611
-     */
612
-    public function isFrontend()
613
-    {
614
-        return $this->request_type->isFrontend();
615
-    }
616
-
617
-
618
-    /**
619
-     * @return bool
620
-     */
621
-    public function isFrontAjax()
622
-    {
623
-        return $this->request_type->isFrontAjax();
624
-    }
625
-
626
-
627
-    /**
628
-     * @return bool
629
-     */
630
-    public function isGQL()
631
-    {
632
-        return $this->request_type->isGQL();
633
-    }
634
-
635
-
636
-    /**
637
-     * @return bool
638
-     */
639
-    public function isIframe()
640
-    {
641
-        return $this->request_type->isIframe();
642
-    }
643
-
644
-
645
-
646
-    /**
647
-     * @return bool
648
-     */
649
-    public function isUnitTesting()
650
-    {
651
-        return $this->request_type->isUnitTesting();
652
-    }
653
-
654
-
655
-    /**
656
-     * @return bool
657
-     */
658
-    public function isWordPressApi()
659
-    {
660
-        return $this->request_type->isWordPressApi();
661
-    }
662
-
663
-
664
-
665
-    /**
666
-     * @return bool
667
-     */
668
-    public function isWordPressHeartbeat()
669
-    {
670
-        return $this->request_type->isWordPressHeartbeat();
671
-    }
672
-
673
-
674
-
675
-    /**
676
-     * @return bool
677
-     */
678
-    public function isWordPressScrape()
679
-    {
680
-        return $this->request_type->isWordPressScrape();
681
-    }
682
-
683
-
684
-    /**
685
-     * @return string
686
-     */
687
-    public function slug()
688
-    {
689
-        return $this->request_type->slug();
690
-    }
20
+	/**
21
+	 * $_GET parameters
22
+	 *
23
+	 * @var array $get
24
+	 */
25
+	private $get;
26
+
27
+	/**
28
+	 * $_POST parameters
29
+	 *
30
+	 * @var array $post
31
+	 */
32
+	private $post;
33
+
34
+	/**
35
+	 * $_COOKIE parameters
36
+	 *
37
+	 * @var array $cookie
38
+	 */
39
+	private $cookie;
40
+
41
+	/**
42
+	 * $_SERVER parameters
43
+	 *
44
+	 * @var array $server
45
+	 */
46
+	private $server;
47
+
48
+	/**
49
+	 * $_FILES parameters
50
+	 *
51
+	 * @var array $files
52
+	 */
53
+	private $files;
54
+
55
+	/**
56
+	 * $_REQUEST parameters
57
+	 *
58
+	 * @var array $request
59
+	 */
60
+	private $request;
61
+
62
+	/**
63
+	 * @var RequestTypeContextCheckerInterface
64
+	 */
65
+	private $request_type;
66
+
67
+	/**
68
+	 * IP address for request
69
+	 *
70
+	 * @var string $ip_address
71
+	 */
72
+	private $ip_address;
73
+
74
+	/**
75
+	 * @var string $user_agent
76
+	 */
77
+	private $user_agent;
78
+
79
+	/**
80
+	 * true if current user appears to be some kind of bot
81
+	 *
82
+	 * @var bool $is_bot
83
+	 */
84
+	private $is_bot;
85
+
86
+
87
+	/**
88
+	 * @param array $get
89
+	 * @param array $post
90
+	 * @param array $cookie
91
+	 * @param array $server
92
+	 * @param array $files
93
+	 */
94
+	public function __construct(array $get, array $post, array $cookie, array $server, array $files = array())
95
+	{
96
+		// grab request vars
97
+		$this->get = $get;
98
+		$this->post = $post;
99
+		$this->cookie = $cookie;
100
+		$this->server = $server;
101
+		$this->files = $files;
102
+		$this->request = array_merge($this->get, $this->post);
103
+		$this->ip_address = $this->visitorIp();
104
+	}
105
+
106
+
107
+	/**
108
+	 * @param RequestTypeContextCheckerInterface $type
109
+	 */
110
+	public function setRequestTypeContextChecker(RequestTypeContextCheckerInterface $type)
111
+	{
112
+		$this->request_type = $type;
113
+	}
114
+
115
+
116
+	/**
117
+	 * @return array
118
+	 */
119
+	public function getParams()
120
+	{
121
+		return $this->get;
122
+	}
123
+
124
+
125
+	/**
126
+	 * @return array
127
+	 */
128
+	public function postParams()
129
+	{
130
+		return $this->post;
131
+	}
132
+
133
+
134
+	/**
135
+	 * @return array
136
+	 */
137
+	public function cookieParams()
138
+	{
139
+		return $this->cookie;
140
+	}
141
+
142
+
143
+	/**
144
+	 * @return array
145
+	 */
146
+	public function serverParams()
147
+	{
148
+		return $this->server;
149
+	}
150
+
151
+
152
+	/**
153
+	 * @return array
154
+	 */
155
+	public function filesParams()
156
+	{
157
+		return $this->files;
158
+	}
159
+
160
+
161
+	/**
162
+	 * returns contents of $_REQUEST
163
+	 *
164
+	 * @return array
165
+	 */
166
+	public function requestParams()
167
+	{
168
+		return $this->request;
169
+	}
170
+
171
+
172
+	/**
173
+	 * @param      $key
174
+	 * @param      $value
175
+	 * @param bool $override_ee
176
+	 * @return    void
177
+	 */
178
+	public function setRequestParam($key, $value, $override_ee = false)
179
+	{
180
+		// don't allow "ee" to be overwritten unless explicitly instructed to do so
181
+		if ($key !== 'ee'
182
+			|| ($key === 'ee' && empty($this->request['ee']))
183
+			|| ($key === 'ee' && ! empty($this->request['ee']) && $override_ee)
184
+		) {
185
+			$this->request[ $key ] = $value;
186
+		}
187
+	}
188
+
189
+
190
+	/**
191
+	 * returns   the value for a request param if the given key exists
192
+	 *
193
+	 * @param       $key
194
+	 * @param null  $default
195
+	 * @return mixed
196
+	 */
197
+	public function getRequestParam($key, $default = null)
198
+	{
199
+		return $this->requestParameterDrillDown($key, $default, 'get');
200
+	}
201
+
202
+
203
+	/**
204
+	 * check if param exists
205
+	 *
206
+	 * @param       $key
207
+	 * @return bool
208
+	 */
209
+	public function requestParamIsSet($key)
210
+	{
211
+		return $this->requestParameterDrillDown($key);
212
+	}
213
+
214
+
215
+	/**
216
+	 * check if a request parameter exists whose key that matches the supplied wildcard pattern
217
+	 * and return the value for the first match found
218
+	 * wildcards can be either of the following:
219
+	 *      ? to represent a single character of any type
220
+	 *      * to represent one or more characters of any type
221
+	 *
222
+	 * @param string     $pattern
223
+	 * @param null|mixed $default
224
+	 * @return mixed
225
+	 */
226
+	public function getMatch($pattern, $default = null)
227
+	{
228
+		return $this->requestParameterDrillDown($pattern, $default, 'match');
229
+	}
230
+
231
+
232
+	/**
233
+	 * check if a request parameter exists whose key matches the supplied wildcard pattern
234
+	 * wildcards can be either of the following:
235
+	 *      ? to represent a single character of any type
236
+	 *      * to represent one or more characters of any type
237
+	 * returns true if a match is found or false if not
238
+	 *
239
+	 * @param string $pattern
240
+	 * @return bool
241
+	 */
242
+	public function matches($pattern)
243
+	{
244
+		return $this->requestParameterDrillDown($pattern, null, 'match') !== null;
245
+	}
246
+
247
+
248
+	/**
249
+	 * @see https://stackoverflow.com/questions/6163055/php-string-matching-with-wildcard
250
+	 * @param string $pattern               A string including wildcards to be converted to a regex pattern
251
+	 *                                      and used to search through the current request's parameter keys
252
+	 * @param array  $request_params        The array of request parameters to search through
253
+	 * @param mixed  $default               [optional] The value to be returned if no match is found.
254
+	 *                                      Default is null
255
+	 * @param string $return                [optional] Controls what kind of value is returned.
256
+	 *                                      Options are:
257
+	 *                                      'bool' will return true or false if match is found or not
258
+	 *                                      'key' will return the first key found that matches the supplied pattern
259
+	 *                                      'value' will return the value for the first request parameter
260
+	 *                                      whose key matches the supplied pattern
261
+	 *                                      Default is 'value'
262
+	 * @return boolean|string
263
+	 */
264
+	private function match($pattern, array $request_params, $default = null, $return = 'value')
265
+	{
266
+		$return = in_array($return, array('bool', 'key', 'value'), true)
267
+			? $return
268
+			: 'is_set';
269
+		// replace wildcard chars with regex chars
270
+		$pattern = str_replace(
271
+			array("\*", "\?"),
272
+			array('.*', '.'),
273
+			preg_quote($pattern, '/')
274
+		);
275
+		foreach ($request_params as $key => $request_param) {
276
+			if (preg_match('/^' . $pattern . '$/is', $key)) {
277
+				// return value for request param
278
+				if ($return === 'value') {
279
+					return $request_params[ $key ];
280
+				}
281
+				// or actual key or true just to indicate it was found
282
+				return $return === 'key' ? $key : true;
283
+			}
284
+		}
285
+		// match not found so return default value or false
286
+		return $return === 'value' ? $default : false;
287
+	}
288
+
289
+
290
+	/**
291
+	 * the supplied key can be a simple string to represent a "top-level" request parameter
292
+	 * or represent a key for a request parameter that is nested deeper within the request parameter array,
293
+	 * by using square brackets to surround keys for deeper array elements.
294
+	 * For example :
295
+	 * if the supplied $key was: "first[second][third]"
296
+	 * then this will attempt to drill down into the request parameter array to find a value.
297
+	 * Given the following request parameters:
298
+	 *  array(
299
+	 *      'first' => array(
300
+	 *          'second' => array(
301
+	 *              'third' => 'has a value'
302
+	 *          )
303
+	 *      )
304
+	 *  )
305
+	 * would return true if default parameters were set
306
+	 *
307
+	 * @param string $callback
308
+	 * @param        $key
309
+	 * @param null   $default
310
+	 * @param array  $request_params
311
+	 * @return bool|mixed|null
312
+	 */
313
+	private function requestParameterDrillDown(
314
+		$key,
315
+		$default = null,
316
+		$callback = 'is_set',
317
+		array $request_params = array()
318
+	) {
319
+		$callback = in_array($callback, array('is_set', 'get', 'match'), true)
320
+			? $callback
321
+			: 'is_set';
322
+		$request_params = ! empty($request_params)
323
+			? $request_params
324
+			: $this->request;
325
+		// does incoming key represent an array like 'first[second][third]'  ?
326
+		if (strpos($key, '[') !== false) {
327
+			// turn it into an actual array
328
+			$key = str_replace(']', '', $key);
329
+			$keys = explode('[', $key);
330
+			$key = array_shift($keys);
331
+			if ($callback === 'match') {
332
+				$real_key = $this->match($key, $request_params, $default, 'key');
333
+				$key = $real_key ? $real_key : $key;
334
+			}
335
+			// check if top level key exists
336
+			if (isset($request_params[ $key ])) {
337
+				// build a new key to pass along like: 'second[third]'
338
+				// or just 'second' depending on depth of keys
339
+				$key_string = array_shift($keys);
340
+				if (! empty($keys)) {
341
+					$key_string .= '[' . implode('][', $keys) . ']';
342
+				}
343
+				return $this->requestParameterDrillDown(
344
+					$key_string,
345
+					$default,
346
+					$callback,
347
+					$request_params[ $key ]
348
+				);
349
+			}
350
+		}
351
+		if ($callback === 'is_set') {
352
+			return isset($request_params[ $key ]);
353
+		}
354
+		if ($callback === 'match') {
355
+			return $this->match($key, $request_params, $default);
356
+		}
357
+		return isset($request_params[ $key ])
358
+			? $request_params[ $key ]
359
+			: $default;
360
+	}
361
+
362
+
363
+	/**
364
+	 * remove param
365
+	 *
366
+	 * @param      $key
367
+	 * @param bool $unset_from_global_too
368
+	 */
369
+	public function unSetRequestParam($key, $unset_from_global_too = false)
370
+	{
371
+		// because unset may not actually remove var
372
+		$this->request[ $key ] = null;
373
+		unset($this->request[ $key ]);
374
+		if ($unset_from_global_too) {
375
+			unset($_REQUEST[ $key ]);
376
+		}
377
+	}
378
+
379
+
380
+	/**
381
+	 * remove params
382
+	 *
383
+	 * @param array $keys
384
+	 * @param bool  $unset_from_global_too
385
+	 */
386
+	public function unSetRequestParams(array $keys, $unset_from_global_too = false)
387
+	{
388
+		foreach ($keys as $key) {
389
+			$this->unSetRequestParam($key, $unset_from_global_too);
390
+		}
391
+	}
392
+
393
+
394
+	/**
395
+	 * @return string
396
+	 */
397
+	public function ipAddress()
398
+	{
399
+		return $this->ip_address;
400
+	}
401
+
402
+
403
+	/**
404
+	 * attempt to get IP address of current visitor from server
405
+	 * plz see: http://stackoverflow.com/a/2031935/1475279
406
+	 *
407
+	 * @access public
408
+	 * @return string
409
+	 */
410
+	private function visitorIp()
411
+	{
412
+		$visitor_ip = '0.0.0.0';
413
+		$server_keys = array(
414
+			'HTTP_CLIENT_IP',
415
+			'HTTP_X_FORWARDED_FOR',
416
+			'HTTP_X_FORWARDED',
417
+			'HTTP_X_CLUSTER_CLIENT_IP',
418
+			'HTTP_FORWARDED_FOR',
419
+			'HTTP_FORWARDED',
420
+			'REMOTE_ADDR',
421
+		);
422
+		foreach ($server_keys as $key) {
423
+			if (isset($this->server[ $key ])) {
424
+				foreach (array_map('trim', explode(',', $this->server[ $key ])) as $ip) {
425
+					if ($ip === '127.0.0.1' || filter_var($ip, FILTER_VALIDATE_IP) !== false) {
426
+						$visitor_ip = $ip;
427
+					}
428
+				}
429
+			}
430
+		}
431
+		return $visitor_ip;
432
+	}
433
+
434
+
435
+	/**
436
+	 * Gets the request's literal URI. Related to `requestUriAfterSiteHomeUri`, see its description for a comparison.
437
+	 * @param boolean $relativeToWpRoot If home_url() is "http://mysite.com/wp/", and a request comes to
438
+	 *                                  "http://mysite.com/wp/wp-json", setting $relativeToWpRoot=true will return
439
+	 *                                  "/wp-json", whereas $relativeToWpRoot=false will return "/wp/wp-json/".
440
+	 * @return string
441
+	 */
442
+	public function requestUri($relativeToWpRoot = false)
443
+	{
444
+		$request_uri = filter_input(
445
+			INPUT_SERVER,
446
+			'REQUEST_URI',
447
+			FILTER_SANITIZE_URL,
448
+			FILTER_NULL_ON_FAILURE
449
+		);
450
+		if (empty($request_uri)) {
451
+			// fallback sanitization if the above fails
452
+			$request_uri = wp_sanitize_redirect($this->server['REQUEST_URI']);
453
+		}
454
+		if ($relativeToWpRoot) {
455
+			$home_path = untrailingslashit(
456
+				parse_url(
457
+					home_url(),
458
+					PHP_URL_PATH
459
+				)
460
+			);
461
+			$request_uri = str_replace(
462
+				$home_path,
463
+				'',
464
+				$request_uri
465
+			);
466
+		}
467
+		return $request_uri;
468
+	}
469
+
470
+	/**
471
+	 * @return string
472
+	 */
473
+	public function userAgent()
474
+	{
475
+		return $this->user_agent;
476
+	}
477
+
478
+
479
+	/**
480
+	 * @param string $user_agent
481
+	 */
482
+	public function setUserAgent($user_agent = '')
483
+	{
484
+		if ($user_agent === '' || ! is_string($user_agent)) {
485
+			$user_agent = isset($_SERVER['HTTP_USER_AGENT']) ? (string) esc_attr($_SERVER['HTTP_USER_AGENT']) : '';
486
+		}
487
+		$this->user_agent = $user_agent;
488
+	}
489
+
490
+
491
+	/**
492
+	 * @return bool
493
+	 */
494
+	public function isBot()
495
+	{
496
+		return $this->is_bot;
497
+	}
498
+
499
+
500
+	/**
501
+	 * @param bool $is_bot
502
+	 */
503
+	public function setIsBot($is_bot)
504
+	{
505
+		$this->is_bot = filter_var($is_bot, FILTER_VALIDATE_BOOLEAN);
506
+	}
507
+
508
+
509
+	/**
510
+	 * @return bool
511
+	 */
512
+	public function isActivation()
513
+	{
514
+		return $this->request_type->isActivation();
515
+	}
516
+
517
+
518
+	/**
519
+	 * @param $is_activation
520
+	 * @return bool
521
+	 */
522
+	public function setIsActivation($is_activation)
523
+	{
524
+		return $this->request_type->setIsActivation($is_activation);
525
+	}
526
+
527
+
528
+	/**
529
+	 * @return bool
530
+	 */
531
+	public function isAdmin()
532
+	{
533
+		return $this->request_type->isAdmin();
534
+	}
535
+
536
+
537
+	/**
538
+	 * @return bool
539
+	 */
540
+	public function isAdminAjax()
541
+	{
542
+		return $this->request_type->isAdminAjax();
543
+	}
544
+
545
+
546
+	/**
547
+	 * @return bool
548
+	 */
549
+	public function isAjax()
550
+	{
551
+		return $this->request_type->isAjax();
552
+	}
553
+
554
+
555
+	/**
556
+	 * @return bool
557
+	 */
558
+	public function isEeAjax()
559
+	{
560
+		return $this->request_type->isEeAjax();
561
+	}
562
+
563
+
564
+	/**
565
+	 * @return bool
566
+	 */
567
+	public function isOtherAjax()
568
+	{
569
+		return $this->request_type->isOtherAjax();
570
+	}
571
+
572
+
573
+	/**
574
+	 * @return bool
575
+	 */
576
+	public function isApi()
577
+	{
578
+		return $this->request_type->isApi();
579
+	}
580
+
581
+
582
+	/**
583
+	 * @return bool
584
+	 */
585
+	public function isCli()
586
+	{
587
+		return $this->request_type->isCli();
588
+	}
589
+
590
+
591
+	/**
592
+	 * @return bool
593
+	 */
594
+	public function isCron()
595
+	{
596
+		return $this->request_type->isCron();
597
+	}
598
+
599
+
600
+	/**
601
+	 * @return bool
602
+	 */
603
+	public function isFeed()
604
+	{
605
+		return $this->request_type->isFeed();
606
+	}
607
+
608
+
609
+	/**
610
+	 * @return bool
611
+	 */
612
+	public function isFrontend()
613
+	{
614
+		return $this->request_type->isFrontend();
615
+	}
616
+
617
+
618
+	/**
619
+	 * @return bool
620
+	 */
621
+	public function isFrontAjax()
622
+	{
623
+		return $this->request_type->isFrontAjax();
624
+	}
625
+
626
+
627
+	/**
628
+	 * @return bool
629
+	 */
630
+	public function isGQL()
631
+	{
632
+		return $this->request_type->isGQL();
633
+	}
634
+
635
+
636
+	/**
637
+	 * @return bool
638
+	 */
639
+	public function isIframe()
640
+	{
641
+		return $this->request_type->isIframe();
642
+	}
643
+
644
+
645
+
646
+	/**
647
+	 * @return bool
648
+	 */
649
+	public function isUnitTesting()
650
+	{
651
+		return $this->request_type->isUnitTesting();
652
+	}
653
+
654
+
655
+	/**
656
+	 * @return bool
657
+	 */
658
+	public function isWordPressApi()
659
+	{
660
+		return $this->request_type->isWordPressApi();
661
+	}
662
+
663
+
664
+
665
+	/**
666
+	 * @return bool
667
+	 */
668
+	public function isWordPressHeartbeat()
669
+	{
670
+		return $this->request_type->isWordPressHeartbeat();
671
+	}
672
+
673
+
674
+
675
+	/**
676
+	 * @return bool
677
+	 */
678
+	public function isWordPressScrape()
679
+	{
680
+		return $this->request_type->isWordPressScrape();
681
+	}
682
+
683
+
684
+	/**
685
+	 * @return string
686
+	 */
687
+	public function slug()
688
+	{
689
+		return $this->request_type->slug();
690
+	}
691 691
 }
Please login to merge, or discard this patch.
core/domain/services/contexts/RequestTypeContextFactoryInterface.php 1 patch
Indentation   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -15,9 +15,9 @@
 block discarded – undo
15 15
 interface RequestTypeContextFactoryInterface
16 16
 {
17 17
 
18
-    /**
19
-     * @param string $slug
20
-     * @return RequestTypeContext
21
-     */
22
-    public function create($slug);
18
+	/**
19
+	 * @param string $slug
20
+	 * @return RequestTypeContext
21
+	 */
22
+	public function create($slug);
23 23
 }
Please login to merge, or discard this patch.
admin_pages/venues/templates/event_venues_metabox_content.template.php 1 patch
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -5,9 +5,9 @@
 block discarded – undo
5 5
                 <?php echo $no_venues_info; ?>
6 6
                 <p><a href="admin.php?page=espresso_venues" target="_blank">
7 7
                         <?php echo __(
8
-                            'Add venues to the Venue Manager',
9
-                            'event_espresso'
10
-                        ) ?></a></p>
8
+							'Add venues to the Venue Manager',
9
+							'event_espresso'
10
+						) ?></a></p>
11 11
             </fieldset>
12 12
         </td>
13 13
     </tr>
Please login to merge, or discard this patch.
core/libraries/form_sections/inputs/EE_Country_Select_Input.php 2 patches
Indentation   +70 added lines, -70 removed lines patch added patch discarded remove patch
@@ -14,80 +14,80 @@
 block discarded – undo
14 14
  */
15 15
 class EE_Country_Select_Input extends EE_Select_Input
16 16
 {
17
-    /**
18
-     * $input_settings key used for detecting the "get" option
19
-     */
20
-    const OPTION_GET_KEY = 'get';
17
+	/**
18
+	 * $input_settings key used for detecting the "get" option
19
+	 */
20
+	const OPTION_GET_KEY = 'get';
21 21
 
22
-    /**
23
-     * indicates that ALL countries should be retrieved from the db for the input
24
-     */
25
-    const OPTION_GET_ALL = 'all';
22
+	/**
23
+	 * indicates that ALL countries should be retrieved from the db for the input
24
+	 */
25
+	const OPTION_GET_ALL = 'all';
26 26
 
27
-    /**
28
-     * indicates that only ACTIVE countries should be retrieved from the db for the input
29
-     */
30
-    const OPTION_GET_ACTIVE = 'active';
27
+	/**
28
+	 * indicates that only ACTIVE countries should be retrieved from the db for the input
29
+	 */
30
+	const OPTION_GET_ACTIVE = 'active';
31 31
 
32 32
 
33
-    /**
34
-     * @param array $country_options
35
-     * @param array $input_settings
36
-     * @throws EE_Error
37
-     * @throws InvalidArgumentException
38
-     * @throws InvalidDataTypeException
39
-     * @throws InvalidInterfaceException
40
-     * @throws ReflectionException
41
-     */
42
-    public function __construct($country_options = null, $input_settings = array())
43
-    {
44
-        $get = isset($input_settings[ self::OPTION_GET_KEY ])
45
-            ? $input_settings[ self::OPTION_GET_KEY ]
46
-            : self::OPTION_GET_ACTIVE;
47
-        $country_options = apply_filters(
48
-            'FHEE__EE_Country_Select_Input____construct__country_options',
49
-            $this->get_country_answer_options($country_options, $get),
50
-            $this,
51
-            $get
52
-        );
53
-        $input_settings['html_class'] = isset($input_settings['html_class'])
54
-            ? $input_settings['html_class'] . ' ee-country-select-js'
55
-            : 'ee-country-select-js';
56
-        parent::__construct($country_options, $input_settings);
57
-    }
33
+	/**
34
+	 * @param array $country_options
35
+	 * @param array $input_settings
36
+	 * @throws EE_Error
37
+	 * @throws InvalidArgumentException
38
+	 * @throws InvalidDataTypeException
39
+	 * @throws InvalidInterfaceException
40
+	 * @throws ReflectionException
41
+	 */
42
+	public function __construct($country_options = null, $input_settings = array())
43
+	{
44
+		$get = isset($input_settings[ self::OPTION_GET_KEY ])
45
+			? $input_settings[ self::OPTION_GET_KEY ]
46
+			: self::OPTION_GET_ACTIVE;
47
+		$country_options = apply_filters(
48
+			'FHEE__EE_Country_Select_Input____construct__country_options',
49
+			$this->get_country_answer_options($country_options, $get),
50
+			$this,
51
+			$get
52
+		);
53
+		$input_settings['html_class'] = isset($input_settings['html_class'])
54
+			? $input_settings['html_class'] . ' ee-country-select-js'
55
+			: 'ee-country-select-js';
56
+		parent::__construct($country_options, $input_settings);
57
+	}
58 58
 
59 59
 
60
-    /**
61
-     * get_country_answer_options
62
-     *
63
-     * @param array  $country_options
64
-     * @param string $get
65
-     * @return array
66
-     * @throws EE_Error
67
-     * @throws InvalidArgumentException
68
-     * @throws ReflectionException
69
-     * @throws InvalidDataTypeException
70
-     * @throws InvalidInterfaceException
71
-     */
72
-    public function get_country_answer_options($country_options = null, $get = self::OPTION_GET_ACTIVE)
73
-    {
74
-        // if passed something that is NOT an array
75
-        if (! is_array($country_options)) {
76
-            // get possibly cached list of countries
77
-            $countries = $get === self::OPTION_GET_ALL
78
-                ? EEM_Country::instance()->get_all_countries()
79
-                : EEM_Country::instance()->get_all_active_countries();
80
-            if (! empty($countries)) {
81
-                $country_options[''] = '';
82
-                foreach ($countries as $country) {
83
-                    if ($country instanceof EE_Country) {
84
-                        $country_options[ $country->ID() ] = $country->name();
85
-                    }
86
-                }
87
-            } else {
88
-                $country_options = array();
89
-            }
90
-        }
91
-        return $country_options;
92
-    }
60
+	/**
61
+	 * get_country_answer_options
62
+	 *
63
+	 * @param array  $country_options
64
+	 * @param string $get
65
+	 * @return array
66
+	 * @throws EE_Error
67
+	 * @throws InvalidArgumentException
68
+	 * @throws ReflectionException
69
+	 * @throws InvalidDataTypeException
70
+	 * @throws InvalidInterfaceException
71
+	 */
72
+	public function get_country_answer_options($country_options = null, $get = self::OPTION_GET_ACTIVE)
73
+	{
74
+		// if passed something that is NOT an array
75
+		if (! is_array($country_options)) {
76
+			// get possibly cached list of countries
77
+			$countries = $get === self::OPTION_GET_ALL
78
+				? EEM_Country::instance()->get_all_countries()
79
+				: EEM_Country::instance()->get_all_active_countries();
80
+			if (! empty($countries)) {
81
+				$country_options[''] = '';
82
+				foreach ($countries as $country) {
83
+					if ($country instanceof EE_Country) {
84
+						$country_options[ $country->ID() ] = $country->name();
85
+					}
86
+				}
87
+			} else {
88
+				$country_options = array();
89
+			}
90
+		}
91
+		return $country_options;
92
+	}
93 93
 }
Please login to merge, or discard this patch.
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -41,8 +41,8 @@  discard block
 block discarded – undo
41 41
      */
42 42
     public function __construct($country_options = null, $input_settings = array())
43 43
     {
44
-        $get = isset($input_settings[ self::OPTION_GET_KEY ])
45
-            ? $input_settings[ self::OPTION_GET_KEY ]
44
+        $get = isset($input_settings[self::OPTION_GET_KEY])
45
+            ? $input_settings[self::OPTION_GET_KEY]
46 46
             : self::OPTION_GET_ACTIVE;
47 47
         $country_options = apply_filters(
48 48
             'FHEE__EE_Country_Select_Input____construct__country_options',
@@ -51,7 +51,7 @@  discard block
 block discarded – undo
51 51
             $get
52 52
         );
53 53
         $input_settings['html_class'] = isset($input_settings['html_class'])
54
-            ? $input_settings['html_class'] . ' ee-country-select-js'
54
+            ? $input_settings['html_class'].' ee-country-select-js'
55 55
             : 'ee-country-select-js';
56 56
         parent::__construct($country_options, $input_settings);
57 57
     }
@@ -72,16 +72,16 @@  discard block
 block discarded – undo
72 72
     public function get_country_answer_options($country_options = null, $get = self::OPTION_GET_ACTIVE)
73 73
     {
74 74
         // if passed something that is NOT an array
75
-        if (! is_array($country_options)) {
75
+        if ( ! is_array($country_options)) {
76 76
             // get possibly cached list of countries
77 77
             $countries = $get === self::OPTION_GET_ALL
78 78
                 ? EEM_Country::instance()->get_all_countries()
79 79
                 : EEM_Country::instance()->get_all_active_countries();
80
-            if (! empty($countries)) {
80
+            if ( ! empty($countries)) {
81 81
                 $country_options[''] = '';
82 82
                 foreach ($countries as $country) {
83 83
                     if ($country instanceof EE_Country) {
84
-                        $country_options[ $country->ID() ] = $country->name();
84
+                        $country_options[$country->ID()] = $country->name();
85 85
                     }
86 86
                 }
87 87
             } else {
Please login to merge, or discard this patch.
core/services/address/CountrySubRegionDao.php 4 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -156,7 +156,7 @@
 block discarded – undo
156 156
 
157 157
     /**
158 158
      * @param string $url
159
-     * @return array
159
+     * @return string
160 160
      */
161 161
     private function retrieveJsonData($url)
162 162
     {
Please login to merge, or discard this patch.
Unused Use Statements   -1 removed lines patch added patch discarded remove patch
@@ -5,7 +5,6 @@
 block discarded – undo
5 5
 use EE_Country;
6 6
 use EE_Error;
7 7
 use EE_State;
8
-use EEM_Country;
9 8
 use EEM_State;
10 9
 use EventEspresso\core\exceptions\InvalidDataTypeException;
11 10
 use EventEspresso\core\exceptions\InvalidInterfaceException;
Please login to merge, or discard this patch.
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -80,7 +80,7 @@  discard block
 block discarded – undo
80 80
         $data = [];
81 81
         if (empty($this->countries)) {
82 82
             $this->data_version = $this->getCountrySubRegionDataVersion();
83
-            $data = $this->retrieveJsonData(self::REPO_URL . 'countries.json');
83
+            $data = $this->retrieveJsonData(self::REPO_URL.'countries.json');
84 84
         }
85 85
         if (empty($data)) {
86 86
             EE_Error::add_error(
@@ -90,7 +90,7 @@  discard block
 block discarded – undo
90 90
                 __LINE__
91 91
             );
92 92
         }
93
-        if (! $has_sub_regions
93
+        if ( ! $has_sub_regions
94 94
             || (isset($data->version) && version_compare($data->version, $this->data_version))
95 95
         ) {
96 96
             if (isset($data->countries)
@@ -142,7 +142,7 @@  discard block
 block discarded – undo
142 142
      */
143 143
     private function processCountryData($CNT_ISO, $countries = array())
144 144
     {
145
-        if (! empty($countries)) {
145
+        if ( ! empty($countries)) {
146 146
             foreach ($countries as $key => $country) {
147 147
                 if ($country instanceof stdClass
148 148
                     && $country->code === $CNT_ISO
@@ -150,7 +150,7 @@  discard block
 block discarded – undo
150 150
                     && ! empty($country->filename)
151 151
                 ) {
152 152
                     $country->sub_regions = $this->retrieveJsonData(
153
-                        self::REPO_URL . 'countries/' . $country->filename . '.json'
153
+                        self::REPO_URL.'countries/'.$country->filename.'.json'
154 154
                     );
155 155
                     return $this->saveSubRegionData($country, $country->sub_regions);
156 156
                 }
@@ -212,7 +212,7 @@  discard block
 block discarded – undo
212 212
             foreach ($sub_regions as $sub_region) {
213 213
                 // remove country code from sub region code
214 214
                 $abbrev = str_replace(
215
-                    $country->code . '-',
215
+                    $country->code.'-',
216 216
                     '',
217 217
                     sanitize_text_field($sub_region->code)
218 218
                 );
@@ -220,7 +220,7 @@  discard block
 block discarded – undo
220 220
                 if (absint($abbrev) !== 0) {
221 221
                     $abbrev = sanitize_text_field($sub_region->code);
222 222
                 }
223
-                if (! in_array($abbrev, $existing_sub_regions, true)
223
+                if ( ! in_array($abbrev, $existing_sub_regions, true)
224 224
                     && $this->state_model->insert(
225 225
                         [
226 226
                             // STA_ID CNT_ISO STA_abbrev STA_name STA_active
Please login to merge, or discard this patch.
Indentation   +223 added lines, -223 removed lines patch added patch discarded remove patch
@@ -26,248 +26,248 @@
 block discarded – undo
26 26
 class CountrySubRegionDao
27 27
 {
28 28
 
29
-    const REPO_URL = 'https://raw.githubusercontent.com/eventespresso/countries-and-subregions/master/';
29
+	const REPO_URL = 'https://raw.githubusercontent.com/eventespresso/countries-and-subregions/master/';
30 30
 
31
-    const OPTION_NAME_COUNTRY_DATA_VERSION = 'espresso-country-sub-region-data-version';
31
+	const OPTION_NAME_COUNTRY_DATA_VERSION = 'espresso-country-sub-region-data-version';
32 32
 
33
-    /**
34
-     * @var EEM_State $state_model
35
-     */
36
-    private $state_model;
33
+	/**
34
+	 * @var EEM_State $state_model
35
+	 */
36
+	private $state_model;
37 37
 
38
-    /**
39
-     * @var JsonValidator $json_validator
40
-     */
41
-    private $json_validator;
38
+	/**
39
+	 * @var JsonValidator $json_validator
40
+	 */
41
+	private $json_validator;
42 42
 
43
-    /**
44
-     * @var string $data_version
45
-     */
46
-    private $data_version;
43
+	/**
44
+	 * @var string $data_version
45
+	 */
46
+	private $data_version;
47 47
 
48
-    /**
49
-     * @var array $countries
50
-     */
51
-    private $countries = array();
48
+	/**
49
+	 * @var array $countries
50
+	 */
51
+	private $countries = array();
52 52
 
53 53
 
54
-    /**
55
-     * CountrySubRegionDao constructor.
56
-     *
57
-     * @param EEM_State     $state_model
58
-     * @param JsonValidator $json_validator
59
-     */
60
-    public function __construct(EEM_State $state_model, JsonValidator $json_validator)
61
-    {
62
-        $this->state_model = $state_model;
63
-        $this->json_validator = $json_validator;
64
-    }
54
+	/**
55
+	 * CountrySubRegionDao constructor.
56
+	 *
57
+	 * @param EEM_State     $state_model
58
+	 * @param JsonValidator $json_validator
59
+	 */
60
+	public function __construct(EEM_State $state_model, JsonValidator $json_validator)
61
+	{
62
+		$this->state_model = $state_model;
63
+		$this->json_validator = $json_validator;
64
+	}
65 65
 
66 66
 
67
-    /**
68
-     * @param EE_Country $country_object
69
-     * @return bool
70
-     * @throws EE_Error
71
-     * @throws InvalidArgumentException
72
-     * @throws InvalidDataTypeException
73
-     * @throws InvalidInterfaceException
74
-     * @throws ReflectionException
75
-     */
76
-    public function saveCountrySubRegions(EE_Country $country_object)
77
-    {
78
-        $CNT_ISO = $country_object->ID();
79
-        $has_sub_regions = $this->state_model->count(array(array('Country.CNT_ISO' => $CNT_ISO)));
80
-        $data = [];
81
-        if (empty($this->countries)) {
82
-            $this->data_version = $this->getCountrySubRegionDataVersion();
83
-            $data = $this->retrieveJsonData(self::REPO_URL . 'countries.json');
84
-        }
85
-        if (empty($data)) {
86
-            EE_Error::add_error(
87
-                'Country Subregion Data could not be retrieved',
88
-                __FILE__,
89
-                __METHOD__,
90
-                __LINE__
91
-            );
92
-        }
93
-        if (! $has_sub_regions
94
-            || (isset($data->version) && version_compare($data->version, $this->data_version))
95
-        ) {
96
-            if (isset($data->countries)
97
-                && $this->processCountryData($CNT_ISO, $data->countries) > 0
98
-            ) {
99
-                $this->countries = $data->countries;
100
-                $this->updateCountrySubRegionDataVersion($data->version);
101
-                return true;
102
-            }
103
-        }
104
-        return false;
105
-    }
67
+	/**
68
+	 * @param EE_Country $country_object
69
+	 * @return bool
70
+	 * @throws EE_Error
71
+	 * @throws InvalidArgumentException
72
+	 * @throws InvalidDataTypeException
73
+	 * @throws InvalidInterfaceException
74
+	 * @throws ReflectionException
75
+	 */
76
+	public function saveCountrySubRegions(EE_Country $country_object)
77
+	{
78
+		$CNT_ISO = $country_object->ID();
79
+		$has_sub_regions = $this->state_model->count(array(array('Country.CNT_ISO' => $CNT_ISO)));
80
+		$data = [];
81
+		if (empty($this->countries)) {
82
+			$this->data_version = $this->getCountrySubRegionDataVersion();
83
+			$data = $this->retrieveJsonData(self::REPO_URL . 'countries.json');
84
+		}
85
+		if (empty($data)) {
86
+			EE_Error::add_error(
87
+				'Country Subregion Data could not be retrieved',
88
+				__FILE__,
89
+				__METHOD__,
90
+				__LINE__
91
+			);
92
+		}
93
+		if (! $has_sub_regions
94
+			|| (isset($data->version) && version_compare($data->version, $this->data_version))
95
+		) {
96
+			if (isset($data->countries)
97
+				&& $this->processCountryData($CNT_ISO, $data->countries) > 0
98
+			) {
99
+				$this->countries = $data->countries;
100
+				$this->updateCountrySubRegionDataVersion($data->version);
101
+				return true;
102
+			}
103
+		}
104
+		return false;
105
+	}
106 106
 
107 107
 
108
-    /**
109
-     * @since 4.9.70.p
110
-     * @return string
111
-     */
112
-    private function getCountrySubRegionDataVersion()
113
-    {
114
-        return get_option(self::OPTION_NAME_COUNTRY_DATA_VERSION, null);
115
-    }
108
+	/**
109
+	 * @since 4.9.70.p
110
+	 * @return string
111
+	 */
112
+	private function getCountrySubRegionDataVersion()
113
+	{
114
+		return get_option(self::OPTION_NAME_COUNTRY_DATA_VERSION, null);
115
+	}
116 116
 
117 117
 
118
-    /**
119
-     * @param string $version
120
-     */
121
-    private function updateCountrySubRegionDataVersion($version = '')
122
-    {
123
-        // add version option if it has never been added before, or update existing
124
-        if ($this->data_version === null) {
125
-            add_option(self::OPTION_NAME_COUNTRY_DATA_VERSION, $version, '', false);
126
-        } else {
127
-            update_option(self::OPTION_NAME_COUNTRY_DATA_VERSION, $version);
128
-        }
129
-    }
118
+	/**
119
+	 * @param string $version
120
+	 */
121
+	private function updateCountrySubRegionDataVersion($version = '')
122
+	{
123
+		// add version option if it has never been added before, or update existing
124
+		if ($this->data_version === null) {
125
+			add_option(self::OPTION_NAME_COUNTRY_DATA_VERSION, $version, '', false);
126
+		} else {
127
+			update_option(self::OPTION_NAME_COUNTRY_DATA_VERSION, $version);
128
+		}
129
+	}
130 130
 
131 131
 
132
-    /**
133
-     * @param string $CNT_ISO
134
-     * @param array  $countries
135
-     * @return int
136
-     * @throws EE_Error
137
-     * @throws InvalidArgumentException
138
-     * @throws InvalidDataTypeException
139
-     * @throws InvalidInterfaceException
140
-     * @throws ReflectionException
141
-     * @since 4.9.70.p
142
-     */
143
-    private function processCountryData($CNT_ISO, $countries = array())
144
-    {
145
-        if (! empty($countries)) {
146
-            foreach ($countries as $key => $country) {
147
-                if ($country instanceof stdClass
148
-                    && $country->code === $CNT_ISO
149
-                    && empty($country->sub_regions)
150
-                    && ! empty($country->filename)
151
-                ) {
152
-                    $country->sub_regions = $this->retrieveJsonData(
153
-                        self::REPO_URL . 'countries/' . $country->filename . '.json'
154
-                    );
155
-                    return $this->saveSubRegionData($country, $country->sub_regions);
156
-                }
157
-            }
158
-        }
159
-        return 0;
160
-    }
132
+	/**
133
+	 * @param string $CNT_ISO
134
+	 * @param array  $countries
135
+	 * @return int
136
+	 * @throws EE_Error
137
+	 * @throws InvalidArgumentException
138
+	 * @throws InvalidDataTypeException
139
+	 * @throws InvalidInterfaceException
140
+	 * @throws ReflectionException
141
+	 * @since 4.9.70.p
142
+	 */
143
+	private function processCountryData($CNT_ISO, $countries = array())
144
+	{
145
+		if (! empty($countries)) {
146
+			foreach ($countries as $key => $country) {
147
+				if ($country instanceof stdClass
148
+					&& $country->code === $CNT_ISO
149
+					&& empty($country->sub_regions)
150
+					&& ! empty($country->filename)
151
+				) {
152
+					$country->sub_regions = $this->retrieveJsonData(
153
+						self::REPO_URL . 'countries/' . $country->filename . '.json'
154
+					);
155
+					return $this->saveSubRegionData($country, $country->sub_regions);
156
+				}
157
+			}
158
+		}
159
+		return 0;
160
+	}
161 161
 
162 162
 
163
-    /**
164
-     * @param string $url
165
-     * @return array
166
-     */
167
-    private function retrieveJsonData($url)
168
-    {
169
-        if (empty($url)) {
170
-            EE_Error::add_error(
171
-                'No URL was provided!',
172
-                __FILE__,
173
-                __METHOD__,
174
-                __LINE__
175
-            );
176
-            return array();
177
-        }
178
-        $request = wp_safe_remote_get($url);
179
-        if ($request instanceof WP_Error) {
180
-            EE_Error::add_error(
181
-                $request->get_error_message(),
182
-                __FILE__,
183
-                __METHOD__,
184
-                __LINE__
185
-            );
186
-            return array();
187
-        }
188
-        $body = wp_remote_retrieve_body($request);
189
-        $json = json_decode($body);
190
-        if ($this->json_validator->isValid(__FILE__, __METHOD__, __LINE__)) {
191
-            return $json;
192
-        }
193
-        return array();
194
-    }
163
+	/**
164
+	 * @param string $url
165
+	 * @return array
166
+	 */
167
+	private function retrieveJsonData($url)
168
+	{
169
+		if (empty($url)) {
170
+			EE_Error::add_error(
171
+				'No URL was provided!',
172
+				__FILE__,
173
+				__METHOD__,
174
+				__LINE__
175
+			);
176
+			return array();
177
+		}
178
+		$request = wp_safe_remote_get($url);
179
+		if ($request instanceof WP_Error) {
180
+			EE_Error::add_error(
181
+				$request->get_error_message(),
182
+				__FILE__,
183
+				__METHOD__,
184
+				__LINE__
185
+			);
186
+			return array();
187
+		}
188
+		$body = wp_remote_retrieve_body($request);
189
+		$json = json_decode($body);
190
+		if ($this->json_validator->isValid(__FILE__, __METHOD__, __LINE__)) {
191
+			return $json;
192
+		}
193
+		return array();
194
+	}
195 195
 
196 196
 
197
-    /**
198
-     * @param stdClass $country
199
-     * @param array    $sub_regions
200
-     * @return int
201
-     * @throws EE_Error
202
-     * @throws InvalidArgumentException
203
-     * @throws InvalidDataTypeException
204
-     * @throws InvalidInterfaceException
205
-     * @throws ReflectionException
206
-     */
207
-    private function saveSubRegionData(stdClass $country, $sub_regions = array())
208
-    {
209
-        $results = 0;
210
-        if (is_array($sub_regions)) {
211
-            $existing_sub_regions = $this->getExistingStateAbbreviations($country->code);
212
-            foreach ($sub_regions as $sub_region) {
213
-                // remove country code from sub region code
214
-                $abbrev = str_replace(
215
-                    $country->code . '-',
216
-                    '',
217
-                    sanitize_text_field($sub_region->code)
218
-                );
219
-                // but NOT if sub region code results in only a number
220
-                if (absint($abbrev) !== 0) {
221
-                    $abbrev = sanitize_text_field($sub_region->code);
222
-                }
223
-                if (! in_array($abbrev, $existing_sub_regions, true)
224
-                    && $this->state_model->insert(
225
-                        [
226
-                            // STA_ID CNT_ISO STA_abbrev STA_name STA_active
227
-                            'CNT_ISO'    => $country->code,
228
-                            'STA_abbrev' => $abbrev,
229
-                            'STA_name'   => sanitize_text_field($sub_region->name),
230
-                            'STA_active' => 1,
231
-                        ]
232
-                    )
233
-                ) {
234
-                    $results++;
235
-                }
236
-            }
237
-        }
238
-        return $results;
239
-    }
197
+	/**
198
+	 * @param stdClass $country
199
+	 * @param array    $sub_regions
200
+	 * @return int
201
+	 * @throws EE_Error
202
+	 * @throws InvalidArgumentException
203
+	 * @throws InvalidDataTypeException
204
+	 * @throws InvalidInterfaceException
205
+	 * @throws ReflectionException
206
+	 */
207
+	private function saveSubRegionData(stdClass $country, $sub_regions = array())
208
+	{
209
+		$results = 0;
210
+		if (is_array($sub_regions)) {
211
+			$existing_sub_regions = $this->getExistingStateAbbreviations($country->code);
212
+			foreach ($sub_regions as $sub_region) {
213
+				// remove country code from sub region code
214
+				$abbrev = str_replace(
215
+					$country->code . '-',
216
+					'',
217
+					sanitize_text_field($sub_region->code)
218
+				);
219
+				// but NOT if sub region code results in only a number
220
+				if (absint($abbrev) !== 0) {
221
+					$abbrev = sanitize_text_field($sub_region->code);
222
+				}
223
+				if (! in_array($abbrev, $existing_sub_regions, true)
224
+					&& $this->state_model->insert(
225
+						[
226
+							// STA_ID CNT_ISO STA_abbrev STA_name STA_active
227
+							'CNT_ISO'    => $country->code,
228
+							'STA_abbrev' => $abbrev,
229
+							'STA_name'   => sanitize_text_field($sub_region->name),
230
+							'STA_active' => 1,
231
+						]
232
+					)
233
+				) {
234
+					$results++;
235
+				}
236
+			}
237
+		}
238
+		return $results;
239
+	}
240 240
 
241 241
 
242
-    /**
243
-     * @param string $CNT_ISO
244
-     * @since 4.9.76.p
245
-     * @return array
246
-     * @throws EE_Error
247
-     * @throws InvalidArgumentException
248
-     * @throws InvalidDataTypeException
249
-     * @throws InvalidInterfaceException
250
-     * @throws ReflectionException
251
-     */
252
-    private function getExistingStateAbbreviations($CNT_ISO)
253
-    {
254
-        $existing_sub_region_IDs = [];
255
-        $existing_sub_regions = $this->state_model->get_all(array(
256
-            array(
257
-                'Country.CNT_ISO' => array(
258
-                    'IN',
259
-                    [$CNT_ISO]
260
-                )
261
-            ),
262
-            'order_by' => array('Country.CNT_name' => 'ASC', 'STA_name' => 'ASC')
263
-        ));
264
-        if (is_array($existing_sub_regions)) {
265
-            foreach ($existing_sub_regions as $existing_sub_region) {
266
-                if ($existing_sub_region instanceof EE_State) {
267
-                    $existing_sub_region_IDs[] = $existing_sub_region->abbrev();
268
-                }
269
-            }
270
-        }
271
-        return $existing_sub_region_IDs;
272
-    }
242
+	/**
243
+	 * @param string $CNT_ISO
244
+	 * @since 4.9.76.p
245
+	 * @return array
246
+	 * @throws EE_Error
247
+	 * @throws InvalidArgumentException
248
+	 * @throws InvalidDataTypeException
249
+	 * @throws InvalidInterfaceException
250
+	 * @throws ReflectionException
251
+	 */
252
+	private function getExistingStateAbbreviations($CNT_ISO)
253
+	{
254
+		$existing_sub_region_IDs = [];
255
+		$existing_sub_regions = $this->state_model->get_all(array(
256
+			array(
257
+				'Country.CNT_ISO' => array(
258
+					'IN',
259
+					[$CNT_ISO]
260
+				)
261
+			),
262
+			'order_by' => array('Country.CNT_name' => 'ASC', 'STA_name' => 'ASC')
263
+		));
264
+		if (is_array($existing_sub_regions)) {
265
+			foreach ($existing_sub_regions as $existing_sub_region) {
266
+				if ($existing_sub_region instanceof EE_State) {
267
+					$existing_sub_region_IDs[] = $existing_sub_region->abbrev();
268
+				}
269
+			}
270
+		}
271
+		return $existing_sub_region_IDs;
272
+	}
273 273
 }
Please login to merge, or discard this patch.
admin_pages/general_settings/General_Settings_Admin_Page.core.php 4 patches
Unused Use Statements   -1 removed lines patch added patch discarded remove patch
@@ -5,7 +5,6 @@
 block discarded – undo
5 5
 use EventEspresso\core\exceptions\InvalidDataTypeException;
6 6
 use EventEspresso\core\exceptions\InvalidFormSubmissionException;
7 7
 use EventEspresso\core\exceptions\InvalidInterfaceException;
8
-use EventEspresso\core\services\loaders\LoaderFactory;
9 8
 
10 9
 /**
11 10
  * General_Settings_Admin_Page
Please login to merge, or discard this patch.
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -661,7 +661,7 @@  discard block
 block discarded – undo
661 661
      *
662 662
      * @param string          $CNT_ISO
663 663
      * @param EE_Country|null $country
664
-     * @return mixed string | array$country
664
+     * @return string|null string | array$country
665 665
      * @throws DomainException
666 666
      * @throws EE_Error
667 667
      * @throws InvalidArgumentException
@@ -1017,7 +1017,7 @@  discard block
 block discarded – undo
1017 1017
      *        delete_state
1018 1018
      *
1019 1019
      * @access    public
1020
-     * @return        boolean
1020
+     * @return        false|null
1021 1021
      * @throws EE_Error
1022 1022
      * @throws InvalidArgumentException
1023 1023
      * @throws InvalidDataTypeException
Please login to merge, or discard this patch.
Indentation   +1385 added lines, -1385 removed lines patch added patch discarded remove patch
@@ -20,1400 +20,1400 @@
 block discarded – undo
20 20
 class General_Settings_Admin_Page extends EE_Admin_Page
21 21
 {
22 22
 
23
-    /**
24
-     * _question_group
25
-     * holds the specific question group object for the question group details screen
26
-     *
27
-     * @var object
28
-     */
29
-    protected $_question_group;
30
-
31
-
32
-    /**
33
-     * Initialize basic properties.
34
-     */
35
-    protected function _init_page_props()
36
-    {
37
-        $this->page_slug = GEN_SET_PG_SLUG;
38
-        $this->page_label = GEN_SET_LABEL;
39
-        $this->_admin_base_url = GEN_SET_ADMIN_URL;
40
-        $this->_admin_base_path = GEN_SET_ADMIN;
41
-    }
42
-
43
-
44
-    /**
45
-     * Set ajax hooks
46
-     */
47
-    protected function _ajax_hooks()
48
-    {
49
-        add_action('wp_ajax_espresso_display_country_settings', array($this, 'display_country_settings'));
50
-        add_action('wp_ajax_espresso_display_country_states', array($this, 'display_country_states'));
51
-        add_action('wp_ajax_espresso_delete_state', array($this, 'delete_state'), 10, 3);
52
-        add_action('wp_ajax_espresso_add_new_state', array($this, 'add_new_state'));
53
-    }
54
-
55
-
56
-    /**
57
-     * More page properties initialization.
58
-     */
59
-    protected function _define_page_props()
60
-    {
61
-        $this->_admin_page_title = GEN_SET_LABEL;
62
-        $this->_labels = array(
63
-            'publishbox' => __('Update Settings', 'event_espresso'),
64
-        );
65
-    }
66
-
67
-
68
-    /**
69
-     * Set page routes property.
70
-     */
71
-    protected function _set_page_routes()
72
-    {
73
-        $this->_page_routes = array(
74
-
75
-            'critical_pages'                => array(
76
-                'func'       => '_espresso_page_settings',
77
-                'capability' => 'manage_options',
78
-            ),
79
-            'update_espresso_page_settings' => array(
80
-                'func'       => '_update_espresso_page_settings',
81
-                'capability' => 'manage_options',
82
-                'noheader'   => true,
83
-            ),
84
-            'default'                       => array(
85
-                'func'       => '_your_organization_settings',
86
-                'capability' => 'manage_options',
87
-            ),
88
-
89
-            'update_your_organization_settings' => array(
90
-                'func'       => '_update_your_organization_settings',
91
-                'capability' => 'manage_options',
92
-                'noheader'   => true,
93
-            ),
94
-
95
-            'admin_option_settings' => array(
96
-                'func'       => '_admin_option_settings',
97
-                'capability' => 'manage_options',
98
-            ),
99
-
100
-            'update_admin_option_settings' => array(
101
-                'func'       => '_update_admin_option_settings',
102
-                'capability' => 'manage_options',
103
-                'noheader'   => true,
104
-            ),
105
-
106
-            'country_settings' => array(
107
-                'func'       => '_country_settings',
108
-                'capability' => 'manage_options',
109
-            ),
110
-
111
-            'update_country_settings' => array(
112
-                'func'       => '_update_country_settings',
113
-                'capability' => 'manage_options',
114
-                'noheader'   => true,
115
-            ),
116
-
117
-            'display_country_settings' => array(
118
-                'func'       => 'display_country_settings',
119
-                'capability' => 'manage_options',
120
-                'noheader'   => true,
121
-            ),
122
-
123
-            'add_new_state' => array(
124
-                'func'       => 'add_new_state',
125
-                'capability' => 'manage_options',
126
-                'noheader'   => true,
127
-            ),
128
-
129
-            'delete_state'            => array(
130
-                'func'       => 'delete_state',
131
-                'capability' => 'manage_options',
132
-                'noheader'   => true,
133
-            ),
134
-            'privacy_settings'        => array(
135
-                'func'       => 'privacySettings',
136
-                'capability' => 'manage_options',
137
-            ),
138
-            'update_privacy_settings' => array(
139
-                'func'               => 'updatePrivacySettings',
140
-                'capability'         => 'manage_options',
141
-                'noheader'           => true,
142
-                'headers_sent_route' => 'privacy_settings',
143
-            ),
144
-        );
145
-    }
146
-
147
-
148
-    /**
149
-     * Set page configuration property
150
-     */
151
-    protected function _set_page_config()
152
-    {
153
-        $this->_page_config = array(
154
-            'critical_pages'        => array(
155
-                'nav'           => array(
156
-                    'label' => __('Critical Pages', 'event_espresso'),
157
-                    'order' => 50,
158
-                ),
159
-                'metaboxes'     => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')),
160
-                'help_tabs'     => array(
161
-                    'general_settings_critical_pages_help_tab' => array(
162
-                        'title'    => __('Critical Pages', 'event_espresso'),
163
-                        'filename' => 'general_settings_critical_pages',
164
-                    ),
165
-                ),
166
-                'help_tour'     => array('Critical_Pages_Help_Tour'),
167
-                'require_nonce' => false,
168
-            ),
169
-            'default'               => array(
170
-                'nav'           => array(
171
-                    'label' => __('Your Organization', 'event_espresso'),
172
-                    'order' => 20,
173
-                ),
174
-                'help_tabs'     => array(
175
-                    'general_settings_your_organization_help_tab' => array(
176
-                        'title'    => __('Your Organization', 'event_espresso'),
177
-                        'filename' => 'general_settings_your_organization',
178
-                    ),
179
-                ),
180
-                'help_tour'     => array('Your_Organization_Help_Tour'),
181
-                'metaboxes'     => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')),
182
-                'require_nonce' => false,
183
-            ),
184
-            'admin_option_settings' => array(
185
-                'nav'           => array(
186
-                    'label' => __('Admin Options', 'event_espresso'),
187
-                    'order' => 60,
188
-                ),
189
-                'metaboxes'     => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')),
190
-                'help_tabs'     => array(
191
-                    'general_settings_admin_options_help_tab' => array(
192
-                        'title'    => __('Admin Options', 'event_espresso'),
193
-                        'filename' => 'general_settings_admin_options',
194
-                    ),
195
-                ),
196
-                'help_tour'     => array('Admin_Options_Help_Tour'),
197
-                'require_nonce' => false,
198
-            ),
199
-            'country_settings'      => array(
200
-                'nav'           => array(
201
-                    'label' => __('Countries', 'event_espresso'),
202
-                    'order' => 70,
203
-                ),
204
-                'help_tabs'     => array(
205
-                    'general_settings_countries_help_tab' => array(
206
-                        'title'    => __('Countries', 'event_espresso'),
207
-                        'filename' => 'general_settings_countries',
208
-                    ),
209
-                ),
210
-                'help_tour'     => array('Countries_Help_Tour'),
211
-                'require_nonce' => false,
212
-            ),
213
-            'privacy_settings'      => array(
214
-                'nav'           => array(
215
-                    'label' => esc_html__('Privacy', 'event_espresso'),
216
-                    'order' => 80,
217
-                ),
218
-                'metaboxes'     => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')),
219
-                'require_nonce' => false,
220
-            ),
221
-        );
222
-    }
223
-
224
-
225
-    protected function _add_screen_options()
226
-    {
227
-    }
228
-
229
-
230
-    protected function _add_feature_pointers()
231
-    {
232
-    }
233
-
234
-
235
-    /**
236
-     * Enqueue global scripts and styles for all routes in the General Settings Admin Pages.
237
-     */
238
-    public function load_scripts_styles()
239
-    {
240
-        // styles
241
-        wp_enqueue_style('espresso-ui-theme');
242
-        // scripts
243
-        wp_enqueue_script('ee_admin_js');
244
-    }
245
-
246
-
247
-    /**
248
-     * Execute logic running on `admin_init`
249
-     */
250
-    public function admin_init()
251
-    {
252
-        EE_Registry::$i18n_js_strings['invalid_server_response'] = __(
253
-            'An error occurred! Your request may have been processed, but a valid response from the server was not received. Please refresh the page and try again.',
254
-            'event_espresso'
255
-        );
256
-        EE_Registry::$i18n_js_strings['error_occurred'] = __(
257
-            'An error occurred! Please refresh the page and try again.',
258
-            'event_espresso'
259
-        );
260
-        EE_Registry::$i18n_js_strings['confirm_delete_state'] = __(
261
-            'Are you sure you want to delete this State / Province?',
262
-            'event_espresso'
263
-        );
264
-        $protocol = isset($_SERVER['HTTPS']) ? 'https://' : 'http://';
265
-        EE_Registry::$i18n_js_strings['ajax_url'] = admin_url(
266
-            'admin-ajax.php?page=espresso_general_settings',
267
-            $protocol
268
-        );
269
-    }
270
-
271
-
272
-    public function admin_notices()
273
-    {
274
-    }
275
-
276
-
277
-    public function admin_footer_scripts()
278
-    {
279
-    }
280
-
281
-
282
-    /**
283
-     * Enqueue scripts and styles for the default route.
284
-     */
285
-    public function load_scripts_styles_default()
286
-    {
287
-        // styles
288
-        wp_enqueue_style('thickbox');
289
-        // scripts
290
-        wp_enqueue_script('media-upload');
291
-        wp_enqueue_script('thickbox');
292
-        wp_register_script(
293
-            'organization_settings',
294
-            GEN_SET_ASSETS_URL . 'your_organization_settings.js',
295
-            array('jquery', 'media-upload', 'thickbox'),
296
-            EVENT_ESPRESSO_VERSION,
297
-            true
298
-        );
299
-        wp_register_style('organization-css', GEN_SET_ASSETS_URL . 'organization.css', array(), EVENT_ESPRESSO_VERSION);
300
-        wp_enqueue_script('organization_settings');
301
-        wp_enqueue_style('organization-css');
302
-        $confirm_image_delete = array(
303
-            'text' => __(
304
-                'Do you really want to delete this image? Please remember to save your settings to complete the removal.',
305
-                'event_espresso'
306
-            ),
307
-        );
308
-        wp_localize_script('organization_settings', 'confirm_image_delete', $confirm_image_delete);
309
-    }
310
-
311
-
312
-    /**
313
-     * Enqueue scripts and styles for the country settings route.
314
-     */
315
-    public function load_scripts_styles_country_settings()
316
-    {
317
-        // scripts
318
-        wp_register_script(
319
-            'gen_settings_countries',
320
-            GEN_SET_ASSETS_URL . 'gen_settings_countries.js',
321
-            array('ee_admin_js'),
322
-            EVENT_ESPRESSO_VERSION,
323
-            true
324
-        );
325
-        wp_register_style('organization-css', GEN_SET_ASSETS_URL . 'organization.css', array(), EVENT_ESPRESSO_VERSION);
326
-        wp_enqueue_script('gen_settings_countries');
327
-        wp_enqueue_style('organization-css');
328
-    }
329
-
330
-
331
-    /*************        Espresso Pages        *************/
332
-    /**
333
-     * _espresso_page_settings
334
-     *
335
-     * @throws \EE_Error
336
-     * @throws DomainException
337
-     * @throws DomainException
338
-     * @throws InvalidDataTypeException
339
-     * @throws InvalidArgumentException
340
-     */
341
-    protected function _espresso_page_settings()
342
-    {
343
-        // Check to make sure all of the main pages are setup properly,
344
-        // if not create the default pages and display an admin notice
345
-        EEH_Activation::verify_default_pages_exist();
346
-        $this->_transient_garbage_collection();
347
-        $this->_template_args['values'] = $this->_yes_no_values;
348
-        $this->_template_args['reg_page_id'] = isset(EE_Registry::instance()->CFG->core->reg_page_id)
349
-            ? EE_Registry::instance()->CFG->core->reg_page_id
350
-            : null;
351
-        $this->_template_args['reg_page_obj'] = isset(EE_Registry::instance()->CFG->core->reg_page_id)
352
-            ? get_page(EE_Registry::instance()->CFG->core->reg_page_id)
353
-            : false;
354
-        $this->_template_args['txn_page_id'] = isset(EE_Registry::instance()->CFG->core->txn_page_id)
355
-            ? EE_Registry::instance()->CFG->core->txn_page_id
356
-            : null;
357
-        $this->_template_args['txn_page_obj'] = isset(EE_Registry::instance()->CFG->core->txn_page_id)
358
-            ? get_page(EE_Registry::instance()->CFG->core->txn_page_id)
359
-            : false;
360
-        $this->_template_args['thank_you_page_id'] = isset(EE_Registry::instance()->CFG->core->thank_you_page_id)
361
-            ? EE_Registry::instance()->CFG->core->thank_you_page_id
362
-            : null;
363
-        $this->_template_args['thank_you_page_obj'] = isset(EE_Registry::instance()->CFG->core->thank_you_page_id)
364
-            ? get_page(EE_Registry::instance()->CFG->core->thank_you_page_id)
365
-            : false;
366
-        $this->_template_args['cancel_page_id'] = isset(EE_Registry::instance()->CFG->core->cancel_page_id)
367
-            ? EE_Registry::instance()->CFG->core->cancel_page_id
368
-            : null;
369
-        $this->_template_args['cancel_page_obj'] = isset(EE_Registry::instance()->CFG->core->cancel_page_id)
370
-            ? get_page(EE_Registry::instance()->CFG->core->cancel_page_id)
371
-            : false;
372
-        $this->_set_add_edit_form_tags('update_espresso_page_settings');
373
-        $this->_set_publish_post_box_vars(null, false, false, null, false);
374
-        $this->_template_args['admin_page_content'] = EEH_Template::display_template(
375
-            GEN_SET_TEMPLATE_PATH . 'espresso_page_settings.template.php',
376
-            $this->_template_args,
377
-            true
378
-        );
379
-        $this->display_admin_page_with_sidebar();
380
-    }
381
-
382
-
383
-    /**
384
-     * Handler for updating espresso page settings.
385
-     *
386
-     * @throws EE_Error
387
-     */
388
-    protected function _update_espresso_page_settings()
389
-    {
390
-        // capture incoming request data && set page IDs
391
-        EE_Registry::instance()->CFG->core->reg_page_id = isset($this->_req_data['reg_page_id'])
392
-            ? absint($this->_req_data['reg_page_id'])
393
-            : EE_Registry::instance()->CFG->core->reg_page_id;
394
-        EE_Registry::instance()->CFG->core->txn_page_id = isset($this->_req_data['txn_page_id'])
395
-            ? absint($this->_req_data['txn_page_id'])
396
-            : EE_Registry::instance()->CFG->core->txn_page_id;
397
-        EE_Registry::instance()->CFG->core->thank_you_page_id = isset($this->_req_data['thank_you_page_id'])
398
-            ? absint($this->_req_data['thank_you_page_id'])
399
-            : EE_Registry::instance()->CFG->core->thank_you_page_id;
400
-        EE_Registry::instance()->CFG->core->cancel_page_id = isset($this->_req_data['cancel_page_id'])
401
-            ? absint($this->_req_data['cancel_page_id'])
402
-            : EE_Registry::instance()->CFG->core->cancel_page_id;
403
-
404
-        EE_Registry::instance()->CFG->core = apply_filters(
405
-            'FHEE__General_Settings_Admin_Page___update_espresso_page_settings__CFG_core',
406
-            EE_Registry::instance()->CFG->core,
407
-            $this->_req_data
408
-        );
409
-        $what = __('Critical Pages & Shortcodes', 'event_espresso');
410
-        $this->_redirect_after_action(
411
-            $this->_update_espresso_configuration(
412
-                $what,
413
-                EE_Registry::instance()->CFG->core,
414
-                __FILE__,
415
-                __FUNCTION__,
416
-                __LINE__
417
-            ),
418
-            $what,
419
-            '',
420
-            array(
421
-                'action' => 'critical_pages',
422
-            ),
423
-            true
424
-        );
425
-    }
426
-
427
-
428
-    /*************        Your Organization        *************/
429
-
430
-
431
-    /**
432
-     * @throws DomainException
433
-     * @throws EE_Error
434
-     * @throws InvalidArgumentException
435
-     * @throws InvalidDataTypeException
436
-     * @throws InvalidInterfaceException
437
-     */
438
-    protected function _your_organization_settings()
439
-    {
440
-        $this->_template_args['admin_page_content'] = '';
441
-        try {
442
-            /** @var EventEspresso\admin_pages\general_settings\OrganizationSettings $organization_settings_form */
443
-            $organization_settings_form = $this->loader->getShared(
444
-                'EventEspresso\admin_pages\general_settings\OrganizationSettings'
445
-            );
446
-            $this->_template_args['admin_page_content'] = $organization_settings_form->display();
447
-        } catch (Exception $e) {
448
-            EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__);
449
-        }
450
-        $this->_set_add_edit_form_tags('update_your_organization_settings');
451
-        $this->_set_publish_post_box_vars(null, false, false, null, false);
452
-        $this->display_admin_page_with_sidebar();
453
-    }
454
-
455
-
456
-    /**
457
-     * Handler for updating organization settings.
458
-     *
459
-     * @throws EE_Error
460
-     */
461
-    protected function _update_your_organization_settings()
462
-    {
463
-        try {
464
-            /** @var EventEspresso\admin_pages\general_settings\OrganizationSettings $organization_settings_form */
465
-            $organization_settings_form = $this->loader->getShared(
466
-                'EventEspresso\admin_pages\general_settings\OrganizationSettings'
467
-            );
468
-            $success = $organization_settings_form->process($this->_req_data);
469
-            EE_Registry::instance()->CFG = apply_filters(
470
-                'FHEE__General_Settings_Admin_Page___update_your_organization_settings__CFG',
471
-                EE_Registry::instance()->CFG
472
-            );
473
-        } catch (Exception $e) {
474
-            EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__);
475
-            $success = false;
476
-        }
477
-
478
-        if ($success) {
479
-            $success = $this->_update_espresso_configuration(
480
-                esc_html__('Your Organization Settings', 'event_espresso'),
481
-                EE_Registry::instance()->CFG,
482
-                __FILE__,
483
-                __FUNCTION__,
484
-                __LINE__
485
-            );
486
-        }
487
-
488
-        $this->_redirect_after_action($success, '', '', array('action' => 'default'), true);
489
-    }
490
-
491
-
492
-
493
-    /*************        Admin Options        *************/
494
-
495
-
496
-    /**
497
-     * _admin_option_settings
498
-     *
499
-     * @throws \EE_Error
500
-     * @throws \LogicException
501
-     */
502
-    protected function _admin_option_settings()
503
-    {
504
-        $this->_template_args['admin_page_content'] = '';
505
-        try {
506
-            $admin_options_settings_form = new AdminOptionsSettings(EE_Registry::instance());
507
-            // still need this for the old school form in Extend_General_Settings_Admin_Page
508
-            $this->_template_args['values'] = $this->_yes_no_values;
509
-            // also need to account for the do_action that was in the old template
510
-            $admin_options_settings_form->setTemplateArgs($this->_template_args);
511
-            $this->_template_args['admin_page_content'] = $admin_options_settings_form->display();
512
-        } catch (Exception $e) {
513
-            EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__);
514
-        }
515
-        $this->_set_add_edit_form_tags('update_admin_option_settings');
516
-        $this->_set_publish_post_box_vars(null, false, false, null, false);
517
-        $this->display_admin_page_with_sidebar();
518
-    }
519
-
520
-
521
-    /**
522
-     * _update_admin_option_settings
523
-     *
524
-     * @throws \EE_Error
525
-     * @throws InvalidDataTypeException
526
-     * @throws \EventEspresso\core\exceptions\InvalidFormSubmissionException
527
-     * @throws \InvalidArgumentException
528
-     * @throws \LogicException
529
-     */
530
-    protected function _update_admin_option_settings()
531
-    {
532
-        try {
533
-            $admin_options_settings_form = new AdminOptionsSettings(EE_Registry::instance());
534
-            $admin_options_settings_form->process($this->_req_data[ $admin_options_settings_form->slug() ]);
535
-            EE_Registry::instance()->CFG->admin = apply_filters(
536
-                'FHEE__General_Settings_Admin_Page___update_admin_option_settings__CFG_admin',
537
-                EE_Registry::instance()->CFG->admin
538
-            );
539
-        } catch (Exception $e) {
540
-            EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__);
541
-        }
542
-        $this->_redirect_after_action(
543
-            apply_filters(
544
-                'FHEE__General_Settings_Admin_Page___update_admin_option_settings__success',
545
-                $this->_update_espresso_configuration(
546
-                    'Admin Options',
547
-                    EE_Registry::instance()->CFG->admin,
548
-                    __FILE__,
549
-                    __FUNCTION__,
550
-                    __LINE__
551
-                )
552
-            ),
553
-            'Admin Options',
554
-            'updated',
555
-            array('action' => 'admin_option_settings')
556
-        );
557
-    }
558
-
559
-
560
-    /*************        Countries        *************/
561
-
562
-
563
-    /**
564
-     * @return string
565
-     */
566
-    protected function getCountryIsoForSite()
567
-    {
568
-        return ! empty(EE_Registry::instance()->CFG->organization->CNT_ISO)
569
-            ? EE_Registry::instance()->CFG->organization->CNT_ISO
570
-            : 'US';
571
-    }
572
-
573
-
574
-    /**
575
-     * @param string          $CNT_ISO
576
-     * @param EE_Country|null $country
577
-     * @return EE_Base_Class|EE_Country
578
-     * @throws EE_Error
579
-     * @throws InvalidArgumentException
580
-     * @throws InvalidDataTypeException
581
-     * @throws InvalidInterfaceException
582
-     * @throws ReflectionException
583
-     */
584
-    protected function verifyOrGetCountryFromIso($CNT_ISO, EE_Country $country = null)
585
-    {
586
-        /** @var EE_Country $country */
587
-        return $country instanceof EE_Country && $country->ID() === $CNT_ISO
588
-            ? $country
589
-            : EEM_Country::instance()->get_one_by_ID($CNT_ISO);
590
-    }
591
-
592
-
593
-    /**
594
-     * Output Country Settings view.
595
-     *
596
-     * @throws DomainException
597
-     * @throws EE_Error
598
-     * @throws InvalidArgumentException
599
-     * @throws InvalidDataTypeException
600
-     * @throws InvalidInterfaceException
601
-     * @throws ReflectionException
602
-     */
603
-    protected function _country_settings()
604
-    {
605
-        $CNT_ISO_for_site = $this->getCountryIsoForSite();
606
-        $CNT_ISO = isset($this->_req_data['country'])
607
-            ? strtoupper(sanitize_text_field($this->_req_data['country']))
608
-            : $CNT_ISO_for_site;
609
-
610
-        // load field generator helper
611
-
612
-        $this->_template_args['values'] = $this->_yes_no_values;
613
-
614
-        $this->_template_args['countries'] = new EE_Question_Form_Input(
615
-            EE_Question::new_instance(
616
-                array(
617
-                    'QST_ID'           => 0,
618
-                    'QST_display_text' => __('Select Country', 'event_espresso'),
619
-                    'QST_system'       => 'admin-country',
620
-                )
621
-            ),
622
-            EE_Answer::new_instance(
623
-                array(
624
-                    'ANS_ID'    => 0,
625
-                    'ANS_value' => $CNT_ISO,
626
-                )
627
-            ),
628
-            array(
629
-                'input_id'       => 'country',
630
-                'input_name'     => 'country',
631
-                'input_prefix'   => '',
632
-                'append_qstn_id' => false,
633
-            )
634
-        );
635
-        $country = $this->verifyOrGetCountryFromIso($CNT_ISO_for_site);
636
-        add_filter('FHEE__EEH_Form_Fields__label_html', array($this, 'country_form_field_label_wrap'), 10, 2);
637
-        add_filter('FHEE__EEH_Form_Fields__input_html', array($this, 'country_form_field_input__wrap'), 10, 2);
638
-        $this->_template_args['country_details_settings'] = $this->display_country_settings(
639
-            $country->ID(),
640
-            $country
641
-        );
642
-        $this->_template_args['country_states_settings'] = $this->display_country_states(
643
-            $country->ID(),
644
-            $country
645
-        );
646
-        $this->_template_args['CNT_name_for_site'] = $country->name();
647
-
648
-        $this->_set_add_edit_form_tags('update_country_settings');
649
-        $this->_set_publish_post_box_vars(null, false, false, null, false);
650
-        $this->_template_args['admin_page_content'] = EEH_Template::display_template(
651
-            GEN_SET_TEMPLATE_PATH . 'countries_settings.template.php',
652
-            $this->_template_args,
653
-            true
654
-        );
655
-        $this->display_admin_page_with_no_sidebar();
656
-    }
657
-
658
-
659
-    /**
660
-     *        display_country_settings
661
-     *
662
-     * @param string          $CNT_ISO
663
-     * @param EE_Country|null $country
664
-     * @return mixed string | array$country
665
-     * @throws DomainException
666
-     * @throws EE_Error
667
-     * @throws InvalidArgumentException
668
-     * @throws InvalidDataTypeException
669
-     * @throws InvalidInterfaceException
670
-     * @throws ReflectionException
671
-     */
672
-    public function display_country_settings($CNT_ISO = '', EE_Country $country = null)
673
-    {
674
-        $CNT_ISO_for_site = $this->getCountryIsoForSite();
675
-
676
-        $CNT_ISO = isset($this->_req_data['country'])
677
-            ? strtoupper(sanitize_text_field($this->_req_data['country']))
678
-            : $CNT_ISO;
679
-        if (! $CNT_ISO) {
680
-            return '';
681
-        }
682
-
683
-        // for ajax
684
-        remove_all_filters('FHEE__EEH_Form_Fields__label_html');
685
-        remove_all_filters('FHEE__EEH_Form_Fields__input_html');
686
-        add_filter('FHEE__EEH_Form_Fields__label_html', array($this, 'country_form_field_label_wrap'), 10, 2);
687
-        add_filter('FHEE__EEH_Form_Fields__input_html', array($this, 'country_form_field_input__wrap'), 10, 2);
688
-        $country = $this->verifyOrGetCountryFromIso($CNT_ISO, $country);
689
-        $CNT_cur_disabled = $CNT_ISO !== $CNT_ISO_for_site;
690
-        $this->_template_args['CNT_cur_disabled'] = $CNT_cur_disabled;
691
-
692
-        $country_input_types = array(
693
-            'CNT_active'      => array(
694
-                'type'             => 'RADIO_BTN',
695
-                'input_name'       => 'cntry[' . $CNT_ISO . ']',
696
-                'class'            => '',
697
-                'options'          => $this->_yes_no_values,
698
-                'use_desc_4_label' => true,
699
-            ),
700
-            'CNT_ISO'         => array(
701
-                'type'       => 'TEXT',
702
-                'input_name' => 'cntry[' . $CNT_ISO . ']',
703
-                'class'      => 'small-text',
704
-            ),
705
-            'CNT_ISO3'        => array(
706
-                'type'       => 'TEXT',
707
-                'input_name' => 'cntry[' . $CNT_ISO . ']',
708
-                'class'      => 'small-text',
709
-            ),
710
-            'RGN_ID'          => array(
711
-                'type'       => 'TEXT',
712
-                'input_name' => 'cntry[' . $CNT_ISO . ']',
713
-                'class'      => 'small-text',
714
-            ),
715
-            'CNT_name'        => array(
716
-                'type'       => 'TEXT',
717
-                'input_name' => 'cntry[' . $CNT_ISO . ']',
718
-                'class'      => 'regular-text',
719
-            ),
720
-            'CNT_cur_code'    => array(
721
-                'type'       => 'TEXT',
722
-                'input_name' => 'cntry[' . $CNT_ISO . ']',
723
-                'class'      => 'small-text',
724
-                'disabled'   => $CNT_cur_disabled,
725
-            ),
726
-            'CNT_cur_single'  => array(
727
-                'type'       => 'TEXT',
728
-                'input_name' => 'cntry[' . $CNT_ISO . ']',
729
-                'class'      => 'medium-text',
730
-                'disabled'   => $CNT_cur_disabled,
731
-            ),
732
-            'CNT_cur_plural'  => array(
733
-                'type'       => 'TEXT',
734
-                'input_name' => 'cntry[' . $CNT_ISO . ']',
735
-                'class'      => 'medium-text',
736
-                'disabled'   => $CNT_cur_disabled,
737
-            ),
738
-            'CNT_cur_sign'    => array(
739
-                'type'         => 'TEXT',
740
-                'input_name'   => 'cntry[' . $CNT_ISO . ']',
741
-                'class'        => 'small-text',
742
-                'htmlentities' => false,
743
-                'disabled'     => $CNT_cur_disabled,
744
-            ),
745
-            'CNT_cur_sign_b4' => array(
746
-                'type'             => 'RADIO_BTN',
747
-                'input_name'       => 'cntry[' . $CNT_ISO . ']',
748
-                'class'            => '',
749
-                'options'          => $this->_yes_no_values,
750
-                'use_desc_4_label' => true,
751
-                'disabled'         => $CNT_cur_disabled,
752
-            ),
753
-            'CNT_cur_dec_plc' => array(
754
-                'type'       => 'RADIO_BTN',
755
-                'input_name' => 'cntry[' . $CNT_ISO . ']',
756
-                'class'      => '',
757
-                'options'    => array(
758
-                    array('id' => 0, 'text' => ''),
759
-                    array('id' => 1, 'text' => ''),
760
-                    array('id' => 2, 'text' => ''),
761
-                    array('id' => 3, 'text' => ''),
762
-                ),
763
-                'disabled'   => $CNT_cur_disabled,
764
-            ),
765
-            'CNT_cur_dec_mrk' => array(
766
-                'type'             => 'RADIO_BTN',
767
-                'input_name'       => 'cntry[' . $CNT_ISO . ']',
768
-                'class'            => '',
769
-                'options'          => array(
770
-                    array(
771
-                        'id'   => ',',
772
-                        'text' => __(', (comma)', 'event_espresso'),
773
-                    ),
774
-                    array('id' => '.', 'text' => __('. (decimal)', 'event_espresso')),
775
-                ),
776
-                'use_desc_4_label' => true,
777
-                'disabled'         => $CNT_cur_disabled,
778
-            ),
779
-            'CNT_cur_thsnds'  => array(
780
-                'type'             => 'RADIO_BTN',
781
-                'input_name'       => 'cntry[' . $CNT_ISO . ']',
782
-                'class'            => '',
783
-                'options'          => array(
784
-                    array(
785
-                        'id'   => ',',
786
-                        'text' => __(', (comma)', 'event_espresso'),
787
-                    ),
788
-                    array('id' => '.', 'text' => __('. (decimal)', 'event_espresso')),
789
-                ),
790
-                'use_desc_4_label' => true,
791
-                'disabled'         => $CNT_cur_disabled,
792
-            ),
793
-            'CNT_tel_code'    => array(
794
-                'type'       => 'TEXT',
795
-                'input_name' => 'cntry[' . $CNT_ISO . ']',
796
-                'class'      => 'small-text',
797
-            ),
798
-            'CNT_is_EU'       => array(
799
-                'type'             => 'RADIO_BTN',
800
-                'input_name'       => 'cntry[' . $CNT_ISO . ']',
801
-                'class'            => '',
802
-                'options'          => $this->_yes_no_values,
803
-                'use_desc_4_label' => true,
804
-            ),
805
-        );
806
-        $this->_template_args['inputs'] = EE_Question_Form_Input::generate_question_form_inputs_for_object(
807
-            $country,
808
-            $country_input_types
809
-        );
810
-        $country_details_settings = EEH_Template::display_template(
811
-            GEN_SET_TEMPLATE_PATH . 'country_details_settings.template.php',
812
-            $this->_template_args,
813
-            true
814
-        );
815
-
816
-        if (defined('DOING_AJAX')) {
817
-            $notices = EE_Error::get_notices(false, false, false);
818
-            echo wp_json_encode(
819
-                array(
820
-                    'return_data' => $country_details_settings,
821
-                    'success'     => $notices['success'],
822
-                    'errors'      => $notices['errors'],
823
-                )
824
-            );
825
-            die();
826
-        } else {
827
-            return $country_details_settings;
828
-        }
829
-    }
830
-
831
-
832
-    /**
833
-     * @param string          $CNT_ISO
834
-     * @param EE_Country|null $country
835
-     * @return string
836
-     * @throws DomainException
837
-     * @throws EE_Error
838
-     * @throws InvalidArgumentException
839
-     * @throws InvalidDataTypeException
840
-     * @throws InvalidInterfaceException
841
-     * @throws ReflectionException
842
-     */
843
-    public function display_country_states($CNT_ISO = '', EE_Country $country = null)
844
-    {
845
-
846
-        $CNT_ISO = isset($this->_req_data['country'])
847
-            ? sanitize_text_field($this->_req_data['country'])
848
-            : $CNT_ISO;
849
-        if (! $CNT_ISO) {
850
-            return '';
851
-        }
852
-        // for ajax
853
-        remove_all_filters('FHEE__EEH_Form_Fields__label_html');
854
-        remove_all_filters('FHEE__EEH_Form_Fields__input_html');
855
-        add_filter('FHEE__EEH_Form_Fields__label_html', array($this, 'state_form_field_label_wrap'), 10, 2);
856
-        add_filter('FHEE__EEH_Form_Fields__input_html', array($this, 'state_form_field_input__wrap'), 10, 2);
857
-        $states = EEM_State::instance()->get_all_states_for_these_countries(array($CNT_ISO => $CNT_ISO));
858
-        if (empty($states)) {
859
-            /** @var EventEspresso\core\services\address\CountrySubRegionDao $countrySubRegionDao */
860
-            $countrySubRegionDao = $this->loader->getShared(
861
-                'EventEspresso\core\services\address\CountrySubRegionDao'
862
-            );
863
-            if ($countrySubRegionDao instanceof EventEspresso\core\services\address\CountrySubRegionDao) {
864
-                $country = $this->verifyOrGetCountryFromIso($CNT_ISO, $country);
865
-                if ($countrySubRegionDao->saveCountrySubRegions($country)) {
866
-                    $states = EEM_State::instance()->get_all_states_for_these_countries(
867
-                        array($CNT_ISO => $CNT_ISO)
868
-                    );
869
-                }
870
-            }
871
-        }
872
-        if (is_array($states)) {
873
-            foreach ($states as $STA_ID => $state) {
874
-                if ($state instanceof EE_State) {
875
-                    // STA_abbrev    STA_name    STA_active
876
-                    $state_input_types = array(
877
-                        'STA_abbrev' => array(
878
-                            'type'       => 'TEXT',
879
-                            'input_name' => 'states[' . $STA_ID . ']',
880
-                            'class'      => 'mid-text',
881
-                        ),
882
-                        'STA_name'   => array(
883
-                            'type'       => 'TEXT',
884
-                            'input_name' => 'states[' . $STA_ID . ']',
885
-                            'class'      => 'regular-text',
886
-                        ),
887
-                        'STA_active' => array(
888
-                            'type'             => 'RADIO_BTN',
889
-                            'input_name'       => 'states[' . $STA_ID . ']',
890
-                            'options'          => $this->_yes_no_values,
891
-                            'use_desc_4_label' => true,
892
-                        ),
893
-                    );
894
-                    $this->_template_args['states'][ $STA_ID ]['inputs'] =
895
-                        EE_Question_Form_Input::generate_question_form_inputs_for_object(
896
-                            $state,
897
-                            $state_input_types
898
-                        );
899
-                    $query_args = array(
900
-                        'action'     => 'delete_state',
901
-                        'STA_ID'     => $STA_ID,
902
-                        'CNT_ISO'    => $CNT_ISO,
903
-                        'STA_abbrev' => $state->abbrev(),
904
-                    );
905
-                    $this->_template_args['states'][ $STA_ID ]['delete_state_url'] =
906
-                        EE_Admin_Page::add_query_args_and_nonce(
907
-                            $query_args,
908
-                            GEN_SET_ADMIN_URL
909
-                        );
910
-                }
911
-            }
912
-        } else {
913
-            $this->_template_args['states'] = false;
914
-        }
915
-
916
-        $this->_template_args['add_new_state_url'] = EE_Admin_Page::add_query_args_and_nonce(
917
-            array('action' => 'add_new_state'),
918
-            GEN_SET_ADMIN_URL
919
-        );
920
-
921
-        $state_details_settings = EEH_Template::display_template(
922
-            GEN_SET_TEMPLATE_PATH . 'state_details_settings.template.php',
923
-            $this->_template_args,
924
-            true
925
-        );
926
-
927
-        if (defined('DOING_AJAX')) {
928
-            $notices = EE_Error::get_notices(false, false, false);
929
-            echo wp_json_encode(
930
-                array(
931
-                    'return_data' => $state_details_settings,
932
-                    'success'     => $notices['success'],
933
-                    'errors'      => $notices['errors'],
934
-                )
935
-            );
936
-            die();
937
-        } else {
938
-            return $state_details_settings;
939
-        }
940
-    }
941
-
942
-
943
-    /**
944
-     *        add_new_state
945
-     *
946
-     * @access    public
947
-     * @return void
948
-     * @throws EE_Error
949
-     * @throws InvalidArgumentException
950
-     * @throws InvalidDataTypeException
951
-     * @throws InvalidInterfaceException
952
-     */
953
-    public function add_new_state()
954
-    {
955
-
956
-        $success = true;
957
-
958
-        $CNT_ISO = isset($this->_req_data['CNT_ISO'])
959
-            ? strtoupper(sanitize_text_field($this->_req_data['CNT_ISO']))
960
-            : false;
961
-        if (! $CNT_ISO) {
962
-            EE_Error::add_error(
963
-                __('No Country ISO code or an invalid Country ISO code was received.', 'event_espresso'),
964
-                __FILE__,
965
-                __FUNCTION__,
966
-                __LINE__
967
-            );
968
-            $success = false;
969
-        }
970
-        $STA_abbrev = isset($this->_req_data['STA_abbrev'])
971
-            ? sanitize_text_field($this->_req_data['STA_abbrev'])
972
-            : false;
973
-        if (! $STA_abbrev) {
974
-            EE_Error::add_error(
975
-                __('No State ISO code or an invalid State ISO code was received.', 'event_espresso'),
976
-                __FILE__,
977
-                __FUNCTION__,
978
-                __LINE__
979
-            );
980
-            $success = false;
981
-        }
982
-        $STA_name = isset($this->_req_data['STA_name'])
983
-            ? sanitize_text_field($this->_req_data['STA_name'])
984
-            : false;
985
-        if (! $STA_name) {
986
-            EE_Error::add_error(
987
-                __('No State name or an invalid State name was received.', 'event_espresso'),
988
-                __FILE__,
989
-                __FUNCTION__,
990
-                __LINE__
991
-            );
992
-            $success = false;
993
-        }
994
-
995
-        if ($success) {
996
-            $cols_n_values = array(
997
-                'CNT_ISO'    => $CNT_ISO,
998
-                'STA_abbrev' => $STA_abbrev,
999
-                'STA_name'   => $STA_name,
1000
-                'STA_active' => true,
1001
-            );
1002
-            $success = EEM_State::instance()->insert($cols_n_values);
1003
-            EE_Error::add_success(__('The State was added successfully.', 'event_espresso'));
1004
-        }
1005
-
1006
-        if (defined('DOING_AJAX')) {
1007
-            $notices = EE_Error::get_notices(false, false, false);
1008
-            echo wp_json_encode(array_merge($notices, array('return_data' => $CNT_ISO)));
1009
-            die();
1010
-        } else {
1011
-            $this->_redirect_after_action($success, 'State', 'added', array('action' => 'country_settings'));
1012
-        }
1013
-    }
1014
-
1015
-
1016
-    /**
1017
-     *        delete_state
1018
-     *
1019
-     * @access    public
1020
-     * @return        boolean
1021
-     * @throws EE_Error
1022
-     * @throws InvalidArgumentException
1023
-     * @throws InvalidDataTypeException
1024
-     * @throws InvalidInterfaceException
1025
-     */
1026
-    public function delete_state()
1027
-    {
1028
-        $CNT_ISO = isset($this->_req_data['CNT_ISO'])
1029
-            ? strtoupper(sanitize_text_field($this->_req_data['CNT_ISO']))
1030
-            : false;
1031
-        $STA_ID = isset($this->_req_data['STA_ID'])
1032
-            ? sanitize_text_field($this->_req_data['STA_ID'])
1033
-            : false;
1034
-        $STA_abbrev = isset($this->_req_data['STA_abbrev'])
1035
-            ? sanitize_text_field($this->_req_data['STA_abbrev'])
1036
-            : false;
1037
-        if (! $STA_ID) {
1038
-            EE_Error::add_error(
1039
-                __('No State ID or an invalid State ID was received.', 'event_espresso'),
1040
-                __FILE__,
1041
-                __FUNCTION__,
1042
-                __LINE__
1043
-            );
1044
-            return false;
1045
-        }
1046
-
1047
-        $success = EEM_State::instance()->delete_by_ID($STA_ID);
1048
-        if ($success !== false) {
1049
-            do_action(
1050
-                'AHEE__General_Settings_Admin_Page__delete_state__state_deleted',
1051
-                $CNT_ISO,
1052
-                $STA_ID,
1053
-                array('STA_abbrev' => $STA_abbrev)
1054
-            );
1055
-            EE_Error::add_success(__('The State was deleted successfully.', 'event_espresso'));
1056
-        }
1057
-        if (defined('DOING_AJAX')) {
1058
-            $notices = EE_Error::get_notices(false, false);
1059
-            $notices['return_data'] = true;
1060
-            echo wp_json_encode($notices);
1061
-            die();
1062
-        } else {
1063
-            $this->_redirect_after_action(
1064
-                $success,
1065
-                'State',
1066
-                'deleted',
1067
-                array('action' => 'country_settings')
1068
-            );
1069
-        }
1070
-    }
1071
-
1072
-
1073
-    /**
1074
-     *        _update_country_settings
1075
-     *
1076
-     * @access    protected
1077
-     * @return void
1078
-     * @throws EE_Error
1079
-     * @throws InvalidArgumentException
1080
-     * @throws InvalidDataTypeException
1081
-     * @throws InvalidInterfaceException
1082
-     */
1083
-    protected function _update_country_settings()
1084
-    {
1085
-        // grab the country ISO code
1086
-        $CNT_ISO = isset($this->_req_data['country'])
1087
-            ? strtoupper(sanitize_text_field($this->_req_data['country']))
1088
-            : false;
1089
-        if (! $CNT_ISO) {
1090
-            EE_Error::add_error(
1091
-                __('No Country ISO code or an invalid Country ISO code was received.', 'event_espresso'),
1092
-                __FILE__,
1093
-                __FUNCTION__,
1094
-                __LINE__
1095
-            );
1096
-
1097
-            return;
1098
-        }
1099
-        $cols_n_values = array();
1100
-        $cols_n_values['CNT_ISO3'] = isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_ISO3'])
1101
-            ? strtoupper(sanitize_text_field($this->_req_data['cntry'][ $CNT_ISO ]['CNT_ISO3']))
1102
-            : false;
1103
-        $cols_n_values['RGN_ID'] = isset($this->_req_data['cntry'][ $CNT_ISO ]['RGN_ID'])
1104
-            ? absint($this->_req_data['cntry'][ $CNT_ISO ]['RGN_ID'])
1105
-            : null;
1106
-        $cols_n_values['CNT_name'] = isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_name'])
1107
-            ? sanitize_text_field($this->_req_data['cntry'][ $CNT_ISO ]['CNT_name'])
1108
-            : null;
1109
-        if (isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_code'])) {
1110
-            $cols_n_values['CNT_cur_code'] = strtoupper(
1111
-                sanitize_text_field($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_code'])
1112
-            );
1113
-        }
1114
-        if (isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_single'])) {
1115
-            $cols_n_values['CNT_cur_single'] = sanitize_text_field(
1116
-                $this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_single']
1117
-            );
1118
-        }
1119
-        if (isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_plural'])) {
1120
-            $cols_n_values['CNT_cur_plural'] = sanitize_text_field(
1121
-                $this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_plural']
1122
-            );
1123
-        }
1124
-        if (isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_sign'])) {
1125
-            $cols_n_values['CNT_cur_sign'] = sanitize_text_field(
1126
-                $this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_sign']
1127
-            );
1128
-        }
1129
-        if (isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_sign_b4'])) {
1130
-            $cols_n_values['CNT_cur_sign_b4'] = absint(
1131
-                $this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_sign_b4']
1132
-            );
1133
-        }
1134
-        if (isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_dec_plc'])) {
1135
-            $cols_n_values['CNT_cur_dec_plc'] = absint(
1136
-                $this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_dec_plc']
1137
-            );
1138
-        }
1139
-        if (isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_dec_mrk'])) {
1140
-            $cols_n_values['CNT_cur_dec_mrk'] = sanitize_text_field(
1141
-                $this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_dec_mrk']
1142
-            );
1143
-        }
1144
-        if (isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_thsnds'])) {
1145
-            $cols_n_values['CNT_cur_thsnds'] = sanitize_text_field(
1146
-                $this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_thsnds']
1147
-            );
1148
-        }
1149
-        $cols_n_values['CNT_tel_code'] = isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_tel_code'])
1150
-            ? sanitize_text_field($this->_req_data['cntry'][ $CNT_ISO ]['CNT_tel_code'])
1151
-            : null;
1152
-        $cols_n_values['CNT_is_EU'] = isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_is_EU'])
1153
-            ? absint($this->_req_data['cntry'][ $CNT_ISO ]['CNT_is_EU'])
1154
-            : false;
1155
-        $cols_n_values['CNT_active'] = isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_active'])
1156
-            ? absint($this->_req_data['cntry'][ $CNT_ISO ]['CNT_active'])
1157
-            : false;
1158
-        // allow filtering of country data
1159
-        $cols_n_values = apply_filters(
1160
-            'FHEE__General_Settings_Admin_Page___update_country_settings__cols_n_values',
1161
-            $cols_n_values
1162
-        );
1163
-
1164
-        // where values
1165
-        $where_cols_n_values = array(array('CNT_ISO' => $CNT_ISO));
1166
-        // run the update
1167
-        $success = EEM_Country::instance()->update($cols_n_values, $where_cols_n_values);
1168
-
1169
-        if (isset($this->_req_data['states']) && is_array($this->_req_data['states']) && $success !== false) {
1170
-            // allow filtering of states data
1171
-            $states = apply_filters(
1172
-                'FHEE__General_Settings_Admin_Page___update_country_settings__states',
1173
-                $this->_req_data['states']
1174
-            );
1175
-
1176
-            // loop thru state data ( looks like : states[75][STA_name] )
1177
-            foreach ($states as $STA_ID => $state) {
1178
-                $cols_n_values = array(
1179
-                    'CNT_ISO'    => $CNT_ISO,
1180
-                    'STA_abbrev' => sanitize_text_field($state['STA_abbrev']),
1181
-                    'STA_name'   => sanitize_text_field($state['STA_name']),
1182
-                    'STA_active' => (bool) absint($state['STA_active']),
1183
-                );
1184
-                // where values
1185
-                $where_cols_n_values = array(array('STA_ID' => $STA_ID));
1186
-                // run the update
1187
-                $success = EEM_State::instance()->update($cols_n_values, $where_cols_n_values);
1188
-                if ($success !== false) {
1189
-                    do_action(
1190
-                        'AHEE__General_Settings_Admin_Page__update_country_settings__state_saved',
1191
-                        $CNT_ISO,
1192
-                        $STA_ID,
1193
-                        $cols_n_values
1194
-                    );
1195
-                }
1196
-            }
1197
-        }
1198
-        // check if country being edited matches org option country, and if so, then  update EE_Config with new settings
1199
-        if (isset(EE_Registry::instance()->CFG->organization->CNT_ISO)
1200
-            && $CNT_ISO == EE_Registry::instance()->CFG->organization->CNT_ISO
1201
-        ) {
1202
-            EE_Registry::instance()->CFG->currency = new EE_Currency_Config($CNT_ISO);
1203
-            EE_Registry::instance()->CFG->update_espresso_config();
1204
-        }
1205
-
1206
-        if ($success !== false) {
1207
-            EE_Error::add_success(
1208
-                esc_html__('Country Settings updated successfully.', 'event_espresso')
1209
-            );
1210
-        }
1211
-        $this->_redirect_after_action(
1212
-            $success,
1213
-            '',
1214
-            '',
1215
-            array('action' => 'country_settings', 'country' => $CNT_ISO),
1216
-            true
1217
-        );
1218
-    }
1219
-
1220
-
1221
-    /**
1222
-     *        form_form_field_label_wrap
1223
-     *
1224
-     * @access        public
1225
-     * @param        string $label
1226
-     * @return        string
1227
-     */
1228
-    public function country_form_field_label_wrap($label, $required_text)
1229
-    {
1230
-        return '
23
+	/**
24
+	 * _question_group
25
+	 * holds the specific question group object for the question group details screen
26
+	 *
27
+	 * @var object
28
+	 */
29
+	protected $_question_group;
30
+
31
+
32
+	/**
33
+	 * Initialize basic properties.
34
+	 */
35
+	protected function _init_page_props()
36
+	{
37
+		$this->page_slug = GEN_SET_PG_SLUG;
38
+		$this->page_label = GEN_SET_LABEL;
39
+		$this->_admin_base_url = GEN_SET_ADMIN_URL;
40
+		$this->_admin_base_path = GEN_SET_ADMIN;
41
+	}
42
+
43
+
44
+	/**
45
+	 * Set ajax hooks
46
+	 */
47
+	protected function _ajax_hooks()
48
+	{
49
+		add_action('wp_ajax_espresso_display_country_settings', array($this, 'display_country_settings'));
50
+		add_action('wp_ajax_espresso_display_country_states', array($this, 'display_country_states'));
51
+		add_action('wp_ajax_espresso_delete_state', array($this, 'delete_state'), 10, 3);
52
+		add_action('wp_ajax_espresso_add_new_state', array($this, 'add_new_state'));
53
+	}
54
+
55
+
56
+	/**
57
+	 * More page properties initialization.
58
+	 */
59
+	protected function _define_page_props()
60
+	{
61
+		$this->_admin_page_title = GEN_SET_LABEL;
62
+		$this->_labels = array(
63
+			'publishbox' => __('Update Settings', 'event_espresso'),
64
+		);
65
+	}
66
+
67
+
68
+	/**
69
+	 * Set page routes property.
70
+	 */
71
+	protected function _set_page_routes()
72
+	{
73
+		$this->_page_routes = array(
74
+
75
+			'critical_pages'                => array(
76
+				'func'       => '_espresso_page_settings',
77
+				'capability' => 'manage_options',
78
+			),
79
+			'update_espresso_page_settings' => array(
80
+				'func'       => '_update_espresso_page_settings',
81
+				'capability' => 'manage_options',
82
+				'noheader'   => true,
83
+			),
84
+			'default'                       => array(
85
+				'func'       => '_your_organization_settings',
86
+				'capability' => 'manage_options',
87
+			),
88
+
89
+			'update_your_organization_settings' => array(
90
+				'func'       => '_update_your_organization_settings',
91
+				'capability' => 'manage_options',
92
+				'noheader'   => true,
93
+			),
94
+
95
+			'admin_option_settings' => array(
96
+				'func'       => '_admin_option_settings',
97
+				'capability' => 'manage_options',
98
+			),
99
+
100
+			'update_admin_option_settings' => array(
101
+				'func'       => '_update_admin_option_settings',
102
+				'capability' => 'manage_options',
103
+				'noheader'   => true,
104
+			),
105
+
106
+			'country_settings' => array(
107
+				'func'       => '_country_settings',
108
+				'capability' => 'manage_options',
109
+			),
110
+
111
+			'update_country_settings' => array(
112
+				'func'       => '_update_country_settings',
113
+				'capability' => 'manage_options',
114
+				'noheader'   => true,
115
+			),
116
+
117
+			'display_country_settings' => array(
118
+				'func'       => 'display_country_settings',
119
+				'capability' => 'manage_options',
120
+				'noheader'   => true,
121
+			),
122
+
123
+			'add_new_state' => array(
124
+				'func'       => 'add_new_state',
125
+				'capability' => 'manage_options',
126
+				'noheader'   => true,
127
+			),
128
+
129
+			'delete_state'            => array(
130
+				'func'       => 'delete_state',
131
+				'capability' => 'manage_options',
132
+				'noheader'   => true,
133
+			),
134
+			'privacy_settings'        => array(
135
+				'func'       => 'privacySettings',
136
+				'capability' => 'manage_options',
137
+			),
138
+			'update_privacy_settings' => array(
139
+				'func'               => 'updatePrivacySettings',
140
+				'capability'         => 'manage_options',
141
+				'noheader'           => true,
142
+				'headers_sent_route' => 'privacy_settings',
143
+			),
144
+		);
145
+	}
146
+
147
+
148
+	/**
149
+	 * Set page configuration property
150
+	 */
151
+	protected function _set_page_config()
152
+	{
153
+		$this->_page_config = array(
154
+			'critical_pages'        => array(
155
+				'nav'           => array(
156
+					'label' => __('Critical Pages', 'event_espresso'),
157
+					'order' => 50,
158
+				),
159
+				'metaboxes'     => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')),
160
+				'help_tabs'     => array(
161
+					'general_settings_critical_pages_help_tab' => array(
162
+						'title'    => __('Critical Pages', 'event_espresso'),
163
+						'filename' => 'general_settings_critical_pages',
164
+					),
165
+				),
166
+				'help_tour'     => array('Critical_Pages_Help_Tour'),
167
+				'require_nonce' => false,
168
+			),
169
+			'default'               => array(
170
+				'nav'           => array(
171
+					'label' => __('Your Organization', 'event_espresso'),
172
+					'order' => 20,
173
+				),
174
+				'help_tabs'     => array(
175
+					'general_settings_your_organization_help_tab' => array(
176
+						'title'    => __('Your Organization', 'event_espresso'),
177
+						'filename' => 'general_settings_your_organization',
178
+					),
179
+				),
180
+				'help_tour'     => array('Your_Organization_Help_Tour'),
181
+				'metaboxes'     => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')),
182
+				'require_nonce' => false,
183
+			),
184
+			'admin_option_settings' => array(
185
+				'nav'           => array(
186
+					'label' => __('Admin Options', 'event_espresso'),
187
+					'order' => 60,
188
+				),
189
+				'metaboxes'     => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')),
190
+				'help_tabs'     => array(
191
+					'general_settings_admin_options_help_tab' => array(
192
+						'title'    => __('Admin Options', 'event_espresso'),
193
+						'filename' => 'general_settings_admin_options',
194
+					),
195
+				),
196
+				'help_tour'     => array('Admin_Options_Help_Tour'),
197
+				'require_nonce' => false,
198
+			),
199
+			'country_settings'      => array(
200
+				'nav'           => array(
201
+					'label' => __('Countries', 'event_espresso'),
202
+					'order' => 70,
203
+				),
204
+				'help_tabs'     => array(
205
+					'general_settings_countries_help_tab' => array(
206
+						'title'    => __('Countries', 'event_espresso'),
207
+						'filename' => 'general_settings_countries',
208
+					),
209
+				),
210
+				'help_tour'     => array('Countries_Help_Tour'),
211
+				'require_nonce' => false,
212
+			),
213
+			'privacy_settings'      => array(
214
+				'nav'           => array(
215
+					'label' => esc_html__('Privacy', 'event_espresso'),
216
+					'order' => 80,
217
+				),
218
+				'metaboxes'     => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')),
219
+				'require_nonce' => false,
220
+			),
221
+		);
222
+	}
223
+
224
+
225
+	protected function _add_screen_options()
226
+	{
227
+	}
228
+
229
+
230
+	protected function _add_feature_pointers()
231
+	{
232
+	}
233
+
234
+
235
+	/**
236
+	 * Enqueue global scripts and styles for all routes in the General Settings Admin Pages.
237
+	 */
238
+	public function load_scripts_styles()
239
+	{
240
+		// styles
241
+		wp_enqueue_style('espresso-ui-theme');
242
+		// scripts
243
+		wp_enqueue_script('ee_admin_js');
244
+	}
245
+
246
+
247
+	/**
248
+	 * Execute logic running on `admin_init`
249
+	 */
250
+	public function admin_init()
251
+	{
252
+		EE_Registry::$i18n_js_strings['invalid_server_response'] = __(
253
+			'An error occurred! Your request may have been processed, but a valid response from the server was not received. Please refresh the page and try again.',
254
+			'event_espresso'
255
+		);
256
+		EE_Registry::$i18n_js_strings['error_occurred'] = __(
257
+			'An error occurred! Please refresh the page and try again.',
258
+			'event_espresso'
259
+		);
260
+		EE_Registry::$i18n_js_strings['confirm_delete_state'] = __(
261
+			'Are you sure you want to delete this State / Province?',
262
+			'event_espresso'
263
+		);
264
+		$protocol = isset($_SERVER['HTTPS']) ? 'https://' : 'http://';
265
+		EE_Registry::$i18n_js_strings['ajax_url'] = admin_url(
266
+			'admin-ajax.php?page=espresso_general_settings',
267
+			$protocol
268
+		);
269
+	}
270
+
271
+
272
+	public function admin_notices()
273
+	{
274
+	}
275
+
276
+
277
+	public function admin_footer_scripts()
278
+	{
279
+	}
280
+
281
+
282
+	/**
283
+	 * Enqueue scripts and styles for the default route.
284
+	 */
285
+	public function load_scripts_styles_default()
286
+	{
287
+		// styles
288
+		wp_enqueue_style('thickbox');
289
+		// scripts
290
+		wp_enqueue_script('media-upload');
291
+		wp_enqueue_script('thickbox');
292
+		wp_register_script(
293
+			'organization_settings',
294
+			GEN_SET_ASSETS_URL . 'your_organization_settings.js',
295
+			array('jquery', 'media-upload', 'thickbox'),
296
+			EVENT_ESPRESSO_VERSION,
297
+			true
298
+		);
299
+		wp_register_style('organization-css', GEN_SET_ASSETS_URL . 'organization.css', array(), EVENT_ESPRESSO_VERSION);
300
+		wp_enqueue_script('organization_settings');
301
+		wp_enqueue_style('organization-css');
302
+		$confirm_image_delete = array(
303
+			'text' => __(
304
+				'Do you really want to delete this image? Please remember to save your settings to complete the removal.',
305
+				'event_espresso'
306
+			),
307
+		);
308
+		wp_localize_script('organization_settings', 'confirm_image_delete', $confirm_image_delete);
309
+	}
310
+
311
+
312
+	/**
313
+	 * Enqueue scripts and styles for the country settings route.
314
+	 */
315
+	public function load_scripts_styles_country_settings()
316
+	{
317
+		// scripts
318
+		wp_register_script(
319
+			'gen_settings_countries',
320
+			GEN_SET_ASSETS_URL . 'gen_settings_countries.js',
321
+			array('ee_admin_js'),
322
+			EVENT_ESPRESSO_VERSION,
323
+			true
324
+		);
325
+		wp_register_style('organization-css', GEN_SET_ASSETS_URL . 'organization.css', array(), EVENT_ESPRESSO_VERSION);
326
+		wp_enqueue_script('gen_settings_countries');
327
+		wp_enqueue_style('organization-css');
328
+	}
329
+
330
+
331
+	/*************        Espresso Pages        *************/
332
+	/**
333
+	 * _espresso_page_settings
334
+	 *
335
+	 * @throws \EE_Error
336
+	 * @throws DomainException
337
+	 * @throws DomainException
338
+	 * @throws InvalidDataTypeException
339
+	 * @throws InvalidArgumentException
340
+	 */
341
+	protected function _espresso_page_settings()
342
+	{
343
+		// Check to make sure all of the main pages are setup properly,
344
+		// if not create the default pages and display an admin notice
345
+		EEH_Activation::verify_default_pages_exist();
346
+		$this->_transient_garbage_collection();
347
+		$this->_template_args['values'] = $this->_yes_no_values;
348
+		$this->_template_args['reg_page_id'] = isset(EE_Registry::instance()->CFG->core->reg_page_id)
349
+			? EE_Registry::instance()->CFG->core->reg_page_id
350
+			: null;
351
+		$this->_template_args['reg_page_obj'] = isset(EE_Registry::instance()->CFG->core->reg_page_id)
352
+			? get_page(EE_Registry::instance()->CFG->core->reg_page_id)
353
+			: false;
354
+		$this->_template_args['txn_page_id'] = isset(EE_Registry::instance()->CFG->core->txn_page_id)
355
+			? EE_Registry::instance()->CFG->core->txn_page_id
356
+			: null;
357
+		$this->_template_args['txn_page_obj'] = isset(EE_Registry::instance()->CFG->core->txn_page_id)
358
+			? get_page(EE_Registry::instance()->CFG->core->txn_page_id)
359
+			: false;
360
+		$this->_template_args['thank_you_page_id'] = isset(EE_Registry::instance()->CFG->core->thank_you_page_id)
361
+			? EE_Registry::instance()->CFG->core->thank_you_page_id
362
+			: null;
363
+		$this->_template_args['thank_you_page_obj'] = isset(EE_Registry::instance()->CFG->core->thank_you_page_id)
364
+			? get_page(EE_Registry::instance()->CFG->core->thank_you_page_id)
365
+			: false;
366
+		$this->_template_args['cancel_page_id'] = isset(EE_Registry::instance()->CFG->core->cancel_page_id)
367
+			? EE_Registry::instance()->CFG->core->cancel_page_id
368
+			: null;
369
+		$this->_template_args['cancel_page_obj'] = isset(EE_Registry::instance()->CFG->core->cancel_page_id)
370
+			? get_page(EE_Registry::instance()->CFG->core->cancel_page_id)
371
+			: false;
372
+		$this->_set_add_edit_form_tags('update_espresso_page_settings');
373
+		$this->_set_publish_post_box_vars(null, false, false, null, false);
374
+		$this->_template_args['admin_page_content'] = EEH_Template::display_template(
375
+			GEN_SET_TEMPLATE_PATH . 'espresso_page_settings.template.php',
376
+			$this->_template_args,
377
+			true
378
+		);
379
+		$this->display_admin_page_with_sidebar();
380
+	}
381
+
382
+
383
+	/**
384
+	 * Handler for updating espresso page settings.
385
+	 *
386
+	 * @throws EE_Error
387
+	 */
388
+	protected function _update_espresso_page_settings()
389
+	{
390
+		// capture incoming request data && set page IDs
391
+		EE_Registry::instance()->CFG->core->reg_page_id = isset($this->_req_data['reg_page_id'])
392
+			? absint($this->_req_data['reg_page_id'])
393
+			: EE_Registry::instance()->CFG->core->reg_page_id;
394
+		EE_Registry::instance()->CFG->core->txn_page_id = isset($this->_req_data['txn_page_id'])
395
+			? absint($this->_req_data['txn_page_id'])
396
+			: EE_Registry::instance()->CFG->core->txn_page_id;
397
+		EE_Registry::instance()->CFG->core->thank_you_page_id = isset($this->_req_data['thank_you_page_id'])
398
+			? absint($this->_req_data['thank_you_page_id'])
399
+			: EE_Registry::instance()->CFG->core->thank_you_page_id;
400
+		EE_Registry::instance()->CFG->core->cancel_page_id = isset($this->_req_data['cancel_page_id'])
401
+			? absint($this->_req_data['cancel_page_id'])
402
+			: EE_Registry::instance()->CFG->core->cancel_page_id;
403
+
404
+		EE_Registry::instance()->CFG->core = apply_filters(
405
+			'FHEE__General_Settings_Admin_Page___update_espresso_page_settings__CFG_core',
406
+			EE_Registry::instance()->CFG->core,
407
+			$this->_req_data
408
+		);
409
+		$what = __('Critical Pages & Shortcodes', 'event_espresso');
410
+		$this->_redirect_after_action(
411
+			$this->_update_espresso_configuration(
412
+				$what,
413
+				EE_Registry::instance()->CFG->core,
414
+				__FILE__,
415
+				__FUNCTION__,
416
+				__LINE__
417
+			),
418
+			$what,
419
+			'',
420
+			array(
421
+				'action' => 'critical_pages',
422
+			),
423
+			true
424
+		);
425
+	}
426
+
427
+
428
+	/*************        Your Organization        *************/
429
+
430
+
431
+	/**
432
+	 * @throws DomainException
433
+	 * @throws EE_Error
434
+	 * @throws InvalidArgumentException
435
+	 * @throws InvalidDataTypeException
436
+	 * @throws InvalidInterfaceException
437
+	 */
438
+	protected function _your_organization_settings()
439
+	{
440
+		$this->_template_args['admin_page_content'] = '';
441
+		try {
442
+			/** @var EventEspresso\admin_pages\general_settings\OrganizationSettings $organization_settings_form */
443
+			$organization_settings_form = $this->loader->getShared(
444
+				'EventEspresso\admin_pages\general_settings\OrganizationSettings'
445
+			);
446
+			$this->_template_args['admin_page_content'] = $organization_settings_form->display();
447
+		} catch (Exception $e) {
448
+			EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__);
449
+		}
450
+		$this->_set_add_edit_form_tags('update_your_organization_settings');
451
+		$this->_set_publish_post_box_vars(null, false, false, null, false);
452
+		$this->display_admin_page_with_sidebar();
453
+	}
454
+
455
+
456
+	/**
457
+	 * Handler for updating organization settings.
458
+	 *
459
+	 * @throws EE_Error
460
+	 */
461
+	protected function _update_your_organization_settings()
462
+	{
463
+		try {
464
+			/** @var EventEspresso\admin_pages\general_settings\OrganizationSettings $organization_settings_form */
465
+			$organization_settings_form = $this->loader->getShared(
466
+				'EventEspresso\admin_pages\general_settings\OrganizationSettings'
467
+			);
468
+			$success = $organization_settings_form->process($this->_req_data);
469
+			EE_Registry::instance()->CFG = apply_filters(
470
+				'FHEE__General_Settings_Admin_Page___update_your_organization_settings__CFG',
471
+				EE_Registry::instance()->CFG
472
+			);
473
+		} catch (Exception $e) {
474
+			EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__);
475
+			$success = false;
476
+		}
477
+
478
+		if ($success) {
479
+			$success = $this->_update_espresso_configuration(
480
+				esc_html__('Your Organization Settings', 'event_espresso'),
481
+				EE_Registry::instance()->CFG,
482
+				__FILE__,
483
+				__FUNCTION__,
484
+				__LINE__
485
+			);
486
+		}
487
+
488
+		$this->_redirect_after_action($success, '', '', array('action' => 'default'), true);
489
+	}
490
+
491
+
492
+
493
+	/*************        Admin Options        *************/
494
+
495
+
496
+	/**
497
+	 * _admin_option_settings
498
+	 *
499
+	 * @throws \EE_Error
500
+	 * @throws \LogicException
501
+	 */
502
+	protected function _admin_option_settings()
503
+	{
504
+		$this->_template_args['admin_page_content'] = '';
505
+		try {
506
+			$admin_options_settings_form = new AdminOptionsSettings(EE_Registry::instance());
507
+			// still need this for the old school form in Extend_General_Settings_Admin_Page
508
+			$this->_template_args['values'] = $this->_yes_no_values;
509
+			// also need to account for the do_action that was in the old template
510
+			$admin_options_settings_form->setTemplateArgs($this->_template_args);
511
+			$this->_template_args['admin_page_content'] = $admin_options_settings_form->display();
512
+		} catch (Exception $e) {
513
+			EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__);
514
+		}
515
+		$this->_set_add_edit_form_tags('update_admin_option_settings');
516
+		$this->_set_publish_post_box_vars(null, false, false, null, false);
517
+		$this->display_admin_page_with_sidebar();
518
+	}
519
+
520
+
521
+	/**
522
+	 * _update_admin_option_settings
523
+	 *
524
+	 * @throws \EE_Error
525
+	 * @throws InvalidDataTypeException
526
+	 * @throws \EventEspresso\core\exceptions\InvalidFormSubmissionException
527
+	 * @throws \InvalidArgumentException
528
+	 * @throws \LogicException
529
+	 */
530
+	protected function _update_admin_option_settings()
531
+	{
532
+		try {
533
+			$admin_options_settings_form = new AdminOptionsSettings(EE_Registry::instance());
534
+			$admin_options_settings_form->process($this->_req_data[ $admin_options_settings_form->slug() ]);
535
+			EE_Registry::instance()->CFG->admin = apply_filters(
536
+				'FHEE__General_Settings_Admin_Page___update_admin_option_settings__CFG_admin',
537
+				EE_Registry::instance()->CFG->admin
538
+			);
539
+		} catch (Exception $e) {
540
+			EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__);
541
+		}
542
+		$this->_redirect_after_action(
543
+			apply_filters(
544
+				'FHEE__General_Settings_Admin_Page___update_admin_option_settings__success',
545
+				$this->_update_espresso_configuration(
546
+					'Admin Options',
547
+					EE_Registry::instance()->CFG->admin,
548
+					__FILE__,
549
+					__FUNCTION__,
550
+					__LINE__
551
+				)
552
+			),
553
+			'Admin Options',
554
+			'updated',
555
+			array('action' => 'admin_option_settings')
556
+		);
557
+	}
558
+
559
+
560
+	/*************        Countries        *************/
561
+
562
+
563
+	/**
564
+	 * @return string
565
+	 */
566
+	protected function getCountryIsoForSite()
567
+	{
568
+		return ! empty(EE_Registry::instance()->CFG->organization->CNT_ISO)
569
+			? EE_Registry::instance()->CFG->organization->CNT_ISO
570
+			: 'US';
571
+	}
572
+
573
+
574
+	/**
575
+	 * @param string          $CNT_ISO
576
+	 * @param EE_Country|null $country
577
+	 * @return EE_Base_Class|EE_Country
578
+	 * @throws EE_Error
579
+	 * @throws InvalidArgumentException
580
+	 * @throws InvalidDataTypeException
581
+	 * @throws InvalidInterfaceException
582
+	 * @throws ReflectionException
583
+	 */
584
+	protected function verifyOrGetCountryFromIso($CNT_ISO, EE_Country $country = null)
585
+	{
586
+		/** @var EE_Country $country */
587
+		return $country instanceof EE_Country && $country->ID() === $CNT_ISO
588
+			? $country
589
+			: EEM_Country::instance()->get_one_by_ID($CNT_ISO);
590
+	}
591
+
592
+
593
+	/**
594
+	 * Output Country Settings view.
595
+	 *
596
+	 * @throws DomainException
597
+	 * @throws EE_Error
598
+	 * @throws InvalidArgumentException
599
+	 * @throws InvalidDataTypeException
600
+	 * @throws InvalidInterfaceException
601
+	 * @throws ReflectionException
602
+	 */
603
+	protected function _country_settings()
604
+	{
605
+		$CNT_ISO_for_site = $this->getCountryIsoForSite();
606
+		$CNT_ISO = isset($this->_req_data['country'])
607
+			? strtoupper(sanitize_text_field($this->_req_data['country']))
608
+			: $CNT_ISO_for_site;
609
+
610
+		// load field generator helper
611
+
612
+		$this->_template_args['values'] = $this->_yes_no_values;
613
+
614
+		$this->_template_args['countries'] = new EE_Question_Form_Input(
615
+			EE_Question::new_instance(
616
+				array(
617
+					'QST_ID'           => 0,
618
+					'QST_display_text' => __('Select Country', 'event_espresso'),
619
+					'QST_system'       => 'admin-country',
620
+				)
621
+			),
622
+			EE_Answer::new_instance(
623
+				array(
624
+					'ANS_ID'    => 0,
625
+					'ANS_value' => $CNT_ISO,
626
+				)
627
+			),
628
+			array(
629
+				'input_id'       => 'country',
630
+				'input_name'     => 'country',
631
+				'input_prefix'   => '',
632
+				'append_qstn_id' => false,
633
+			)
634
+		);
635
+		$country = $this->verifyOrGetCountryFromIso($CNT_ISO_for_site);
636
+		add_filter('FHEE__EEH_Form_Fields__label_html', array($this, 'country_form_field_label_wrap'), 10, 2);
637
+		add_filter('FHEE__EEH_Form_Fields__input_html', array($this, 'country_form_field_input__wrap'), 10, 2);
638
+		$this->_template_args['country_details_settings'] = $this->display_country_settings(
639
+			$country->ID(),
640
+			$country
641
+		);
642
+		$this->_template_args['country_states_settings'] = $this->display_country_states(
643
+			$country->ID(),
644
+			$country
645
+		);
646
+		$this->_template_args['CNT_name_for_site'] = $country->name();
647
+
648
+		$this->_set_add_edit_form_tags('update_country_settings');
649
+		$this->_set_publish_post_box_vars(null, false, false, null, false);
650
+		$this->_template_args['admin_page_content'] = EEH_Template::display_template(
651
+			GEN_SET_TEMPLATE_PATH . 'countries_settings.template.php',
652
+			$this->_template_args,
653
+			true
654
+		);
655
+		$this->display_admin_page_with_no_sidebar();
656
+	}
657
+
658
+
659
+	/**
660
+	 *        display_country_settings
661
+	 *
662
+	 * @param string          $CNT_ISO
663
+	 * @param EE_Country|null $country
664
+	 * @return mixed string | array$country
665
+	 * @throws DomainException
666
+	 * @throws EE_Error
667
+	 * @throws InvalidArgumentException
668
+	 * @throws InvalidDataTypeException
669
+	 * @throws InvalidInterfaceException
670
+	 * @throws ReflectionException
671
+	 */
672
+	public function display_country_settings($CNT_ISO = '', EE_Country $country = null)
673
+	{
674
+		$CNT_ISO_for_site = $this->getCountryIsoForSite();
675
+
676
+		$CNT_ISO = isset($this->_req_data['country'])
677
+			? strtoupper(sanitize_text_field($this->_req_data['country']))
678
+			: $CNT_ISO;
679
+		if (! $CNT_ISO) {
680
+			return '';
681
+		}
682
+
683
+		// for ajax
684
+		remove_all_filters('FHEE__EEH_Form_Fields__label_html');
685
+		remove_all_filters('FHEE__EEH_Form_Fields__input_html');
686
+		add_filter('FHEE__EEH_Form_Fields__label_html', array($this, 'country_form_field_label_wrap'), 10, 2);
687
+		add_filter('FHEE__EEH_Form_Fields__input_html', array($this, 'country_form_field_input__wrap'), 10, 2);
688
+		$country = $this->verifyOrGetCountryFromIso($CNT_ISO, $country);
689
+		$CNT_cur_disabled = $CNT_ISO !== $CNT_ISO_for_site;
690
+		$this->_template_args['CNT_cur_disabled'] = $CNT_cur_disabled;
691
+
692
+		$country_input_types = array(
693
+			'CNT_active'      => array(
694
+				'type'             => 'RADIO_BTN',
695
+				'input_name'       => 'cntry[' . $CNT_ISO . ']',
696
+				'class'            => '',
697
+				'options'          => $this->_yes_no_values,
698
+				'use_desc_4_label' => true,
699
+			),
700
+			'CNT_ISO'         => array(
701
+				'type'       => 'TEXT',
702
+				'input_name' => 'cntry[' . $CNT_ISO . ']',
703
+				'class'      => 'small-text',
704
+			),
705
+			'CNT_ISO3'        => array(
706
+				'type'       => 'TEXT',
707
+				'input_name' => 'cntry[' . $CNT_ISO . ']',
708
+				'class'      => 'small-text',
709
+			),
710
+			'RGN_ID'          => array(
711
+				'type'       => 'TEXT',
712
+				'input_name' => 'cntry[' . $CNT_ISO . ']',
713
+				'class'      => 'small-text',
714
+			),
715
+			'CNT_name'        => array(
716
+				'type'       => 'TEXT',
717
+				'input_name' => 'cntry[' . $CNT_ISO . ']',
718
+				'class'      => 'regular-text',
719
+			),
720
+			'CNT_cur_code'    => array(
721
+				'type'       => 'TEXT',
722
+				'input_name' => 'cntry[' . $CNT_ISO . ']',
723
+				'class'      => 'small-text',
724
+				'disabled'   => $CNT_cur_disabled,
725
+			),
726
+			'CNT_cur_single'  => array(
727
+				'type'       => 'TEXT',
728
+				'input_name' => 'cntry[' . $CNT_ISO . ']',
729
+				'class'      => 'medium-text',
730
+				'disabled'   => $CNT_cur_disabled,
731
+			),
732
+			'CNT_cur_plural'  => array(
733
+				'type'       => 'TEXT',
734
+				'input_name' => 'cntry[' . $CNT_ISO . ']',
735
+				'class'      => 'medium-text',
736
+				'disabled'   => $CNT_cur_disabled,
737
+			),
738
+			'CNT_cur_sign'    => array(
739
+				'type'         => 'TEXT',
740
+				'input_name'   => 'cntry[' . $CNT_ISO . ']',
741
+				'class'        => 'small-text',
742
+				'htmlentities' => false,
743
+				'disabled'     => $CNT_cur_disabled,
744
+			),
745
+			'CNT_cur_sign_b4' => array(
746
+				'type'             => 'RADIO_BTN',
747
+				'input_name'       => 'cntry[' . $CNT_ISO . ']',
748
+				'class'            => '',
749
+				'options'          => $this->_yes_no_values,
750
+				'use_desc_4_label' => true,
751
+				'disabled'         => $CNT_cur_disabled,
752
+			),
753
+			'CNT_cur_dec_plc' => array(
754
+				'type'       => 'RADIO_BTN',
755
+				'input_name' => 'cntry[' . $CNT_ISO . ']',
756
+				'class'      => '',
757
+				'options'    => array(
758
+					array('id' => 0, 'text' => ''),
759
+					array('id' => 1, 'text' => ''),
760
+					array('id' => 2, 'text' => ''),
761
+					array('id' => 3, 'text' => ''),
762
+				),
763
+				'disabled'   => $CNT_cur_disabled,
764
+			),
765
+			'CNT_cur_dec_mrk' => array(
766
+				'type'             => 'RADIO_BTN',
767
+				'input_name'       => 'cntry[' . $CNT_ISO . ']',
768
+				'class'            => '',
769
+				'options'          => array(
770
+					array(
771
+						'id'   => ',',
772
+						'text' => __(', (comma)', 'event_espresso'),
773
+					),
774
+					array('id' => '.', 'text' => __('. (decimal)', 'event_espresso')),
775
+				),
776
+				'use_desc_4_label' => true,
777
+				'disabled'         => $CNT_cur_disabled,
778
+			),
779
+			'CNT_cur_thsnds'  => array(
780
+				'type'             => 'RADIO_BTN',
781
+				'input_name'       => 'cntry[' . $CNT_ISO . ']',
782
+				'class'            => '',
783
+				'options'          => array(
784
+					array(
785
+						'id'   => ',',
786
+						'text' => __(', (comma)', 'event_espresso'),
787
+					),
788
+					array('id' => '.', 'text' => __('. (decimal)', 'event_espresso')),
789
+				),
790
+				'use_desc_4_label' => true,
791
+				'disabled'         => $CNT_cur_disabled,
792
+			),
793
+			'CNT_tel_code'    => array(
794
+				'type'       => 'TEXT',
795
+				'input_name' => 'cntry[' . $CNT_ISO . ']',
796
+				'class'      => 'small-text',
797
+			),
798
+			'CNT_is_EU'       => array(
799
+				'type'             => 'RADIO_BTN',
800
+				'input_name'       => 'cntry[' . $CNT_ISO . ']',
801
+				'class'            => '',
802
+				'options'          => $this->_yes_no_values,
803
+				'use_desc_4_label' => true,
804
+			),
805
+		);
806
+		$this->_template_args['inputs'] = EE_Question_Form_Input::generate_question_form_inputs_for_object(
807
+			$country,
808
+			$country_input_types
809
+		);
810
+		$country_details_settings = EEH_Template::display_template(
811
+			GEN_SET_TEMPLATE_PATH . 'country_details_settings.template.php',
812
+			$this->_template_args,
813
+			true
814
+		);
815
+
816
+		if (defined('DOING_AJAX')) {
817
+			$notices = EE_Error::get_notices(false, false, false);
818
+			echo wp_json_encode(
819
+				array(
820
+					'return_data' => $country_details_settings,
821
+					'success'     => $notices['success'],
822
+					'errors'      => $notices['errors'],
823
+				)
824
+			);
825
+			die();
826
+		} else {
827
+			return $country_details_settings;
828
+		}
829
+	}
830
+
831
+
832
+	/**
833
+	 * @param string          $CNT_ISO
834
+	 * @param EE_Country|null $country
835
+	 * @return string
836
+	 * @throws DomainException
837
+	 * @throws EE_Error
838
+	 * @throws InvalidArgumentException
839
+	 * @throws InvalidDataTypeException
840
+	 * @throws InvalidInterfaceException
841
+	 * @throws ReflectionException
842
+	 */
843
+	public function display_country_states($CNT_ISO = '', EE_Country $country = null)
844
+	{
845
+
846
+		$CNT_ISO = isset($this->_req_data['country'])
847
+			? sanitize_text_field($this->_req_data['country'])
848
+			: $CNT_ISO;
849
+		if (! $CNT_ISO) {
850
+			return '';
851
+		}
852
+		// for ajax
853
+		remove_all_filters('FHEE__EEH_Form_Fields__label_html');
854
+		remove_all_filters('FHEE__EEH_Form_Fields__input_html');
855
+		add_filter('FHEE__EEH_Form_Fields__label_html', array($this, 'state_form_field_label_wrap'), 10, 2);
856
+		add_filter('FHEE__EEH_Form_Fields__input_html', array($this, 'state_form_field_input__wrap'), 10, 2);
857
+		$states = EEM_State::instance()->get_all_states_for_these_countries(array($CNT_ISO => $CNT_ISO));
858
+		if (empty($states)) {
859
+			/** @var EventEspresso\core\services\address\CountrySubRegionDao $countrySubRegionDao */
860
+			$countrySubRegionDao = $this->loader->getShared(
861
+				'EventEspresso\core\services\address\CountrySubRegionDao'
862
+			);
863
+			if ($countrySubRegionDao instanceof EventEspresso\core\services\address\CountrySubRegionDao) {
864
+				$country = $this->verifyOrGetCountryFromIso($CNT_ISO, $country);
865
+				if ($countrySubRegionDao->saveCountrySubRegions($country)) {
866
+					$states = EEM_State::instance()->get_all_states_for_these_countries(
867
+						array($CNT_ISO => $CNT_ISO)
868
+					);
869
+				}
870
+			}
871
+		}
872
+		if (is_array($states)) {
873
+			foreach ($states as $STA_ID => $state) {
874
+				if ($state instanceof EE_State) {
875
+					// STA_abbrev    STA_name    STA_active
876
+					$state_input_types = array(
877
+						'STA_abbrev' => array(
878
+							'type'       => 'TEXT',
879
+							'input_name' => 'states[' . $STA_ID . ']',
880
+							'class'      => 'mid-text',
881
+						),
882
+						'STA_name'   => array(
883
+							'type'       => 'TEXT',
884
+							'input_name' => 'states[' . $STA_ID . ']',
885
+							'class'      => 'regular-text',
886
+						),
887
+						'STA_active' => array(
888
+							'type'             => 'RADIO_BTN',
889
+							'input_name'       => 'states[' . $STA_ID . ']',
890
+							'options'          => $this->_yes_no_values,
891
+							'use_desc_4_label' => true,
892
+						),
893
+					);
894
+					$this->_template_args['states'][ $STA_ID ]['inputs'] =
895
+						EE_Question_Form_Input::generate_question_form_inputs_for_object(
896
+							$state,
897
+							$state_input_types
898
+						);
899
+					$query_args = array(
900
+						'action'     => 'delete_state',
901
+						'STA_ID'     => $STA_ID,
902
+						'CNT_ISO'    => $CNT_ISO,
903
+						'STA_abbrev' => $state->abbrev(),
904
+					);
905
+					$this->_template_args['states'][ $STA_ID ]['delete_state_url'] =
906
+						EE_Admin_Page::add_query_args_and_nonce(
907
+							$query_args,
908
+							GEN_SET_ADMIN_URL
909
+						);
910
+				}
911
+			}
912
+		} else {
913
+			$this->_template_args['states'] = false;
914
+		}
915
+
916
+		$this->_template_args['add_new_state_url'] = EE_Admin_Page::add_query_args_and_nonce(
917
+			array('action' => 'add_new_state'),
918
+			GEN_SET_ADMIN_URL
919
+		);
920
+
921
+		$state_details_settings = EEH_Template::display_template(
922
+			GEN_SET_TEMPLATE_PATH . 'state_details_settings.template.php',
923
+			$this->_template_args,
924
+			true
925
+		);
926
+
927
+		if (defined('DOING_AJAX')) {
928
+			$notices = EE_Error::get_notices(false, false, false);
929
+			echo wp_json_encode(
930
+				array(
931
+					'return_data' => $state_details_settings,
932
+					'success'     => $notices['success'],
933
+					'errors'      => $notices['errors'],
934
+				)
935
+			);
936
+			die();
937
+		} else {
938
+			return $state_details_settings;
939
+		}
940
+	}
941
+
942
+
943
+	/**
944
+	 *        add_new_state
945
+	 *
946
+	 * @access    public
947
+	 * @return void
948
+	 * @throws EE_Error
949
+	 * @throws InvalidArgumentException
950
+	 * @throws InvalidDataTypeException
951
+	 * @throws InvalidInterfaceException
952
+	 */
953
+	public function add_new_state()
954
+	{
955
+
956
+		$success = true;
957
+
958
+		$CNT_ISO = isset($this->_req_data['CNT_ISO'])
959
+			? strtoupper(sanitize_text_field($this->_req_data['CNT_ISO']))
960
+			: false;
961
+		if (! $CNT_ISO) {
962
+			EE_Error::add_error(
963
+				__('No Country ISO code or an invalid Country ISO code was received.', 'event_espresso'),
964
+				__FILE__,
965
+				__FUNCTION__,
966
+				__LINE__
967
+			);
968
+			$success = false;
969
+		}
970
+		$STA_abbrev = isset($this->_req_data['STA_abbrev'])
971
+			? sanitize_text_field($this->_req_data['STA_abbrev'])
972
+			: false;
973
+		if (! $STA_abbrev) {
974
+			EE_Error::add_error(
975
+				__('No State ISO code or an invalid State ISO code was received.', 'event_espresso'),
976
+				__FILE__,
977
+				__FUNCTION__,
978
+				__LINE__
979
+			);
980
+			$success = false;
981
+		}
982
+		$STA_name = isset($this->_req_data['STA_name'])
983
+			? sanitize_text_field($this->_req_data['STA_name'])
984
+			: false;
985
+		if (! $STA_name) {
986
+			EE_Error::add_error(
987
+				__('No State name or an invalid State name was received.', 'event_espresso'),
988
+				__FILE__,
989
+				__FUNCTION__,
990
+				__LINE__
991
+			);
992
+			$success = false;
993
+		}
994
+
995
+		if ($success) {
996
+			$cols_n_values = array(
997
+				'CNT_ISO'    => $CNT_ISO,
998
+				'STA_abbrev' => $STA_abbrev,
999
+				'STA_name'   => $STA_name,
1000
+				'STA_active' => true,
1001
+			);
1002
+			$success = EEM_State::instance()->insert($cols_n_values);
1003
+			EE_Error::add_success(__('The State was added successfully.', 'event_espresso'));
1004
+		}
1005
+
1006
+		if (defined('DOING_AJAX')) {
1007
+			$notices = EE_Error::get_notices(false, false, false);
1008
+			echo wp_json_encode(array_merge($notices, array('return_data' => $CNT_ISO)));
1009
+			die();
1010
+		} else {
1011
+			$this->_redirect_after_action($success, 'State', 'added', array('action' => 'country_settings'));
1012
+		}
1013
+	}
1014
+
1015
+
1016
+	/**
1017
+	 *        delete_state
1018
+	 *
1019
+	 * @access    public
1020
+	 * @return        boolean
1021
+	 * @throws EE_Error
1022
+	 * @throws InvalidArgumentException
1023
+	 * @throws InvalidDataTypeException
1024
+	 * @throws InvalidInterfaceException
1025
+	 */
1026
+	public function delete_state()
1027
+	{
1028
+		$CNT_ISO = isset($this->_req_data['CNT_ISO'])
1029
+			? strtoupper(sanitize_text_field($this->_req_data['CNT_ISO']))
1030
+			: false;
1031
+		$STA_ID = isset($this->_req_data['STA_ID'])
1032
+			? sanitize_text_field($this->_req_data['STA_ID'])
1033
+			: false;
1034
+		$STA_abbrev = isset($this->_req_data['STA_abbrev'])
1035
+			? sanitize_text_field($this->_req_data['STA_abbrev'])
1036
+			: false;
1037
+		if (! $STA_ID) {
1038
+			EE_Error::add_error(
1039
+				__('No State ID or an invalid State ID was received.', 'event_espresso'),
1040
+				__FILE__,
1041
+				__FUNCTION__,
1042
+				__LINE__
1043
+			);
1044
+			return false;
1045
+		}
1046
+
1047
+		$success = EEM_State::instance()->delete_by_ID($STA_ID);
1048
+		if ($success !== false) {
1049
+			do_action(
1050
+				'AHEE__General_Settings_Admin_Page__delete_state__state_deleted',
1051
+				$CNT_ISO,
1052
+				$STA_ID,
1053
+				array('STA_abbrev' => $STA_abbrev)
1054
+			);
1055
+			EE_Error::add_success(__('The State was deleted successfully.', 'event_espresso'));
1056
+		}
1057
+		if (defined('DOING_AJAX')) {
1058
+			$notices = EE_Error::get_notices(false, false);
1059
+			$notices['return_data'] = true;
1060
+			echo wp_json_encode($notices);
1061
+			die();
1062
+		} else {
1063
+			$this->_redirect_after_action(
1064
+				$success,
1065
+				'State',
1066
+				'deleted',
1067
+				array('action' => 'country_settings')
1068
+			);
1069
+		}
1070
+	}
1071
+
1072
+
1073
+	/**
1074
+	 *        _update_country_settings
1075
+	 *
1076
+	 * @access    protected
1077
+	 * @return void
1078
+	 * @throws EE_Error
1079
+	 * @throws InvalidArgumentException
1080
+	 * @throws InvalidDataTypeException
1081
+	 * @throws InvalidInterfaceException
1082
+	 */
1083
+	protected function _update_country_settings()
1084
+	{
1085
+		// grab the country ISO code
1086
+		$CNT_ISO = isset($this->_req_data['country'])
1087
+			? strtoupper(sanitize_text_field($this->_req_data['country']))
1088
+			: false;
1089
+		if (! $CNT_ISO) {
1090
+			EE_Error::add_error(
1091
+				__('No Country ISO code or an invalid Country ISO code was received.', 'event_espresso'),
1092
+				__FILE__,
1093
+				__FUNCTION__,
1094
+				__LINE__
1095
+			);
1096
+
1097
+			return;
1098
+		}
1099
+		$cols_n_values = array();
1100
+		$cols_n_values['CNT_ISO3'] = isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_ISO3'])
1101
+			? strtoupper(sanitize_text_field($this->_req_data['cntry'][ $CNT_ISO ]['CNT_ISO3']))
1102
+			: false;
1103
+		$cols_n_values['RGN_ID'] = isset($this->_req_data['cntry'][ $CNT_ISO ]['RGN_ID'])
1104
+			? absint($this->_req_data['cntry'][ $CNT_ISO ]['RGN_ID'])
1105
+			: null;
1106
+		$cols_n_values['CNT_name'] = isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_name'])
1107
+			? sanitize_text_field($this->_req_data['cntry'][ $CNT_ISO ]['CNT_name'])
1108
+			: null;
1109
+		if (isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_code'])) {
1110
+			$cols_n_values['CNT_cur_code'] = strtoupper(
1111
+				sanitize_text_field($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_code'])
1112
+			);
1113
+		}
1114
+		if (isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_single'])) {
1115
+			$cols_n_values['CNT_cur_single'] = sanitize_text_field(
1116
+				$this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_single']
1117
+			);
1118
+		}
1119
+		if (isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_plural'])) {
1120
+			$cols_n_values['CNT_cur_plural'] = sanitize_text_field(
1121
+				$this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_plural']
1122
+			);
1123
+		}
1124
+		if (isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_sign'])) {
1125
+			$cols_n_values['CNT_cur_sign'] = sanitize_text_field(
1126
+				$this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_sign']
1127
+			);
1128
+		}
1129
+		if (isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_sign_b4'])) {
1130
+			$cols_n_values['CNT_cur_sign_b4'] = absint(
1131
+				$this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_sign_b4']
1132
+			);
1133
+		}
1134
+		if (isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_dec_plc'])) {
1135
+			$cols_n_values['CNT_cur_dec_plc'] = absint(
1136
+				$this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_dec_plc']
1137
+			);
1138
+		}
1139
+		if (isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_dec_mrk'])) {
1140
+			$cols_n_values['CNT_cur_dec_mrk'] = sanitize_text_field(
1141
+				$this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_dec_mrk']
1142
+			);
1143
+		}
1144
+		if (isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_thsnds'])) {
1145
+			$cols_n_values['CNT_cur_thsnds'] = sanitize_text_field(
1146
+				$this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_thsnds']
1147
+			);
1148
+		}
1149
+		$cols_n_values['CNT_tel_code'] = isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_tel_code'])
1150
+			? sanitize_text_field($this->_req_data['cntry'][ $CNT_ISO ]['CNT_tel_code'])
1151
+			: null;
1152
+		$cols_n_values['CNT_is_EU'] = isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_is_EU'])
1153
+			? absint($this->_req_data['cntry'][ $CNT_ISO ]['CNT_is_EU'])
1154
+			: false;
1155
+		$cols_n_values['CNT_active'] = isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_active'])
1156
+			? absint($this->_req_data['cntry'][ $CNT_ISO ]['CNT_active'])
1157
+			: false;
1158
+		// allow filtering of country data
1159
+		$cols_n_values = apply_filters(
1160
+			'FHEE__General_Settings_Admin_Page___update_country_settings__cols_n_values',
1161
+			$cols_n_values
1162
+		);
1163
+
1164
+		// where values
1165
+		$where_cols_n_values = array(array('CNT_ISO' => $CNT_ISO));
1166
+		// run the update
1167
+		$success = EEM_Country::instance()->update($cols_n_values, $where_cols_n_values);
1168
+
1169
+		if (isset($this->_req_data['states']) && is_array($this->_req_data['states']) && $success !== false) {
1170
+			// allow filtering of states data
1171
+			$states = apply_filters(
1172
+				'FHEE__General_Settings_Admin_Page___update_country_settings__states',
1173
+				$this->_req_data['states']
1174
+			);
1175
+
1176
+			// loop thru state data ( looks like : states[75][STA_name] )
1177
+			foreach ($states as $STA_ID => $state) {
1178
+				$cols_n_values = array(
1179
+					'CNT_ISO'    => $CNT_ISO,
1180
+					'STA_abbrev' => sanitize_text_field($state['STA_abbrev']),
1181
+					'STA_name'   => sanitize_text_field($state['STA_name']),
1182
+					'STA_active' => (bool) absint($state['STA_active']),
1183
+				);
1184
+				// where values
1185
+				$where_cols_n_values = array(array('STA_ID' => $STA_ID));
1186
+				// run the update
1187
+				$success = EEM_State::instance()->update($cols_n_values, $where_cols_n_values);
1188
+				if ($success !== false) {
1189
+					do_action(
1190
+						'AHEE__General_Settings_Admin_Page__update_country_settings__state_saved',
1191
+						$CNT_ISO,
1192
+						$STA_ID,
1193
+						$cols_n_values
1194
+					);
1195
+				}
1196
+			}
1197
+		}
1198
+		// check if country being edited matches org option country, and if so, then  update EE_Config with new settings
1199
+		if (isset(EE_Registry::instance()->CFG->organization->CNT_ISO)
1200
+			&& $CNT_ISO == EE_Registry::instance()->CFG->organization->CNT_ISO
1201
+		) {
1202
+			EE_Registry::instance()->CFG->currency = new EE_Currency_Config($CNT_ISO);
1203
+			EE_Registry::instance()->CFG->update_espresso_config();
1204
+		}
1205
+
1206
+		if ($success !== false) {
1207
+			EE_Error::add_success(
1208
+				esc_html__('Country Settings updated successfully.', 'event_espresso')
1209
+			);
1210
+		}
1211
+		$this->_redirect_after_action(
1212
+			$success,
1213
+			'',
1214
+			'',
1215
+			array('action' => 'country_settings', 'country' => $CNT_ISO),
1216
+			true
1217
+		);
1218
+	}
1219
+
1220
+
1221
+	/**
1222
+	 *        form_form_field_label_wrap
1223
+	 *
1224
+	 * @access        public
1225
+	 * @param        string $label
1226
+	 * @return        string
1227
+	 */
1228
+	public function country_form_field_label_wrap($label, $required_text)
1229
+	{
1230
+		return '
1231 1231
 			<tr>
1232 1232
 				<th>
1233 1233
 					' . $label . '
1234 1234
 				</th>';
1235
-    }
1236
-
1237
-
1238
-    /**
1239
-     *        form_form_field_input__wrap
1240
-     *
1241
-     * @access        public
1242
-     * @param        string $label
1243
-     * @return        string
1244
-     */
1245
-    public function country_form_field_input__wrap($input, $label)
1246
-    {
1247
-        return '
1235
+	}
1236
+
1237
+
1238
+	/**
1239
+	 *        form_form_field_input__wrap
1240
+	 *
1241
+	 * @access        public
1242
+	 * @param        string $label
1243
+	 * @return        string
1244
+	 */
1245
+	public function country_form_field_input__wrap($input, $label)
1246
+	{
1247
+		return '
1248 1248
 				<td class="general-settings-country-input-td">
1249 1249
 					' . $input . '
1250 1250
 				</td>
1251 1251
 			</tr>';
1252
-    }
1253
-
1254
-
1255
-    /**
1256
-     *        form_form_field_label_wrap
1257
-     *
1258
-     * @access        public
1259
-     * @param        string $label
1260
-     * @param        string $required_text
1261
-     * @return        string
1262
-     */
1263
-    public function state_form_field_label_wrap($label, $required_text)
1264
-    {
1265
-        return $required_text;
1266
-    }
1267
-
1268
-
1269
-    /**
1270
-     *        form_form_field_input__wrap
1271
-     *
1272
-     * @access        public
1273
-     * @param        string $label
1274
-     * @return        string
1275
-     */
1276
-    public function state_form_field_input__wrap($input, $label)
1277
-    {
1278
-        return '
1252
+	}
1253
+
1254
+
1255
+	/**
1256
+	 *        form_form_field_label_wrap
1257
+	 *
1258
+	 * @access        public
1259
+	 * @param        string $label
1260
+	 * @param        string $required_text
1261
+	 * @return        string
1262
+	 */
1263
+	public function state_form_field_label_wrap($label, $required_text)
1264
+	{
1265
+		return $required_text;
1266
+	}
1267
+
1268
+
1269
+	/**
1270
+	 *        form_form_field_input__wrap
1271
+	 *
1272
+	 * @access        public
1273
+	 * @param        string $label
1274
+	 * @return        string
1275
+	 */
1276
+	public function state_form_field_input__wrap($input, $label)
1277
+	{
1278
+		return '
1279 1279
 				<td class="general-settings-country-state-input-td">
1280 1280
 					' . $input . '
1281 1281
 				</td>';
1282
-    }
1283
-
1284
-
1285
-    /***********/
1286
-
1287
-
1288
-    /**
1289
-     * displays edit and view links for critical EE pages
1290
-     *
1291
-     * @access public
1292
-     * @param int $ee_page_id
1293
-     * @return string
1294
-     */
1295
-    public static function edit_view_links($ee_page_id)
1296
-    {
1297
-        $links = '<a href="'
1298
-                 . add_query_arg(
1299
-                     array('post' => $ee_page_id, 'action' => 'edit'),
1300
-                     admin_url('post.php')
1301
-                 )
1302
-                 . '" >'
1303
-                 . __('Edit', 'event_espresso')
1304
-                 . '</a>';
1305
-        $links .= ' &nbsp;|&nbsp; ';
1306
-        $links .= '<a href="' . get_permalink($ee_page_id) . '" >' . __('View', 'event_espresso') . '</a>';
1307
-
1308
-        return $links;
1309
-    }
1310
-
1311
-
1312
-    /**
1313
-     * displays page and shortcode status for critical EE pages
1314
-     *
1315
-     * @param WP page object $ee_page
1316
-     * @return string
1317
-     */
1318
-    public static function page_and_shortcode_status($ee_page, $shortcode)
1319
-    {
1320
-
1321
-        // page status
1322
-        if (isset($ee_page->post_status) && $ee_page->post_status == 'publish') {
1323
-            $pg_colour = 'green';
1324
-            $pg_status = sprintf(__('Page%sStatus%sOK', 'event_espresso'), '&nbsp;', '&nbsp;');
1325
-        } else {
1326
-            $pg_colour = 'red';
1327
-            $pg_status = sprintf(__('Page%sVisibility%sProblem', 'event_espresso'), '&nbsp;', '&nbsp;');
1328
-        }
1329
-
1330
-        // shortcode status
1331
-        if (isset($ee_page->post_content) && strpos($ee_page->post_content, $shortcode) !== false) {
1332
-            $sc_colour = 'green';
1333
-            $sc_status = sprintf(__('Shortcode%sOK', 'event_espresso'), '&nbsp;');
1334
-        } else {
1335
-            $sc_colour = 'red';
1336
-            $sc_status = sprintf(__('Shortcode%sProblem', 'event_espresso'), '&nbsp;');
1337
-        }
1338
-
1339
-        return '<span style="color:' . $pg_colour . '; margin-right:2em;"><strong>'
1340
-               . $pg_status
1341
-               . '</strong></span><span style="color:' . $sc_colour . '"><strong>' . $sc_status . '</strong></span>';
1342
-    }
1343
-
1344
-
1345
-    /**
1346
-     * generates a dropdown of all parent pages - copied from WP core
1347
-     *
1348
-     * @param int $default
1349
-     * @param int $parent
1350
-     * @param int $level
1351
-     */
1352
-    public static function page_settings_dropdown($default = 0, $parent = 0, $level = 0)
1353
-    {
1354
-        global $wpdb;
1355
-        $items = $wpdb->get_results(
1356
-            $wpdb->prepare(
1357
-                "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",
1358
-                $parent
1359
-            )
1360
-        );
1361
-
1362
-        if ($items) {
1363
-            foreach ($items as $item) {
1364
-                $pad = str_repeat('&nbsp;', $level * 3);
1365
-                if ($item->ID == $default) {
1366
-                    $current = ' selected="selected"';
1367
-                } else {
1368
-                    $current = '';
1369
-                }
1370
-
1371
-                echo "\n\t<option class='level-$level' value='$item->ID'$current>$pad "
1372
-                     . esc_html($item->post_title)
1373
-                     . "</option>";
1374
-                parent_dropdown($default, $item->ID, $level + 1);
1375
-            }
1376
-        }
1377
-    }
1378
-
1379
-
1380
-    /**
1381
-     * Loads the scripts for the privacy settings form
1382
-     */
1383
-    public function load_scripts_styles_privacy_settings()
1384
-    {
1385
-        $form_handler = $this->loader->getShared('EventEspresso\core\domain\services\admin\privacy\forms\PrivacySettingsFormHandler');
1386
-        $form_handler->enqueueStylesAndScripts();
1387
-    }
1388
-
1389
-
1390
-    /**
1391
-     * display the privacy settings form
1392
-     */
1393
-    public function privacySettings()
1394
-    {
1395
-        $this->_set_add_edit_form_tags('update_privacy_settings');
1396
-        $this->_set_publish_post_box_vars(null, false, false, null, false);
1397
-        $form_handler = $this->loader->getShared('EventEspresso\core\domain\services\admin\privacy\forms\PrivacySettingsFormHandler');
1398
-        $this->_template_args['admin_page_content'] = $form_handler->display();
1399
-        $this->display_admin_page_with_sidebar();
1400
-    }
1401
-
1402
-
1403
-    /**
1404
-     * Update the privacy settings from form data
1405
-     *
1406
-     * @throws EE_Error
1407
-     */
1408
-    public function updatePrivacySettings()
1409
-    {
1410
-        $form_handler = $this->loader->getShared('EventEspresso\core\domain\services\admin\privacy\forms\PrivacySettingsFormHandler');
1411
-        $success = $form_handler->process($this->get_request_data());
1412
-        $this->_redirect_after_action(
1413
-            $success,
1414
-            esc_html__('Registration Form Options', 'event_espresso'),
1415
-            'updated',
1416
-            array('action' => 'privacy_settings')
1417
-        );
1418
-    }
1282
+	}
1283
+
1284
+
1285
+	/***********/
1286
+
1287
+
1288
+	/**
1289
+	 * displays edit and view links for critical EE pages
1290
+	 *
1291
+	 * @access public
1292
+	 * @param int $ee_page_id
1293
+	 * @return string
1294
+	 */
1295
+	public static function edit_view_links($ee_page_id)
1296
+	{
1297
+		$links = '<a href="'
1298
+				 . add_query_arg(
1299
+					 array('post' => $ee_page_id, 'action' => 'edit'),
1300
+					 admin_url('post.php')
1301
+				 )
1302
+				 . '" >'
1303
+				 . __('Edit', 'event_espresso')
1304
+				 . '</a>';
1305
+		$links .= ' &nbsp;|&nbsp; ';
1306
+		$links .= '<a href="' . get_permalink($ee_page_id) . '" >' . __('View', 'event_espresso') . '</a>';
1307
+
1308
+		return $links;
1309
+	}
1310
+
1311
+
1312
+	/**
1313
+	 * displays page and shortcode status for critical EE pages
1314
+	 *
1315
+	 * @param WP page object $ee_page
1316
+	 * @return string
1317
+	 */
1318
+	public static function page_and_shortcode_status($ee_page, $shortcode)
1319
+	{
1320
+
1321
+		// page status
1322
+		if (isset($ee_page->post_status) && $ee_page->post_status == 'publish') {
1323
+			$pg_colour = 'green';
1324
+			$pg_status = sprintf(__('Page%sStatus%sOK', 'event_espresso'), '&nbsp;', '&nbsp;');
1325
+		} else {
1326
+			$pg_colour = 'red';
1327
+			$pg_status = sprintf(__('Page%sVisibility%sProblem', 'event_espresso'), '&nbsp;', '&nbsp;');
1328
+		}
1329
+
1330
+		// shortcode status
1331
+		if (isset($ee_page->post_content) && strpos($ee_page->post_content, $shortcode) !== false) {
1332
+			$sc_colour = 'green';
1333
+			$sc_status = sprintf(__('Shortcode%sOK', 'event_espresso'), '&nbsp;');
1334
+		} else {
1335
+			$sc_colour = 'red';
1336
+			$sc_status = sprintf(__('Shortcode%sProblem', 'event_espresso'), '&nbsp;');
1337
+		}
1338
+
1339
+		return '<span style="color:' . $pg_colour . '; margin-right:2em;"><strong>'
1340
+			   . $pg_status
1341
+			   . '</strong></span><span style="color:' . $sc_colour . '"><strong>' . $sc_status . '</strong></span>';
1342
+	}
1343
+
1344
+
1345
+	/**
1346
+	 * generates a dropdown of all parent pages - copied from WP core
1347
+	 *
1348
+	 * @param int $default
1349
+	 * @param int $parent
1350
+	 * @param int $level
1351
+	 */
1352
+	public static function page_settings_dropdown($default = 0, $parent = 0, $level = 0)
1353
+	{
1354
+		global $wpdb;
1355
+		$items = $wpdb->get_results(
1356
+			$wpdb->prepare(
1357
+				"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",
1358
+				$parent
1359
+			)
1360
+		);
1361
+
1362
+		if ($items) {
1363
+			foreach ($items as $item) {
1364
+				$pad = str_repeat('&nbsp;', $level * 3);
1365
+				if ($item->ID == $default) {
1366
+					$current = ' selected="selected"';
1367
+				} else {
1368
+					$current = '';
1369
+				}
1370
+
1371
+				echo "\n\t<option class='level-$level' value='$item->ID'$current>$pad "
1372
+					 . esc_html($item->post_title)
1373
+					 . "</option>";
1374
+				parent_dropdown($default, $item->ID, $level + 1);
1375
+			}
1376
+		}
1377
+	}
1378
+
1379
+
1380
+	/**
1381
+	 * Loads the scripts for the privacy settings form
1382
+	 */
1383
+	public function load_scripts_styles_privacy_settings()
1384
+	{
1385
+		$form_handler = $this->loader->getShared('EventEspresso\core\domain\services\admin\privacy\forms\PrivacySettingsFormHandler');
1386
+		$form_handler->enqueueStylesAndScripts();
1387
+	}
1388
+
1389
+
1390
+	/**
1391
+	 * display the privacy settings form
1392
+	 */
1393
+	public function privacySettings()
1394
+	{
1395
+		$this->_set_add_edit_form_tags('update_privacy_settings');
1396
+		$this->_set_publish_post_box_vars(null, false, false, null, false);
1397
+		$form_handler = $this->loader->getShared('EventEspresso\core\domain\services\admin\privacy\forms\PrivacySettingsFormHandler');
1398
+		$this->_template_args['admin_page_content'] = $form_handler->display();
1399
+		$this->display_admin_page_with_sidebar();
1400
+	}
1401
+
1402
+
1403
+	/**
1404
+	 * Update the privacy settings from form data
1405
+	 *
1406
+	 * @throws EE_Error
1407
+	 */
1408
+	public function updatePrivacySettings()
1409
+	{
1410
+		$form_handler = $this->loader->getShared('EventEspresso\core\domain\services\admin\privacy\forms\PrivacySettingsFormHandler');
1411
+		$success = $form_handler->process($this->get_request_data());
1412
+		$this->_redirect_after_action(
1413
+			$success,
1414
+			esc_html__('Registration Form Options', 'event_espresso'),
1415
+			'updated',
1416
+			array('action' => 'privacy_settings')
1417
+		);
1418
+	}
1419 1419
 }
Please login to merge, or discard this patch.
Spacing   +70 added lines, -70 removed lines patch added patch discarded remove patch
@@ -291,12 +291,12 @@  discard block
 block discarded – undo
291 291
         wp_enqueue_script('thickbox');
292 292
         wp_register_script(
293 293
             'organization_settings',
294
-            GEN_SET_ASSETS_URL . 'your_organization_settings.js',
294
+            GEN_SET_ASSETS_URL.'your_organization_settings.js',
295 295
             array('jquery', 'media-upload', 'thickbox'),
296 296
             EVENT_ESPRESSO_VERSION,
297 297
             true
298 298
         );
299
-        wp_register_style('organization-css', GEN_SET_ASSETS_URL . 'organization.css', array(), EVENT_ESPRESSO_VERSION);
299
+        wp_register_style('organization-css', GEN_SET_ASSETS_URL.'organization.css', array(), EVENT_ESPRESSO_VERSION);
300 300
         wp_enqueue_script('organization_settings');
301 301
         wp_enqueue_style('organization-css');
302 302
         $confirm_image_delete = array(
@@ -317,12 +317,12 @@  discard block
 block discarded – undo
317 317
         // scripts
318 318
         wp_register_script(
319 319
             'gen_settings_countries',
320
-            GEN_SET_ASSETS_URL . 'gen_settings_countries.js',
320
+            GEN_SET_ASSETS_URL.'gen_settings_countries.js',
321 321
             array('ee_admin_js'),
322 322
             EVENT_ESPRESSO_VERSION,
323 323
             true
324 324
         );
325
-        wp_register_style('organization-css', GEN_SET_ASSETS_URL . 'organization.css', array(), EVENT_ESPRESSO_VERSION);
325
+        wp_register_style('organization-css', GEN_SET_ASSETS_URL.'organization.css', array(), EVENT_ESPRESSO_VERSION);
326 326
         wp_enqueue_script('gen_settings_countries');
327 327
         wp_enqueue_style('organization-css');
328 328
     }
@@ -372,7 +372,7 @@  discard block
 block discarded – undo
372 372
         $this->_set_add_edit_form_tags('update_espresso_page_settings');
373 373
         $this->_set_publish_post_box_vars(null, false, false, null, false);
374 374
         $this->_template_args['admin_page_content'] = EEH_Template::display_template(
375
-            GEN_SET_TEMPLATE_PATH . 'espresso_page_settings.template.php',
375
+            GEN_SET_TEMPLATE_PATH.'espresso_page_settings.template.php',
376 376
             $this->_template_args,
377 377
             true
378 378
         );
@@ -531,7 +531,7 @@  discard block
 block discarded – undo
531 531
     {
532 532
         try {
533 533
             $admin_options_settings_form = new AdminOptionsSettings(EE_Registry::instance());
534
-            $admin_options_settings_form->process($this->_req_data[ $admin_options_settings_form->slug() ]);
534
+            $admin_options_settings_form->process($this->_req_data[$admin_options_settings_form->slug()]);
535 535
             EE_Registry::instance()->CFG->admin = apply_filters(
536 536
                 'FHEE__General_Settings_Admin_Page___update_admin_option_settings__CFG_admin',
537 537
                 EE_Registry::instance()->CFG->admin
@@ -648,7 +648,7 @@  discard block
 block discarded – undo
648 648
         $this->_set_add_edit_form_tags('update_country_settings');
649 649
         $this->_set_publish_post_box_vars(null, false, false, null, false);
650 650
         $this->_template_args['admin_page_content'] = EEH_Template::display_template(
651
-            GEN_SET_TEMPLATE_PATH . 'countries_settings.template.php',
651
+            GEN_SET_TEMPLATE_PATH.'countries_settings.template.php',
652 652
             $this->_template_args,
653 653
             true
654 654
         );
@@ -676,7 +676,7 @@  discard block
 block discarded – undo
676 676
         $CNT_ISO = isset($this->_req_data['country'])
677 677
             ? strtoupper(sanitize_text_field($this->_req_data['country']))
678 678
             : $CNT_ISO;
679
-        if (! $CNT_ISO) {
679
+        if ( ! $CNT_ISO) {
680 680
             return '';
681 681
         }
682 682
 
@@ -692,59 +692,59 @@  discard block
 block discarded – undo
692 692
         $country_input_types = array(
693 693
             'CNT_active'      => array(
694 694
                 'type'             => 'RADIO_BTN',
695
-                'input_name'       => 'cntry[' . $CNT_ISO . ']',
695
+                'input_name'       => 'cntry['.$CNT_ISO.']',
696 696
                 'class'            => '',
697 697
                 'options'          => $this->_yes_no_values,
698 698
                 'use_desc_4_label' => true,
699 699
             ),
700 700
             'CNT_ISO'         => array(
701 701
                 'type'       => 'TEXT',
702
-                'input_name' => 'cntry[' . $CNT_ISO . ']',
702
+                'input_name' => 'cntry['.$CNT_ISO.']',
703 703
                 'class'      => 'small-text',
704 704
             ),
705 705
             'CNT_ISO3'        => array(
706 706
                 'type'       => 'TEXT',
707
-                'input_name' => 'cntry[' . $CNT_ISO . ']',
707
+                'input_name' => 'cntry['.$CNT_ISO.']',
708 708
                 'class'      => 'small-text',
709 709
             ),
710 710
             'RGN_ID'          => array(
711 711
                 'type'       => 'TEXT',
712
-                'input_name' => 'cntry[' . $CNT_ISO . ']',
712
+                'input_name' => 'cntry['.$CNT_ISO.']',
713 713
                 'class'      => 'small-text',
714 714
             ),
715 715
             'CNT_name'        => array(
716 716
                 'type'       => 'TEXT',
717
-                'input_name' => 'cntry[' . $CNT_ISO . ']',
717
+                'input_name' => 'cntry['.$CNT_ISO.']',
718 718
                 'class'      => 'regular-text',
719 719
             ),
720 720
             'CNT_cur_code'    => array(
721 721
                 'type'       => 'TEXT',
722
-                'input_name' => 'cntry[' . $CNT_ISO . ']',
722
+                'input_name' => 'cntry['.$CNT_ISO.']',
723 723
                 'class'      => 'small-text',
724 724
                 'disabled'   => $CNT_cur_disabled,
725 725
             ),
726 726
             'CNT_cur_single'  => array(
727 727
                 'type'       => 'TEXT',
728
-                'input_name' => 'cntry[' . $CNT_ISO . ']',
728
+                'input_name' => 'cntry['.$CNT_ISO.']',
729 729
                 'class'      => 'medium-text',
730 730
                 'disabled'   => $CNT_cur_disabled,
731 731
             ),
732 732
             'CNT_cur_plural'  => array(
733 733
                 'type'       => 'TEXT',
734
-                'input_name' => 'cntry[' . $CNT_ISO . ']',
734
+                'input_name' => 'cntry['.$CNT_ISO.']',
735 735
                 'class'      => 'medium-text',
736 736
                 'disabled'   => $CNT_cur_disabled,
737 737
             ),
738 738
             'CNT_cur_sign'    => array(
739 739
                 'type'         => 'TEXT',
740
-                'input_name'   => 'cntry[' . $CNT_ISO . ']',
740
+                'input_name'   => 'cntry['.$CNT_ISO.']',
741 741
                 'class'        => 'small-text',
742 742
                 'htmlentities' => false,
743 743
                 'disabled'     => $CNT_cur_disabled,
744 744
             ),
745 745
             'CNT_cur_sign_b4' => array(
746 746
                 'type'             => 'RADIO_BTN',
747
-                'input_name'       => 'cntry[' . $CNT_ISO . ']',
747
+                'input_name'       => 'cntry['.$CNT_ISO.']',
748 748
                 'class'            => '',
749 749
                 'options'          => $this->_yes_no_values,
750 750
                 'use_desc_4_label' => true,
@@ -752,7 +752,7 @@  discard block
 block discarded – undo
752 752
             ),
753 753
             'CNT_cur_dec_plc' => array(
754 754
                 'type'       => 'RADIO_BTN',
755
-                'input_name' => 'cntry[' . $CNT_ISO . ']',
755
+                'input_name' => 'cntry['.$CNT_ISO.']',
756 756
                 'class'      => '',
757 757
                 'options'    => array(
758 758
                     array('id' => 0, 'text' => ''),
@@ -764,7 +764,7 @@  discard block
 block discarded – undo
764 764
             ),
765 765
             'CNT_cur_dec_mrk' => array(
766 766
                 'type'             => 'RADIO_BTN',
767
-                'input_name'       => 'cntry[' . $CNT_ISO . ']',
767
+                'input_name'       => 'cntry['.$CNT_ISO.']',
768 768
                 'class'            => '',
769 769
                 'options'          => array(
770 770
                     array(
@@ -778,7 +778,7 @@  discard block
 block discarded – undo
778 778
             ),
779 779
             'CNT_cur_thsnds'  => array(
780 780
                 'type'             => 'RADIO_BTN',
781
-                'input_name'       => 'cntry[' . $CNT_ISO . ']',
781
+                'input_name'       => 'cntry['.$CNT_ISO.']',
782 782
                 'class'            => '',
783 783
                 'options'          => array(
784 784
                     array(
@@ -792,12 +792,12 @@  discard block
 block discarded – undo
792 792
             ),
793 793
             'CNT_tel_code'    => array(
794 794
                 'type'       => 'TEXT',
795
-                'input_name' => 'cntry[' . $CNT_ISO . ']',
795
+                'input_name' => 'cntry['.$CNT_ISO.']',
796 796
                 'class'      => 'small-text',
797 797
             ),
798 798
             'CNT_is_EU'       => array(
799 799
                 'type'             => 'RADIO_BTN',
800
-                'input_name'       => 'cntry[' . $CNT_ISO . ']',
800
+                'input_name'       => 'cntry['.$CNT_ISO.']',
801 801
                 'class'            => '',
802 802
                 'options'          => $this->_yes_no_values,
803 803
                 'use_desc_4_label' => true,
@@ -808,7 +808,7 @@  discard block
 block discarded – undo
808 808
             $country_input_types
809 809
         );
810 810
         $country_details_settings = EEH_Template::display_template(
811
-            GEN_SET_TEMPLATE_PATH . 'country_details_settings.template.php',
811
+            GEN_SET_TEMPLATE_PATH.'country_details_settings.template.php',
812 812
             $this->_template_args,
813 813
             true
814 814
         );
@@ -846,7 +846,7 @@  discard block
 block discarded – undo
846 846
         $CNT_ISO = isset($this->_req_data['country'])
847 847
             ? sanitize_text_field($this->_req_data['country'])
848 848
             : $CNT_ISO;
849
-        if (! $CNT_ISO) {
849
+        if ( ! $CNT_ISO) {
850 850
             return '';
851 851
         }
852 852
         // for ajax
@@ -876,22 +876,22 @@  discard block
 block discarded – undo
876 876
                     $state_input_types = array(
877 877
                         'STA_abbrev' => array(
878 878
                             'type'       => 'TEXT',
879
-                            'input_name' => 'states[' . $STA_ID . ']',
879
+                            'input_name' => 'states['.$STA_ID.']',
880 880
                             'class'      => 'mid-text',
881 881
                         ),
882 882
                         'STA_name'   => array(
883 883
                             'type'       => 'TEXT',
884
-                            'input_name' => 'states[' . $STA_ID . ']',
884
+                            'input_name' => 'states['.$STA_ID.']',
885 885
                             'class'      => 'regular-text',
886 886
                         ),
887 887
                         'STA_active' => array(
888 888
                             'type'             => 'RADIO_BTN',
889
-                            'input_name'       => 'states[' . $STA_ID . ']',
889
+                            'input_name'       => 'states['.$STA_ID.']',
890 890
                             'options'          => $this->_yes_no_values,
891 891
                             'use_desc_4_label' => true,
892 892
                         ),
893 893
                     );
894
-                    $this->_template_args['states'][ $STA_ID ]['inputs'] =
894
+                    $this->_template_args['states'][$STA_ID]['inputs'] =
895 895
                         EE_Question_Form_Input::generate_question_form_inputs_for_object(
896 896
                             $state,
897 897
                             $state_input_types
@@ -902,7 +902,7 @@  discard block
 block discarded – undo
902 902
                         'CNT_ISO'    => $CNT_ISO,
903 903
                         'STA_abbrev' => $state->abbrev(),
904 904
                     );
905
-                    $this->_template_args['states'][ $STA_ID ]['delete_state_url'] =
905
+                    $this->_template_args['states'][$STA_ID]['delete_state_url'] =
906 906
                         EE_Admin_Page::add_query_args_and_nonce(
907 907
                             $query_args,
908 908
                             GEN_SET_ADMIN_URL
@@ -919,7 +919,7 @@  discard block
 block discarded – undo
919 919
         );
920 920
 
921 921
         $state_details_settings = EEH_Template::display_template(
922
-            GEN_SET_TEMPLATE_PATH . 'state_details_settings.template.php',
922
+            GEN_SET_TEMPLATE_PATH.'state_details_settings.template.php',
923 923
             $this->_template_args,
924 924
             true
925 925
         );
@@ -958,7 +958,7 @@  discard block
 block discarded – undo
958 958
         $CNT_ISO = isset($this->_req_data['CNT_ISO'])
959 959
             ? strtoupper(sanitize_text_field($this->_req_data['CNT_ISO']))
960 960
             : false;
961
-        if (! $CNT_ISO) {
961
+        if ( ! $CNT_ISO) {
962 962
             EE_Error::add_error(
963 963
                 __('No Country ISO code or an invalid Country ISO code was received.', 'event_espresso'),
964 964
                 __FILE__,
@@ -970,7 +970,7 @@  discard block
 block discarded – undo
970 970
         $STA_abbrev = isset($this->_req_data['STA_abbrev'])
971 971
             ? sanitize_text_field($this->_req_data['STA_abbrev'])
972 972
             : false;
973
-        if (! $STA_abbrev) {
973
+        if ( ! $STA_abbrev) {
974 974
             EE_Error::add_error(
975 975
                 __('No State ISO code or an invalid State ISO code was received.', 'event_espresso'),
976 976
                 __FILE__,
@@ -982,7 +982,7 @@  discard block
 block discarded – undo
982 982
         $STA_name = isset($this->_req_data['STA_name'])
983 983
             ? sanitize_text_field($this->_req_data['STA_name'])
984 984
             : false;
985
-        if (! $STA_name) {
985
+        if ( ! $STA_name) {
986 986
             EE_Error::add_error(
987 987
                 __('No State name or an invalid State name was received.', 'event_espresso'),
988 988
                 __FILE__,
@@ -1034,7 +1034,7 @@  discard block
 block discarded – undo
1034 1034
         $STA_abbrev = isset($this->_req_data['STA_abbrev'])
1035 1035
             ? sanitize_text_field($this->_req_data['STA_abbrev'])
1036 1036
             : false;
1037
-        if (! $STA_ID) {
1037
+        if ( ! $STA_ID) {
1038 1038
             EE_Error::add_error(
1039 1039
                 __('No State ID or an invalid State ID was received.', 'event_espresso'),
1040 1040
                 __FILE__,
@@ -1086,7 +1086,7 @@  discard block
 block discarded – undo
1086 1086
         $CNT_ISO = isset($this->_req_data['country'])
1087 1087
             ? strtoupper(sanitize_text_field($this->_req_data['country']))
1088 1088
             : false;
1089
-        if (! $CNT_ISO) {
1089
+        if ( ! $CNT_ISO) {
1090 1090
             EE_Error::add_error(
1091 1091
                 __('No Country ISO code or an invalid Country ISO code was received.', 'event_espresso'),
1092 1092
                 __FILE__,
@@ -1097,63 +1097,63 @@  discard block
 block discarded – undo
1097 1097
             return;
1098 1098
         }
1099 1099
         $cols_n_values = array();
1100
-        $cols_n_values['CNT_ISO3'] = isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_ISO3'])
1101
-            ? strtoupper(sanitize_text_field($this->_req_data['cntry'][ $CNT_ISO ]['CNT_ISO3']))
1100
+        $cols_n_values['CNT_ISO3'] = isset($this->_req_data['cntry'][$CNT_ISO]['CNT_ISO3'])
1101
+            ? strtoupper(sanitize_text_field($this->_req_data['cntry'][$CNT_ISO]['CNT_ISO3']))
1102 1102
             : false;
1103
-        $cols_n_values['RGN_ID'] = isset($this->_req_data['cntry'][ $CNT_ISO ]['RGN_ID'])
1104
-            ? absint($this->_req_data['cntry'][ $CNT_ISO ]['RGN_ID'])
1103
+        $cols_n_values['RGN_ID'] = isset($this->_req_data['cntry'][$CNT_ISO]['RGN_ID'])
1104
+            ? absint($this->_req_data['cntry'][$CNT_ISO]['RGN_ID'])
1105 1105
             : null;
1106
-        $cols_n_values['CNT_name'] = isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_name'])
1107
-            ? sanitize_text_field($this->_req_data['cntry'][ $CNT_ISO ]['CNT_name'])
1106
+        $cols_n_values['CNT_name'] = isset($this->_req_data['cntry'][$CNT_ISO]['CNT_name'])
1107
+            ? sanitize_text_field($this->_req_data['cntry'][$CNT_ISO]['CNT_name'])
1108 1108
             : null;
1109
-        if (isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_code'])) {
1109
+        if (isset($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_code'])) {
1110 1110
             $cols_n_values['CNT_cur_code'] = strtoupper(
1111
-                sanitize_text_field($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_code'])
1111
+                sanitize_text_field($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_code'])
1112 1112
             );
1113 1113
         }
1114
-        if (isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_single'])) {
1114
+        if (isset($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_single'])) {
1115 1115
             $cols_n_values['CNT_cur_single'] = sanitize_text_field(
1116
-                $this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_single']
1116
+                $this->_req_data['cntry'][$CNT_ISO]['CNT_cur_single']
1117 1117
             );
1118 1118
         }
1119
-        if (isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_plural'])) {
1119
+        if (isset($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_plural'])) {
1120 1120
             $cols_n_values['CNT_cur_plural'] = sanitize_text_field(
1121
-                $this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_plural']
1121
+                $this->_req_data['cntry'][$CNT_ISO]['CNT_cur_plural']
1122 1122
             );
1123 1123
         }
1124
-        if (isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_sign'])) {
1124
+        if (isset($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_sign'])) {
1125 1125
             $cols_n_values['CNT_cur_sign'] = sanitize_text_field(
1126
-                $this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_sign']
1126
+                $this->_req_data['cntry'][$CNT_ISO]['CNT_cur_sign']
1127 1127
             );
1128 1128
         }
1129
-        if (isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_sign_b4'])) {
1129
+        if (isset($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_sign_b4'])) {
1130 1130
             $cols_n_values['CNT_cur_sign_b4'] = absint(
1131
-                $this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_sign_b4']
1131
+                $this->_req_data['cntry'][$CNT_ISO]['CNT_cur_sign_b4']
1132 1132
             );
1133 1133
         }
1134
-        if (isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_dec_plc'])) {
1134
+        if (isset($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_dec_plc'])) {
1135 1135
             $cols_n_values['CNT_cur_dec_plc'] = absint(
1136
-                $this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_dec_plc']
1136
+                $this->_req_data['cntry'][$CNT_ISO]['CNT_cur_dec_plc']
1137 1137
             );
1138 1138
         }
1139
-        if (isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_dec_mrk'])) {
1139
+        if (isset($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_dec_mrk'])) {
1140 1140
             $cols_n_values['CNT_cur_dec_mrk'] = sanitize_text_field(
1141
-                $this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_dec_mrk']
1141
+                $this->_req_data['cntry'][$CNT_ISO]['CNT_cur_dec_mrk']
1142 1142
             );
1143 1143
         }
1144
-        if (isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_thsnds'])) {
1144
+        if (isset($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_thsnds'])) {
1145 1145
             $cols_n_values['CNT_cur_thsnds'] = sanitize_text_field(
1146
-                $this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_thsnds']
1146
+                $this->_req_data['cntry'][$CNT_ISO]['CNT_cur_thsnds']
1147 1147
             );
1148 1148
         }
1149
-        $cols_n_values['CNT_tel_code'] = isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_tel_code'])
1150
-            ? sanitize_text_field($this->_req_data['cntry'][ $CNT_ISO ]['CNT_tel_code'])
1149
+        $cols_n_values['CNT_tel_code'] = isset($this->_req_data['cntry'][$CNT_ISO]['CNT_tel_code'])
1150
+            ? sanitize_text_field($this->_req_data['cntry'][$CNT_ISO]['CNT_tel_code'])
1151 1151
             : null;
1152
-        $cols_n_values['CNT_is_EU'] = isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_is_EU'])
1153
-            ? absint($this->_req_data['cntry'][ $CNT_ISO ]['CNT_is_EU'])
1152
+        $cols_n_values['CNT_is_EU'] = isset($this->_req_data['cntry'][$CNT_ISO]['CNT_is_EU'])
1153
+            ? absint($this->_req_data['cntry'][$CNT_ISO]['CNT_is_EU'])
1154 1154
             : false;
1155
-        $cols_n_values['CNT_active'] = isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_active'])
1156
-            ? absint($this->_req_data['cntry'][ $CNT_ISO ]['CNT_active'])
1155
+        $cols_n_values['CNT_active'] = isset($this->_req_data['cntry'][$CNT_ISO]['CNT_active'])
1156
+            ? absint($this->_req_data['cntry'][$CNT_ISO]['CNT_active'])
1157 1157
             : false;
1158 1158
         // allow filtering of country data
1159 1159
         $cols_n_values = apply_filters(
@@ -1230,7 +1230,7 @@  discard block
 block discarded – undo
1230 1230
         return '
1231 1231
 			<tr>
1232 1232
 				<th>
1233
-					' . $label . '
1233
+					' . $label.'
1234 1234
 				</th>';
1235 1235
     }
1236 1236
 
@@ -1246,7 +1246,7 @@  discard block
 block discarded – undo
1246 1246
     {
1247 1247
         return '
1248 1248
 				<td class="general-settings-country-input-td">
1249
-					' . $input . '
1249
+					' . $input.'
1250 1250
 				</td>
1251 1251
 			</tr>';
1252 1252
     }
@@ -1277,7 +1277,7 @@  discard block
 block discarded – undo
1277 1277
     {
1278 1278
         return '
1279 1279
 				<td class="general-settings-country-state-input-td">
1280
-					' . $input . '
1280
+					' . $input.'
1281 1281
 				</td>';
1282 1282
     }
1283 1283
 
@@ -1303,7 +1303,7 @@  discard block
 block discarded – undo
1303 1303
                  . __('Edit', 'event_espresso')
1304 1304
                  . '</a>';
1305 1305
         $links .= ' &nbsp;|&nbsp; ';
1306
-        $links .= '<a href="' . get_permalink($ee_page_id) . '" >' . __('View', 'event_espresso') . '</a>';
1306
+        $links .= '<a href="'.get_permalink($ee_page_id).'" >'.__('View', 'event_espresso').'</a>';
1307 1307
 
1308 1308
         return $links;
1309 1309
     }
@@ -1336,9 +1336,9 @@  discard block
 block discarded – undo
1336 1336
             $sc_status = sprintf(__('Shortcode%sProblem', 'event_espresso'), '&nbsp;');
1337 1337
         }
1338 1338
 
1339
-        return '<span style="color:' . $pg_colour . '; margin-right:2em;"><strong>'
1339
+        return '<span style="color:'.$pg_colour.'; margin-right:2em;"><strong>'
1340 1340
                . $pg_status
1341
-               . '</strong></span><span style="color:' . $sc_colour . '"><strong>' . $sc_status . '</strong></span>';
1341
+               . '</strong></span><span style="color:'.$sc_colour.'"><strong>'.$sc_status.'</strong></span>';
1342 1342
     }
1343 1343
 
1344 1344
 
Please login to merge, or discard this patch.
core/services/validators/JsonValidator.php 2 patches
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -32,19 +32,19 @@  discard block
 block discarded – undo
32 32
      */
33 33
     public function isValid($file, $func, $line)
34 34
     {
35
-        if (! defined('JSON_ERROR_RECURSION')) {
35
+        if ( ! defined('JSON_ERROR_RECURSION')) {
36 36
             define('JSON_ERROR_RECURSION', 6);
37 37
         }
38
-        if (! defined('JSON_ERROR_INF_OR_NAN')) {
38
+        if ( ! defined('JSON_ERROR_INF_OR_NAN')) {
39 39
             define('JSON_ERROR_INF_OR_NAN', 7);
40 40
         }
41
-        if (! defined('JSON_ERROR_UNSUPPORTED_TYPE')) {
41
+        if ( ! defined('JSON_ERROR_UNSUPPORTED_TYPE')) {
42 42
             define('JSON_ERROR_UNSUPPORTED_TYPE', 8);
43 43
         }
44
-        if (! defined('JSON_ERROR_INVALID_PROPERTY_NAME')) {
44
+        if ( ! defined('JSON_ERROR_INVALID_PROPERTY_NAME')) {
45 45
             define('JSON_ERROR_INVALID_PROPERTY_NAME', 9);
46 46
         }
47
-        if (! defined('JSON_ERROR_UTF16')) {
47
+        if ( ! defined('JSON_ERROR_UTF16')) {
48 48
             define('JSON_ERROR_UTF16', 10);
49 49
         }
50 50
         switch (json_last_error()) {
@@ -84,7 +84,7 @@  discard block
 block discarded – undo
84 84
                 $error = ': Unknown error';
85 85
                 break;
86 86
         }
87
-        EE_Error::add_error('JSON decoding failed' . $error, $file, $func, $line);
87
+        EE_Error::add_error('JSON decoding failed'.$error, $file, $func, $line);
88 88
         return false;
89 89
     }
90 90
 }
Please login to merge, or discard this patch.
Indentation   +72 added lines, -72 removed lines patch added patch discarded remove patch
@@ -18,76 +18,76 @@
 block discarded – undo
18 18
 class JsonValidator
19 19
 {
20 20
 
21
-    /**
22
-     * Call this method IMMEDIATELY after json_decode() and
23
-     * it will will return true if the decoded JSON was valid,
24
-     * or return false after adding an error if not valid.
25
-     * The actual JSON file does not need to be supplied,
26
-     * but details re: code execution location are required.
27
-     * ex:
28
-     * JsonValidator::isValid(__FILE__, __METHOD__, __LINE__)
29
-     *
30
-     * @param string $file
31
-     * @param string $func
32
-     * @param string $line
33
-     * @return boolean
34
-     * @since 4.9.70.p
35
-     */
36
-    public function isValid($file, $func, $line)
37
-    {
38
-        if (! defined('JSON_ERROR_RECURSION')) {
39
-            define('JSON_ERROR_RECURSION', 6);
40
-        }
41
-        if (! defined('JSON_ERROR_INF_OR_NAN')) {
42
-            define('JSON_ERROR_INF_OR_NAN', 7);
43
-        }
44
-        if (! defined('JSON_ERROR_UNSUPPORTED_TYPE')) {
45
-            define('JSON_ERROR_UNSUPPORTED_TYPE', 8);
46
-        }
47
-        if (! defined('JSON_ERROR_INVALID_PROPERTY_NAME')) {
48
-            define('JSON_ERROR_INVALID_PROPERTY_NAME', 9);
49
-        }
50
-        if (! defined('JSON_ERROR_UTF16')) {
51
-            define('JSON_ERROR_UTF16', 10);
52
-        }
53
-        switch (json_last_error()) {
54
-            case JSON_ERROR_NONE:
55
-                return true;
56
-            case JSON_ERROR_DEPTH:
57
-                $error = ': Maximum stack depth exceeded';
58
-                break;
59
-            case JSON_ERROR_STATE_MISMATCH:
60
-                $error = ': Invalid or malformed JSON';
61
-                break;
62
-            case JSON_ERROR_CTRL_CHAR:
63
-                $error = ': Control character error, possible malformed JSON';
64
-                break;
65
-            case JSON_ERROR_SYNTAX:
66
-                $error = ': Syntax error, malformed JSON';
67
-                break;
68
-            case JSON_ERROR_UTF8:
69
-                $error = ': Malformed UTF-8 characters, possible malformed JSON';
70
-                break;
71
-            case JSON_ERROR_RECURSION:
72
-                $error = ': One or more recursive references in the value to be encoded';
73
-                break;
74
-            case JSON_ERROR_INF_OR_NAN:
75
-                $error = ': One or more NAN or INF values in the value to be encoded';
76
-                break;
77
-            case JSON_ERROR_UNSUPPORTED_TYPE:
78
-                $error = ': A value of a type that cannot be encoded was given';
79
-                break;
80
-            case JSON_ERROR_INVALID_PROPERTY_NAME:
81
-                $error = ': A property name that cannot be encoded was given';
82
-                break;
83
-            case JSON_ERROR_UTF16:
84
-                $error = ': Malformed UTF-16 characters, possibly incorrectly encoded';
85
-                break;
86
-            default:
87
-                $error = ': Unknown error';
88
-                break;
89
-        }
90
-        EE_Error::add_error('JSON decoding failed' . $error, $file, $func, $line);
91
-        return false;
92
-    }
21
+	/**
22
+	 * Call this method IMMEDIATELY after json_decode() and
23
+	 * it will will return true if the decoded JSON was valid,
24
+	 * or return false after adding an error if not valid.
25
+	 * The actual JSON file does not need to be supplied,
26
+	 * but details re: code execution location are required.
27
+	 * ex:
28
+	 * JsonValidator::isValid(__FILE__, __METHOD__, __LINE__)
29
+	 *
30
+	 * @param string $file
31
+	 * @param string $func
32
+	 * @param string $line
33
+	 * @return boolean
34
+	 * @since 4.9.70.p
35
+	 */
36
+	public function isValid($file, $func, $line)
37
+	{
38
+		if (! defined('JSON_ERROR_RECURSION')) {
39
+			define('JSON_ERROR_RECURSION', 6);
40
+		}
41
+		if (! defined('JSON_ERROR_INF_OR_NAN')) {
42
+			define('JSON_ERROR_INF_OR_NAN', 7);
43
+		}
44
+		if (! defined('JSON_ERROR_UNSUPPORTED_TYPE')) {
45
+			define('JSON_ERROR_UNSUPPORTED_TYPE', 8);
46
+		}
47
+		if (! defined('JSON_ERROR_INVALID_PROPERTY_NAME')) {
48
+			define('JSON_ERROR_INVALID_PROPERTY_NAME', 9);
49
+		}
50
+		if (! defined('JSON_ERROR_UTF16')) {
51
+			define('JSON_ERROR_UTF16', 10);
52
+		}
53
+		switch (json_last_error()) {
54
+			case JSON_ERROR_NONE:
55
+				return true;
56
+			case JSON_ERROR_DEPTH:
57
+				$error = ': Maximum stack depth exceeded';
58
+				break;
59
+			case JSON_ERROR_STATE_MISMATCH:
60
+				$error = ': Invalid or malformed JSON';
61
+				break;
62
+			case JSON_ERROR_CTRL_CHAR:
63
+				$error = ': Control character error, possible malformed JSON';
64
+				break;
65
+			case JSON_ERROR_SYNTAX:
66
+				$error = ': Syntax error, malformed JSON';
67
+				break;
68
+			case JSON_ERROR_UTF8:
69
+				$error = ': Malformed UTF-8 characters, possible malformed JSON';
70
+				break;
71
+			case JSON_ERROR_RECURSION:
72
+				$error = ': One or more recursive references in the value to be encoded';
73
+				break;
74
+			case JSON_ERROR_INF_OR_NAN:
75
+				$error = ': One or more NAN or INF values in the value to be encoded';
76
+				break;
77
+			case JSON_ERROR_UNSUPPORTED_TYPE:
78
+				$error = ': A value of a type that cannot be encoded was given';
79
+				break;
80
+			case JSON_ERROR_INVALID_PROPERTY_NAME:
81
+				$error = ': A property name that cannot be encoded was given';
82
+				break;
83
+			case JSON_ERROR_UTF16:
84
+				$error = ': Malformed UTF-16 characters, possibly incorrectly encoded';
85
+				break;
86
+			default:
87
+				$error = ': Unknown error';
88
+				break;
89
+		}
90
+		EE_Error::add_error('JSON decoding failed' . $error, $file, $func, $line);
91
+		return false;
92
+	}
93 93
 }
Please login to merge, or discard this patch.