Plugin Directory

Changeset 1868553


Ignore:
Timestamp:
05/04/2018 09:15:16 AM (8 years ago)
Author:
davidmerinas
Message:

New version 1.0.6 - Now you can switch between CHANNEL or USER ID

Location:
auto-last-youtube-video/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • auto-last-youtube-video/trunk/autolastyoutubevideo.php

    r1845607 r1868553  
    44Plugin URI: http://wordpress.org/plugins/auto-last-youtube-video/
    55Description: This plugin providesboth Widget and Shortcode to show latest videos from any public Youtube channel. Using [auto_last_youtube_video user='channel_name' width='450' height='320'][/auto_last_youtube_video] in a page or post will show last video uploaded to that channel and will change if another video is uploaded. The widget let you show as many videos as you want from any Youtube channel.
    6 Version: 1.0.5
     6Version: 1.0.6
    77Author: davidmerinas
    88Author URI: https://www.davidmerinas.com
     
    1111$_SESSION['AUTO_LAST_YOUTUBE_VIDEO_PATH']=plugin_dir_path( __FILE__ );
    1212 
    13 function AUTO_LAST_YOUTUBE_VIDEO_showvideo($canal='davidmerinas',$number=1,$title="",$visittext="Visit Youtube Channel",$introtext=""){
     13function AUTO_LAST_YOUTUBE_VIDEO_showvideo($canal='davidmerinas',$number=1,$title="",$visittext="Visit Youtube Channel",$introtext="",$type="user"){
    1414    global $wp_embed;
    15     $videos=youtube($canal,$number);
     15    $videos=youtube($canal,$number,$type);
    1616    echo('<h2 class="widget-title">'.($title!=""?$title:__("Latest from Youtube","autolastyoutubevideo")).'</h2>');
    1717    if($introtext!="")
     
    2727}
    2828
    29 function youtube($canal,$lim=1)
     29function youtube($canal,$lim=1,$type="user")
    3030{
    3131    require_once 'inc/Zend/Feed.php';
    32     $url="https://www.youtube.com/feeds/videos.xml?user=".$canal;
     32    if($type=="user")
     33    {
     34        $url="https://www.youtube.com/feeds/videos.xml?user=".$canal;
     35    }
     36    else
     37    {
     38        $url="https://www.youtube.com/feeds/videos.xml?channel_id=".$canal;
     39    }
    3340    $rss=new Zend_Feed();
    3441    $channel = $rss->import($url);
     
    5360    extract(shortcode_atts(array(
    5461    'user'=>'',
     62    'channel'=>'',
    5563    'width'=>'540',
    56     'height'=>'405'
     64    'height'=>'405',
     65    'number'=>1
    5766    ), $atts));
    5867    global $wp_embed;
    59     $videos=youtube($user,1);
     68    if($user=="")
     69    {
     70        $videos=youtube($channel,$number,'channel');
     71    }
     72    else
     73    {
     74        $videos=youtube($user,$number,'user');
     75    }
     76   
    6077    $contenido="";
    6178    if(count($videos)>0)
     
    6380        foreach($videos as $video)
    6481        {
    65             $contenido='[embed width="'.$width.'" height="'.$height.'"]https://www.youtube.com/watch?v='.$video['idyoutube'].'[/embed]';
     82            $contenido.='[embed width="'.$width.'" height="'.$height.'"]https://www.youtube.com/watch?v='.$video['idyoutube'].'[/embed]';
     83            if($number>1)
     84            {
     85                $contenido.="<p>&nbsp;</p>";
     86            }
    6687        }
    6788    }
     
    80101        $options['AUTO_LAST_YOUTUBE_VIDEO_channelurl'] = $widget_data['AUTO_LAST_YOUTUBE_VIDEO_channelurl'];
    81102        $options['AUTO_LAST_YOUTUBE_VIDEO_number'] = $widget_data['AUTO_LAST_YOUTUBE_VIDEO_number'];
     103        $options['AUTO_LAST_YOUTUBE_VIDEO_type'] = $widget_data['AUTO_LAST_YOUTUBE_VIDEO_type'];
    82104        $options['AUTO_LAST_YOUTUBE_VIDEO_visittext'] = $widget_data['AUTO_LAST_YOUTUBE_VIDEO_visittext'];
    83105        update_option(AUTO_LAST_YOUTUBE_VIDEO_WIDGET_ID, $options);
     
    88110    $AUTO_LAST_YOUTUBE_VIDEO_channelurl = $options['AUTO_LAST_YOUTUBE_VIDEO_channelurl'];
    89111    $AUTO_LAST_YOUTUBE_VIDEO_number = $options['AUTO_LAST_YOUTUBE_VIDEO_number'];
     112    $AUTO_LAST_YOUTUBE_VIDEO_type = $options['AUTO_LAST_YOUTUBE_VIDEO_type'];
    90113    $AUTO_LAST_YOUTUBE_VIDEO_visittext = $options['AUTO_LAST_YOUTUBE_VIDEO_visittext'];
    91114   
     
    121144        id="<?php echo AUTO_LAST_YOUTUBE_VIDEO_WIDGET_ID; ?>-channelurl"
    122145        value="<?php echo $AUTO_LAST_YOUTUBE_VIDEO_channelurl; ?>"/>
     146    </p>
     147    <p>
     148      <label for="<?php echo AUTO_LAST_YOUTUBE_VIDEO_WIDGET_ID;?>-type">
     149        <?php _e('User or Channel?','autolastyoutubevideo');?>
     150      </label>
     151      <select class="widefat"
     152        name="<?php echo AUTO_LAST_YOUTUBE_VIDEO_WIDGET_ID; ?>[AUTO_LAST_YOUTUBE_VIDEO_type]"
     153        id="<?php echo AUTO_LAST_YOUTUBE_VIDEO_WIDGET_ID; ?>-type">
     154        <option value="channel" <?php echo($AUTO_LAST_YOUTUBE_VIDEO_type=="channel"?"selected":"");?>>Channel ID</option>
     155        <option value="user" <?php echo($AUTO_LAST_YOUTUBE_VIDEO_type=="user"?"selected":"");?>>User ID</option>
     156      </select>
    123157    </p>
    124158    <p>
     
    156190    $AUTO_LAST_YOUTUBE_VIDEO_introtext = $options["AUTO_LAST_YOUTUBE_VIDEO_introtext"];
    157191    $AUTO_LAST_YOUTUBE_VIDEO_channelurl = $options["AUTO_LAST_YOUTUBE_VIDEO_channelurl"];
     192    $AUTO_LAST_YOUTUBE_VIDEO_type = $options["AUTO_LAST_YOUTUBE_VIDEO_type"];
    158193    $AUTO_LAST_YOUTUBE_VIDEO_number = $options["AUTO_LAST_YOUTUBE_VIDEO_number"];
    159194    $AUTO_LAST_YOUTUBE_VIDEO_visittext = $options["AUTO_LAST_YOUTUBE_VIDEO_visittext"];
    160195
    161196    echo $before_widget;
    162     AUTO_LAST_YOUTUBE_VIDEO_showvideo($AUTO_LAST_YOUTUBE_VIDEO_channelurl,$AUTO_LAST_YOUTUBE_VIDEO_number,$AUTO_LAST_YOUTUBE_VIDEO_title,$AUTO_LAST_YOUTUBE_VIDEO_visittext,$AUTO_LAST_YOUTUBE_VIDEO_introtext);
     197    AUTO_LAST_YOUTUBE_VIDEO_showvideo($AUTO_LAST_YOUTUBE_VIDEO_channelurl,$AUTO_LAST_YOUTUBE_VIDEO_number,$AUTO_LAST_YOUTUBE_VIDEO_title,$AUTO_LAST_YOUTUBE_VIDEO_visittext,$AUTO_LAST_YOUTUBE_VIDEO_introtext,$AUTO_LAST_YOUTUBE_VIDEO_type);
    163198    echo $after_widget;
    164199}
  • auto-last-youtube-video/trunk/readme.txt

    r1845607 r1868553  
    44Tags: youtube,last videos,shortcode,widget,davidmerinas
    55Requires at least: 3.3
    6 Tested up to: 4.9.4
     6Tested up to: 4.9.5
    77Stable tag: trunk
    88License: GPLv2 or later
     
    2222To activate the widget:
    23233. Go to 'Widgets' menu and drag and drop 'Auto Last Youtube Video' widget to your prefered sidebar
    24 4. Configure the widget: fill in the title, channel name and anchor text and select the number of video to show
     244. Configure the widget: fill in the title, channel or user id and anchor text and select the number of video to show
    25255. Click on "Save"
    2626
    2727To use the shortcode:
    28 6. When editing a page or a post, add the code [auto_last_youtube_video user='channel_name' width='450' height='320'][/auto_last_youtube_video] to show the last video from that channel. You can also configure width and height.
     286. When editing a page or a post, add the code [auto_last_youtube_video user='username' width='450' height='320'][/auto_last_youtube_video] to show the last video from that user or [auto_last_youtube_video channel='channelid' width='450' height='320'][/auto_last_youtube_video] to display the last video from that channel. You can also configure width and height.
    2929
    3030
     
    3838
    3939== Changelog ==
     40
     41= 1.0.6 =
     42*Now you can configure the widget and the shortcode with user ID or channel ID (thanks to gcediblemediacomau).
    4043
    4144= 1.0.5 =
Note: See TracChangeset for help on using the changeset viewer.