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