WC_Geolite_Integration::get_country_iso()
Устарела с версии 3.9.0. Больше не поддерживается и может быть удалена. Рекомендуется заменить эту функцию на аналог.
Get country 2-letters ISO by IP address. Returns empty string when not able to find any ISO code.
Метод класса: WC_Geolite_Integration{}
Хуков нет.
Возвращает
Строку
.
Использование
$WC_Geolite_Integration = new WC_Geolite_Integration(); $WC_Geolite_Integration->get_country_iso( $ip_address );
- $ip_address(строка) (обязательный)
- User IP address.
Список изменений
Устарела с | 3.9.0 |
Код WC_Geolite_Integration::get_country_iso() WC Geolite Integration::get country iso WC 9.7.1
public function get_country_iso( $ip_address ) { wc_deprecated_function( 'get_country_iso', '3.9.0' ); $iso_code = ''; try { $reader = new MaxMind\Db\Reader( $this->database ); // phpcs:ignore PHPCompatibility.LanguageConstructs.NewLanguageConstructs.t_ns_separatorFound $data = $reader->get( $ip_address ); if ( isset( $data['country']['iso_code'] ) ) { $iso_code = $data['country']['iso_code']; } $reader->close(); } catch ( Exception $e ) { $this->log( $e->getMessage(), 'warning' ); } return sanitize_text_field( strtoupper( $iso_code ) ); }