the_title(); ?> "><?php the_title(); ?> </a></h1> <div class="aside"> <?php the_content(); ?> </div> <div class="aside-info"><?php the_time("l"); ?> <?php if (get_post_meta($post->ID, 'weather_value', true) != '') { $weather = get_weather(); ?> <div class="weather-name"><?php echo $weather[get_post_meta($post->ID, 'weather_value', true)]; ?> </div> <div class="weather-box weather-<?php echo get_post_meta($post->ID, 'weather_value', true); ?> "></div> <?php } ?> </div> </article>
<?php /** * Created by PhpStorm. * User: steveperry * Date: 9/14/15 * Time: 6:41 PM */ $cities = ['Denver', 'New York City', 'Los Angeles']; $err = []; $all_weather = get_weather($cities); function get_weather($ary) { $all_weather = []; foreach ($ary as $val) { $req = curl_init('http://api.openweathermap.org/data/2.5/weather?q=' . urlencode($val)); curl_setopt($req, CURLOPT_HEADER, false); curl_setopt($req, CURLOPT_RETURNTRANSFER, true); $data = curl_exec($req); $all_weather[$val] = json_decode($data, true); } return $all_weather; } function kelvin_to_fahrenheit($int) { return ($int - 273.15) * 1.8 + 32; } function prittify_text($str) { return ucfirst($str) . '.'; }
function new_meta_boxes() { global $post, $new_meta_boxes; foreach ($new_meta_boxes as $meta_box) { $meta_box_value = get_post_meta($post->ID, $meta_box['name'] . '_value', true); echo '<input type="hidden" name="' . $meta_box['name'] . '_noncename" id="' . $meta_box['name'] . '_noncename" value="' . wp_create_nonce(plugin_basename(__FILE__)) . '" />'; echo '<h4>' . $meta_box['std'] . '</h4>'; if ($meta_box['name'] == 'weather') { ?> <select name="<?php echo $meta_box['name'] . '_value'; ?> "> <?php $weather = get_weather(); foreach ($weather as $key => $val) { ?> <option <?php if ($key == $meta_box_value) { echo "selected"; } ?> value="<?php echo $key; ?> "><?php echo $val; ?> </option> <?php } ?> </select> <?php } else { echo '<textarea cols="60" rows="3" name="' . $meta_box['name'] . '_value">' . $meta_box_value . '</textarea><br />'; } } }
// Изменение города if ($_POST['update']) { $data = array('appid' => $_POST['appid'], 'period' => $_POST['period'], 'units' => $_POST['units'], 'title' => $_POST['title'], 'city_id' => $_POST['city-id']); $update_city = $db->query("UPDATE " . DB_PREFIX . "_weather SET ?u WHERE id=?i", $data, $_POST['id']); if ($update_city) { $message = 'Настройки города обновлены'; } else { $error = 'Возникла ошибка при обновлении настроек города'; } } // удаление города if ($_GET['action'] == 'delete' && empty($error)) { terminator(); } if ($_GET['action'] == 'add' || $_GET['action'] == 'edit') { if ($_GET['action'] == 'edit') { $sql_list = $db->getRow("SELECT * FROM " . DB_PREFIX . "_weather WHERE id=?i", $_GET['id']); } $tpl = "weather_add_tpl.php"; } // просмотр данных выбранного города if ($_GET['action'] == 'view') { get_weather($_GET['id']); $tpl = "weather_view_tpl.php"; } if ($_GET['action'] == 'list') { $limit = '10'; $sql_array = get_weather_list($limit); $tpl = "weather_list_tpl.php"; } include "weather_main_tpl.php";
} } } } } } } } } } return $ret; } //TEMPMAXC $out = ''; $weather_req = urlencode($word); $url = 'API'; $content = httpGet($url); $weather = get_weather($content); if ($weather == '') { $url = 'API'; $content = httpGet($url); $out = get_region($content); if ($out != '') { $weather_req = urlencode($out); $url = 'API'; $content = httpGet($url); $weather = get_weather($content); } } $weather_return = $weather; //out put will get in $weather;