Advertisement
fabi0

Untitled

Aug 20th, 2014
265
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.63 KB | None | 0 0
  1. if (!function_exists('weather')) {
  2.  
  3.     function weather($atts, $content = null) {
  4.         $params = shortcode_atts(array(
  5.             'city' => '',
  6.             'country' => '',
  7.                 ), $atts);
  8.         $WeatherApi = "http://api.openweathermap.org/data/2.5/weather?q={$params['city']},{$params['country']}";
  9.         $WeatherC = json_decode(@file_get_contents($WeatherApi));
  10.         $f = $WeatherC->main->temp;
  11.         $WeatherF = json_decode(@file_get_contents($WeatherApi . '&units=metric'));
  12.         $c = $WeatherF->main->temp;
  13.         return '<p>' . $c . "/" . $f . '</p>';
  14.     }
  15.  
  16. }
  17. add_shortcode('weather', 'weather');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement