- Timestamp:
- 03/07/2017 01:28:35 AM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/api.wordpress.org/public_html/events/1.0/index.php
r5099 r5100 140 140 * @param string $country_code 141 141 * 142 * @return false| array false on failure; an arrayon success142 * @return false|object false on failure; an object on success 143 143 */ 144 144 function guess_location_from_city( $location_name, $timezone, $country_code ) { 145 145 $guess = guess_location_from_geonames( $location_name, $timezone, $country_code ); 146 146 $location_word_count = str_word_count( $location_name ); 147 $location_name_parts = explode( ' ', $location_name ); 148 149 /* 150 * Multi-word queries may contain cities, regions, and countries, so try to extract just the city 151 */ 152 if ( ! $guess && $location_word_count >= 2 ) { 153 // Catch input like "Portland Maine" 154 $guess = guess_location_from_geonames( $location_name_parts[0], $timezone, $country_code ); 155 } 156 157 if ( ! $guess && $location_word_count >= 3 ) { 158 // Catch input like "Sao Paulo Brazil" 159 $city_name = sprintf( '%s %s', $location_name_parts[0], $location_name_parts[1] ); 160 $guess = guess_location_from_geonames( $city_name, $timezone, $country_code ); 161 } 147 162 148 163 // Normalize all errors to boolean false for consistency
Note:
See TracChangeset
for help on using the changeset viewer.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)