Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if (!function_exists('weather')) {
- function weather($atts, $content = null) {
- $params = shortcode_atts(array(
- 'city' => '',
- 'country' => '',
- ), $atts);
- $WeatherApi = "http://api.openweathermap.org/data/2.5/weather?q={$params['city']},{$params['country']}";
- $WeatherC = json_decode(@file_get_contents($WeatherApi));
- $f = $WeatherC->main->temp;
- $WeatherF = json_decode(@file_get_contents($WeatherApi . '&units=metric'));
- $c = $WeatherF->main->temp;
- return '<p>' . $c . "/" . $f . '</p>';
- }
- }
- add_shortcode('weather', 'weather');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement