YouTube Channel - Version 1.5.0

Version Description

  • Add inline debug tracker
  • Fix deprecated functions - changed rss.php by feed.php and split() by extract()
  • Fix video description parser for new YouTube feed format
  • Fix autoplay for single video bug
  • Fix autoplay for multiple videos to play only first video
  • Code cleanup
  • Update compatibility to WordPress 3.5.1
Download this release

Release Info

Developer urkekg
Plugin Icon YouTube Channel
Version 1.5.0
Comparing to
See all releases

Code changes from version 1.4.0 to 1.5.0

Files changed (2) hide show
  1. readme.txt +14 -3
  2. youtube-channel.php +135 -77
readme.txt CHANGED
@@ -2,9 +2,11 @@
2
  Contributors: urkekg
3
  Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=Q6Q762MQ97XJ6
4
  Tags: youtube, channel, playlist, single, widget, widgets, youtube player, flash player, rss, feed, video, thumbnail, embed, sidebar, chromeless, iframe, html5
5
- Requires at least: 3.2.1
6
- Tested up to: 3.4.2
7
- Stable tag: 1.4.0
 
 
8
 
9
  Sidebar widget to show latest video thumbnail, playable flash object or chromeless video from YouTube Channel or Playlist.
10
 
@@ -107,6 +109,15 @@ Value for `Fetch latest` says how many items will containt set of videos for cho
107
  value for `Show ... videos` says how many videos will be displayed in widget.
108
 
109
  == Changelog ==
 
 
 
 
 
 
 
 
 
110
  = 1.4.0 =
111
  * Added option to show preferred quantity of videos
112
  * Added option to embed classic playlist
2
  Contributors: urkekg
3
  Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=Q6Q762MQ97XJ6
4
  Tags: youtube, channel, playlist, single, widget, widgets, youtube player, flash player, rss, feed, video, thumbnail, embed, sidebar, chromeless, iframe, html5
5
+ Requires at least: 3.4.0
6
+ Tested up to: 3.5.1
7
+ Stable tag: 1.5.0
8
+ License: GPLv3
9
+ License URI: http://www.gnu.org/licenses/gpl-3.0.html
10
 
11
  Sidebar widget to show latest video thumbnail, playable flash object or chromeless video from YouTube Channel or Playlist.
12
 
109
  value for `Show ... videos` says how many videos will be displayed in widget.
110
 
111
  == Changelog ==
112
+ = 1.5.0 =
113
+ * Add inline debug tracker
114
+ * Fix deprecated functions - changed rss.php by feed.php and split() by extract()
115
+ * Fix video description parser for new YouTube feed format
116
+ * Fix autoplay for single video bug
117
+ * Fix autoplay for multiple videos to play only first video
118
+ * Code cleanup
119
+ * Update compatibility to WordPress 3.5.1
120
+
121
  = 1.4.0 =
122
  * Added option to show preferred quantity of videos
123
  * Added option to embed classic playlist
youtube-channel.php CHANGED
@@ -4,17 +4,20 @@ Plugin Name: YouTube Channel
4
  Plugin URI: http://blog.urosevic.net/wordpress/youtube-channel/
5
  Description: <a href="widgets.php">Widget</a> that display latest video thumbnail, iframe (HTML5 video), object (Flash video) or chromeless video from YouTube Channel or Playlist.
6
  Author: Aleksandar Urošević
7
- Version: 1.4.0
8
  Author URI: http://urosevic.net/
9
  */
10
-
 
11
  define( 'YOUTUBE_CHANNEL_URL', plugin_dir_url(__FILE__) );
 
 
12
 
13
  /* Load plugin's textdomain */
 
14
  function youtube_channel_init() {
15
  load_plugin_textdomain( 'youtube-channel', false, dirname( plugin_basename( __FILE__ ) ) . '/languages' );
16
  }
17
- add_action( 'init', 'youtube_channel_init' );
18
 
19
  /* youtube widget */
20
  class YouTube_Channel_Widget extends WP_Widget {
@@ -44,7 +47,7 @@ class YouTube_Channel_Widget extends WP_Widget {
44
  $width = esc_attr($instance['width']);
45
  $height = esc_attr($instance['height']);
46
  $to_show = esc_attr($instance['to_show']);
47
- $lightbox = esc_attr($instance['lightbox']);
48
  $autoplay = esc_attr($instance['autoplay']);
49
  $controls = esc_attr($instance['controls']);
50
  $fixnoitem = esc_attr($instance['fixnoitem']);
@@ -53,12 +56,13 @@ class YouTube_Channel_Widget extends WP_Widget {
53
  $hideinfo = esc_attr($instance['hideinfo']);
54
  $hideanno = esc_attr($instance['hideanno']);
55
  $themelight = esc_attr($instance['themelight']);
 
56
  ?>
57
  <p><label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Widget Title:', 'youtube-channel'); ?><input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo $title; ?>" /></label></p>
58
  <p><label for="<?php echo $this->get_field_id('channel'); ?>"><?php _e('Channel:', 'youtube-channel'); ?> <input class="widefat" id="<?php echo $this->get_field_id('channel'); ?>" name="<?php echo $this->get_field_name('channel'); ?>" type="text" value="<?php echo $channel; ?>" /></label></p>
59
  <p><label for="<?php echo $this->get_field_id('playlist'); ?>"><?php _e('Playlist:', 'youtube-channel'); ?> <input class="widefat" id="<?php echo $this->get_field_id('playlist'); ?>" name="<?php echo $this->get_field_name('playlist'); ?>" type="text" value="<?php echo $playlist; ?>" /></label></p>
60
  <p><label for="<?php echo $this->get_field_id('maxrnd'); ?>"><?php _e('Fetch latest:', 'youtube-channel'); ?> <input class="small-text" id="<?php echo $this->get_field_id('maxrnd'); ?>" name="<?php echo $this->get_field_name('maxrnd'); ?>" type="number" min="2" value="<?php echo $maxrnd; ?>" /> (min 2, max 50)</label></p>
61
- <p><label for="<?php echo $this->get_field_id('vidqty'); ?>"><?php _e('Show:', 'youtube-channel'); ?></label> <input class="small-text" id="<?php echo $this->get_field_id('vidqty'); ?>" name="<?php echo $this->get_field_name('vidqty'); ?>" type="number" min="1" value="<?php echo $vidqty; ?>" /> videos</p>
62
  <p><input class="checkbox" type="checkbox" <?php checked( (bool) $instance['fixnoitem'], true ); ?> id="<?php echo $this->get_field_id( 'fixnoitem' ); ?>" name="<?php echo $this->get_field_name( 'fixnoitem' ); ?>" /> <label for="<?php echo $this->get_field_id( 'fixnoitem' ); ?>"><?php _e('Try to fix `No items` error', 'youtube-channel'); ?></label><br />
63
  <input class="checkbox" type="checkbox" <?php checked( (bool) $instance['usepl'], true ); ?> id="<?php echo $this->get_field_id( 'usepl' ); ?>" name="<?php echo $this->get_field_name( 'usepl' ); ?>" /> <label for="<?php echo $this->get_field_id( 'usepl' ); ?>"><?php _e('Use the playlist instead of channel', 'youtube-channel'); ?></label><br />
64
  <input class="checkbox" type="checkbox" <?php checked( (bool) $instance['getrnd'], true ); ?> id="<?php echo $this->get_field_id( 'getrnd' ); ?>" name="<?php echo $this->get_field_name( 'getrnd' ); ?>" /> <label for="<?php echo $this->get_field_id( 'getrnd' ); ?>"><?php _e('Show random video', 'youtube-channel'); ?></label><br />
@@ -87,7 +91,7 @@ class YouTube_Channel_Widget extends WP_Widget {
87
  <input class="checkbox" type="checkbox" <?php checked( (bool) $instance['fixyt'], true ); ?> id="<?php echo $this->get_field_id( 'fixyt' ); ?>" name="<?php echo $this->get_field_name( 'fixyt' ); ?>" /> <label for="<?php echo $this->get_field_id( 'fixyt' ); ?>"><?php _e('Fix height taken by controls', 'youtube-channel'); ?></label><br />
88
  <?php /* <input class="checkbox" type="checkbox" <?php checked( (bool) $instance['lightbox'], true ); ?> id="<?php echo $this->get_field_id( 'lightbox' ); ?>" name="<?php echo $this->get_field_name( 'lightbox' ); ?>" /> <label for="<?php echo $this->get_field_id( 'lightbox' ); ?>"><?php _e('Open thumbnail video in lightbox', 'youtube-channel'); ?></label><br /> */ ?>
89
  <?php /*if ( $instance['to_show'] == 'thumbnail' && $instance['lightbox'] && !is_plugin_active('wp-video-lightbox/wp-video-lightbox.php') ){ echo '<p>To load videos in lightbox please install and activate <a href="http://wordpress.org/extend/plugins/wp-video-lightbox/">WP Video Lightbox</a> plugin by Ruhul Amin.</p>'; } */?>
90
- <input class="checkbox" type="checkbox" <?php checked( (bool) $instance['autoplay'], true ); ?> id="<?php echo $this->get_field_id( 'autoplay' ); ?>" name="<?php echo $this->get_field_name( 'autoplay' ); ?>" /> <label for="<?php echo $this->get_field_id( 'autoplay' ); ?>"><?php _e('Autoplay video', 'youtube-channel'); ?></label></p>
91
  <h4><?php _e('Layout behaviour', 'youtube-channel'); ?></h4>
92
  <p><input class="checkbox" type="checkbox" <?php checked( (bool) $instance['showtitle'], true ); ?> id="<?php echo $this->get_field_id( 'showtitle' ); ?>" name="<?php echo $this->get_field_name( 'showtitle' ); ?>" /> <label for="<?php echo $this->get_field_id( 'showtitle' ); ?>"><?php _e('Show video title', 'youtube-channel'); ?></label><br />
93
  <input class="checkbox" type="checkbox" <?php checked( (bool) $instance['showvidesc'], true ); ?> id="<?php echo $this->get_field_id( 'showvidesc' ); ?>" name="<?php echo $this->get_field_name( 'showvidesc' ); ?>" /> <label for="<?php echo $this->get_field_id( 'showvidesc' ); ?>"><?php _e('Show video description', 'youtube-channel'); ?></label><br />
@@ -101,7 +105,24 @@ class YouTube_Channel_Widget extends WP_Widget {
101
  <input class="checkbox" type="checkbox" <?php checked( (bool) $instance['showgoto'], true ); ?> id="<?php echo $this->get_field_id( 'showgoto' ); ?>" name="<?php echo $this->get_field_name( 'showgoto' ); ?>" /> <label for="<?php echo $this->get_field_id( 'showgoto' ); ?>"><?php _e('Show link to channel', 'youtube-channel'); ?></label><br />
102
  <input class="checkbox" type="checkbox" <?php checked( (bool) $instance['popupgoto'], true ); ?> id="<?php echo $this->get_field_id( 'popupgoto' ); ?>" name="<?php echo $this->get_field_name( 'popupgoto' ); ?>" /> <label for="<?php echo $this->get_field_id( 'popupgoto' ); ?>"><?php _e('Open channel in new window/tab', 'youtube-channel'); ?></label><br />
103
  <input class="checkbox" type="checkbox" <?php checked( (bool) $instance['target'], true ); ?> id="<?php echo $this->get_field_id( 'target' ); ?>" name="<?php echo $this->get_field_name( 'target' ); ?>" /> <label for="<?php echo $this->get_field_id( 'target' ); ?>"><?php _e('Use target="_blank" (invalid XHTML)', 'youtube-channel'); ?></label></p>
104
- <p><input type="button" value="Support YTC / Donate via PayPal" onclick="window.location='https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=Q6Q762MQ97XJ6'" class="button-secondary"></p>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
105
  <?php
106
  }
107
 
@@ -128,7 +149,7 @@ class YouTube_Channel_Widget extends WP_Widget {
128
  $instance['height'] = strip_tags($new_instance['height']);
129
  $instance['to_show'] = strip_tags($new_instance['to_show']);
130
  $instance['autoplay'] = $new_instance['autoplay'];
131
- $instance['lightbox'] = $new_instance['lightbox'];
132
  $instance['controls'] = $new_instance['controls'];
133
  $instance['fixnoitem'] = $new_instance['fixnoitem'];
134
  $instance['ratio'] = strip_tags($new_instance['ratio']);
@@ -136,6 +157,7 @@ class YouTube_Channel_Widget extends WP_Widget {
136
  $instance['hideinfo'] = $new_instance['hideinfo'];
137
  $instance['hideanno'] = $new_instance['hideanno'];
138
  $instance['themelight'] = $new_instance['themelight'];
 
139
 
140
  return $instance;
141
  }
@@ -147,26 +169,27 @@ class YouTube_Channel_Widget extends WP_Widget {
147
 
148
  // set default channel if nothing predefined
149
  $channel = $instance['channel'];
150
- if ( $channel == "" ) { $channel = "urkekg"; }
 
151
 
152
  // set playlist id
153
  $playlist = $instance['playlist'];
154
- if ( $playlist == "" ) { $playlist = "PLEC850BE962234400"; }
 
 
155
  // trim PL in front of playlist ID
156
  $playlist = preg_replace('/^PL/', '', $playlist);
157
  $usepl = $instance['usepl'];
158
 
159
- echo $before_widget;
 
160
  if ( $title )
161
- echo $before_title . $title . $after_title;
162
-
163
- ?>
164
 
165
- <div class="youtube_channel">
166
 
167
- <?php
168
  if ( $instance['only_pl'] ) { // print standard playlist
169
- ytc_only_pl($instance);
170
  } else { // channel or playlist single videos
171
 
172
  // get max items for random video
@@ -174,11 +197,9 @@ class YouTube_Channel_Widget extends WP_Widget {
174
  if ( $maxrnd < 1 ) { $maxrnd = 10; } // default 10
175
  elseif ( $maxrnd > 50 ) { $maxrnd = 50; } // max 50
176
 
177
- include_once(ABSPATH . WPINC . '/rss.php');
178
  $rss_settings = '?alt=rss&v=2';
179
- if ( !$instance['fixnoitem'] ) {
180
  $rss_settings .= '&orderby=published';
181
- }
182
 
183
  #$vidqty = $instance['vidqty'];
184
  #if ( $maxrnd > $vidqty ) {}
@@ -186,12 +207,14 @@ class YouTube_Channel_Widget extends WP_Widget {
186
  if ( $usepl ) {
187
  // check what is set: full URL or playlist ID
188
  $playlist = ytc_clean_playlist_id($playlist);
189
-
190
  $rss_url = 'http://gdata.youtube.com/feeds/api/playlists/'.$playlist.$rss_settings;
191
  } else {
192
  $rss_url = 'http://gdata.youtube.com/feeds/base/users/'.$channel.'/uploads'.$rss_settings;
193
  }
194
 
 
 
195
  $rss = fetch_feed($rss_url);
196
  if ( !is_wp_error($rss) ) {
197
  $getrnd = $instance['getrnd'];
@@ -202,17 +225,19 @@ class YouTube_Channel_Widget extends WP_Widget {
202
  if ( $getrnd ) {
203
  $items = $rss->get_items(0, $maxitems);
204
  } else {
205
- if ( !$vidqty ) { $vidqty = 1; }
 
206
  $items = $rss->get_items(0, $vidqty); // set 0, 2 for next video
207
  }
208
  }
209
 
210
  if ($maxitems == 0) {
211
- echo __( 'No items' , 'youtube-channel' );
212
  } else {
213
- if ( $getrnd ) { $rnd_used = array(); } // set array for unique random item
214
- for ($y = 1; $y <= $vidqty; $y++) {
215
 
 
216
  if ( $getrnd ) {
217
  $rnd_item = mt_rand(0, (count($items)-1));
218
  while ( $y > 1 && in_array($rnd_item, $rnd_used) ) {
@@ -226,17 +251,18 @@ class YouTube_Channel_Widget extends WP_Widget {
226
  }
227
 
228
  // print single video block
229
- ytc_print_video($item, $instance, $y);
230
  }
231
  }
232
  } // single playlist or ytc way
233
 
234
- ytc_channel_link($instance); // insert link to channel on bootom of widget
235
- ?>
 
 
 
 
236
 
237
- </div><!-- .youtube_channel -->
238
- <?php
239
- echo $after_widget;
240
  }
241
 
242
  }
@@ -244,19 +270,29 @@ class YouTube_Channel_Widget extends WP_Widget {
244
  /* function to print standard playlist embed code */
245
  function ytc_only_pl($instance) {
246
  $width = $instance['width'];
 
 
 
 
 
 
 
247
  $height = height_ratio($width, $instance['ratio']) + 25;
248
- $playlist = ytc_clean_playlist_id($instance['playlist']);
249
- print '
250
- <div class="ytc_video_container ytc_video_1 ytc_video_single">
251
- <iframe src="http://www.youtube.com/embed/videoseries?list=PL'.$playlist.'"
252
- width="'.$width.'" height="'.$height.'" frameborder="0"></iframe>
253
- </div>
254
- ';
 
 
255
  }
256
 
257
  /* function to print video in widget */
258
  function ytc_print_video($item, $instance, $y) {
259
  /* video settings */
 
260
 
261
  // get hideinfo, autoplay and controls settings
262
  // where this is used?
@@ -266,6 +302,8 @@ function ytc_print_video($item, $instance, $y) {
266
 
267
  // set width and height
268
  $width = $instance['width'];
 
 
269
  $height = height_ratio($width, $instance['ratio']);
270
 
271
  // calculate image height based on width for 4:3 thumbnail
@@ -273,17 +311,17 @@ function ytc_print_video($item, $instance, $y) {
273
 
274
  // which type to show
275
  $to_show = $instance['to_show'];
276
- if ( $to_show == "" ) { $to_show = "object"; }
 
277
 
278
  // if not thumbnail, increase video height for 25px taken by video controls
279
- if ( $to_show != 'thumbnail' && !$controls && $instance['fixyt'] ) {
280
  $height += 25;
281
- }
282
 
283
  $hideanno = $instance['hideanno'];
284
  $themelight = $instance['themelight'];
285
  /* end of video settings */
286
-
287
  if ( $instance['usepl'] ) {
288
  $yt_id = $item->get_link();
289
  $yt_id = preg_replace('/^.*=(.*)&.*$/', '${1}', $yt_id);
@@ -294,7 +332,7 @@ function ytc_print_video($item, $instance, $y) {
294
  # $yt_url = "p/$playlist";
295
  #}
296
  } else {
297
- $yt_id = split(":", $item->get_id());
298
  $yt_id = $yt_id[3];
299
  $yt_url = "v/$yt_id";
300
  }
@@ -303,7 +341,7 @@ function ytc_print_video($item, $instance, $y) {
303
  $yt_video = $item->get_permalink();
304
  $yt_title = esc_html( $item->get_title() );
305
  $yt_date = $item->get_date('j F Y | g:i a');
306
- // $next_id = split(":", $next_item->get_id());
307
  // $next_id = $yt_id[3];
308
 
309
  switch ($y) {
@@ -311,19 +349,20 @@ function ytc_print_video($item, $instance, $y) {
311
  $vnumclass = 'first';
312
  break;
313
  case $instance['vidqty']:
 
314
  $vnumclass = 'last';
315
  break;
316
  default:
317
  $vnumclass = 'mid';
 
318
  break;
319
  }
320
 
321
- echo '<div class="ytc_video_container ytc_video_'.$y.' ytc_video_'.$vnumclass.'">';
322
 
323
  // show video title?
324
- if ( $instance['showtitle'] ) {
325
- echo '<h3 class="ytc_title">'.$yt_title.'</h3>';
326
- }
327
 
328
  // define object ID
329
  $ytc_vid = 'ytc_' . $yt_id;
@@ -332,25 +371,40 @@ function ytc_print_video($item, $instance, $y) {
332
  if ( $to_show == "thumbnail" ) {
333
  $title = sprintf( __( 'Watch video %1$s published on %2$s' , 'youtube-channel' ), $yt_title, $yt_date );
334
  /* if ( $instance['lightbox'] ) { $in_lightbox = 'rel="ytc-lightbox"'; } else { $in_lightbox = ''; } */
335
- echo <<<EOF
336
- <a href="$yt_video" title="$title"><div style="width: ${width}px; height: ${height}px; overflow: hidden; background: url($yt_thumb) 50% 50% no-repeat; background-size: ${width}px ${imgfixedheight}px;" title="$yt_title" id="$ytc_vid"></div></a>
337
- EOF;
338
  } else if ( $to_show == "chromeless" ) {
 
339
  ?>
340
  <object type="application/x-shockwave-flash" data="<?php echo YOUTUBE_CHANNEL_URL . 'chromeless.swf'; ?>" width="<?php echo $width; ?>" height="<?php echo $height; ?>" id="<?php echo $ytc_vid; ?>">
341
- <param name="flashVars" value="video_source=<?php echo $yt_id; ?>&video_width=<?php echo $width; ?>&video_height=<?php echo $height; ?><?php if ( $autoplay ) { echo "&autoplay=Yes"; } if ( !$controls ) { echo "&youtube_controls=Yes"; } if ( $hideanno ) { echo "&iv_load_policy=3"; } if ( $themelight ) { echo "&theme=light"; } ?>" />
342
  <param name="quality" value="high" />
343
  <param name="wmode" value="opaque" />
344
  <param name="swfversion" value="6.0.65.0" />
345
  <param name="movie" value="<?php echo YOUTUBE_CHANNEL_URL . 'chromeless.swf'; ?>" />
346
  </object>
347
  <?php
 
 
348
  } else if ( $to_show == "iframe" ) {
349
- if (!$usepl) { $yt_url = $yt_id; }
350
- ?>
351
- <iframe title="YouTube video player" width="<?php echo $width; ?>" height="<?php echo $height; ?>" src="http://www.youtube.com/embed/<?php echo $yt_url."?wmode=opaque&enablejsapi=1"; if ( $controls ) { echo "&controls=0"; } if ( $hideinfo ) { echo "&showinfo=0"; } if ( $autoplay ) { echo "&autoplay=1"; } if ( $hideanno ) { echo "&iv_load_policy=3"; } if ( $themelight ) { echo "&theme=light"; } ?>" frameborder="0" allowfullscreen id="<?php echo $ytc_vid ?>"></iframe>
352
- <?php
 
 
 
 
 
 
 
 
 
 
 
 
353
  } else { // default is object
 
354
  ?>
355
  <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="<?php echo $width; ?>" height="<?php echo $height; ?>" id="<?php echo $ytc_vid; ?>">
356
  <param name="movie" value="http://www.youtube.com/<?php echo $yt_url; ?>?version=3<?php if ( $controls ) { echo "&amp;controls=0"; } if ( $hideinfo ) { echo "&amp;showinfo=0"; } if ( $autoplay ) { echo "&amp;autoplay=1"; } if ( $hideanno ) { echo "&amp;iv_load_policy=3"; } if ( $themelight ) { echo "&amp;theme=light"; } ?>" />
@@ -364,11 +418,14 @@ EOF;
364
  <!--<![endif]-->
365
  </object>
366
  <?php
 
 
367
  }
368
 
369
  // do we need to show video description?
370
  if ( $instance['showvidesc'] ) {
371
- preg_match('/<div><span>(.*)<\/span><\/div>/', $item->get_description(), $videsc);
 
372
  if ( $instance['videsclen'] > 0 ) {
373
  $video_description = substr($videsc[1], 0, $instance['videsclen']);
374
  } else {
@@ -380,59 +437,60 @@ EOF;
380
  } else {
381
  $etcetera = '&hellip;';
382
  }
 
383
  }
384
- echo '<p class="ytc_description">' .$video_description.$etcetera. '</p>';
385
  }
386
- echo '</div><!-- .ytc_video_container -->';
 
 
387
  }
388
 
389
  // function to calculate height by width and ratio
390
  function height_ratio($width, $ratio) {
391
- if ( $width == "" ) { $width = 220; }
 
392
 
393
  if ( $ratio == 1 ) { // 4:3
394
  $height = round(($width / 4 ) * 3);
395
- } else if ( $ratio == 2 ) { // 16:10
396
  $height = round(($width / 16 ) * 10);
397
- } else if ( $ratio == 3 ) { // 16:9
398
  $height = round(($width / 16 ) * 9);
399
  } else { // set default if 0 or ratio not set
400
  $height = $instance['height'];
401
- if ( $height == "" ) { $height = 165; }
 
402
  }
403
  return $height;
404
  }
405
 
406
  // function to insert link to channel
407
  function ytc_channel_link($instance) {
 
408
  // do we need to show goto link?
409
  if ( $instance['showgoto'] ) {
410
  $channel = $instance['channel'];
 
 
411
  $goto_txt = $instance['goto_txt'];
412
- if ( $goto_txt == "" ) {
413
  $goto_txt = sprintf( __( 'Visit channel %1$s' , 'youtube-channel' ), $channel );
414
- }
415
 
416
- echo '<div class="ytc_link">';
417
  if ( $instance['popupgoto'] ) {
418
  $newtab = __("in new window/tab", "youtube-channel");
419
  if ( $instance['target'] ) {
420
- echo <<<EOF
421
- <a href="http://www.youtube.com/user/$channel/" target="_blank" title="$goto_txt $newtab">$goto_txt</a>
422
- EOF;
423
  } else {
424
- echo <<<EOF
425
- <a href="javascript: window.open('http://www.youtube.com/user/$channel/'); void 0;" title="$goto_txt $newtab">$goto_txt</a>
426
- EOF;
427
  } // target
428
  } else {
429
- echo <<<EOF
430
- <p><a href="http://www.youtube.com/user/$channel/" title="$goto_txt">$goto_txt</a></p>
431
- EOF;
432
  } // popupgoto
433
- echo '</div>';
434
 
435
  } // showgoto
 
436
  }
437
 
438
  function ytc_clean_playlist_id($playlist) {
@@ -450,4 +508,4 @@ function youtube_channel_register_widget() {
450
  register_widget( 'YouTube_Channel_Widget' );
451
  }
452
  add_action( 'widgets_init', 'youtube_channel_register_widget' );
453
- ?>
4
  Plugin URI: http://blog.urosevic.net/wordpress/youtube-channel/
5
  Description: <a href="widgets.php">Widget</a> that display latest video thumbnail, iframe (HTML5 video), object (Flash video) or chromeless video from YouTube Channel or Playlist.
6
  Author: Aleksandar Urošević
7
+ Version: 1.5.0
8
  Author URI: http://urosevic.net/
9
  */
10
+ error_reporting(E_DEPRECATED);
11
+ define( 'YTCVER', '1.5.0' );
12
  define( 'YOUTUBE_CHANNEL_URL', plugin_dir_url(__FILE__) );
13
+ define( 'YTCPLID', 'PLEC850BE962234400' );
14
+ define( 'YTCUID', 'urkekg' );
15
 
16
  /* Load plugin's textdomain */
17
+ add_action( 'init', 'youtube_channel_init' );
18
  function youtube_channel_init() {
19
  load_plugin_textdomain( 'youtube-channel', false, dirname( plugin_basename( __FILE__ ) ) . '/languages' );
20
  }
 
21
 
22
  /* youtube widget */
23
  class YouTube_Channel_Widget extends WP_Widget {
47
  $width = esc_attr($instance['width']);
48
  $height = esc_attr($instance['height']);
49
  $to_show = esc_attr($instance['to_show']);
50
+ //$lightbox = esc_attr($instance['lightbox']);
51
  $autoplay = esc_attr($instance['autoplay']);
52
  $controls = esc_attr($instance['controls']);
53
  $fixnoitem = esc_attr($instance['fixnoitem']);
56
  $hideinfo = esc_attr($instance['hideinfo']);
57
  $hideanno = esc_attr($instance['hideanno']);
58
  $themelight = esc_attr($instance['themelight']);
59
+ $debugon = esc_attr($instance['debugon']);
60
  ?>
61
  <p><label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Widget Title:', 'youtube-channel'); ?><input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo $title; ?>" /></label></p>
62
  <p><label for="<?php echo $this->get_field_id('channel'); ?>"><?php _e('Channel:', 'youtube-channel'); ?> <input class="widefat" id="<?php echo $this->get_field_id('channel'); ?>" name="<?php echo $this->get_field_name('channel'); ?>" type="text" value="<?php echo $channel; ?>" /></label></p>
63
  <p><label for="<?php echo $this->get_field_id('playlist'); ?>"><?php _e('Playlist:', 'youtube-channel'); ?> <input class="widefat" id="<?php echo $this->get_field_id('playlist'); ?>" name="<?php echo $this->get_field_name('playlist'); ?>" type="text" value="<?php echo $playlist; ?>" /></label></p>
64
  <p><label for="<?php echo $this->get_field_id('maxrnd'); ?>"><?php _e('Fetch latest:', 'youtube-channel'); ?> <input class="small-text" id="<?php echo $this->get_field_id('maxrnd'); ?>" name="<?php echo $this->get_field_name('maxrnd'); ?>" type="number" min="2" value="<?php echo $maxrnd; ?>" /> (min 2, max 50)</label></p>
65
+ <p><label for="<?php echo $this->get_field_id('vidqty'); ?>"><?php _e('Show:', 'youtube-channel'); ?></label> <input class="small-text" id="<?php echo $this->get_field_id('vidqty'); ?>" name="<?php echo $this->get_field_name('vidqty'); ?>" type="number" min="1" value="<?php echo ( $vidqty ) ? $vidqty : '1'; ?>" /> videos</p>
66
  <p><input class="checkbox" type="checkbox" <?php checked( (bool) $instance['fixnoitem'], true ); ?> id="<?php echo $this->get_field_id( 'fixnoitem' ); ?>" name="<?php echo $this->get_field_name( 'fixnoitem' ); ?>" /> <label for="<?php echo $this->get_field_id( 'fixnoitem' ); ?>"><?php _e('Try to fix `No items` error', 'youtube-channel'); ?></label><br />
67
  <input class="checkbox" type="checkbox" <?php checked( (bool) $instance['usepl'], true ); ?> id="<?php echo $this->get_field_id( 'usepl' ); ?>" name="<?php echo $this->get_field_name( 'usepl' ); ?>" /> <label for="<?php echo $this->get_field_id( 'usepl' ); ?>"><?php _e('Use the playlist instead of channel', 'youtube-channel'); ?></label><br />
68
  <input class="checkbox" type="checkbox" <?php checked( (bool) $instance['getrnd'], true ); ?> id="<?php echo $this->get_field_id( 'getrnd' ); ?>" name="<?php echo $this->get_field_name( 'getrnd' ); ?>" /> <label for="<?php echo $this->get_field_id( 'getrnd' ); ?>"><?php _e('Show random video', 'youtube-channel'); ?></label><br />
91
  <input class="checkbox" type="checkbox" <?php checked( (bool) $instance['fixyt'], true ); ?> id="<?php echo $this->get_field_id( 'fixyt' ); ?>" name="<?php echo $this->get_field_name( 'fixyt' ); ?>" /> <label for="<?php echo $this->get_field_id( 'fixyt' ); ?>"><?php _e('Fix height taken by controls', 'youtube-channel'); ?></label><br />
92
  <?php /* <input class="checkbox" type="checkbox" <?php checked( (bool) $instance['lightbox'], true ); ?> id="<?php echo $this->get_field_id( 'lightbox' ); ?>" name="<?php echo $this->get_field_name( 'lightbox' ); ?>" /> <label for="<?php echo $this->get_field_id( 'lightbox' ); ?>"><?php _e('Open thumbnail video in lightbox', 'youtube-channel'); ?></label><br /> */ ?>
93
  <?php /*if ( $instance['to_show'] == 'thumbnail' && $instance['lightbox'] && !is_plugin_active('wp-video-lightbox/wp-video-lightbox.php') ){ echo '<p>To load videos in lightbox please install and activate <a href="http://wordpress.org/extend/plugins/wp-video-lightbox/">WP Video Lightbox</a> plugin by Ruhul Amin.</p>'; } */?>
94
+ <input class="checkbox" type="checkbox" <?php checked( (bool) $instance['autoplay'], true ); ?> id="<?php echo $this->get_field_id( 'autoplay' ); ?>" name="<?php echo $this->get_field_name( 'autoplay' ); ?>" /> <label for="<?php echo $this->get_field_id( 'autoplay' ); ?>"><?php _e('Autoplay video or playlist', 'youtube-channel'); ?></label></p>
95
  <h4><?php _e('Layout behaviour', 'youtube-channel'); ?></h4>
96
  <p><input class="checkbox" type="checkbox" <?php checked( (bool) $instance['showtitle'], true ); ?> id="<?php echo $this->get_field_id( 'showtitle' ); ?>" name="<?php echo $this->get_field_name( 'showtitle' ); ?>" /> <label for="<?php echo $this->get_field_id( 'showtitle' ); ?>"><?php _e('Show video title', 'youtube-channel'); ?></label><br />
97
  <input class="checkbox" type="checkbox" <?php checked( (bool) $instance['showvidesc'], true ); ?> id="<?php echo $this->get_field_id( 'showvidesc' ); ?>" name="<?php echo $this->get_field_name( 'showvidesc' ); ?>" /> <label for="<?php echo $this->get_field_id( 'showvidesc' ); ?>"><?php _e('Show video description', 'youtube-channel'); ?></label><br />
105
  <input class="checkbox" type="checkbox" <?php checked( (bool) $instance['showgoto'], true ); ?> id="<?php echo $this->get_field_id( 'showgoto' ); ?>" name="<?php echo $this->get_field_name( 'showgoto' ); ?>" /> <label for="<?php echo $this->get_field_id( 'showgoto' ); ?>"><?php _e('Show link to channel', 'youtube-channel'); ?></label><br />
106
  <input class="checkbox" type="checkbox" <?php checked( (bool) $instance['popupgoto'], true ); ?> id="<?php echo $this->get_field_id( 'popupgoto' ); ?>" name="<?php echo $this->get_field_name( 'popupgoto' ); ?>" /> <label for="<?php echo $this->get_field_id( 'popupgoto' ); ?>"><?php _e('Open channel in new window/tab', 'youtube-channel'); ?></label><br />
107
  <input class="checkbox" type="checkbox" <?php checked( (bool) $instance['target'], true ); ?> id="<?php echo $this->get_field_id( 'target' ); ?>" name="<?php echo $this->get_field_name( 'target' ); ?>" /> <label for="<?php echo $this->get_field_id( 'target' ); ?>"><?php _e('Use target="_blank" (invalid XHTML)', 'youtube-channel'); ?></label></p>
108
+
109
+ <h4><?php _e('Debug YTC', 'youtube-channel'); ?></h4>
110
+ <p><input class="checkbox" type="checkbox" <?php checked( (bool) $instance['debugon'], true ); ?> id="<?php echo $this->get_field_id( 'debugon' ); ?>" name="<?php echo $this->get_field_name( 'debugon' ); ?>" /><label for="debugon">Enable debugging</label><br />
111
+ <?php if ( $instance['debugon'] ) {
112
+ $debug_arr = array_merge(
113
+ array(
114
+ 'apache ver' => apache_get_version(),
115
+ 'php ver' => phpversion(),
116
+ 'wp ver' => get_bloginfo('version'),
117
+ 'ytc ver' => YTCVER
118
+ ),
119
+ $instance); ?>
120
+ <textarea name="debug" class="widefat" style="height: 100px;"><?php var_export($debug_arr); ?></textarea><br />
121
+ Insert debug data to <a href="http://wordpress.org/support/plugin/youtube-channel" target="_support">support forum</a>.
122
+ <?php } ?></p>
123
+
124
+ <p><input type="button" value="Support YTC / Donate via PayPal" onclick="window.location='https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=Q6Q762MQ97XJ6'" class="button-secondary"></p>
125
+
126
  <?php
127
  }
128
 
149
  $instance['height'] = strip_tags($new_instance['height']);
150
  $instance['to_show'] = strip_tags($new_instance['to_show']);
151
  $instance['autoplay'] = $new_instance['autoplay'];
152
+ //$instance['lightbox'] = $new_instance['lightbox'];
153
  $instance['controls'] = $new_instance['controls'];
154
  $instance['fixnoitem'] = $new_instance['fixnoitem'];
155
  $instance['ratio'] = strip_tags($new_instance['ratio']);
157
  $instance['hideinfo'] = $new_instance['hideinfo'];
158
  $instance['hideanno'] = $new_instance['hideanno'];
159
  $instance['themelight'] = $new_instance['themelight'];
160
+ $instance['debugon'] = $new_instance['debugon'];
161
 
162
  return $instance;
163
  }
169
 
170
  // set default channel if nothing predefined
171
  $channel = $instance['channel'];
172
+ if ( $channel == "" )
173
+ $channel = YTCUID;
174
 
175
  // set playlist id
176
  $playlist = $instance['playlist'];
177
+ if ( $playlist == "" )
178
+ $playlist = YTCPLID;
179
+
180
  // trim PL in front of playlist ID
181
  $playlist = preg_replace('/^PL/', '', $playlist);
182
  $usepl = $instance['usepl'];
183
 
184
+ $output = array();
185
+ $output[] = $before_widget;
186
  if ( $title )
187
+ $output[] = $before_title . $title . $after_title;
 
 
188
 
189
+ $output[] = '<div class="youtube_channel">';
190
 
 
191
  if ( $instance['only_pl'] ) { // print standard playlist
192
+ $output = array_merge($output, ytc_only_pl($instance));
193
  } else { // channel or playlist single videos
194
 
195
  // get max items for random video
197
  if ( $maxrnd < 1 ) { $maxrnd = 10; } // default 10
198
  elseif ( $maxrnd > 50 ) { $maxrnd = 50; } // max 50
199
 
 
200
  $rss_settings = '?alt=rss&v=2';
201
+ if ( !$instance['fixnoitem'] )
202
  $rss_settings .= '&orderby=published';
 
203
 
204
  #$vidqty = $instance['vidqty'];
205
  #if ( $maxrnd > $vidqty ) {}
207
  if ( $usepl ) {
208
  // check what is set: full URL or playlist ID
209
  $playlist = ytc_clean_playlist_id($playlist);
210
+
211
  $rss_url = 'http://gdata.youtube.com/feeds/api/playlists/'.$playlist.$rss_settings;
212
  } else {
213
  $rss_url = 'http://gdata.youtube.com/feeds/base/users/'.$channel.'/uploads'.$rss_settings;
214
  }
215
 
216
+ //include_once(ABSPATH . WPINC . '/rss.php');
217
+ include_once(ABSPATH . WPINC . '/feed.php');
218
  $rss = fetch_feed($rss_url);
219
  if ( !is_wp_error($rss) ) {
220
  $getrnd = $instance['getrnd'];
225
  if ( $getrnd ) {
226
  $items = $rss->get_items(0, $maxitems);
227
  } else {
228
+ if ( !$vidqty )
229
+ $vidqty = 1;
230
  $items = $rss->get_items(0, $vidqty); // set 0, 2 for next video
231
  }
232
  }
233
 
234
  if ($maxitems == 0) {
235
+ $output[] = __( 'No items' , 'youtube-channel' );
236
  } else {
237
+ if ( $getrnd )
238
+ $rnd_used = array(); // set array for unique random item
239
 
240
+ for ($y = 1; $y <= $vidqty; $y++) {
241
  if ( $getrnd ) {
242
  $rnd_item = mt_rand(0, (count($items)-1));
243
  while ( $y > 1 && in_array($rnd_item, $rnd_used) ) {
251
  }
252
 
253
  // print single video block
254
+ $output = array_merge( $output, ytc_print_video($item, $instance, $y) );
255
  }
256
  }
257
  } // single playlist or ytc way
258
 
259
+ $output = array_merge( $output, ytc_channel_link($instance) ); // insert link to channel on bootom of widget
260
+
261
+ $output[] = '</div><!-- .youtube_channel -->';
262
+ $output[] = $after_widget;
263
+
264
+ echo implode('',$output);
265
 
 
 
 
266
  }
267
 
268
  }
270
  /* function to print standard playlist embed code */
271
  function ytc_only_pl($instance) {
272
  $width = $instance['width'];
273
+ if ( empty($width) )
274
+ $width = 220;
275
+
276
+ $instance['playlist'];
277
+ if ( empty($playlist) )
278
+ $playlist = YTCPLID;
279
+
280
  $height = height_ratio($width, $instance['ratio']) + 25;
281
+ $playlist = ytc_clean_playlist_id($playlist);
282
+
283
+ $autoplay = $instance['autoplay'];
284
+ if ( $autoplay )
285
+ $autoplay = '&autoplay=1';
286
+ $output[] = '<div class="ytc_video_container ytc_video_1 ytc_video_single">
287
+ <iframe src="http://www.youtube.com/embed/videoseries?list=PL'.$playlist.$autoplay.'"
288
+ width="'.$width.'" height="'.$height.'" frameborder="0"></iframe></div>';
289
+ return $output;
290
  }
291
 
292
  /* function to print video in widget */
293
  function ytc_print_video($item, $instance, $y) {
294
  /* video settings */
295
+ //$output = '';
296
 
297
  // get hideinfo, autoplay and controls settings
298
  // where this is used?
302
 
303
  // set width and height
304
  $width = $instance['width'];
305
+ if ( empty($width) )
306
+ $width = 220;
307
  $height = height_ratio($width, $instance['ratio']);
308
 
309
  // calculate image height based on width for 4:3 thumbnail
311
 
312
  // which type to show
313
  $to_show = $instance['to_show'];
314
+ if ( $to_show == "" )
315
+ $to_show = "object";
316
 
317
  // if not thumbnail, increase video height for 25px taken by video controls
318
+ if ( $to_show != 'thumbnail' && !$controls && $instance['fixyt'] )
319
  $height += 25;
 
320
 
321
  $hideanno = $instance['hideanno'];
322
  $themelight = $instance['themelight'];
323
  /* end of video settings */
324
+
325
  if ( $instance['usepl'] ) {
326
  $yt_id = $item->get_link();
327
  $yt_id = preg_replace('/^.*=(.*)&.*$/', '${1}', $yt_id);
332
  # $yt_url = "p/$playlist";
333
  #}
334
  } else {
335
+ $yt_id = explode(":", $item->get_id());
336
  $yt_id = $yt_id[3];
337
  $yt_url = "v/$yt_id";
338
  }
341
  $yt_video = $item->get_permalink();
342
  $yt_title = esc_html( $item->get_title() );
343
  $yt_date = $item->get_date('j F Y | g:i a');
344
+ // $next_id = explode(":", $next_item->get_id());
345
  // $next_id = $yt_id[3];
346
 
347
  switch ($y) {
349
  $vnumclass = 'first';
350
  break;
351
  case $instance['vidqty']:
352
+ $autoplay = false;
353
  $vnumclass = 'last';
354
  break;
355
  default:
356
  $vnumclass = 'mid';
357
+ $autoplay = false;
358
  break;
359
  }
360
 
361
+ $output[] = '<div class="ytc_video_container ytc_video_'.$y.' ytc_video_'.$vnumclass.'">';
362
 
363
  // show video title?
364
+ if ( $instance['showtitle'] )
365
+ $output[] = '<h3 class="ytc_title">'.$yt_title.'</h3>';
 
366
 
367
  // define object ID
368
  $ytc_vid = 'ytc_' . $yt_id;
371
  if ( $to_show == "thumbnail" ) {
372
  $title = sprintf( __( 'Watch video %1$s published on %2$s' , 'youtube-channel' ), $yt_title, $yt_date );
373
  /* if ( $instance['lightbox'] ) { $in_lightbox = 'rel="ytc-lightbox"'; } else { $in_lightbox = ''; } */
374
+ $output[] = '<a href="'.$yt_video.'" title="'.$title.'"><span style="width: '.$width.'px; height: '.$height.'px; overflow: hidden; display: block; background: url('.$yt_thumb.') 50% 50% no-repeat; background-size: '.$width.'px '.$imgfixedheight.'px;" title="'.$yt_title.'" id="'.$ytc_vid.'"></span></a>';
375
+
 
376
  } else if ( $to_show == "chromeless" ) {
377
+ ob_start();
378
  ?>
379
  <object type="application/x-shockwave-flash" data="<?php echo YOUTUBE_CHANNEL_URL . 'chromeless.swf'; ?>" width="<?php echo $width; ?>" height="<?php echo $height; ?>" id="<?php echo $ytc_vid; ?>">
380
+ <param name="flashVars" value="video_source=<?php echo $yt_id; ?>&video_width=<?php echo $width; ?>&video_height=<?php echo $height; ?><?php if ( $autoplay ) echo "&autoplay=Yes"; if ( !$controls ) echo "&youtube_controls=Yes"; if ( $hideanno ) echo "&iv_load_policy=3"; if ( $themelight ) echo "&theme=light"; ?>" />
381
  <param name="quality" value="high" />
382
  <param name="wmode" value="opaque" />
383
  <param name="swfversion" value="6.0.65.0" />
384
  <param name="movie" value="<?php echo YOUTUBE_CHANNEL_URL . 'chromeless.swf'; ?>" />
385
  </object>
386
  <?php
387
+ $output[] = ob_get_contents();
388
+ ob_end_clean();
389
  } else if ( $to_show == "iframe" ) {
390
+ if ( !$usepl )
391
+ $yt_url = $yt_id;
392
+
393
+ $output[] = '<iframe title="YouTube video player" width="'.$width.'" height="'.$height.'" src="http://www.youtube.com/embed/'.$yt_url.'?wmode=opaque&enablejsapi=1';
394
+ if ( $controls )
395
+ $output[] = "&controls=0";
396
+ if ( $hideinfo )
397
+ $output[] = "&showinfo=0";
398
+ if ( $autoplay )
399
+ $output[] = "&autoplay=1";
400
+ if ( $hideanno )
401
+ $output[] = "&iv_load_policy=3";
402
+ if ( $themelight )
403
+ $output[] = "&theme=light";
404
+
405
+ $output[] = '" frameborder="0" allowfullscreen id="'.$ytc_vid.'"></iframe>';
406
  } else { // default is object
407
+ ob_start();
408
  ?>
409
  <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="<?php echo $width; ?>" height="<?php echo $height; ?>" id="<?php echo $ytc_vid; ?>">
410
  <param name="movie" value="http://www.youtube.com/<?php echo $yt_url; ?>?version=3<?php if ( $controls ) { echo "&amp;controls=0"; } if ( $hideinfo ) { echo "&amp;showinfo=0"; } if ( $autoplay ) { echo "&amp;autoplay=1"; } if ( $hideanno ) { echo "&amp;iv_load_policy=3"; } if ( $themelight ) { echo "&amp;theme=light"; } ?>" />
418
  <!--<![endif]-->
419
  </object>
420
  <?php
421
+ $output[] = ob_get_contents();
422
+ ob_end_clean();
423
  }
424
 
425
  // do we need to show video description?
426
  if ( $instance['showvidesc'] ) {
427
+ preg_match('/><span>(.*)<\/span><\/div>/', $item->get_description(), $videsc);
428
+ //preg_match('/<div><span>(.*)<\/span><\/div>/', $item->get_description(), $videsc);
429
  if ( $instance['videsclen'] > 0 ) {
430
  $video_description = substr($videsc[1], 0, $instance['videsclen']);
431
  } else {
437
  } else {
438
  $etcetera = '&hellip;';
439
  }
440
+ $output[] = '<p class="ytc_description">' .$video_description.$etcetera. '</p>';
441
  }
 
442
  }
443
+ $output[] = '</div><!-- .ytc_video_container -->';
444
+
445
+ return $output;
446
  }
447
 
448
  // function to calculate height by width and ratio
449
  function height_ratio($width, $ratio) {
450
+ if ( $width == "" )
451
+ $width = 220;
452
 
453
  if ( $ratio == 1 ) { // 4:3
454
  $height = round(($width / 4 ) * 3);
455
+ } elseif ( $ratio == 2 ) { // 16:10
456
  $height = round(($width / 16 ) * 10);
457
+ } elseif ( $ratio == 3 ) { // 16:9
458
  $height = round(($width / 16 ) * 9);
459
  } else { // set default if 0 or ratio not set
460
  $height = $instance['height'];
461
+ if ( $height == "" )
462
+ $height = 165;
463
  }
464
  return $height;
465
  }
466
 
467
  // function to insert link to channel
468
  function ytc_channel_link($instance) {
469
+ //$output = '';
470
  // do we need to show goto link?
471
  if ( $instance['showgoto'] ) {
472
  $channel = $instance['channel'];
473
+ if ( !$channel )
474
+ $channel = 'urkekg';
475
  $goto_txt = $instance['goto_txt'];
476
+ if ( $goto_txt == "" )
477
  $goto_txt = sprintf( __( 'Visit channel %1$s' , 'youtube-channel' ), $channel );
 
478
 
479
+ $output[] = '<div class="ytc_link">';
480
  if ( $instance['popupgoto'] ) {
481
  $newtab = __("in new window/tab", "youtube-channel");
482
  if ( $instance['target'] ) {
483
+ $output[] = '<a href="http://www.youtube.com/user/'.$channel.'/" target="_blank" title="'.$goto_txt.' '.$newtab.'">'.$goto_txt.'</a>';
 
 
484
  } else {
485
+ $output[] = '<a href="javascript: window.open(\'http://www.youtube.com/user/'.$channel.'/\'); void 0;" title="'.$goto_txt.' '.$newtab.'">'.$goto_txt.'</a>';
 
 
486
  } // target
487
  } else {
488
+ $output[] = '<p><a href="http://www.youtube.com/user/'.$channel.'/" title="'.$goto_txt.'">'.$goto_txt.'</a></p>';
 
 
489
  } // popupgoto
490
+ $output[] = '</div>';
491
 
492
  } // showgoto
493
+ return $output;
494
  }
495
 
496
  function ytc_clean_playlist_id($playlist) {
508
  register_widget( 'YouTube_Channel_Widget' );
509
  }
510
  add_action( 'widgets_init', 'youtube_channel_register_widget' );
511
+ ?>