Plugin Directory

Changeset 2019463


Ignore:
Timestamp:
01/26/2019 07:42:26 AM (7 years ago)
Author:
sksni
Message:

Hotfix: Only display streams if we have necessery data

Location:
livetwitch/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • livetwitch/trunk/includes/class-twitch.php

    r2019461 r2019463  
    220220        return $this->version;
    221221    }
    222    
     222
    223223    /**
    224224     * Create shortcode that takes 2 variables (count and singular).
     
    248248            $singletext = false;
    249249
    250             if(!empty($atts['singletext'])){
    251                 $singletext = true;
    252             }
    253 
    254250            $viewers = $game = $link = $image = $stream_title = "";
    255251            $streams = get_posts(
    256252                            array(
    257253                                'title'      => $atts['singular'], // by post title
    258                                 'post_type'  => 'twitch' // post type of your preference
     254                                'post_type'  => 'twitch', // post type of your preference
     255                                'meta_query' =>
     256                                    array(
     257                                        'key'   => 'type',   
     258                                        'value' => 'live',
     259                                    )
    259260                            )
    260261                        );
     
    263264
    264265            if(isset($cf['viewer_count'])){
    265                 $viewers = $cf['viewer_count'][0];
     266                $viewers = $cf['viewer_count'][0];
     267                if(!empty($atts['singletext'])){
     268                    $singletext = true;
     269                }
    266270            }
    267271            if(isset($cf['game_id'])){
     
    297301        if( is_array($streams) ){
    298302            foreach($streams as $stream){
    299                 $stream = array_map(array('LiveTwitchWidget','LiveTwitch_DisplayString'), $stream);
    300                 echo $this->display_stream($stream);
     303                $stream = array_map(array('LiveTwitchWidget','LiveTwitch_DisplayString'), $stream);
     304                if($stream['viewers'] != "N/A"){
     305                    echo $this->display_stream($stream);
     306                }
    301307               
    302308            }
    303309        }elseif ($singletext) {
    304             echo '<span class="livetwitch is-live">Live</span>';
     310            if($stream['viewers'] != "N/A"){
     311                echo '<span class="livetwitch is-live">Live</span>';
     312            }
    305313        }else {
    306314            $stream = array_map(array('LiveTwitchWidget','LiveTwitch_DisplayString'), $stream);
    307             echo $this->display_stream($stream);
    308 
     315            if($stream['viewers'] != "N/A"){
     316                echo $this->display_stream($stream);
     317            }
    309318        }
    310319       
     
    314323    }
    315324
    316     /**
    317      * Add filter for Twitch game name.
    318      *
    319      * @since    0.0.3
    320      * @access   public
    321      * @var      string    $game    Game name.
    322      */
    323     public static function display_singlelive($game) {
    324         livetwitch_get_template('single-live.php');
    325     }
    326    
    327325    /**
    328326     * Add filter for Twitch game name.
  • livetwitch/trunk/live-twitch.php

    r2019461 r2019463  
    2525}
    2626
    27 define( 'LiveTwitch', '0.0.4' );
     27define( 'LiveTwitch', '0.0.5' );
    2828/**
    2929 * The core plugin class that is used to define internationalization,
Note: See TracChangeset for help on using the changeset viewer.