There are no products on the Wishlist!
private function geoip_lookup($ip) { if (!$ip) { return ['country' => null, 'city' => null, 'lat' => null, 'lng' => null]; } $cache_key = 'wclv_geo_' . md5($ip); $cached = get_transient($cache_key); if ($cached) return $cached; $response = wp_remote_get('http://ip-api.com/json/' . rawurlencode($ip) . '?fields=status,countryCode,city,lat,lon', [ 'timeout' => 3, ]); if (is_wp_error($response)) { return ['country' => null, 'city' => null, 'lat' => null, 'lng' => null]; } $body = json_decode(wp_remote_retrieve_body($response), true); if (!is_array($body) || ($body['status'] ?? '') !== 'success') { return ['country' => null, 'city' => null, 'lat' => null, 'lng' => null]; } $geo = [ 'country' => sanitize_text_field($body['countryCode'] ?? ''), 'city' => sanitize_text_field($body['city'] ?? ''), 'lat' => isset($body['lat']) ? (float) $body['lat'] : null, 'lng' => isset($body['lon']) ? (float) $body['lon'] : null, ]; set_transient($cache_key, $geo, DAY_IN_SECONDS * 7); return $geo; }