Changeset 347725
- Timestamp:
- 02/19/2011 02:37:19 PM (15 years ago)
- Location:
- simple-weather/trunk
- Files:
-
- 2 edited
-
readme.txt (modified) (3 diffs)
-
simple_weather.php (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
simple-weather/trunk/readme.txt
r345165 r347725 5 5 Requires at least: 2.8 6 6 Tested up to: 3.0.5 7 Stable tag: 1. 297 Stable tag: 1.30 8 8 9 9 Shows current weather for specified location. … … 29 29 == Upgrade Notice == 30 30 31 = 0.39 = 32 33 You can now specify temperature scale to use (Celsius or Fahrenheit). 34 31 35 = 0.38 = 32 36 … … 39 43 == Changelog == 40 44 45 = 0.39 = 46 47 Fahrenheit scale added. 48 41 49 = 0.38 = 42 50 -
simple-weather/trunk/simple_weather.php
r345036 r347725 4 4 * Plugin URI: http://code.google.com/p/wp-simple-weather/ 5 5 * Description: Shows current weather for your specified location. Makes use of "secret" Google Weather API. Uses cURL, so works even on hosts with security restricions, like url-disabled file_get_contents. 6 * Version: 0.3 86 * Version: 0.39 7 7 * Author: Nordvind 8 8 * Author URI: http://www.recon-by-fire.eu … … 87 87 return $hmd; 88 88 } 89 public function get_temper( ){89 public function get_temper($tm){ 90 90 if (empty($this->w_xml)) return -1; 91 $t = $this->w_xml->getElementsByTagName('temp_c')->item(0)->getAttribute('data'); 91 if ($tm == 'C') $t = $this->w_xml->getElementsByTagName('temp_c')->item(0)->getAttribute('data'); 92 elseif ($tm == 'F') $t = $this->w_xml->getElementsByTagName('temp_f')->item(0)->getAttribute('data'); 93 else $t = 'ivalid parameter'; 92 94 return $t; 93 95 } … … 125 127 function widget($args,$instance){ 126 128 $loc = $instance['location']; 129 $tm = $instance['measure']; 127 130 if (empty($loc)) $loc = 'Riga'; 128 131 … … 137 140 echo '<div id="weather-text-data">'; 138 141 echo '<span id="loc-name">'.$g->get_loc().'</span>'; 139 echo '<span id="curr-t">'.$g->get_temper( ).'C</span><br />';142 echo '<span id="curr-t">'.$g->get_temper($tm).$tm.'</span><br />'; 140 143 echo '<p>'.$g->get_condition().'</p>'; 141 144 echo '<p id="w-humid">'.$g->get_hum().'</p>'; … … 152 155 $instance = $old_instance; 153 156 $instance['location'] = strip_tags( $new_instance['location'] ); 157 $instance['measure'] = $new_instance['measure']; 154 158 return $instance; 155 159 } 156 160 function form($instance){ 157 $def = array(' location' => 'Riga');161 $def = array('measure' => 'C','location' => 'Riga'); 158 162 $instance = wp_parse_args((array)$instance,$def); 159 163 ?> … … 164 168 style="width:100%;" /> 165 169 </p> 166 <p style="color:# 505050;">You can filllocation field like this:<br />170 <p style="color:#606060;">You can fill in location field like this:<br /> 167 171 <span>[city]</span><br /> 168 172 <span>or</span><br /> … … 170 174 </p> 171 175 <p style="color:#FF0000;">Warning: no whitespace allowed in location field</p> 176 <p> 177 <label for="<?php echo $this->get_field_id('measure'); ?>">Temperature measure:</label><br /> 178 <input id="<?php echo $this->get_field_id( 'title' ); ?>" type="radio" name="<?php 179 echo $this->get_field_name( 'measure' ); ?>" value="C" <?php if($instance['measure']=='C') echo 'checked="checked"' ?> /> Celsius<br /> 180 <input type="radio" id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php 181 echo $this->get_field_name( 'measure' ); ?>" value="F" <?php if($instance['measure']=='F') echo 'checked="checked"' ?> /> Fahrenheit 182 </p> 172 183 <?php 173 184 }
Note: See TracChangeset
for help on using the changeset viewer.