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