Ejemplo n.º 1
0
/**
 * The Wunderground shortcode
 *
 * @action wunderground_render_template Render the template with the settings passed to the shortcode
 * @param  string|array       $passed_atts  String or array of settings for the shortcode
 * @param  string      $content     Content inside shortcode tags. Should be empty.
 * @return [type]                   [description]
 */
function wunderground_shortcode($passed_atts = array(), $content = NULL, $shortcode = 'wunderground')
{
    $atts = wunderground_parse_atts($passed_atts, $shortcode);
    ob_start();
    $atts['wunderground'] = new KWS_Wunderground(new Wunderground_Request($atts['location'], null, $atts['language'], $atts['measurement']));
    do_action('wunderground_render_template', $atts['layout'], $atts);
    Wunderground_Plugin::log_debug('Shortcode Atts passed to render_template', $atts);
    $content = ob_get_clean();
    return $content;
}
 function __construct(Wunderground_Request $request)
 {
     $results = $request->get_results();
     if (!empty($results->error)) {
         // TODO: Handle properly
         Wunderground_Plugin::log_error('Error loading results KWS_Wunderground', $results->error);
         return NULL;
     }
     $this->response = new Wunderground_Response($request);
     $this->forecast = new Wunderground_Forecast($request);
     $this->current_observation = new Wunderground_Current_Observation($request);
     $this->alerts = new Wunderground_Alerts($request);
     Wunderground_Plugin::log_debug('Wunderground_Forecast', $this);
 }
 function __construct(Wunderground_Request $request)
 {
     $results = $request->get_results();
     if (empty($results->forecast)) {
         Wunderground_Plugin::log_error('Response is empty.');
         return NULL;
     }
     if (!empty($results->forecast) && !empty($results->forecast->days)) {
         $this->days = array();
         foreach ($results->forecast->days as $key => $day) {
             $this->days[] = new Wunderground_Forecast_Summary($day);
         }
     }
     Wunderground_Plugin::log_debug('Wunderground_Forecast', $this);
 }
Ejemplo n.º 4
0
 function __construct(Wunderground_Request $request)
 {
     $results = $request->get_results();
     #	echo '<pre>';
     #	print_r($results);
     #	echo '</pre>';
     if (!empty($results->error)) {
         die(print_r($results->error));
         return NULL;
     }
     $this->response = new Wunderground_Response($request);
     $this->forecast = new Wunderground_Forecast($request);
     $this->current_observation = new Wunderground_Current_Observation($request);
     $this->alerts = new Wunderground_Alerts($request);
     Wunderground_Plugin::log_debug('Wunderground_Forecast', $this);
 }
Ejemplo n.º 5
0
 private function set_results()
 {
     try {
         $url = $this->build_url();
     } catch (Exception $e) {
         Wunderground_Plugin::log_debug('Wunderground_Request had no location set. Returning because of exception.');
         return;
     }
     $response = self::request($url, $this->cache);
     $response = $this->_v2_json_fix($response);
     $this->results = json_decode($response);
     Wunderground_Plugin::log_debug('Wunderground_Request results for URL ' . $url, $this->results);
 }