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