Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function weatherWidget($place) {
- //delete_transient('weatherWidget');
- $transient = 'weatherWidget';
- $weather = get_transient($transient);
- if(false === $weather) {
- $weather = json_decode(json_encode((array) simplexml_load_file('http://www.google.com/ig/api?weather='.$place)),1);
- set_transient($transient, $weather, 60 * 60 * 1); // clear cache every 60 minutes
- }
- $temp_c = $weather['weather']['current_conditions']['temp_c']['@attributes']['data'];
- $base = get_template_directory_uri().'/library/images';
- $icon = $base.$weather['weather']['current_conditions']['icon']['@attributes']['data'];
- echo "<span class='temp'>$temp_c °</span><img src='$icon' alt='weather'>";
- } // end weatherWidget
Add Comment
Please, Sign In to add comment