diff --git a/ACF_City_Selector.php b/ACF_City_Selector.php index f2187bb..7430073 100755 --- a/ACF_City_Selector.php +++ b/ACF_City_Selector.php @@ -3,7 +3,7 @@ Plugin Name: ACF City Selector Plugin URI: https://acf-city-selector.com Description: An extension for ACF which allows you to select a city based on country and province/state. - Version: 1.15.1 + Version: 1.16.0 Tested up to: 6.6.1 Requires PHP: 7.0 Author: Beee @@ -38,7 +38,7 @@ public function __construct() { $this->settings = [ 'db_version' => '1.0', 'url' => plugin_dir_url( __FILE__ ), - 'version' => '1.15.1', + 'version' => '1.16.0', ]; if ( ! class_exists( 'ACFCS_WEBSITE_URL' ) ) { diff --git a/README.md b/README.md index 41828a4..db9f839 100644 --- a/README.md +++ b/README.md @@ -228,6 +228,9 @@ I got the idea for this plugin through [Fabrizio Sabato](https://github.com/fab0 ### Changelog +1.16.0 +* add nonces for forms + 1.15.1 * use wp_filesystem for csv files * sanitize/escape more diff --git a/admin/acf-city-selector-v4.php b/admin/acf-city-selector-v4.php index 69fb659..46f6d5d 100755 --- a/admin/acf-city-selector-v4.php +++ b/admin/acf-city-selector-v4.php @@ -234,7 +234,7 @@ function input_admin_enqueue_scripts() { $all_info = acfcs_get_field_settings(); $js_vars[ 'ajaxurl' ] = admin_url( 'admin-ajax.php' ); $js_vars[ 'default_country' ] = ( isset( $all_info[ 'default_country' ] ) && false != $all_info[ 'default_country' ] ) ? $all_info[ 'default_country' ] : false; - $js_vars[ 'post_id' ] = ( isset( $_GET[ 'post' ] ) ) ? (int) $_GET[ 'post' ] : false; + $js_vars[ 'post_id' ] = 0 < get_the_ID() ? (int) get_the_ID() : false; $js_vars[ 'show_labels' ] = ( isset( $all_info[ 'show_labels' ] ) ) ? $all_info[ 'show_labels' ] : apply_filters( 'acfcs_show_labels', true ); $js_vars[ 'use_select2' ] = ( isset( $all_info[ 'use_select2' ] ) ) ? $all_info[ 'use_select2' ] : false; $js_vars[ 'which_fields' ] = ( isset( $all_info[ 'which_fields' ] ) ) ? $all_info[ 'which_fields' ] : 'all'; diff --git a/admin/acf-city-selector-v5.php b/admin/acf-city-selector-v5.php index 808e7e9..7b6b1c6 100755 --- a/admin/acf-city-selector-v5.php +++ b/admin/acf-city-selector-v5.php @@ -201,15 +201,17 @@ function input_admin_enqueue_scripts() { wp_register_script( 'acfcs-process', "{$plugin_url}assets/js/city-selector.js", array( 'jquery', 'acf-input' ), $plugin_version, false ); wp_enqueue_script( 'acfcs-process' ); - - $all_info = acfcs_get_field_settings(); - $js_vars[ 'ajaxurl' ] = admin_url( 'admin-ajax.php' ); - $js_vars[ 'default_country' ] = ( isset( $all_info[ 'default_country' ] ) && false != $all_info[ 'default_country' ] ) ? $all_info[ 'default_country' ] : false; - $js_vars[ 'post_id' ] = ( isset( $_GET[ 'post' ] ) ) ? (int) $_GET[ 'post' ] : false; - $js_vars[ 'show_labels' ] = ( isset( $all_info[ 'show_labels' ] ) ) ? $all_info[ 'show_labels' ] : apply_filters( 'acfcs_show_labels', true ); - $js_vars[ 'store_meta' ] = ( isset( $all_info[ 'store_meta' ] ) ) ? $all_info[ 'store_meta' ] : false; - $js_vars[ 'use_select2' ] = ( isset( $all_info[ 'use_select2' ] ) ) ? $all_info[ 'use_select2' ] : false; - $js_vars[ 'which_fields' ] = ( isset( $all_info[ 'which_fields' ] ) ) ? $all_info[ 'which_fields' ] : 'all'; + + $all_info = acfcs_get_field_settings(); + $js_vars[ 'ajaxurl' ] = admin_url( 'admin-ajax.php' ); + $js_vars[ 'default_country' ] = ( isset( $all_info[ 'default_country' ] ) && false != $all_info[ 'default_country' ] ) ? $all_info[ 'default_country' ] : false; + $js_vars[ 'post_id' ] = 0 < get_the_ID() ? (int) get_the_ID() : false; + $js_vars[ 'acfcs_state_nonce' ] = wp_create_nonce( 'acfcs-state-nonce' ); + $js_vars[ 'acfcs_city_nonce' ] = wp_create_nonce( 'acfcs-city-nonce' ); + $js_vars[ 'show_labels' ] = ( isset( $all_info[ 'show_labels' ] ) ) ? $all_info[ 'show_labels' ] : apply_filters( 'acfcs_show_labels', true ); + $js_vars[ 'store_meta' ] = ( isset( $all_info[ 'store_meta' ] ) ) ? $all_info[ 'store_meta' ] : false; + $js_vars[ 'use_select2' ] = ( isset( $all_info[ 'use_select2' ] ) ) ? $all_info[ 'use_select2' ] : false; + $js_vars[ 'which_fields' ] = ( isset( $all_info[ 'which_fields' ] ) ) ? $all_info[ 'which_fields' ] : 'all'; wp_localize_script( 'acfcs-process', 'city_selector_vars', $js_vars ); } diff --git a/admin/acfcs-dashboard.php b/admin/acfcs-dashboard.php index ba26969..367e718 100755 --- a/admin/acfcs-dashboard.php +++ b/admin/acfcs-dashboard.php @@ -7,7 +7,16 @@ function acfcs_dashboard() { if ( ! current_user_can( apply_filters( 'acfcs_user_cap', 'manage_options' ) ) ) { wp_die( esc_html__( 'You do not have sufficient permissions to access this page.', 'acf-city-selector' ) ); } - + + $submitted_raw_data = false; + if ( isset( $_POST[ 'acfcs_import_raw_nonce' ] ) ) { + if ( ! wp_verify_nonce( sanitize_text_field( wp_unslash( $_POST[ 'acfcs_import_raw_nonce' ] ) ), 'acfcs-import-raw-nonce' ) ) { + ACF_City_Selector::acfcs_errors()->add( 'error_no_nonce_match', esc_html__( 'Something went wrong, please try again.', 'acf-city-selector' ) ); + } else { + $submitted_raw_data = ( isset( $_POST[ 'raw_csv_import' ] ) ) ? sanitize_textarea_field( wp_unslash( $_POST[ 'raw_csv_import' ] ) ) : false; + } + } + ACF_City_Selector::acfcs_show_admin_notices(); $show_raw_import = true; @@ -38,7 +47,6 @@ function acfcs_dashboard() { -
diff --git a/admin/acfcs-preview-form.php b/admin/acfcs-preview-form.php index ef5c8c2..319dc8b 100755 --- a/admin/acfcs-preview-form.php +++ b/admin/acfcs-preview-form.php @@ -8,6 +8,7 @@