Created WC_Geo_IP class
This commit is contained in:
parent
3e9f06a8eb
commit
5389dc3812
File diff suppressed because it is too large
Load Diff
|
@ -170,13 +170,15 @@ class WC_Geolocation {
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
private static function geolocate_via_db( $ip_address ) {
|
private static function geolocate_via_db( $ip_address ) {
|
||||||
if ( ! class_exists( 'GeoIP' ) && ! class_exists( 'geoiprecord' ) ) {
|
if ( ! class_exists( 'WC_Geo_IP' ) ) {
|
||||||
include_once( 'libraries/geoip.php' );
|
include_once( 'class-wc-geo-ip.php' );
|
||||||
}
|
}
|
||||||
$database = self::get_local_database_path();
|
$database = self::get_local_database_path();
|
||||||
$gi = geoip_open( $database, GEOIP_STANDARD );
|
$gi = new WC_Geo_IP();
|
||||||
$country_code = geoip_country_code_by_addr( $gi, $ip_address );
|
|
||||||
geoip_close( $gi );
|
$gi->geoip_open( $database, 0 );
|
||||||
|
$country_code = $gi->geoip_country_code_by_addr( $ip_address );
|
||||||
|
$gi->geoip_close();
|
||||||
|
|
||||||
return sanitize_text_field( strtoupper( $country_code ) );
|
return sanitize_text_field( strtoupper( $country_code ) );
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue