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