Advertisement
urosevic

Get stock data from outside of StockQuote plugin

Aug 1st, 2018
206
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.54 KB | None | 0 0
  1. <?php
  2. // [demo_stock_quote symbol="MSFT"]
  3. add_shortcode( 'demosq', 'demo_stock_quote' );
  4. function demo_stock_quote( $atts, $content = null ) {
  5.     $atts = shortcode_atts( array(
  6.         'symbol' => 'AAPL'
  7.     ), $atts );
  8.  
  9.     if ( ! class_exists( 'Wpau_Stock_Quote' ) ) {
  10.         return "We can not get data for symbol $symbol at the moment";
  11.     }
  12.     $sq = new Wpau_Stock_Quote();
  13.     $data = $sq->get_stock_from_db( $atts['symbol'] );
  14.     if ( ! empty( $data ) ) {
  15.         return print_r( $data, true );
  16.     }
  17.     return "We have no data for $symbol";
  18. } // EOF demo_stock_quote()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement