diff --git a/CHANGELOG.md b/CHANGELOG.md index 8c1dfb371b..70503c27a5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,16 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## Releases +### [5.0.31] + +#### Fixed + - [Add Nonce for Add New State AJAX Requests (#1630)](https://github.com/eventespresso/cafe/pull/1630) + - [PUE Fix - Dont translate plugin data when checking version numbers (#1632)](https://github.com/eventespresso/cafe/pull/1632) + +#### Changed + - [BuildMachine 5.0.30 changes (#1629)](https://github.com/eventespresso/cafe/pull/1629) + - [Set the min required WP User integration version number to be 2.1.3 (#1633)](https://github.com/eventespresso/cafe/pull/1633) + ### [5.0.30] #### Added @@ -33,6 +43,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - [Improve Loco Translate bundle to include both translation filenames (#1626)](https://github.com/eventespresso/cafe/pull/1626) + + + + ### [5.0.29] #### Fixed diff --git a/admin_pages/general_settings/General_Settings_Admin_Page.core.php b/admin_pages/general_settings/General_Settings_Admin_Page.core.php index 85f975bb10..dd2de21177 100644 --- a/admin_pages/general_settings/General_Settings_Admin_Page.core.php +++ b/admin_pages/general_settings/General_Settings_Admin_Page.core.php @@ -107,9 +107,10 @@ protected function _set_page_routes() ], 'update_country_settings' => [ - 'func' => [$this, '_update_country_settings'], - 'capability' => 'manage_options', - 'noheader' => true, + 'func' => [$this, '_update_country_settings'], + 'capability' => 'manage_options', + 'noheader' => true, + 'require_nonce' => true, ], 'display_country_settings' => [ @@ -119,18 +120,20 @@ protected function _set_page_routes() ], 'add_new_state' => [ - 'func' => [$this, 'add_new_state'], - 'capability' => 'manage_options', - 'noheader' => true, + 'func' => [$this, 'add_new_state'], + 'capability' => 'manage_options', + 'noheader' => true, + 'require_nonce' => true, ], - 'delete_state' => [ - 'func' => [$this, 'delete_state'], - 'capability' => 'manage_options', - 'noheader' => true, + 'delete_state' => [ + 'func' => [$this, 'delete_state'], + 'capability' => 'manage_options', + 'noheader' => true, + 'require_nonce' => true, ], - 'privacy_settings' => [ + 'privacy_settings' => [ 'func' => [$this, 'privacySettings'], 'capability' => 'manage_options', ], @@ -921,62 +924,56 @@ public function display_country_states(string $CNT_ISO = '', ?EE_Country $countr } } } - if (is_array($states)) { - foreach ($states as $STA_ID => $state) { - if ($state instanceof EE_State) { - $inputs = EE_Question_Form_Input::generate_question_form_inputs_for_object( - $state, - [ - 'STA_abbrev' => [ - 'type' => 'TEXT', - 'label' => esc_html__('Code', 'event_espresso'), - 'input_name' => "states[$STA_ID]", - 'class' => 'ee-input-width--tiny', - 'add_mobile_label' => true, - ], - 'STA_name' => [ - 'type' => 'TEXT', - 'label' => esc_html__('Name', 'event_espresso'), - 'input_name' => "states[$STA_ID]", - 'class' => 'ee-input-width--big', - 'add_mobile_label' => true, - ], - 'STA_active' => [ - 'type' => 'RADIO_BTN', - 'label' => esc_html__( - 'State Appears in Dropdown Select Lists', - 'event_espresso' - ), - 'input_name' => "states[$STA_ID]", - 'options' => $this->_yes_no_values, - 'use_desc_4_label' => true, - 'add_mobile_label' => true, - ], - ] - ); - - $delete_state_url = EE_Admin_Page::add_query_args_and_nonce( - [ - 'action' => 'delete_state', - 'STA_ID' => $STA_ID, - 'CNT_ISO' => $CNT_ISO, - 'STA_abbrev' => $state->abbrev(), + foreach ($states as $STA_ID => $state) { + if ($state instanceof EE_State) { + $inputs = EE_Question_Form_Input::generate_question_form_inputs_for_object( + $state, + [ + 'STA_abbrev' => [ + 'type' => 'TEXT', + 'label' => esc_html__('Code', 'event_espresso'), + 'input_name' => "states[$STA_ID]", + 'class' => 'ee-input-width--tiny', + 'add_mobile_label' => true, ], - GEN_SET_ADMIN_URL - ); + 'STA_name' => [ + 'type' => 'TEXT', + 'label' => esc_html__('Name', 'event_espresso'), + 'input_name' => "states[$STA_ID]", + 'class' => 'ee-input-width--big', + 'add_mobile_label' => true, + ], + 'STA_active' => [ + 'type' => 'RADIO_BTN', + 'label' => esc_html__( + 'State Appears in Dropdown Select Lists', + 'event_espresso' + ), + 'input_name' => "states[$STA_ID]", + 'options' => $this->_yes_no_values, + 'use_desc_4_label' => true, + 'add_mobile_label' => true, + ], + ] + ); - $this->_template_args['states'][ $STA_ID ]['inputs'] = $inputs; - $this->_template_args['states'][ $STA_ID ]['delete_state_url'] = $delete_state_url; - } + $delete_state_url = EE_Admin_Page::add_query_args_and_nonce( + [ + 'action' => 'delete_state', + 'STA_ID' => $STA_ID, + 'CNT_ISO' => $CNT_ISO, + 'STA_abbrev' => $state->abbrev(), + ], + GEN_SET_ADMIN_URL + ); + + $this->_template_args['states'][ $STA_ID ]['inputs'] = $inputs; + $this->_template_args['states'][ $STA_ID ]['delete_state_url'] = $delete_state_url; } - } else { - $this->_template_args['states'] = false; } - $this->_template_args['add_new_state_url'] = EE_Admin_Page::add_query_args_and_nonce( - ['action' => 'add_new_state'], - GEN_SET_ADMIN_URL - ); + $this->_template_args['add_new_state_nonce'] = wp_create_nonce('espresso_add_new_state'); + $this->_template_args['delete_state_nonce'] = wp_create_nonce('espresso_delete_state'); $state_details_settings = EEH_Template::display_template( GEN_SET_TEMPLATE_PATH . 'state_details_settings.template.php', @@ -1009,6 +1006,8 @@ public function display_country_states(string $CNT_ISO = '', ?EE_Country $countr */ public function add_new_state() { + $this->_verify_nonce(); + // add_new_state_nonce if (! $this->capabilities->current_user_can('manage_options', __FUNCTION__)) { wp_die(esc_html__('You do not have the required privileges to perform this action', 'event_espresso')); } @@ -1080,6 +1079,7 @@ public function add_new_state() */ public function delete_state() { + $this->_verify_nonce(); if (! $this->capabilities->current_user_can('manage_options', __FUNCTION__)) { wp_die(esc_html__('You do not have the required privileges to perform this action', 'event_espresso')); } diff --git a/admin_pages/general_settings/assets/gen_settings_countries.js b/admin_pages/general_settings/assets/gen_settings_countries.js index 4bdabab03c..7ef1e8b42b 100644 --- a/admin_pages/general_settings/assets/gen_settings_countries.js +++ b/admin_pages/general_settings/assets/gen_settings_countries.js @@ -215,12 +215,13 @@ jQuery(document).ready(function($) { */ add_new_state : function () { // post data to be sent - var formData = { + const formData = { page: 'espresso_general_settings', action: 'espresso_add_new_state', CNT_ISO: $('#country').val(), STA_abbrev: $('#STA_abbrev-XXX').val(), STA_name: $('#STA_name-XXX').val(), + espresso_add_new_state_nonce: $('#add_new_state_nonce').val(), ee_admin_ajax: true, noheader : 'true' }; @@ -237,7 +238,11 @@ jQuery(document).ready(function($) { //console.log(response); if ( typeof response.errors !== 'undefined' && response.errors !== '' ) { show_admin_page_ajax_msg( response ); - } else if ( typeof(response.return_data) !== 'undefined' && response.return_data !== false && response.return_data !== null ) { + } else if ( + typeof(response.return_data) !== 'undefined' + && response.return_data !== false + && response.return_data !== null + ) { EE_CNT_STA.get_country_states( response.return_data ); show_admin_page_ajax_msg( response ); } else { @@ -279,6 +284,7 @@ jQuery(document).ready(function($) { CNT_ISO: CNT_ISO, STA_ID: STA_ID, STA_abbrev: STA_abbrev, + espresso_delete_state_nonce: $('#delete_state_nonce').val(), ee_admin_ajax : true, noheader : 'true' }; @@ -319,4 +325,4 @@ jQuery(document).ready(function($) { EE_CNT_STA.init(); -}); \ No newline at end of file +}); diff --git a/admin_pages/general_settings/templates/state_details_settings.template.php b/admin_pages/general_settings/templates/state_details_settings.template.php index 61c2925d93..f402e6c0a7 100644 --- a/admin_pages/general_settings/templates/state_details_settings.template.php +++ b/admin_pages/general_settings/templates/state_details_settings.template.php @@ -1,6 +1,8 @@ @@ -34,6 +36,7 @@ class="button button--secondary button--icon-only delete-state-lnk" > + +