Changeset 5311
- Timestamp:
- 04/10/2017 09:28:19 PM (8 years ago)
- Location:
- sites/trunk/api.wordpress.org/public_html/events/1.0
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/api.wordpress.org/public_html/events/1.0/index.php
r5278 r5311 356 356 } 357 357 358 /** 359 * Determine a location for the given parameters 360 * 361 * @param array $args 362 * 363 * @return false|array 364 */ 358 365 function get_location( $args = array() ) { 359 366 global $cache_life, $cache_group; … … 378 385 } 379 386 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: 381 404 if ( ! $location && isset( $args['location_name'] ) ) { 382 405 $guess = guess_location_from_city( $args['location_name'], $args['timezone'] ?? '', $country_code ); … … 412 435 ); 413 436 } 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 );429 437 } 430 438 -
sites/trunk/api.wordpress.org/public_html/events/1.0/tests/test-index.php
r5277 r5311 534 534 ), 535 535 536 /* 537 * Coordinates should take precedence over IP addresses 538 */ 539 'coordinates-over-ip-us' => array( 540 'input' => array( 541 'latitude' => '47.6062100', 542 'longitude' => '-122.3320700', 543 'ip' => '192.0.70.251', // San Francisco, USA 544 'timezone' => 'America/Los_Angeles', 545 'locale' => 'en_US', 546 ), 547 'expected' => array( 548 'description' => 'seattle', 549 'latitude' => '47.606', 550 'longitude' => '-122.332', 551 ), 552 ), 553 554 'coordinates-over-ip-africa' => array( 555 'input' => array( 556 'latitude' => '-19.634233', 557 'longitude' => '17.331767', 558 'ip' => '41.190.96.5', // Tsumeb, Namibia 559 'timezone' => 'Africa/Windhoek', 560 'locale' => 'af', 561 ), 562 'expected' => array( 563 'description' => 'otavi', 564 'latitude' => '-19.634', 565 'longitude' => '17.332', 566 ), 567 ), 536 568 537 569 /*
Note: See TracChangeset
for help on using the changeset viewer.