Changeset 1868553
- Timestamp:
- 05/04/2018 09:15:16 AM (8 years ago)
- Location:
- auto-last-youtube-video/trunk
- Files:
-
- 2 edited
-
autolastyoutubevideo.php (modified) (9 diffs)
-
readme.txt (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
auto-last-youtube-video/trunk/autolastyoutubevideo.php
r1845607 r1868553 4 4 Plugin URI: http://wordpress.org/plugins/auto-last-youtube-video/ 5 5 Description: 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. 56 Version: 1.0.6 7 7 Author: davidmerinas 8 8 Author URI: https://www.davidmerinas.com … … 11 11 $_SESSION['AUTO_LAST_YOUTUBE_VIDEO_PATH']=plugin_dir_path( __FILE__ ); 12 12 13 function AUTO_LAST_YOUTUBE_VIDEO_showvideo($canal='davidmerinas',$number=1,$title="",$visittext="Visit Youtube Channel",$introtext="" ){13 function AUTO_LAST_YOUTUBE_VIDEO_showvideo($canal='davidmerinas',$number=1,$title="",$visittext="Visit Youtube Channel",$introtext="",$type="user"){ 14 14 global $wp_embed; 15 $videos=youtube($canal,$number );15 $videos=youtube($canal,$number,$type); 16 16 echo('<h2 class="widget-title">'.($title!=""?$title:__("Latest from Youtube","autolastyoutubevideo")).'</h2>'); 17 17 if($introtext!="") … … 27 27 } 28 28 29 function youtube($canal,$lim=1 )29 function youtube($canal,$lim=1,$type="user") 30 30 { 31 31 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 } 33 40 $rss=new Zend_Feed(); 34 41 $channel = $rss->import($url); … … 53 60 extract(shortcode_atts(array( 54 61 'user'=>'', 62 'channel'=>'', 55 63 'width'=>'540', 56 'height'=>'405' 64 'height'=>'405', 65 'number'=>1 57 66 ), $atts)); 58 67 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 60 77 $contenido=""; 61 78 if(count($videos)>0) … … 63 80 foreach($videos as $video) 64 81 { 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> </p>"; 86 } 66 87 } 67 88 } … … 80 101 $options['AUTO_LAST_YOUTUBE_VIDEO_channelurl'] = $widget_data['AUTO_LAST_YOUTUBE_VIDEO_channelurl']; 81 102 $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']; 82 104 $options['AUTO_LAST_YOUTUBE_VIDEO_visittext'] = $widget_data['AUTO_LAST_YOUTUBE_VIDEO_visittext']; 83 105 update_option(AUTO_LAST_YOUTUBE_VIDEO_WIDGET_ID, $options); … … 88 110 $AUTO_LAST_YOUTUBE_VIDEO_channelurl = $options['AUTO_LAST_YOUTUBE_VIDEO_channelurl']; 89 111 $AUTO_LAST_YOUTUBE_VIDEO_number = $options['AUTO_LAST_YOUTUBE_VIDEO_number']; 112 $AUTO_LAST_YOUTUBE_VIDEO_type = $options['AUTO_LAST_YOUTUBE_VIDEO_type']; 90 113 $AUTO_LAST_YOUTUBE_VIDEO_visittext = $options['AUTO_LAST_YOUTUBE_VIDEO_visittext']; 91 114 … … 121 144 id="<?php echo AUTO_LAST_YOUTUBE_VIDEO_WIDGET_ID; ?>-channelurl" 122 145 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> 123 157 </p> 124 158 <p> … … 156 190 $AUTO_LAST_YOUTUBE_VIDEO_introtext = $options["AUTO_LAST_YOUTUBE_VIDEO_introtext"]; 157 191 $AUTO_LAST_YOUTUBE_VIDEO_channelurl = $options["AUTO_LAST_YOUTUBE_VIDEO_channelurl"]; 192 $AUTO_LAST_YOUTUBE_VIDEO_type = $options["AUTO_LAST_YOUTUBE_VIDEO_type"]; 158 193 $AUTO_LAST_YOUTUBE_VIDEO_number = $options["AUTO_LAST_YOUTUBE_VIDEO_number"]; 159 194 $AUTO_LAST_YOUTUBE_VIDEO_visittext = $options["AUTO_LAST_YOUTUBE_VIDEO_visittext"]; 160 195 161 196 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); 163 198 echo $after_widget; 164 199 } -
auto-last-youtube-video/trunk/readme.txt
r1845607 r1868553 4 4 Tags: youtube,last videos,shortcode,widget,davidmerinas 5 5 Requires at least: 3.3 6 Tested up to: 4.9. 46 Tested up to: 4.9.5 7 7 Stable tag: trunk 8 8 License: GPLv2 or later … … 22 22 To activate the widget: 23 23 3. 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 nameand anchor text and select the number of video to show24 4. Configure the widget: fill in the title, channel or user id and anchor text and select the number of video to show 25 25 5. Click on "Save" 26 26 27 27 To 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 showthe last video from that channel. You can also configure width and height.28 6. 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. 29 29 30 30 … … 38 38 39 39 == 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). 40 43 41 44 = 1.0.5 =
Note: See TracChangeset
for help on using the changeset viewer.