Changeset 6811 for sites/trunk/wordpress.org/public_html/wp-content/plugins/official-wordpress-events/official-wordpress-events.php
- Timestamp:
- 03/01/2018 01:55:23 AM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/plugins/official-wordpress-events/official-wordpress-events.php
r6779 r6811 344 344 } else { 345 345 $geocoded_location = $this->reverse_geocode( $meetup->group->group_lat, $meetup->group->group_lon ); 346 $location_parts = $this->parse_reverse_geocode_address( $geocoded_location ->address_components);346 $location_parts = $this->parse_reverse_geocode_address( $geocoded_location ); 347 347 $location = sprintf( 348 348 '%s%s%s', … … 444 444 protected function reverse_geocode( $latitude, $longitude ) { 445 445 $address = false; 446 $cache_key = 'geocode_' . md5( $latitude, $longitude ); 447 $cached_response = wp_cache_get( $cache_key, 'events' ); 448 449 if ( false !== $cached_response ) { 450 return $cached_response; 451 } 452 453 // Rough attempt at avoiding rate limit. 454 usleep( 75000 ); 455 446 456 $response = $this->remote_get( sprintf( 447 457 'https://maps.googleapis.com/maps/api/geocode/json?latlng=%s,%s&sensor=false', … … 455 465 $body = json_decode( wp_remote_retrieve_body( $response ) ); 456 466 457 if ( isset( $body->results[0] ) ) { 458 $address = $body->results[0]; 467 if ( isset( $body->results[0]->address_components ) ) { 468 $address = $body->results[0]->address_components; 469 wp_cache_set( $cache_key, $address, 'events', 0 ); 459 470 } 460 471 }
Note: See TracChangeset
for help on using the changeset viewer.