Changeset 917703
- Timestamp:
- 05/20/2014 06:38:05 AM (12 years ago)
- File:
-
- 1 edited
-
show-stock-quotes/trunk/show_stock_quotes.php (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
show-stock-quotes/trunk/show_stock_quotes.php
r870535 r917703 4 4 Plugin URI: http://kylebenkapps.com/wordpress-plugins/ 5 5 Description: Show stock quotes updated in real-time. 6 Version: 1. 4.16 Version: 1.5 7 7 Author: Kyle Benk 8 8 Author URI: http://kylebenkapps.com … … 49 49 /** @see WP_Widget::widget */ 50 50 function widget($args, $instance) { 51 51 52 extract( $args ); 53 52 54 $title = $instance['title']; 53 55 … … 60 62 } 61 63 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); 63 76 64 77 //Display all stock data … … 143 156 $stock = isset($instance['stock_'.$i]) ? $instance['stock_'.$i] : ''; 144 157 ?> 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> 146 159 <?php 147 160 } … … 161 174 wp_enqueue_style('kjb_quotes_css_src'); 162 175 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 } 183 191 } 184 */185 $out[] = $ticker;186 192 } 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 } 193 199 194 200 wp_localize_script('kjb_quotes_js_src', 'passed_data', $passed_data); 195 196 197 //set_transient('kjb_stockdata_transient',$out,60);198 //}199 201 200 202 return isset($out) ? $out : array();
Note: See TracChangeset
for help on using the changeset viewer.