|
@@ -43,12 +43,12 @@ discard block |
|
|
block discarded – undo |
|
43
|
43
|
*/ |
|
44
|
44
|
function geocode( $address ) { |
|
45
|
45
|
|
|
46
|
|
- $location = new \WP_Error(100, 'No results found', array( 'address' => $address ) ); |
|
|
46
|
+ $location = new \WP_Error( 100, 'No results found', array( 'address' => $address ) ); |
|
47
|
47
|
$url = $this->_make_url( $address ); |
|
48
|
48
|
|
|
49
|
49
|
$response = $this->_make_request( $url ); |
|
50
|
50
|
|
|
51
|
|
- if ( ! is_wp_error( $response ) && count( $response['results'] ) > 0 ) { |
|
|
51
|
+ if ( !is_wp_error( $response ) && count( $response['results'] ) > 0 ) { |
|
52
|
52
|
$location = $this->_make_location( $response['results'][0] ); |
|
53
|
53
|
} |
|
54
|
54
|
|
|
@@ -81,7 +81,7 @@ discard block |
|
|
block discarded – undo |
|
81
|
81
|
$response = new Location( array( |
|
82
|
82
|
'address' => $results['formatted_address'], |
|
83
|
83
|
'formatted_address' => $results['formatted_address'], |
|
84
|
|
- 'state' => isset( $results['address_components'][4] ) ? $results['address_components'][4]['short_name'] : '', |
|
|
84
|
+ 'state' => isset($results['address_components'][4]) ? $results['address_components'][4]['short_name'] : '', |
|
85
|
85
|
'latitude' => $results['geometry']['location']['lat'], |
|
86
|
86
|
'longitude' => $results['geometry']['location']['lng'], |
|
87
|
87
|
'place_id' => $results['place_id'], |
|
@@ -125,7 +125,7 @@ discard block |
|
|
block discarded – undo |
|
125
|
125
|
|
|
126
|
126
|
$cache_key = md5( serialize( $url ) ); |
|
127
|
127
|
|
|
128
|
|
- if ( ! $data = wp_cache_get( $cache_key ) ) { |
|
|
128
|
+ if ( !$data = wp_cache_get( $cache_key ) ) { |
|
129
|
129
|
$data = wp_remote_get( $url ); |
|
130
|
130
|
wp_cache_add( $cache_key, $data, 300 ); |
|
131
|
131
|
} |