/** * Try to get a language-sensitive place administrative name. * * First look in the names cached in the database, then query geonames.org for it. * If a name can't be found for the requested language, a default name is returned, * usually in the local language. If nothing can be found, returns NULL. * * @since 1.4 * * @param string $country_code Two-character ISO country code. * @param string $admin_code Code for the administrative area within the country, or NULL to get the country name. * @param string $language Language code, defaults to the WordPress locale language. * @return string|null Place name in the appropriate language, or if not available in the default language. */ public static function get_administrative_name($country_code, $admin_code = null, $language = '') { $language = self::primary_language_code($language); $name = GeoMashupDB::get_cached_administrative_name($country_code, $admin_code, $language); if (empty($name)) { // Look it up with Geonames if (!class_exists('GeoMashupHttpGeocoder')) { include_once path_join(GEO_MASHUP_DIR_PATH, 'geo-mashup-geocoders.php'); } $geocoder = new GeoMashupGeonamesGeocoder(); $name = $geocoder->get_administrative_name($country_code, $admin_code); if (is_wp_error($name)) { $name = null; } } return $name; }