Plugin Directory

Changeset 917703


Ignore:
Timestamp:
05/20/2014 06:38:05 AM (12 years ago)
Author:
kjbenk
Message:

Fixed Bug with Multiple Portfolios

File:
1 edited

Legend:

Unmodified
Added
Removed
  • show-stock-quotes/trunk/show_stock_quotes.php

    r870535 r917703  
    44Plugin URI: http://kylebenkapps.com/wordpress-plugins/
    55Description: Show stock quotes updated in real-time.
    6 Version: 1.4.1
     6Version: 1.5
    77Author: Kyle Benk
    88Author URI: http://kylebenkapps.com
     
    4949    /** @see WP_Widget::widget */
    5050    function widget($args, $instance) {
     51       
    5152        extract( $args );
     53       
    5254        $title = $instance['title'];
    5355       
     
    6062        }
    6163       
    62         $tickers = $this->kjb_get_stock_data($instance);
     64        $tickers = array();
     65       
     66        for ($i = 1; $i < 21; $i++) {
     67           
     68            $ticker = $instance['stock_' . $i];
     69           
     70            if ($ticker != '') {
     71                $tickers[] = $ticker;
     72            }
     73        }
     74       
     75        $this->kjb_get_stock_data($instance);
    6376       
    6477        //Display all stock data
     
    143156                $stock = isset($instance['stock_'.$i]) ? $instance['stock_'.$i] : '';
    144157                ?>
    145                 <li><input class="widefat" id="<?php echo $this->get_field_id( 'stock_'.$i ); ?>" name="<?php echo $this->get_field_name( 'stock_'.$i); ?>" type="text" value="<?php echo esc_attr( $stock ); ?>" /></li>
     158                <li><input class="widefat" id="<?php echo $this->get_field_id( 'stock_'.$i ); ?>" name="<?php echo $this->get_field_name('stock_' . $i); ?>" type="text" value="<?php echo esc_attr( $stock ); ?>" /></li>
    146159                <?php
    147160            }
     
    161174        wp_enqueue_style('kjb_quotes_css_src');
    162175       
    163         wp_enqueue_script('kjb_jquery', "//code.jquery.com/jquery-1.10.2.js");
    164        
    165         //$out = get_transient('kjb_stockdata_transient');
    166        
    167         //if (false === $out){
    168         for ($i = 1; $i < 21; $i++) {
    169             $ticker = $ticker_info['stock_'.$i];
    170             if ($ticker != '') {
    171                 //Get stock data
    172                 //$contents = str_getcsv(file_get_contents('http://download.finance.yahoo.com/d/quotes.csv?s='.$ticker.'&f=sl1c1c0&e=.csv'),',');
    173                 /*
    174 if ($contents[1] != '0.00') {
    175                     $temp = array(
    176                     'ticker' => $contents[],
    177                     'quote' => $contents[],
    178                     'change' => $contents[],
    179                     'change_precent' => $contents[]
    180                 );
    181                 }else{
    182                     $temp = 'Invalid ticker';
     176        $out = array();
     177       
     178        $all_tickers = get_option('widget_kjb_show_stocks');
     179       
     180        if ($all_tickers !== false) {
     181           
     182            foreach ($all_tickers as $key => $val) {
     183               
     184                for ($i = 1; $i < 21; $i++) {
     185           
     186                    $ticker = $val['stock_' . $i];
     187                   
     188                    if ($ticker != '') {
     189                        $out[] = $ticker;
     190                    }
    183191                }
    184 */                 
    185                 $out[] = $ticker;
    186192            }
    187         }
    188        
    189         $passed_data = array(
    190             'out'                   => isset($out) ? $out : array(),
    191             'quote_display_color'   => $ticker_info['quote_display_color']
    192         );
     193           
     194            $passed_data = array(
     195                'out'                   => isset($out) ? $out : array(),
     196                'quote_display_color'   => $val['quote_display_color']
     197            );
     198        }
    193199       
    194200        wp_localize_script('kjb_quotes_js_src', 'passed_data', $passed_data);
    195            
    196            
    197             //set_transient('kjb_stockdata_transient',$out,60);
    198         //}
    199201       
    200202        return isset($out) ? $out : array();
Note: See TracChangeset for help on using the changeset viewer.