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