コード例 #1
0
 function __construct(Wunderground_Request $request)
 {
     $results = $request->get_results();
     if (empty($results->response)) {
         Wunderground_Plugin::log_error('Response is empty.');
         return NULL;
     }
     foreach ($results->response as $key => $value) {
         $this->{$key} = $value;
     }
     $this->date = empty($this->date) ? NULL : new Wunderground_Date($this->date);
 }
コード例 #2
0
 function __construct()
 {
     self::$file = __FILE__;
     self::$dir_path = plugin_dir_path(__FILE__);
     // Fire AJAX requests immediately
     include_once self::$dir_path . 'inc/class-ajax.php';
     // Load once we're sure everything's been loaded.
     add_action('plugins_loaded', array(&$this, 'require_files'));
     add_action('init', array(&$this, 'init'));
     // Use the `wunderground_log_debug` action for logging
     add_action('wunderground_log_debug', array('Wunderground_Plugin', 'log_debug'), 10, 2);
 }
コード例 #3
0
 function __construct($request)
 {
     $results = $request->get_results();
     if (empty($results->forecast)) {
         Wunderground_Plugin::log_error('Response is empty.');
         return NULL;
     }
     foreach ($results->current_observation as $key => $value) {
         $this->{$key} = $value;
     }
     $this->station = new Wunderground_Station($this->station);
     $this->date = new Wunderground_Date($this->date);
 }
コード例 #4
0
 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);
 }
コード例 #5
0
ファイル: functions.php プロジェクト: umairakhtar123/hova
/**
 * Handle edgecases and validation for shortcode attributes.
 *
 * @link http://codex.wordpress.org/Formatting_Date_and_Time Date & Time formatting
 * @param  array      $passed_atts   Array of values to parse
 * @param  array      $shortcode Name of shortcode being used (`wunderground`)
 * @return array                [description]
 */
function wunderground_parse_atts($passed_atts, $shortcode = 'wunderground')
{
    $defaults = array('title' => __('Weather Forecast', 'wunderground'), 'location_title' => NULL, 'location_data' => '', 'city' => '', 'location' => '', 'iconset' => 'Incredible', 'numdays' => 5, 'class' => 'wp_wunderground', 'layout' => 'table-vertical', 'measurement' => 'english', 'datelabel' => 'm/d', 'language' => wunderground_get_language(), 'showdata' => array('search', 'alerts', 'daynames', 'pop', 'icon', 'text', 'conditions', 'date'), 'hidedata' => array());
    // Use previous settings as defaults to better support backward compatibility
    $defaults = wp_parse_args(get_option('wp_wunderground', array()), $defaults);
    if (!empty($shortcode)) {
        $atts = shortcode_atts($defaults, $passed_atts, $shortcode);
    } else {
        $atts = wp_parse_args((array) $passed_atts, $defaults);
    }
    $atts['datelabel'] = wunderground_get_date_format($atts['datelabel']);
    // If there was no numdays passed,
    // 4 is a better default for table-horizontal layout
    if (empty($passed_atts['numdays'])) {
        switch ($atts['layout']) {
            case 'table-horizontal':
                $atts['numdays'] = 4;
                break;
        }
    }
    // Convert comma-separated value to array
    $atts['showdata'] = is_string($atts['showdata']) ? explode(',', $atts['showdata']) : $atts['showdata'];
    if (!is_numeric($atts['numdays'])) {
        Wunderground_Plugin::log_error(sprintf('"numdays" was set not a number: %s. Changed to the default: %d. wunderground_shortcode', $atts['numdays'], $defaults['numdays']));
        $atts['numdays'] = $defaults['numdays'];
    } else {
        if (absint($atts['numdays']) > 10) {
            Wunderground_Plugin::log_error(sprintf('"numdays" set too high in shortcode: %s. It was changed to the max: 10. wunderground_shortcode', $atts['numdays']));
            $atts['numdays'] = 10;
        }
    }
    // What to show in the search bar
    if (empty($atts['location_title'])) {
        $atts['location_title'] = $atts['location'];
    }
    // Process hidedata/showdata
    if (!empty($atts['hidedata'])) {
        $hidedata = is_array($atts['hidedata']) ? $hidedata : explode(',', $atts['hidedata']);
        // For each hidedata, unset showdata.
        foreach ($hidedata as $value) {
            foreach ($atts['showdata'] as $k => $v) {
                if ($v === $value) {
                    unset($atts['showdata'][$k]);
                }
            }
        }
    }
    return $atts;
}
コード例 #6
0
 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);
 }
コード例 #7
0
ファイル: Wunderground.php プロジェクト: umairakhtar123/hova
 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);
 }
コード例 #8
0
ファイル: class-request.php プロジェクト: umairakhtar123/hova
 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);
 }