Changeset 2841215
- Timestamp:
- 12/29/2022 07:01:45 PM (3 years ago)
- Location:
- acf-city-selector/trunk
- Files:
-
- 10 edited
-
ACF_City_Selector.php (modified) (5 diffs)
-
admin/acf-city-selector-v5.php (modified) (18 diffs)
-
admin/acfcs-countries.php (modified) (1 diff)
-
admin/acfcs-info.php (modified) (1 diff)
-
assets/css/general.css (modified) (2 diffs)
-
inc/acfcs-actions.php (modified) (1 diff)
-
inc/acfcs-ajax.php (modified) (2 diffs)
-
inc/acfcs-functions.php (modified) (20 diffs)
-
inc/form-handling.php (modified) (1 diff)
-
readme.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
acf-city-selector/trunk/ACF_City_Selector.php
r2798478 r2841215 4 4 Plugin URI: https://acf-city-selector.com 5 5 Description: An extension for ACF which allows you to select a city based on country and province/state. 6 Version: 1. 9.17 Tested up to: 6. 0.26 Version: 1.10.0 7 Tested up to: 6.1.1 8 8 Requires PHP: 7.0 9 9 Author: Beee … … 36 36 'db_version' => '1.0', 37 37 'url' => plugin_dir_url( __FILE__ ), 38 'version' => '1. 9.1',38 'version' => '1.10.0', 39 39 ); 40 40 … … 109 109 do_action( 'acfcs_delete_transients' ); 110 110 // other important stuff gets done in uninstall.php 111 }112 113 114 /*115 * Prepare database upon plugin activation116 */117 public function acfcs_fill_database() {118 $countries = array( 'nl', 'be' );119 foreach( $countries as $country ) {120 acfcs_import_data( $country . '.csv', ACFCS_PLUGIN_PATH . 'import/' );121 }122 111 } 123 112 … … 270 259 */ 271 260 public function acfcs_settings_link( $links ) { 272 $settings_link = [ 'settings' => '<a href="options-general.php?page=acfcs-dashboard">' . esc_html__( 'Settings', 'acf-city-selector' ) . '</a>'];261 $settings_link = [ 'settings' => sprintf( '<a href="%s">%s</a>', admin_url( 'options-general.php?page=acfcs-dashboard' ), esc_html__( 'Settings', 'acf-city-selector' ) ) ]; 273 262 274 263 return array_merge( $settings_link, $links ); … … 383 372 * @param $to_index 384 373 */ 385 public staticfunction acfcs_move_array_element( &$array, $from_index, $to_index ) {374 public function acfcs_move_array_element( &$array, $from_index, $to_index ) { 386 375 $splice = array_splice( $array, $from_index, 1 ); 387 376 array_splice( $array, $to_index, 0, $splice ); -
acf-city-selector/trunk/admin/acf-city-selector-v5.php
r2696652 r2841215 11 11 */ 12 12 class acf_field_city_selector extends acf_field { 13 14 13 /* 15 14 * Function index … … 26 25 * acf_field_city_selector constructor 27 26 * 28 * This function will set up the class functionality27 * This function will set up the class functionality 29 28 * 30 29 * @param $settings 31 30 */ 32 31 function __construct( $settings ) { 33 34 32 $this->name = 'acf_city_selector'; 35 33 $this->label = 'City Selector'; … … 37 35 $this->defaults = array( 38 36 'show_labels' => 1, 37 'store_meta' => 0, 39 38 'which_fields' => 'all', 40 39 'use_select2' => 0, … … 46 45 47 46 parent::__construct(); 48 49 } 47 } 48 50 49 51 50 /** … … 57 56 */ 58 57 function render_field_settings( $field ) { 59 60 58 $select_options = array( 61 59 1 => esc_attr__( 'Yes', 'acf-city-selector' ), … … 72 70 ) ); 73 71 74 acf_render_field_setting( $field, array(72 acf_render_field_setting( $field, array( 75 73 'choices' => $select_options, 76 74 'instructions' => esc_html__( 'Use select2 for dropdowns', 'acf-city-selector' ), … … 80 78 'type' => 'radio', 81 79 'value' => $field[ 'use_select2' ], 80 ) ); 81 82 acf_render_field_setting( $field, array( 83 'choices' => $select_options, 84 'instructions' => esc_html__( 'Store location as single meta values', 'acf-city-selector' ), 85 'label' => esc_html__( 'Store meta', 'acf-city-selector' ), 86 'layout' => 'horizontal', 87 'name' => 'store_meta', 88 'type' => 'radio', 89 'value' => $field[ 'store_meta' ], 82 90 ) ); 83 91 … … 107 115 } 108 116 117 109 118 /** 110 119 * render_field() … … 115 124 */ 116 125 function render_field( $field ) { 117 118 $default_country = ( isset( $field[ 'default_country' ] ) && ! empty( $field[ 'default_country' ] ) ) ? $field[ 'default_country' ] : false;119 $prefill_cities = array();120 $prefill_states = array();121 $selected_country = ( isset( $field[ 'value' ][ 'countryCode' ] ) ) ? $field[ 'value' ][ 'countryCode' ] : false;122 $selected_state = ( isset( $field[ 'value' ][ 'stateCode' ] ) ) ? $field[ 'value' ][ 'stateCode' ] : false;123 $selected_city = ( isset( $field[ 'value' ][ 'cityName' ] ) ) ? $field[ 'value' ][ 'cityName' ] : false;124 $show_first = true;125 $which_fields = ( isset( $field[ 'which_fields' ] ) ) ? $field[ 'which_fields' ] : 'all';126 127 if ( false !== $default_country && false == $selected_country ) {126 $default_country = ( isset( $field[ 'default_country' ] ) && ! empty( $field[ 'default_country' ] ) ) ? $field[ 'default_country' ] : false; 127 $prefill_cities = []; 128 $prefill_states = []; 129 $selected_country = ( isset( $field[ 'value' ][ 'countryCode' ] ) ) ? $field[ 'value' ][ 'countryCode' ] : false; 130 $selected_state = ( isset( $field[ 'value' ][ 'stateCode' ] ) ) ? $field[ 'value' ][ 'stateCode' ] : false; 131 $selected_city = ( isset( $field[ 'value' ][ 'cityName' ] ) ) ? $field[ 'value' ][ 'cityName' ] : false; 132 $show_first = true; 133 $store_meta = ( isset( $field[ 'value' ][ 'store_meta' ] ) ) ? $field[ 'value' ][ 'store_meta' ] : false; 134 $which_fields = ( isset( $field[ 'which_fields' ] ) ) ? $field[ 'which_fields' ] : 'all'; 135 136 if ( false !== $default_country && false == $selected_country ) { 128 137 // New post with default country 129 138 if ( in_array( $which_fields, [ 'all', 'country_state', 'state_city' ] ) ) { … … 167 176 echo acfcs_render_dropdown( 'city', $field, $selected_city, $prefill_values ); 168 177 } 178 if ( ! isset( $field[ 'parent_layout' ] ) && ! isset( $field[ 'parent_repeater' ] ) && $store_meta ) { 179 echo acfcs_render_hidden_field( 'store_meta', '1' ); 180 } 169 181 } 170 182 … … 177 189 */ 178 190 function input_admin_enqueue_scripts() { 179 180 191 $plugin_url = $this->settings[ 'url' ]; 181 192 $plugin_version = $this->settings[ 'version' ]; … … 192 203 $js_vars[ 'post_id' ] = ( isset( $_GET[ 'post' ] ) ) ? (int) $_GET[ 'post' ] : false; 193 204 $js_vars[ 'show_labels' ] = ( isset( $all_info[ 'show_labels' ] ) ) ? $all_info[ 'show_labels' ] : apply_filters( 'acfcs_show_labels', true ); 205 $js_vars[ 'store_meta' ] = ( isset( $all_info[ 'store_meta' ] ) ) ? $all_info[ 'store_meta' ] : false; 194 206 $js_vars[ 'use_select2' ] = ( isset( $all_info[ 'use_select2' ] ) ) ? $all_info[ 'use_select2' ] : false; 195 207 $js_vars[ 'which_fields' ] = ( isset( $all_info[ 'which_fields' ] ) ) ? $all_info[ 'which_fields' ] : 'all'; 196 208 197 209 wp_localize_script( 'acfcs-process', 'city_selector_vars', $js_vars ); 198 199 210 } 200 211 … … 214 225 */ 215 226 function load_value( $value, $post_id, $field ) { 216 217 227 $state_code = false; 218 228 $country_code = ( isset( $value[ 'countryCode' ] ) ) ? $value[ 'countryCode' ] : false; … … 231 241 if ( strlen( $country_code ) == 2 && false != $state_code ) { 232 242 global $wpdb; 233 $sql_query = $wpdb->prepare( "SELECT country, state_name FROM {$wpdb->prefix}cities WHERE country_code= %s AND state_code= %s", $country_code, $state_code ); 234 $row = $wpdb->get_row( $sql_query ); 235 $value[ 'stateCode' ] = $state_code; 236 $value[ 'stateName' ] = ( isset( $row->state_name ) ) ? $row->state_name : false; 237 $value[ 'countryName' ] = ( isset( $row->country ) ) ? $row->country : false; 243 $table = $wpdb->prefix . 'cities'; 244 $sql_query = $wpdb->prepare( "SELECT country, state_name FROM {$table} WHERE country_code = %s AND state_code = %s", $country_code, $state_code ); 245 $row = $wpdb->get_row( $sql_query ); 246 $value[ 'stateCode' ] = $state_code; 247 $value[ 'stateName' ] = ( isset( $row->state_name ) ) ? $row->state_name : false; 248 $value[ 'countryName' ] = ( isset( $row->country ) ) ? $row->country : false; 238 249 } 239 250 … … 255 266 */ 256 267 function update_value( $value, $post_id, $field ) { 257 258 268 $required = $field[ 'required' ]; 259 269 if ( 0 == $required ) { … … 316 326 } 317 327 328 if ( ! isset( $field[ 'parent_layout' ] ) && ! isset( $field[ 'parent_repeater' ] ) ) { 329 do_action( 'acfcs_store_meta', $value, $post_id ); 330 } 331 318 332 return $value; 319 320 333 } 321 334 … … 336 349 */ 337 350 function validate_value( $valid, $value, $field, $input ) { 338 339 351 if ( 1 == $field[ 'required' ] ) { 340 352 $nothing = esc_html__( "You didn't select anything.", 'acf-city-selector' ); … … 384 396 385 397 new acf_field_city_selector( $this->settings ); 386 387 398 } -
acf-city-selector/trunk/admin/acfcs-countries.php
r2685642 r2841215 52 52 <p> 53 53 <?php esc_html_e( "And now you can !! We have created several 'country packages' for you to import 'as is'.", 'acf-city-selector' ); ?> 54 <?php echo sprintf( __( 'Download them %s.', 'acf-city-selector' ), sprintf( '<a href="%s">%s</a>', esc_url( ACFCS_WEBSITE_URL . '/get-countries/' ),__( 'here', 'acf-city-selector' ) ) ); ?>54 <?php echo sprintf( esc_html__( 'Download them %s.', 'acf-city-selector' ), sprintf( '<a href="%s" target="_blank" rel="noopener">%s</a>', esc_url( ACFCS_WEBSITE_URL . '/get-countries/' ), esc_html__( 'here', 'acf-city-selector' ) ) ); ?> 55 55 </p> 56 56 </div> -
acf-city-selector/trunk/admin/acfcs-info.php
r2696652 r2841215 27 27 <p> 28 28 <?php esc_html_e( 'This page shows real-time info about your site and settings.', 'acf-city-selector' ); ?> 29 <br />30 <?php esc_html_e( 'We might ask for this info if support is helping you fix a problem.', 'acf-city-selector' ); ?>31 29 </p> 32 30 </div> -
acf-city-selector/trunk/assets/css/general.css
r2685642 r2841215 1 1 /* errors */ 2 2 .acfcs .notice--error { 3 border-left-color: #dc3232;3 border-left-color: #dc3232; 4 4 } 5 5 6 6 .acfcs .notice--success { 7 border-left-color: #43bc71;7 border-left-color: #43bc71; 8 8 } 9 9 10 10 .acfcs .notice--warning { 11 border-left-color: #ff9000;11 border-left-color: #ff9000; 12 12 } 13 13 14 14 .acfcs .notice--info { 15 border-left-color: #00a0d2;15 border-left-color: #00a0d2; 16 16 } 17 17 18 18 .acfcs .field__message { 19 background-color:#f9f9f9;20 border-left:2px solid #ccd0d4;21 border-top:1px solid #ccd0d4;22 border-right:1px solid #ccd0d4;23 border-bottom:1px solid #ccd0d4;24 margin-bottom:1rem;25 padding:5px;19 background-color: #f9f9f9; 20 border-left: 2px solid #ccd0d4; 21 border-top: 1px solid #ccd0d4; 22 border-right: 1px solid #ccd0d4; 23 border-bottom: 1px solid #ccd0d4; 24 margin-bottom: 1rem; 25 padding: 5px; 26 26 } 27 27 28 28 .acfcs .field__message--error { 29 border-left-color: #dc3232;29 border-left-color: #dc3232; 30 30 } 31 31 32 32 .acfcs .field__message--warning { 33 border-left-color: #ff9000;33 border-left-color: #ff9000; 34 34 } 35 35 … … 37 37 /* not actively supported anymore */ 38 38 .field_type-acf_city_selector .acfcs__dropdown-box { 39 margin-bottom: 1rem;39 margin-bottom: 1rem; 40 40 } 41 41 42 42 .field_type-acf_city_selector span.acf-input-header { 43 display: block;44 margin-bottom: 10px;43 display: block; 44 margin-bottom: 10px; 45 45 } 46 46 47 47 /* edit post screens v5 */ 48 48 .acf-field-acf-city-selector .acfcs__dropdown-box { 49 margin-bottom: 1rem; 49 margin-bottom: 1rem; 50 } 51 52 .acf-field-acf-city-selector .acfcs__checkbox { 53 display: flex; 54 flex-flow: row nowrap; 55 align-items: center; 56 } 57 58 .acfcs__checkbox input[type="checkbox"] { 59 margin-right: 0.5rem; 60 } 61 62 .acfcs__checkbox label { 63 vertical-align: initial; 50 64 } 51 65 52 66 .acf-field.acf-field-acf-city-selector select.acfcs__dropdown { 53 padding: 4px;67 padding: 4px; 54 68 } 55 69 56 70 .acf-field-acf-city-selector .acf-input-header { 57 margin-bottom: 10px;71 margin-bottom: 10px; 58 72 } -
acf-city-selector/trunk/inc/acfcs-actions.php
r2797458 r2841215 48 48 } 49 49 add_action( 'acfcs_after_success_import', 'acfcs_reimport_cities' ); 50 51 52 /** 53 * Save location as single meta values 54 * 55 * @param $value 56 * @param $post_id 57 * 58 * @return void 59 */ 60 function acfcs_save_single_meta( $value, $post_id ) { 61 if ( isset( $_POST[ 'store_meta' ] ) && 1 == $_POST[ 'store_meta' ] ) { 62 if ( ! empty( $value[ 'countryCode' ] ) ) { 63 update_post_meta( $post_id, 'acfcs_search_country', $value[ 'countryCode' ] ); 64 } 65 if ( ! empty( $value[ 'stateCode' ] ) ) { 66 update_post_meta( $post_id, 'acfcs_search_state', $value[ 'stateCode' ] ); 67 } 68 if ( ! empty( $value[ 'cityName' ] ) ) { 69 update_post_meta( $post_id, 'acfcs_search_city', $value[ 'cityName' ] ); 70 } 71 } elseif ( $post_id ) { 72 // remove meta 73 delete_post_meta( $post_id, 'acfcs_search_country' ); 74 delete_post_meta( $post_id, 'acfcs_search_state' ); 75 delete_post_meta( $post_id, 'acfcs_search_city' ); 76 } 77 } 78 add_action( 'acfcs_store_meta', 'acfcs_save_single_meta', 10, 2 ); -
acf-city-selector/trunk/inc/acfcs-ajax.php
r2685642 r2841215 28 28 } 29 29 30 if ( ! isset( $field[ 'show_labels' ] ) ) { 31 if ( isset( $_POST[ 'show_labels' ] ) ) { 32 $field[ 'show_labels' ] = ( '1' == sanitize_text_field( $_POST[ 'show_labels' ] ) ) ? true : false; 33 } 34 } 30 if ( ! isset( $field[ 'show_labels' ] ) && isset( $_POST[ 'show_labels' ] ) ) { 31 $field[ 'show_labels' ] = ( '1' == sanitize_text_field( $_POST[ 'show_labels' ] ) ) ? true : false; 32 } 35 33 36 34 if ( isset( $country_code ) ) { … … 83 81 } 84 82 85 if ( ! isset( $field[ 'show_labels' ] ) ) { 86 if ( isset( $_POST[ 'show_labels' ] ) ) { 87 $show_labels = sanitize_text_field( $_POST[ 'show_labels' ] ); 88 if ( '1' == $show_labels ) { 89 $field[ 'show_labels' ] = true; 90 } elseif ( '0' == $show_labels ) { 91 $field[ 'show_labels' ] = false; 92 } 93 } 83 if ( ! isset( $field[ 'show_labels' ] ) && isset( $_POST[ 'show_labels' ] ) ) { 84 $show_labels = sanitize_text_field( $_POST[ 'show_labels' ] ); 85 if ( '1' == $show_labels ) { 86 $field[ 'show_labels' ] = true; 87 } elseif ( '0' == $show_labels ) { 88 $field[ 'show_labels' ] = false; 89 } 94 90 } 95 91 -
acf-city-selector/trunk/inc/acfcs-functions.php
r2797458 r2841215 29 29 } 30 30 31 global $wpdb; 32 $results = $wpdb->get_results( " 33 SELECT * FROM {$wpdb->prefix}cities 34 GROUP BY country 35 ORDER BY country ASC 36 " ); 31 global $wpdb; 32 $table = $wpdb->prefix . 'cities'; 33 $results = $wpdb->get_results( "SELECT * FROM $table GROUP BY country ORDER BY country ASC" ); 37 34 38 35 if ( ! empty( $results ) ) { … … 46 43 } 47 44 48 49 45 return $countries; 50 46 } … … 76 72 $transient = get_transient( 'acfcs_states_' . strtolower( $country_code ) ); 77 73 if ( false == $transient || is_array( $transient ) && empty( $transient ) ) { 78 $order = ' ORDER BY state_name ASC';74 $order = ' ORDER BY state_name ASC'; 79 75 if ( 'FR' == $country_code ) { 80 $order = "ORDER BY LENGTH(state_name), state_name"; 81 } 82 83 global $wpdb; 84 $sql = $wpdb->prepare( " 85 SELECT * 86 FROM {$wpdb->prefix}cities 87 WHERE country_code = %s 88 GROUP BY state_code 89 " . $order, strtoupper( $country_code ) 90 ); 91 $results = $wpdb->get_results( $sql ); 76 $order = " ORDER BY LENGTH(state_name), state_name"; 77 } 78 79 global $wpdb; 80 $table = $wpdb->prefix . 'cities'; 81 $sql = $wpdb->prepare( "SELECT * FROM $table WHERE country_code = %s GROUP BY state_code" . $order, strtoupper( $country_code ) ); 82 $results = $wpdb->get_results( $sql ); 92 83 93 84 $state_results = array(); … … 151 142 if ( false !== $country_code ) { 152 143 global $wpdb; 153 $query = "SELECT * FROM {$wpdb->prefix}cities"; 144 $table = $wpdb->prefix . 'cities'; 145 $query = "SELECT * FROM $table"; 154 146 if ( $country_code && $state_code ) { 155 147 if ( 3 < strlen( $state_code ) ) { … … 198 190 function acfcs_get_country_name( $country_code = false ) { 199 191 if ( false != $country_code ) { 200 global $wpdb; 201 $country = $wpdb->get_row( $wpdb->prepare( "SELECT country FROM {$wpdb->prefix}cities WHERE country_code = %s", $country_code ) ); 192 global $wpdb; 193 $table = $wpdb->prefix . 'cities'; 194 $query = $wpdb->prepare( "SELECT country FROM $table WHERE country_code = %s", $country_code ); 195 $country = $wpdb->get_row( $query ); 196 202 197 if ( isset( $country->country ) ) { 203 198 return $country->country; … … 215 210 216 211 /** 217 * Checks if there a ny cities in the database (for page availability)212 * Checks if there are any cities in the database (for page availability) 218 213 * 219 214 * @param $country_code … … 223 218 function acfcs_has_cities( $country_code = false ) { 224 219 global $wpdb; 225 $query = "SELECT * FROM {$wpdb->prefix}cities LIMIT 1"; 220 $table = $wpdb->prefix . 'cities'; 221 $query = "SELECT * FROM $table LIMIT 1"; 226 222 if ( $country_code ) { 227 $query = $wpdb->prepare( "SELECT * FROM {$wpdb->prefix}citiesWHERE country_code = %s LIMIT 1", $country_code );223 $query = $wpdb->prepare( "SELECT * FROM $table WHERE country_code = %s LIMIT 1", $country_code ); 228 224 } 229 225 … … 244 240 */ 245 241 function acfcs_check_if_files() { 246 $target_dir = acfcs_upload_folder(); 247 if ( is_dir( $target_dir ) ) { 242 $actual_files = []; 243 $target_dir = acfcs_upload_folder(); 244 245 if ( is_dir( $target_dir ) ) { 248 246 $file_index = scandir( $target_dir ); 249 247 $excluded_files = [ … … 255 253 256 254 if ( is_array( $file_index ) ) { 257 $actual_files = array();258 255 foreach ( $file_index as $file ) { 259 256 if ( ! in_array( $file, $excluded_files ) ) { … … 267 264 } 268 265 269 return array();266 return $actual_files; 270 267 } 271 268 … … 439 436 function acfcs_get_countries_info() { 440 437 global $wpdb; 441 $results = $wpdb->get_results( " 442 SELECT country_code FROM {$wpdb->prefix}cities 443 GROUP BY country_code 444 ORDER BY country_code ASC 445 " ); 438 $table = $wpdb->prefix . 'cities'; 439 $results = $wpdb->get_results( "SELECT country_code FROM $table GROUP BY country_code ORDER BY country_code ASC" ); 446 440 447 441 $acfcs_info = array(); 448 442 foreach ( $results as $data ) { 449 $country_code = $data->country_code; 450 $results = $wpdb->get_results( $wpdb->prepare( " 451 SELECT * FROM {$wpdb->prefix}cities 452 WHERE country_code = %s 453 ORDER BY country_code ASC 454 ", $country_code ) ); 443 $country_code = $data->country_code; 444 $query = $wpdb->prepare( "SELECT * FROM $table WHERE country_code = %s ORDER BY country_code ASC", $country_code ); 445 $results = $wpdb->get_results( $query ); 455 446 456 447 $acfcs_info[ $country_code ] = [ … … 589 580 590 581 582 function acfcs_render_hidden_field( $name, $value ) { 583 if ( $name && $value ) { 584 return sprintf( '<input type="hidden" name="%s" value="%s" />', $name, $value ); 585 } 586 587 return false; 588 } 589 590 591 591 /** 592 592 * Verify CSV data … … 726 726 if ( ! empty( $sanitized_country_codes ) ) { 727 727 global $wpdb; 728 $country_string = strtoupper( "'" . implode( "', '", $sanitized_country_codes ) . "'" ); 729 $query = "DELETE FROM {$wpdb->prefix}cities WHERE `country_code` IN ({$country_string})"; 730 $result = $wpdb->query( $query ); 728 $table = $wpdb->prefix . 'cities'; 729 $country_string = strtoupper( "'" . implode( "', '", $sanitized_country_codes ) . "'" ); 730 $query = $wpdb->prepare( "DELETE FROM $table WHERE `country_code` IN (%s)", $country_string ); 731 $result = $wpdb->query( $query ); 732 731 733 if ( $result > 0 ) { 732 734 ACF_City_Selector::acfcs_errors()->add( 'success_country_remove', sprintf( esc_html__( 'You have successfully removed all entries for %s.', 'acf-city-selector' ), $country_names_and ) ); … … 763 765 */ 764 766 function acfcs_render_preview_results( $csv_data = [] ) { 765 if ( ! empty( $csv_data ) ) { 767 $table = ''; 768 if ( ! empty( $csv_data ) ) { 766 769 $table_columns = [ 767 770 esc_html__( 'City', 'acf-city-selector' ), … … 789 792 $table_body = sprintf( '<tbody>%s</tbody>', $table_rows ); 790 793 $table = sprintf( '<table class="acfcs__table acfcs__table--preview-result scrollable">%s%s</table>', $table_headers, $table_body ); 791 792 return $table; 793 } 794 795 return ''; 794 } 795 796 return $table; 796 797 } 797 798 … … 806 807 function acfcs_get_states_optgroup() { 807 808 $results = acfcs_get_countries( false ); 809 $states = []; 810 808 811 // if there is at least 1 country 809 812 if ( ! empty( $results ) ) { … … 817 820 // get states for these countries 818 821 if ( ! empty( $countries ) ) { 819 global $wpdb; 820 $states = array(); 821 foreach ( $countries as $country ) { 822 global $wpdb; 823 $table = $wpdb->prefix . 'cities'; 824 825 foreach ( $countries as $country ) { 822 826 $states[] = array( 823 827 'state' => 'open_optgroup', … … 830 834 } 831 835 832 $query = "SELECT * FROM {$wpdb->prefix}citiesWHERE country_code = %s GROUP BY state_code " . $order;836 $query = "SELECT * FROM $table WHERE country_code = %s GROUP BY state_code " . $order; 833 837 $sql = $wpdb->prepare( $query, $country[ 'code' ] ); 834 838 $results = $wpdb->get_results( $sql ); … … 848 852 ); 849 853 } 850 851 return $states; 852 } 853 } 854 855 return []; 854 } 855 } 856 857 return $states; 856 858 } 857 859 … … 905 907 } 906 908 907 $sql = "SELECT * FROM {$wpdb->prefix}cities 908 " . $where . " 909 " . $orderby . " 910 " . $search_limit . " 911 "; 912 $cities = $wpdb->get_results( $sql ); 909 $table = $wpdb->prefix . 'cities'; 910 $query = $wpdb->prepare( "SELECT * FROM $table %s %s %s", $where, $orderby, $search_limit ); 911 $cities = $wpdb->get_results( $query ); 913 912 914 913 return $cities; -
acf-city-selector/trunk/inc/form-handling.php
r2685642 r2841215 119 119 } 120 120 } 121 $cities = implode( ', ', $cities ); 122 $row_ids = implode( ',', $ids ); 123 $query = "DELETE FROM " . $wpdb->prefix . "cities WHERE id IN (" . $row_ids . ")"; 124 $amount = $wpdb->query( $query ); 121 $cities = implode( ', ', $cities ); 122 $row_ids = implode( ',', $ids ); 123 $table = $wpdb->prefix . 'cities'; 124 $query = $wpdb->prepare( "DELETE FROM {$table} WHERE id IN (%s)", $row_ids ); 125 $amount = $wpdb->query( $query ); 125 126 126 127 if ( $amount > 0 ) { -
acf-city-selector/trunk/readme.txt
r2798478 r2841215 4 4 Requires at least: 3.6.0 5 5 Requires PHP: 7.0 6 Tested up to: 6. 0.27 Stable tag: 1. 9.16 Tested up to: 6.1.1 7 Stable tag: 1.10.0 8 8 License: GPLv2 or later 9 9 License URI: http://www.gnu.org/licenses/gpl-2.0.html 10 10 11 This plugin sadds a new (ACF) field to select a city depending on country and state/province.11 This plugin adds a new (ACF) field to select a city depending on country and state/province. 12 12 13 13 == Description == … … 42 42 == Changelog == 43 43 44 = 1.10.0 = 45 * Add option to store location as single meta values 46 * Fix ordering for states (which caused some issues) 47 44 48 = 1.9.1 = 45 49 * fix incorrect version
Note: See TracChangeset
for help on using the changeset viewer.