Plugin Directory

Changeset 2797458


Ignore:
Timestamp:
10/11/2022 11:27:02 PM (3 years ago)
Author:
Beee
Message:

fixes 1.9.0

Location:
acf-city-selector/trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • acf-city-selector/trunk/ACF_City_Selector.php

    r2791052 r2797458  
    44    Plugin URI:     https://acf-city-selector.com
    55    Description:    An extension for ACF which allows you to select a city based on country and province/state.
    6     Version:        1.8.0
     6    Version:        1.9.0
    77    Tested up to:   6.0.2
    88    Requires PHP:   7.0
     
    3636                    'db_version' => '1.0',
    3737                    'url'        => plugin_dir_url( __FILE__ ),
    38                     'version'    => get_plugin_data( __FILE__ )['Version'],
     38                    'version'    => '1.9.0',
    3939                );
    4040
  • acf-city-selector/trunk/inc/acfcs-actions.php

    r2791052 r2797458  
    1515                foreach( $countries as $country_code => $label ) {
    1616                    do_action( 'acfcs_delete_transients', $country_code );
     17                    // @TODO: also add states
    1718                }
    1819            }
  • acf-city-selector/trunk/inc/acfcs-functions.php

    r2791052 r2797458  
    3030
    3131        global $wpdb;
    32         $results = $wpdb->get_results( '
    33                 SELECT * FROM ' . $wpdb->prefix . 'cities
    34                 GROUP BY country
    35                 ORDER BY country ASC
    36             ' );
     32        $results = $wpdb->get_results( "
     33            SELECT * FROM {$wpdb->prefix}cities
     34            GROUP BY country
     35            ORDER BY country ASC
     36        " );
    3737
    3838        if ( ! empty( $results ) ) {
     
    8484                $sql = $wpdb->prepare( "
    8585                    SELECT *
    86                     FROM " . $wpdb->prefix . "cities
     86                    FROM {$wpdb->prefix}cities
    8787                    WHERE country_code = %s
    8888                    GROUP BY state_code
     
    9393                $state_results = array();
    9494                foreach ( $results as $data ) {
    95                     $state_results[ $country_code . '-' . $data->state_code ] = esc_attr__( $data->state_name, 'acf-city-selector' );
     95                    $state_results[ strtoupper( $country_code ) . '-' . $data->state_code ] = esc_attr__( $data->state_name, 'acf-city-selector' );
    9696                }
    9797
     
    151151            if ( false !== $country_code ) {
    152152                global $wpdb;
    153                 $query = 'SELECT * FROM ' . $wpdb->prefix . 'cities';
     153                $query = "SELECT * FROM {$wpdb->prefix}cities";
    154154                if ( $country_code && $state_code ) {
    155155                    if ( 3 < strlen( $state_code ) ) {
    156156                        $state_code = substr( $state_code, 3 );
    157157                    }
    158                     $query .= " WHERE country_code = '{$country_code}' AND state_code = '{$state_code}'";
    159                     $query .= " ORDER BY state_name, city_name ASC";
     158                    $query = $wpdb->prepare( $query . " WHERE country_code = %s AND state_code = %s ORDER BY state_name, city_name ASC", $country_code, $state_code );
    160159                } elseif ( $country_code ) {
    161                     $query .= " WHERE country_code = '{$country_code}'";
     160                    $query = $wpdb->prepare( $query . " WHERE country_code = %s", $country_code );
    162161                }
    163162                $city_results = array();
     
    224223    function acfcs_has_cities( $country_code = false ) {
    225224        global $wpdb;
    226         $query = 'SELECT * FROM ' . $wpdb->prefix . 'cities LIMIT 1';
     225        $query = "SELECT * FROM {$wpdb->prefix}cities LIMIT 1";
    227226        if ( $country_code ) {
    228             $query = $wpdb->prepare( 'SELECT * FROM ' . $wpdb->prefix . 'cities WHERE country_code = %s LIMIT 1', $country_code );
     227            $query = $wpdb->prepare( "SELECT * FROM {$wpdb->prefix}cities WHERE country_code = %s LIMIT 1", $country_code );
    229228        }
    230229
     
    440439    function acfcs_get_countries_info() {
    441440        global $wpdb;
    442         $results = $wpdb->get_results( '
    443                 SELECT country_code FROM ' . $wpdb->prefix . 'cities
     441        $results = $wpdb->get_results( "
     442                SELECT country_code FROM {$wpdb->prefix}cities
    444443                GROUP BY country_code
    445444                ORDER BY country_code ASC
    446             ' );
     445            " );
    447446
    448447        $acfcs_info = array();
    449448        foreach ( $results as $data ) {
    450449            $country_code = $data->country_code;
    451             $results      = $wpdb->get_results( $wpdb->prepare( '
    452                 SELECT * FROM ' . $wpdb->prefix . 'cities
     450            $results      = $wpdb->get_results( $wpdb->prepare( "
     451                SELECT * FROM {$wpdb->prefix}cities
    453452                WHERE country_code = %s
    454453                ORDER BY country_code ASC
    455             ', $country_code ) );
     454            ", $country_code ) );
    456455
    457456            $acfcs_info[ $country_code ] = [
     
    828827                    $order = 'ORDER BY state_name ASC';
    829828                    if ( 'FR' == $country[ 'code' ] ) {
    830                         $order = "ORDER BY LENGTH(state_name), state_name";
    831                     }
    832 
    833                     $query   = "SELECT * FROM " . $wpdb->prefix . "cities WHERE country_code = %s GROUP BY state_code " . $order;
     829                        $order = 'ORDER BY LENGTH(state_name), state_name';
     830                    }
     831
     832                    $query   = "SELECT * FROM {$wpdb->prefix}cities WHERE country_code = %s GROUP BY state_code " . $order;
    834833                    $sql     = $wpdb->prepare( $query, $country[ 'code' ] );
    835834                    $results = $wpdb->get_results( $sql );
     
    906905        }
    907906
    908         $sql = "SELECT * FROM " . $wpdb->prefix . "cities
     907        $sql = "SELECT * FROM {$wpdb->prefix}cities
    909908                " . $where . "
    910909                " . $orderby . "
  • acf-city-selector/trunk/readme.txt

    r2791052 r2797458  
    4040A. Please read the FAQ @ [https://acf-city-selector.com/documentation/](https://acf-city-selector.com/documentation/)
    4141
    42 == Upgrade Notice ==
     42== Changelog ==
    4343
    44 = 1.8.0 =
    45 The preview option was broken, which is now fixed. Also all 'broken' special characters are replaced.
    46 
    47 == Changelog ==
     44= 1.9.0 =
     45* fixed case for country code in states transient
     46* added wpdb->prepare (where needed)
     47* reverted version by function due to some people reporting errors
    4848
    4949= 1.8.0 =
Note: See TracChangeset for help on using the changeset viewer.