Warning: This method has been deprecated.
WC_Geolite_Integration::get_country_iso( string $ip_address )
Get country 2-letters ISO by IP address.
Description Description
Returns empty string when not able to find any ISO code.
Parameters Parameters
- $ip_address
-
(Required) User IP address.
Return Return
(string)
Source Source
File: includes/class-wc-geolite-integration.php
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 ) ); }
Changelog Changelog
Version | Description |
---|---|
3.9.0 | Introduced. |