1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
use EventEspresso\admin_pages\general_settings\AdminOptionsSettings; |
4
|
|
|
use EventEspresso\admin_pages\general_settings\OrganizationSettings; |
5
|
|
|
use EventEspresso\core\exceptions\InvalidDataTypeException; |
6
|
|
|
use EventEspresso\core\exceptions\InvalidFormSubmissionException; |
7
|
|
|
use EventEspresso\core\exceptions\InvalidInterfaceException; |
8
|
|
|
use EventEspresso\core\services\loaders\LoaderFactory; |
9
|
|
|
|
10
|
|
|
/** |
11
|
|
|
* General_Settings_Admin_Page |
12
|
|
|
* This contains the logic for setting up the Custom General_Settings related pages. Any methods without phpdoc |
13
|
|
|
* comments have inline docs with parent class. |
14
|
|
|
* |
15
|
|
|
* @package General_Settings_Admin_Page |
16
|
|
|
* @subpackage includes/core/admin/general_settings/General_Settings_Admin_Page.core.php |
17
|
|
|
* @author Brent Christensen |
18
|
|
|
* ------------------------------------------------------------------------ |
19
|
|
|
*/ |
20
|
|
|
class General_Settings_Admin_Page extends EE_Admin_Page |
21
|
|
|
{ |
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
|
|
View Code Duplication |
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
|
|
View Code Duplication |
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
|
|
View Code Duplication |
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
|
|
View Code Duplication |
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
|
|
View Code Duplication |
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
|
|
View Code Duplication |
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
|
|
View Code Duplication |
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
|
|
View Code Duplication |
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
|
|
View Code Duplication |
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
|
|
View Code Duplication |
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
|
|
View Code Duplication |
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
|
|
View Code Duplication |
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
|
|
|
<tr> |
1232
|
|
|
<th> |
1233
|
|
|
' . $label . ' |
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 ' |
1248
|
|
|
<td class="general-settings-country-input-td"> |
1249
|
|
|
' . $input . ' |
1250
|
|
|
</td> |
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 ' |
1279
|
|
|
<td class="general-settings-country-state-input-td"> |
1280
|
|
|
' . $input . ' |
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 .= ' | '; |
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'), ' ', ' '); |
1325
|
|
|
} else { |
1326
|
|
|
$pg_colour = 'red'; |
1327
|
|
|
$pg_status = sprintf(__('Page%sVisibility%sProblem', 'event_espresso'), ' ', ' '); |
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'), ' '); |
1334
|
|
|
} else { |
1335
|
|
|
$sc_colour = 'red'; |
1336
|
|
|
$sc_status = sprintf(__('Shortcode%sProblem', 'event_espresso'), ' '); |
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(' ', $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
|
|
View Code Duplication |
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
|
|
|
} |
1420
|
|
|
|
In PHP, under loose comparison (like
==
, or!=
, orswitch
conditions), values of different types might be equal.For
string
values, the empty string''
is a special case, in particular the following results might be unexpected: