Making WordPress.org


Ignore:
Timestamp:
04/10/2017 09:28:19 PM (10 years ago)
Author:
iandunn
Message:

Events: Change search order so that coordinates take precedence over IPs

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/api.wordpress.org/public_html/events/1.0/index.php

    r5278 r5311  
    356356}
    357357
     358/**
     359 * Determine a location for the given parameters
     360 *
     361 * @param array $args
     362 *
     363 * @return false|array
     364 */
    358365function get_location( $args = array() ) {
    359366        global $cache_life, $cache_group;
    … …  
    378385        }
    379386
    380         // Location was provided by the user:
     387        // Coordinates provided
     388        if (
     389                ! $location && (
     390                        ! empty( $args['latitude'] )  && is_numeric( $args['latitude'] ) &&
     391                        ! empty( $args['longitude'] ) && is_numeric( $args['longitude'] )
     392                )
     393        ) {
     394                $city = get_city_from_coordinates( $args['latitude'], $args['longitude'] );
     395
     396                $location = array(
     397                        'description' => $city ? $city : "{$args['latitude']}, {$args['longitude']}",
     398                        'latitude'    => $args['latitude'],
     399                        'longitude'   => $args['longitude']
     400                );
     401        }
     402
     403        // City was provided by the user:
    381404        if ( ! $location && isset( $args['location_name'] ) ) {
    382405                $guess = guess_location_from_city( $args['location_name'], $args['timezone'] ?? '', $country_code  );
    … …  
    412435                        );
    413436                }
    414         }
    415 
    416         if (
    417                 ! $location && (
    418                         ! empty( $args['latitude'] )  && is_numeric( $args['latitude'] ) &&
    419                         ! empty( $args['longitude'] ) && is_numeric( $args['longitude'] )
    420                 )
    421         ) {
    422                 $city = get_city_from_coordinates( $args['latitude'], $args['longitude'] );
    423 
    424                 $location = array(
    425                         'description' => $city ? $city : "{$args['latitude']}, {$args['longitude']}",
    426                         'latitude'  => $args['latitude'],
    427                         'longitude' => $args['longitude']
    428                 );
    429437        }
    430438
Note: See TracChangeset for help on using the changeset viewer.