= 5.4 include 'inc/geolite2-compatibility.php'; $country_code = wpo_get_country_code_from_geolite2($defaults['wc_geolocate_database'], $defaults['WC_ABSPATH']); } if (!empty($country_code)) return $country_code; // 3. Use default country if (isset($defaults['wc_default_country'])) { $country_code = $defaults['wc_default_country']; return $country_code; } return ''; } /** * Get the user's IP Address (Extracted from WooCommerce WC_Geolocation::get_ip_address()) * * @return string */ function wpo_cache_get_visitor_ip_address() { if (isset($_SERVER['HTTP_X_REAL_IP'])) { return $_SERVER['HTTP_X_REAL_IP']; } elseif (isset($_SERVER['HTTP_X_FORWARDED_FOR'])) { // Proxy servers can send through this header like this: X-Forwarded-For: client1, proxy1, proxy2 // Make sure we always only send through the first IP in the list which should always be the client IP. return (string) trim(current(preg_split('/,/', $_SERVER['HTTP_X_FORWARDED_FOR']))); } elseif (isset($_SERVER['REMOTE_ADDR'])) { return $_SERVER['REMOTE_ADDR']; } return ''; }