function ywttp_html($atts) { YWTTP::update_attributes($atts); YWTTP::query(); echo YWTTP::render(); }
private function render_forecast() { if (!isset(self::$data['results']['channel']['item']['forecast'])) { return '[ywttp ErrorQuery]'; } $data = self::$data['results']['channel']['item']['forecast']; $forecast_day_count = count($data); $forecast_city_title = self::$data['results']['channel']['title']; $return = '<div class="ywttp"><table class="ywttp-forecast">'; $return .= '<thead><tr><td colspan="' . $forecast_day_count . '">' . $forecast_city_title . '</td></tr></thead>'; $return .= '<tbody>'; $day_row = ''; // first row of days $temp_row = ''; //second row of temperature foreach ($data as $k => $v) { //formatting date $date = strtotime($v['date']); if ($date === false) { $date = $v['date']; } else { $date = strftime('%d.%m', $date); } $day_row .= '<th>' . $date . '</th>'; $temp_low = $v['low']; $temp_high = $v['high']; $temp_str = 'F'; if (self::$atts['celsius']) { $temp_low = YWTTP::fahrenheit_to_celsius($temp_low); $temp_high = YWTTP::fahrenheit_to_celsius($temp_high); $temp_str = 'C'; } $temp_row .= '<td>' . $temp_low . ' .. ' . $temp_high . ' °' . $temp_str . '</td>'; } $return .= '<tr>' . $day_row . '</tr>'; $return .= '<tr>' . $temp_row . '</tr>'; $return .= '</tbody>'; $return .= '</table></div>'; return $return; }