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