Plugin Directory

Changeset 347725


Ignore:
Timestamp:
02/19/2011 02:37:19 PM (15 years ago)
Author:
Nordvind
Message:

fahrenheit added

Location:
simple-weather/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • simple-weather/trunk/readme.txt

    r345165 r347725  
    55Requires at least: 2.8
    66Tested up to: 3.0.5
    7 Stable tag: 1.29
     7Stable tag: 1.30
    88
    99Shows current weather for specified location.
     
    2929== Upgrade Notice ==
    3030
     31= 0.39 =
     32
     33You can now specify temperature scale to use (Celsius or Fahrenheit).
     34
    3135= 0.38 =
    3236
     
    3943== Changelog ==
    4044
     45= 0.39 =
     46
     47Fahrenheit scale added.
     48
    4149= 0.38 =
    4250
  • simple-weather/trunk/simple_weather.php

    r345036 r347725  
    44 * Plugin URI: http://code.google.com/p/wp-simple-weather/
    55 * 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.38
     6 * Version: 0.39
    77 * Author: Nordvind
    88 * Author URI: http://www.recon-by-fire.eu
     
    8787        return $hmd;
    8888    }
    89     public function get_temper(){
     89    public function get_temper($tm){
    9090        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';
    9294        return $t;
    9395    }
     
    125127    function widget($args,$instance){
    126128        $loc = $instance['location'];
     129        $tm = $instance['measure'];
    127130        if (empty($loc)) $loc = 'Riga';
    128131       
     
    137140        echo '<div id="weather-text-data">';
    138141        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 />';
    140143        echo '<p>'.$g->get_condition().'</p>';
    141144        echo '<p id="w-humid">'.$g->get_hum().'</p>';
     
    152155    $instance = $old_instance;
    153156    $instance['location'] = strip_tags( $new_instance['location'] );
     157    $instance['measure'] = $new_instance['measure'];
    154158    return $instance;
    155159    }
    156160    function form($instance){
    157     $def = array('location' => 'Riga');
     161    $def = array('measure' => 'C','location' => 'Riga');
    158162    $instance = wp_parse_args((array)$instance,$def);
    159163    ?>
     
    164168    style="width:100%;" />
    165169    </p>
    166     <p style="color:#505050;">You can fill location field like this:<br />
     170    <p style="color:#606060;">You can fill in location field like this:<br />
    167171    <span>[city]</span><br />
    168172    <span>or</span><br />
     
    170174    </p>
    171175    <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>
    172183    <?php
    173184    }
Note: See TracChangeset for help on using the changeset viewer.