Exemplo n.º 1
0
<?php

/**
 * Template: Event Low to High (plain text)
 *
 * Override this template in your own theme by creating a file at [your-child-theme]/tk-event-weather/low_high.php
 *
 */
if (!defined('ABSPATH')) {
    die('-1');
}
// make sure we have data to work with!
if (empty($context) || !is_object($context)) {
    return false;
}
$output = '';
if ($context->weather_hourly_high == $context->weather_hourly_low) {
    $output .= sprintf('<span class="degrees-same">%s%s</span>', TkEventWeather__Functions::temperature_to_display($context->weather_hourly_low), $context->temperature_units);
} else {
    $output .= sprintf('<span class="temperature-low">%s</span>
		<span class="temperature-separator">&ndash;</span>
		<span class="temperature-high">%s</span><span class="temperature-units">%s</span>', TkEventWeather__Functions::temperature_to_display($context->weather_hourly_low, 0, ''), TkEventWeather__Functions::temperature_to_display($context->weather_hourly_high), $context->temperature_units);
}
echo $output;
        } elseif (true === $context->sunrise_sunset['sunset_to_be_inserted'] && $context->sunrise_sunset['sunset_timestamp'] == $value->time) {
            // unless this hour's timestamp = sunset timestamp
        } else {
            // actually do this hour's weather
            $output .= TkEventWeather__Functions::template_start_of_each_item($context->template_class_name, $index);
            $wind_bearing = '';
            if (isset($value->windBearing)) {
                $wind_bearing = $value->windBearing;
            }
            $wind_direction = TkEventWeather__Functions::wind_bearing_to_direction($value->windBearing, false);
            $wind_html = sprintf('<span class="%1$s__wind" title="%2$s %3$s %4$s">%2$s %3$s</span>', $context->template_class_name, TkEventWeather__Functions::rounded_float_value($value->windSpeed), $context->wind_speed_units, $wind_direction);
            $output .= sprintf('">
				<span data-timestamp="%1$d" class="%2$s__time">%3$s</span>
				<span class="%2$s__icon %4$s" title="%5$s">%6$s</span>
				<span class="%2$s__temperature">%7$s%8$s</span>
				%9$s', $value->time, $context->template_class_name, $display_time, $value->icon, $value->summary, TkEventWeather__Functions::icon_html($value->icon), TkEventWeather__Functions::temperature_to_display($value->temperature), $context->temperature_units, $wind_html);
            $output .= PHP_EOL;
            $output .= '</div>';
            // close template_start_of_each_item()
            $index++;
            // increment index
        }
    }
    // now do sunrise or sunset
    if (true === $context->sunrise_sunset['sunrise_to_be_inserted'] && $value->time == $context->sunrise_sunset['sunrise_hour_timestamp']) {
        $output .= TkEventWeather__Functions::template_start_of_each_item($context->template_class_name, $index);
        $output .= sprintf(' sunrise">
			<span data-timestamp="%1$d" class="%2$s__time">%3$s</span>
			<span class="%2$s__icon sunrise" title="%4$s">%5$s</span>
			<span>&nbsp;</span>', $context->sunrise_sunset['sunrise_timestamp'], $context->template_class_name, TkEventWeather__Functions::timestamp_to_display($context->sunrise_sunset['sunrise_timestamp'], $context->utc_offset_hours, __('g:i')), __('Sunrise', 'tk-event-weather'), TkEventWeather__Functions::icon_html('sunrise'));
        $output .= PHP_EOL;