Plugin Directory

Changeset 2015814


Ignore:
Timestamp:
01/20/2019 01:58:16 PM (7 years ago)
Author:
sksni
Message:

Added filter for Twitch game name display & css tweaks

Location:
livetwitch
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • livetwitch/tags/1.0/README.txt

    r1995959 r2015814  
    44Tags: twitch,live stream,twitch live,streams,twitch.tv
    55Requires at least: 4.8
    6 Tested up to: 5.0
    7 Stable tag: 4.8.9
     6Tested up to: 5.0.3
     7Stable tag: 5.0.3
    88License: GPLv2 or later
    99License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    35353. Settings page
    36364. Twitch CPT
    37 
    38 == Changelog ==
    39 
    40 = 1.0 =
    41 * Initial.
  • livetwitch/tags/1.0/admin/class-twitch-admin.php

    r1995959 r2015814  
    141141   
    142142        $options = get_option( 'twitch_settings' );
     143        $checked = NULL;
     144        if(isset($options['twitch_style'])){
     145            $checked =  $options['twitch_style'];
     146        }
    143147        ?>
    144         <input type="checkbox" value="1" <?php checked( $options['twitch_style'], 1 ); ?> name='twitch_settings[twitch_style]' size="32">
     148        <input type="checkbox" value="1" <?php checked( $checked, 1 ); ?> name='twitch_settings[twitch_style]' size="32">
    145149        Check for darker display theme.
    146150        <?php
  • livetwitch/tags/1.0/includes/class-twitch-cron.php

    r1995959 r2015814  
    125125        $response = wp_remote_get( $api_url, $args);
    126126        $json = json_decode($response['body']);
    127 
    128127        return $json;
    129128
     
    163162        $r = false;
    164163        $d = $data;
    165 
    166         foreach($d->data as $stream){
    167             $post = get_page_by_title($stream->user_name,OBJECT,'twitch');
    168 
    169            $game_name = $this->LiveTwitch_GameNameById($stream->game_id);
    170             foreach($metadatas as $meta){
    171                 $value = $stream->$meta;
    172                 if($meta == "game_id"){
    173                     $value = $game_name->data[0]->name;
     164        if(!isset($d->status) || $d->status != '401'){
     165                if(is_array($d)){
     166                    $d = $d['data'];
     167                }elseif(is_object($d)) {
     168                    $d = $d->data;
    174169                }
    175                
    176                 update_post_meta($post->ID, $meta, $value);
    177                 $r = true;
    178             }
     170                foreach($d as $stream){
     171                    $post = get_page_by_title($stream->user_name,OBJECT,'twitch');
     172
     173                    if( !is_null($post) ){
     174                        $game_name = $this->LiveTwitch_GameNameById($stream->game_id);
     175                        foreach($metadatas as $meta){
     176                            $value = $stream->$meta;
     177                            if($meta == "game_id"){
     178                                $value = $game_name->data[0]->name;
     179                            }
     180                           
     181                            update_post_meta($post->ID, $meta, $value);
     182                            $r = true;
     183                        }
     184                    }
     185                }
     186           
     187        }else {
     188            error_log( print_r( $data, true ) );
    179189        }
    180190    }
  • livetwitch/tags/1.0/includes/class-twitch.php

    r1995959 r2015814  
    5151            $this->version = PLUGIN_NAME_VERSION;
    5252        } else {
    53             $this->version = '0.0.2';
     53            $this->version = '0.0.3';
    5454        }
    5555        $this->activator = new LiveTwitch_Activator();
     
    305305    }
    306306
     307   
     308    /**
     309     * Add filter for Twitch game name.
     310     *
     311     * @since    0.0.3
     312     * @access   public
     313     * @var      string    $game    Game name.
     314     */
     315    static function livetwitch_gamedisplay($game) {
     316        return apply_filters('livetwitch_gamedisplay_filter', $game);
     317    }
     318
    307319    static public function display_stream($stream){
    308320
    309321        $options = get_option( 'twitch_settings' );
    310         if($options['twitch_style']){
    311             $class = " dark";
    312         }else {
    313             $class = "";
    314         }
     322        $class = "";
     323
     324        if(isset($options['twitch_style'])){
     325            if($options['twitch_style']){
     326                $class = " dark";
     327            }
     328        }
     329
    315330        $st_length = strlen($stream['stream_title']);
    316331        $extra_class = "";
     
    328343        ob_start();
    329344        ?>
    330         <div class="twitch-card<?php echo $class; ?>">
     345        <div class="mx-auto twitch-card<?php echo $class; ?>">
    331346            <a target="_blank" class="twitch-link" href="https://www.twitch.tv/<?php echo $stream['title']; ?>">
    332347                <div class="thumbnail">
    333348                    <img class='img-responsive' src='<?php echo $stream['image'];?>'>
    334349                    <p class="streamer"><?php echo $stream['title'];?></p>
    335                         <div class="stream-title<?php echo $extra_class; ?>">
    336                             <p><?php echo $stream['stream_title']; ?></p>
    337                         </div>
     350                    <p class="viewers"><svg class="views" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 21 21"><g transform="matrix(.02146 0 0 .02146 1 1)"><path d="m466.07 161.53c-205.6 0-382.8 121.2-464.2 296.1-2.5 5.3-2.5 11.5 0 16.9 81.4 174.9 258.6 296.1 464.2 296.1 205.6 0 382.8-121.2 464.2-296.1 2.5-5.3 2.5-11.5 0-16.9-81.4-174.9-258.6-296.1-464.2-296.1m0 514.7c-116.1 0-210.1-94.1-210.1-210.1 0-116.1 94.1-210.1 210.1-210.1 116.1 0 210.1 94.1 210.1 210.1 0 116-94.1 210.1-210.1 210.1"/><circle cx="466.08" cy="466.02" r="134.5"/></g></svg><?php echo $stream['viewers'];?></p>
     351                    <div class="stream-title<?php echo $extra_class; ?>">
     352                        <p><?php echo $stream['stream_title']; ?></p>
     353                    </div>
    338354                </div>
    339355                <div class="information">
    340                     <p class="viewers"><svg class="views" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 22 22"><g transform="matrix(.02146 0 0 .02146 1 1)"><path d="m466.07 161.53c-205.6 0-382.8 121.2-464.2 296.1-2.5 5.3-2.5 11.5 0 16.9 81.4 174.9 258.6 296.1 464.2 296.1 205.6 0 382.8-121.2 464.2-296.1 2.5-5.3 2.5-11.5 0-16.9-81.4-174.9-258.6-296.1-464.2-296.1m0 514.7c-116.1 0-210.1-94.1-210.1-210.1 0-116.1 94.1-210.1 210.1-210.1 116.1 0 210.1 94.1 210.1 210.1 0 116-94.1 210.1-210.1 210.1"/><circle cx="466.08" cy="466.02" r="134.5"/></g></svg><?php echo $stream['viewers'];?></p>
    341                     <p class="game"><?php echo $stream['game'];?></p>
     356                    <p class="game">
     357                        <?php
     358                        echo LiveTwitch::livetwitch_gamedisplay($stream['game']);
     359                        ?>
     360                    </p>
    342361                </div>
    343362            </a>
  • livetwitch/tags/1.0/public/css/twitch-public.css

    r1995959 r2015814  
    1515 }
    1616.twitch-card {
    17     display: inline-block;
    18     width: 250px;
     17    display: flex;
     18    justify-self: center;
     19    flex-flow: column;
     20    flex-wrap: wrap;
     21    max-width: 250px;
     22    min-width: 150px;
    1923    background-color: #ECECEC;
    2024    color: #232323;
     
    4347 
    4448.twitch-card .thumbnail {
    45     height: 150px;
    46     width: 250px;
     49    margin: initial;
     50    width: auto;
     51    max-height: 170px;
     52    max-width: 250px;
     53    margin-top: 0px;
    4754    position: relative;
    4855}
     
    7380
    7481.twitch-card .thumbnail  img.img-responsive{
    75     width: 250px;
     82    max-width: 250px;
    7683    border-top-left-radius: calc(.25rem - 1px);
    7784    border-top-right-radius: calc(.25rem - 1px);
     
    142149}
    143150
    144 .twitch-card  .streamer {
    145     font-weight: 800;
     151.twitch-card .streamer, .twitch-card .viewers {
    146152    position: absolute;
    147153    top: 10px;
    148     left: 10px;
    149154    color: white;
    150     text-shadow: 0px 0px #232323;
     155    text-shadow: 0px 0px 2px #232323;
    151156    z-index: 3;
    152157}
     158.twitch-card .viewers {
     159    right: 10px;
     160}
     161.twitch-card .streamer {
     162    font-weight: 800;
     163    left: 10px;
     164}
    153165
    154 .twitch-card .viewers, .twitch-card .game {
     166.twitch-card .game {
    155167    display: inline-block;
    156168    margin-bottom: 0;
    157169    font-size: 0.9em;
    158 }
    159 
    160 .twitch-card .game {
    161     float: right;
    162     max-width: 145px;
     170    max-width: inherit;
    163171    white-space: nowrap;
    164172    overflow: hidden;
     
    166174}
    167175
     176.twitch-card svg.views{
     177    height: 1em;
     178    vertical-align: middle;
     179    fill: currentColor;
     180    margin-top: -2px;
     181    margin-right: 2px;
     182}
    168183
    169 .twitch-card svg.views{
    170     height: 1.3em;
    171     vertical-align: top;
    172     fill: currentColor;
     184.twitch-card:last-of-type{
     185    margin-bottom: 20px;
    173186}
Note: See TracChangeset for help on using the changeset viewer.