/** * Logging method. * * @param string $message */ public static function log($message) { if (empty(self::$log)) { self::$log = new WC_Logger(); } self::$log->add('geoip', $message); }
/** * Logging method. * * @param string $message */ public static function log($message) { if (!class_exists('WC_Logger')) { include_once 'class-wc-logger.php'; } if (empty(self::$log)) { self::$log = new WC_Logger(); } self::$log->add('geoip', $message); }
/** * Use MAXMIND GeoLite database to geolocation the user. * @param string $ip_address * @return string */ private static function geolocate_via_db($ip_address) { if (!class_exists('WC_Geo_IP')) { include_once 'class-wc-geo-ip.php'; } $gi = new WC_Geo_IP(); if (self::is_IPv6($ip_address)) { $database = self::get_local_database_path('v6'); $gi->geoip_open($database, 0); $country_code = $gi->geoip_country_code_by_addr_v6($ip_address); } else { $database = self::get_local_database_path(); $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)); }