WordPress.org

Plugin Directory

Changeset 811233


Ignore:
Timestamp:
11/27/13 08:48:50 (3 years ago)
Author:
bradmkjr
Message:

Added display choices for widget, to select currencies.

Location:
bitcoin-exchange-widget/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • bitcoin-exchange-widget/trunk/btc-exchange.php

    r809966 r811233  
    22/** 
    33 * @package btc-exchange 
    4  * @version 1.14 
     4 * @version 1.15 
    55 */ 
    66/* 
    77Plugin Name: BTC Exchange Rate Widget 
    88Plugin URI: http://wordpress.org/plugins/btc-exchange-widget/ 
    9 Description: Show realtime BTC exchange rates in sidebar widgets. 
     9Description: Show BTC exchange rates in sidebar widgets. Rates shown in 16 different international currencies. 
    1010Author: Bradford Knowton 
    11 Version: 1.14 
     11Version: 1.15 
    1212Author URI: http://bradknowlton.com/ 
    1313License: GPLv2 or later 
     
    2323    // property declaration 
    2424    protected $url = BLOCKCHAIN_TICKET_URL;  
     25    protected $displayed_values = array(); 
    2526     
    2627    /** 
     
    5253        $json = $this->load_json($this->url); 
    5354         
    54         echo '<ul>'; 
     55        echo '<ul class="bitcoin-widget-list">'; 
    5556        foreach($json as $key => $value){ 
    56             // var_dump($value); 
    57             echo sprintf("<li>1 BTC = %s %.2f %s</li>", $value->symbol, $value->{'15m'}, $key); 
     57             
     58            if(in_array($key, $instance['displayed_values'])){ 
     59                echo sprintf("<li>1 BTC = %s %.2f %s</li>", $value->symbol, $value->{'15m'}, $key);  
     60            } 
     61             
    5862        } 
    5963        echo '</ul>'; 
     
    7074     */ 
    7175    public function form( $instance ) { 
    72         if ( isset( $instance[ 'title' ] ) ) { 
    73             $title = $instance[ 'title' ]; 
     76         
     77        if ( isset( $instance ) ) { 
     78            $title = esc_attr($instance[ 'title' ]); 
     79            $displayed_values = $instance['displayed_values']; 
    7480        } 
    7581        else { 
    7682            $title = __( 'New title', 'text_domain' ); 
     83            $displayed_values = array(); 
    7784        } 
    7885        ?> 
     
    8087        <label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php _e( 'Title:' ); ?></label>  
    8188        <input class="widefat" id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" type="text" value="<?php echo esc_attr( $title ); ?>" /> 
     89        </p> 
     90        <p> 
     91        <label for="<?php echo $this->get_field_id( 'displayed_values' ); ?>"><?php _e( 'Currencies to Display in Widget:' ); ?></label>  
     92        <ul> 
     93        <?php 
     94        $json = $this->load_json($this->url); 
     95                 
     96        echo '<ul class="bitcoin-widget-list">'; 
     97        foreach($json as $key => $value){ 
     98            ?>   
     99                <li> 
     100                <label for="displayed_values_<?php echo $key; ?>"> 
     101                <input class="" id="displayed_values_<?php echo $key; ?>" name="<?php echo $this->get_field_name('displayed_values'); ?>[]" type="checkbox" value="<?php echo esc_attr( $key ); ?>" 
     102                    <?php if(in_array($key, $displayed_values)){echo ' checked="checked" '; } ?> 
     103                 /> <?php echo $key; ?></label> 
     104                </li> 
     105            <?php 
     106        } 
     107        ?> 
     108        </ul> 
    82109        </p> 
    83110        <?php  
     
    95122     */ 
    96123    public function update( $new_instance, $old_instance ) { 
     124     
    97125        $instance = array(); 
    98126        $instance['title'] = ( ! empty( $new_instance['title'] ) ) ? strip_tags( $new_instance['title'] ) : ''; 
     127        $instance['displayed_values'] = ( ! empty( $new_instance['displayed_values'] ) ) ? $new_instance['displayed_values'] : array(); 
    99128 
    100129        return $instance; 
     
    119148         
    120149        // check cache, if it exists otherwise reload url 
    121         $result = wp_cache_get( 'iphods_'.$key ); 
     150        $result = wp_cache_get( 'btc_exchange_widget_'.$key ); 
    122151        if ( false === $result ) { 
    123152            $result = wp_remote_get($url); 
     
    127156            }  
    128157             
    129             wp_cache_set( 'iphods_'.$key, $result['body'], 'btc_exchange', 15*60 ); 
     158            wp_cache_set( 'btc_exchange_widget_'.$key, $result['body'], 'btc_exchange', 15*60 ); 
    130159        }  
    131160        // Do something with $result; 
  • bitcoin-exchange-widget/trunk/readme.txt

    r811224 r811233  
    55Requires at least: 3.6.1 
    66Tested up to: 3.7.1 
    7 Stable tag: 1.14 
     7Stable tag: 1.15 
    88License: GPLv2 or later 
    99License URI: http://www.gnu.org/licenses/gpl-2.0.html 
     
    24242. Drag the widget to the desired sidebar on the appearance panel of the wordpress dashboard. 
    25253. Enter in the desired title, leave blank for no title. 
    26 4. Save, and view it on the frontend of site. 
    27 5. Enjoy. 
     264. Select which currencies will be displayed in widget on front of site. 
     275. Save, and view it on the frontend of site. 
     286. Enjoy. 
    2829 
    2930 
     
    4849* Added in WP standard caching, to minimize load on API. 
    4950 
     51= 1.15 = 
     52* Added donation information into readme.txt and plugin description 
     53* Added checkboxes to choose which Currencies will be displayed in Widget+ 
     54 
    5055== Upgrade Notice == 
    5156 
    5257= 1.14 = 
    5358No previous version was released, no upgrade actions required. 
     59 
     60= 1.15 = 
     61Addition of instance storage of display data, should be 100% painless upgrade. 
Note: See TracChangeset for help on using the changeset viewer.