WC_Geolocation::get_country_code_from_headers
Fetches the country code from the request headers, if one is available.
Метод класса: WC_Geolocation{}
Хуков нет.
Возвращает
Строку. The country code pulled from the headers, or empty string if one was not found.
Использование
$result = WC_Geolocation::get_country_code_from_headers();
Список изменений
| С версии 3.9.0 | Введена. |
Код WC_Geolocation::get_country_code_from_headers() WC Geolocation::get country code from headers WC 10.7.0
private static function get_country_code_from_headers() {
$country_code = '';
$headers = array(
'MM_COUNTRY_CODE',
'GEOIP_COUNTRY_CODE',
'HTTP_CF_IPCOUNTRY',
'HTTP_X_COUNTRY_CODE',
);
foreach ( $headers as $header ) {
if ( empty( $_SERVER[ $header ] ) ) {
continue;
}
$country_code = strtoupper( sanitize_text_field( wp_unslash( $_SERVER[ $header ] ) ) );
break;
}
return $country_code;
}