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