Ładowanie...

krupapiotr.pl

Technologia, na której można polegać

TVP Kobieta

15]); if (!is_wp_error($response)) { $data = json_decode(wp_remote_retrieve_body($response), true); if (isset($data['weather'])) { set_transient('krupa_current_weather_data', $data, 3600); } } } // 2. Sprawdzenie prognozy - jeśli puste, wymuszamy pobranie if (false === get_transient('krupa_weather_transient_data')) { $url_f = "https://api.openweathermap.org/data/2.5/forecast?lat={$lat}&lon={$lon}&appid={$api_key}&units=metric&lang=pl"; $response_f = wp_remote_get($url_f, ['timeout' => 15]); if (!is_wp_error($response_f)) { $data_f = json_decode(wp_remote_retrieve_body($response_f), true); if (isset($data_f['list'])) { set_transient('krupa_weather_transient_data', $data_f, 3600); } } } } // Uruchamiamy silnik przy każdym ładowaniu strony, ale on i tak sprawdzi transienty // więc nie obciąży API, chyba że dane wygasną. add_action('init', 'krupa_weather_api_sync_engine', 1);