Plugin Directory

Changeset 769469


Ignore:
Timestamp:
09/10/2013 12:02:38 AM (13 years ago)
Author:
ixiter
Message:
  • Implemented: No live message feature - #1941
Location:
ix-show-latest-youtube/trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • ix-show-latest-youtube/trunk/loader.php

    r768073 r769469  
    44  Description: Provides a shortcode and a template tag to embed the lates video or current live stream of a specified YouTube channel.
    55  Author: Ixiter IT - Peter Liebetrau <peter.liebetrau@ixiter.com>
    6   Version: 2.1.1
     6  Version: 2.2
    77  Plugin-Uri: http://ixiter.it/ix-show-latest-youtube
    88  Author-Uri: https://plus.google.com/u/0/102408750978338972864/about
  • ix-show-latest-youtube/trunk/plugin/Ix_ShowLatestYt.php

    r768074 r769469  
    66 * @package Ixiter WordPress Plugins
    77 * @subpackage IX Show Latest YouTube
    8  * @version 2.1.1
     8 * @version 2.2
    99 * @author Peter Liebetrau <ixiter@ixiter.com>
    1010 * @license GPL 3 or greater
     
    2323            'autoplay' => '0', // no autoplay by default
    2424            'count_of_videos' => '1', // Embed one latest video by default
     25            'no_live_message' => '' // displayed when no live broadcasting available, when set.
    2526        );
    2627        private $options = array();
     
    9394        }
    9495
    95         public function get_options(){
     96        public function get_options() {
    9697            return $this->options;
    9798        }
     
    107108        public function show_latest($atts) {
    108109            extract(shortcode_atts(array(
    109                         'ytid' => $this->options['ytid'],
    110                         'width' => $this->options['width'],
    111                         'height' => $this->options['height'],
    112                         'autoplay' => $this->options['autoplay'],
    113                         'count_of_videos' => $this->options['count_of_videos'],
    114                             ), $atts)
     110                'ytid' => $this->options['ytid'],
     111                'width' => $this->options['width'],
     112                'height' => $this->options['height'],
     113                'autoplay' => $this->options['autoplay'],
     114                'count_of_videos' => $this->options['count_of_videos'],
     115                'no_live_message' => $this->options['no_live_message'],
     116                    ), $atts)
    115117            );
    116118            $html = '';
     
    139141                }
    140142            } else {
    141                 $feedUrl = 'http://gdata.youtube.com/feeds/users/' . $ytid . '/uploads?alt=json&max-results=' . $count_of_videos;
    142                 $feed = json_decode(file_get_contents($feedUrl));
    143                 //ix_dump($feed);
    144                 if (isset($feed->feed->entry)) {
    145                     $loop = 0;
    146                     foreach ($feed->feed->entry as $key => $value) {
    147                         $autoplay = $loop > 0 ? false : $autoplay;
    148                         $loop++;
     143                if ($this->options['no_live_message'] == '') {
     144                    $feedUrl = 'http://gdata.youtube.com/feeds/users/' . $ytid . '/uploads?alt=json&max-results=' . $count_of_videos;
     145                    $feed = json_decode(file_get_contents($feedUrl));
     146                    //ix_dump($feed);
     147                    if (isset($feed->feed->entry)) {
     148                        $loop = 0;
     149                        foreach ($feed->feed->entry as $key => $value) {
     150                            $autoplay = $loop > 0 ? false : $autoplay;
     151                            $loop++;
    149152                            $videoFeedUrl = $value->id->$t;
    150153                            $uriParts = explode('/', $videoFeedUrl);
    151154                            $videoId = $uriParts[count($uriParts) - 1];
    152155                            $html .= $this->embedIframe($videoId, $width, $height, false);
     156                        }
     157                    } else {
     158                        $html .= sprintf(__('No more videos found for channel %s'), $this->options['ytid']);
    153159                    }
    154160                } else {
    155                     $html .= sprintf(__('No more videos found for channel %s'), $this->options['ytid']);
    156                 }
    157             }
    158             $feed = @file_get_contents($feedUrl);
     161                    $html .= '
     162                        <div style="width:'.$width.'px; height:'.$height.'px; background-color:black;">
     163                            <span style="display:block; width:80%; margin:0 auto; padding-top:50px; color:#f0f0f0; text-align:center;">'.$no_live_message.'</span>
     164                        </div>
     165                    ';
     166                }
     167            }
    159168
    160169            return $html;
     
    193202// BEGIN: Template Tags
    194203
    195     function ix_show_latest_yt($ytid = '', $width = '', $height = '', $autoplay = '', $count_of_videos = '') {
     204    function ix_show_latest_yt($ytid = '', $width = '', $height = '', $autoplay = '', $count_of_videos = '', $no_live_message = '') {
    196205        $options = Ix_ShowLatestYt::get_instance()->get_options();
    197206        $ytid = empty($ytid) ? $options['ytid'] : $ytid;
     
    201210        $count_of_videos = empty($count_of_videos) ? $options['count_of_videos'] : $count_of_videos;
    202211
    203         echo Ix_ShowLatestYt::get_instance()->show_latest(compact('ytid', 'width', 'height', 'autoplay', 'count_of_videos'));
     212        echo Ix_ShowLatestYt::get_instance()->show_latest(compact('ytid', 'width', 'height', 'autoplay', 'count_of_videos', 'no_live_message'));
    204213    }
    205214
  • ix-show-latest-youtube/trunk/plugin/admin/options-page.phtml

    r696650 r769469  
    3232                        <p class="ix_form_element_description"><?php _e('If checked, video starts automatically.', $textdomain) ?></p>
    3333                    </dd>
    34 
     34                   
    3535                    <dt class="ix_form_element_label"><label for="count_of_videos"><?php _e('Count of latest videos') ?></label></dt>
    3636                    <dd class="ix_form_element">
    3737                        <input type="text" name="count_of_videos" value="<?php echo $count_of_videos; ?>" />
    3838                        <p class="ix_form_element_description"><?php _e('Number of latest videos you want to embed. If autoplay ist set, only the first video will autoplay.', $textdomain) ?></p>
     39                    </dd>
     40
     41                    <dt class="ix_form_element_label"><label for="no_live_message"><?php _e('Show message if not broadcasting', $textdomain) ?></label></dt>
     42                    <dd class="ix_form_element">
     43                        <input type="text" name="no_live_message" value="<?php echo $no_live_message; ?>" />
     44                        <p class="ix_form_element_description"><?php _e('If a message is set, it will be displayed in case there is no live video, instead of showing the latest video.', $textdomain) ?></p>
    3945                    </dd>
    4046
     
    4854                <p><?php _e('If you want to use other values, you can set them with the shortcode or template tag.', $textdomain); ?></p>
    4955                <h4>Shortcode</h4>
    50                 <code>[ix_show_latest_yt ytid="youtubeid" width="###" height="###" autoplay="on/off" count_of_videos="#"]</code>
     56                <code>[ix_show_latest_yt ytid="youtubeid" width="###" height="###" autoplay="on/off" count_of_videos="#" no_live_message="some text"]</code>
    5157                <p class="ix_description"><?php _e('The shortcode is available in posts, pages and text widgets. The count and order of parameters dont matter. Empty values will be overwritten by the default options.', $textdomain); ?></p>
    5258                <h4>Template Tag</h4>
    53                 <code>&lt;?php ix_show_latest_yt($ytid, $width, $height, $autoplay, $count_of_videos); ?></code>
     59                <code>&lt;?php ix_show_latest_yt($ytid, $width, $height, $autoplay, $count_of_videos, $no_live_message); ?></code>
    5460                <p class="ix_description"><?php _e('The template tag is available in your theme template files and plugins. The count of parameters depends on their positions. The order matters! Empty values will be overwritten by the default options.', $textdomain); ?></p>
    5561               
  • ix-show-latest-youtube/trunk/readme.txt

    r768073 r769469  
    55Requires at least: 3.4
    66Tested up to: 3.5.1
    7 Stable tag: 2.1.1
     7Stable tag: 2.2
    88License: GPLv3 or later
    99License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    3434
    3535== Changelog ==
     36
     37= 2.2 =
     38* September, 10th 2013
     39* No live message feature added
    3640
    3741= 2.1.1 =
Note: See TracChangeset for help on using the changeset viewer.