Merge pull request #7367 from woothemes/wc-geo-ip

WC_Geo_IP class
This commit is contained in:
Claudio Sanches 2015-02-11 16:04:56 -02:00
commit 3593df34b3
3 changed files with 1750 additions and 1891 deletions

1738
includes/class-wc-geo-ip.php Normal file

File diff suppressed because it is too large Load Diff

View File

@ -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 ) );
} }

File diff suppressed because it is too large Load Diff