File "class-wc-geolite-integration.php"
Full path: /home/kosmetik/public_html/wp-content/plugins/woocommerce/includes/class-wc-geolite-integration.php
File
size: 1014 B (1014 B bytes)
MIME-type: text/x-php
Charset: utf-8
Download Open Edit Advanced Editor Back
<?php
defined('ABSPATH') || exit;
class WC_Geolite_Integration
{
private $database = '';
private $log = null;
public function __construct($database)
{
$this->database = $database;
}
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);
$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));
}
private function log($message, $level = 'info')
{
if (is_null($this->log)) {
$this->log = wc_get_logger();
}
$this->log->log($level, $message, array('source' => 'geoip'));
}
}