YouTube Channel - Version 3.0.9

Version Description

  • Fix: broken autoplay when start to play all videos instead only first in YTC block set
  • Fix: remove $_SESSION variable and replace with class variable to avoid duplicate sets of JS code
Download this release

Release Info

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

Code changes from version 3.0.8.9 to 3.0.9

Files changed (2) hide show
  1. readme.txt +6 -2
  2. youtube-channel.php +14 -11
readme.txt CHANGED
@@ -4,7 +4,7 @@ Donate link: http://urosevic.net/wordpress/donate/?donate_for=youtube-channel
4
  Tags: youtube, channel, playlist, single, widget, widgets, youtube player, feed, video, thumbnail, embed, sidebar, iframe, html5, responsive
5
  Requires at least: 4.0
6
  Tested up to: 4.4
7
- Stable tag: 3.0.8.9
8
  License: GPLv3
9
  License URI: http://www.gnu.org/licenses/gpl-3.0.html
10
 
@@ -206,7 +206,7 @@ Do exactly what message says - check and correct Channel ID in default settings/
206
 
207
  > **YTC ERROR** Check YouTube Data API Key restrictions, empty cache if enabled by appending in browser address bar parameter ?ytc_force_recache=1
208
 
209
- 1. Try to remove restrictions by referer or IP in your **YouTube Data API Key** and refresh page after couple minutes.
210
  1. If that does not help, please try to create new API Key for Server w/o restrictions (not to regenerate existing one).
211
 
212
  = How to use Google APIs Explorer to verify YouTube feeds? =
@@ -354,6 +354,10 @@ If you don't wish to pay for enhancements (then you don't care would that be imp
354
 
355
  == Changelog ==
356
 
 
 
 
 
357
  = 3.0.8.9 =
358
  * Fix: Set `Hide link` for `Link to` option for `Link to Channel` in global setting does not work (reported by drweby2).
359
  * Change: Set minumal required WordPress version 4.0
4
  Tags: youtube, channel, playlist, single, widget, widgets, youtube player, feed, video, thumbnail, embed, sidebar, iframe, html5, responsive
5
  Requires at least: 4.0
6
  Tested up to: 4.4
7
+ Stable tag: 3.0.9
8
  License: GPLv3
9
  License URI: http://www.gnu.org/licenses/gpl-3.0.html
10
 
206
 
207
  > **YTC ERROR** Check YouTube Data API Key restrictions, empty cache if enabled by appending in browser address bar parameter ?ytc_force_recache=1
208
 
209
+ 1. Try to remove restrictions by IP in your Server **YouTube Data API Key** and refresh page after couple minutes.
210
  1. If that does not help, please try to create new API Key for Server w/o restrictions (not to regenerate existing one).
211
 
212
  = How to use Google APIs Explorer to verify YouTube feeds? =
354
 
355
  == Changelog ==
356
 
357
+ = 3.0.9 =
358
+ * Fix: broken autoplay when start to play all videos instead only first in YTC block set
359
+ * Fix: remove $_SESSION variable and replace with class variable to avoid duplicate sets of JS code
360
+
361
  = 3.0.8.9 =
362
  * Fix: Set `Hide link` for `Link to` option for `Link to Channel` in global setting does not work (reported by drweby2).
363
  * Change: Set minumal required WordPress version 4.0
youtube-channel.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: YouTube Channel
4
  Plugin URI: http://urosevic.net/wordpress/plugins/youtube-channel/
5
  Description: Quick and easy embed latest or random videos from YouTube channel (user uploads, liked or favourited videos) or playlist. Use <a href="widgets.php">widget</a> for sidebar or shortcode for content. Works with <em>YouTube Data API v3</em>.
6
- Version: 3.0.8.9
7
  Author: Aleksandar Urošević
8
  Author URI: http://urosevic.net/
9
  Text Domain: youtube-channel
@@ -19,13 +19,15 @@ if ( ! class_exists( 'WPAU_YOUTUBE_CHANNEL' ) ) {
19
  {
20
 
21
  const DB_VER = 14;
22
- const VER = '3.0.8.9';
23
 
24
  public $plugin_name = 'YouTube Channel';
25
  public $plugin_slug = 'youtube-channel';
26
  public $plugin_option = 'youtube_channel_defaults';
27
  public $plugin_url;
28
 
 
 
29
  /**
30
  * Construct class
31
  */
@@ -428,7 +430,8 @@ if ( ! class_exists( 'WPAU_YOUTUBE_CHANNEL' ) ) {
428
  $js = '';
429
 
430
  // Print YT API only if we have set ytc_html5_js in $_SESSION
431
- if ( ! empty( $_SESSION['ytc_html5_js'] ) ) {
 
432
  $js .= "
433
  if (!window['YT']) {
434
  var tag=document.createElement('script');
@@ -437,7 +440,7 @@ if ( ! class_exists( 'WPAU_YOUTUBE_CHANNEL' ) ) {
437
  firstScriptTag.parentNode.insertBefore(tag,firstScriptTag);
438
  }
439
  function ytc_create_ytplayers(){
440
- {$_SESSION['ytc_html5_js']}
441
  }
442
  try {
443
  ytc_create_ytplayers();
@@ -1151,7 +1154,7 @@ if ( ! class_exists( 'WPAU_YOUTUBE_CHANNEL' ) ) {
1151
  if ( ! empty( $instance['norel'] ) ) { $output[] = '&amp;rel=0'; } // disable related videos
1152
  if ( ! empty( $instance['controls'] ) ) { $output[] = '&amp;controls=0'; }
1153
  if ( ! empty( $instance['hideinfo'] ) ) { $output[] = '&amp;showinfo=0'; }
1154
- if ( ! empty( $instance['autoplay'] ) ) { $output[] = '&amp;autoplay=1'; }
1155
  if ( ! empty( $instance['hideanno'] ) ) { $output[] = '&amp;iv_load_policy=3'; }
1156
  if ( ! empty( $instance['themelight'] ) ) { $output[] = '&amp;theme=light'; }
1157
  if ( ! empty( $instance['modestbranding'] ) ) { $output[] = '&amp;modestbranding=1'; }
@@ -1168,7 +1171,7 @@ if ( ! class_exists( 'WPAU_YOUTUBE_CHANNEL' ) ) {
1168
  // youtube API async
1169
  $js_vars = '';
1170
  $js_vars .= ( ! empty( $instance['norel'] ) ) ? 'rel:0,' : '';
1171
- $js_vars .= ( ! empty( $instance['autoplay'] ) ) ? 'autoplay:1,' : '';
1172
  $js_vars .= ( ! empty( $instance['hideinfo'] ) ) ? 'showinfo:0,' : '';
1173
  $js_vars .= ( ! empty( $instance['controls'] ) ) ? 'controls:0,' : '';
1174
  $js_vars .= ( ! empty( $instance['themelight'] ) ) ? "theme:'light'," : '';
@@ -1179,7 +1182,7 @@ if ( ! class_exists( 'WPAU_YOUTUBE_CHANNEL' ) ) {
1179
 
1180
  $js_end = '';
1181
  $js_end .= ( ! empty( $instance['hideanno'] ) ) ? 'iv_load_policy:3,' : '';
1182
- $js_end .= ( ! empty( $instance['autoplay'] ) && ! empty( $instance['autoplay_mute'] ) ) ? "events:{'onReady':ytc_mute}," : '';
1183
  $js_end = rtrim( $js_end, ',' );
1184
 
1185
  $js_player_id = str_replace( '-', '_', $yt_id );
@@ -1202,10 +1205,10 @@ if ( ! class_exists( 'WPAU_YOUTUBE_CHANNEL' ) ) {
1202
  $ytc_html5_js .= "videoId:'{$yt_id}',enablejsapi:1,playerVars:{{$js_vars}},origin:'{$site_domain}',{$js_end}});";
1203
 
1204
  // prepare JS for footer
1205
- if ( empty( $_SESSION['ytc_html5_js'] ) ) {
1206
- $_SESSION['ytc_html5_js'] = $ytc_html5_js;
1207
  } else {
1208
- $_SESSION['ytc_html5_js'] .= $ytc_html5_js;
1209
  }
1210
  } else { // default is thumbnail
1211
 
@@ -1226,7 +1229,6 @@ if ( ! class_exists( 'WPAU_YOUTUBE_CHANNEL' ) ) {
1226
  // Do we need thumbnail w/ or w/o tooltip
1227
  $tag_title = ( empty( $instance['no_thumb_title'] ) ) ? $tag_title = "title=\"{$yt_title}\"" : '';
1228
  $output[] = "<a href=\"//www.youtube.com/watch?v=${yt_id}${p}\" ${tag_title} class=\"ytc_thumb ytc-lightbox {$arclass}\"><span style=\"background-image: url({$yt_thumb});\" ${tag_title} id=\"ytc_{$yt_id}\"></span></a>";
1229
- // $output[] = "<a href=\"//${youtube_domain}/watch?v=${yt_id}${p}\" ${tag_title} class=\"ytc_thumb ytc-lightbox {$arclass}\"><span style=\"background-image: url({$yt_thumb});\" ${tag_title} id=\"ytc_{$yt_id}\"></span></a>";
1230
 
1231
  } // what to show conditions
1232
 
@@ -1240,6 +1242,7 @@ if ( ! class_exists( 'WPAU_YOUTUBE_CHANNEL' ) ) {
1240
 
1241
  $video_description = $item->snippet->description;
1242
  $etcetera = '';
 
1243
  if ( $instance['desclen'] > 0 ) {
1244
  if ( strlen( $video_description ) > $instance['desclen'] ) {
1245
  $video_description = substr( $video_description, 0, $instance['desclen'] );
3
  Plugin Name: YouTube Channel
4
  Plugin URI: http://urosevic.net/wordpress/plugins/youtube-channel/
5
  Description: Quick and easy embed latest or random videos from YouTube channel (user uploads, liked or favourited videos) or playlist. Use <a href="widgets.php">widget</a> for sidebar or shortcode for content. Works with <em>YouTube Data API v3</em>.
6
+ Version: 3.0.9
7
  Author: Aleksandar Urošević
8
  Author URI: http://urosevic.net/
9
  Text Domain: youtube-channel
19
  {
20
 
21
  const DB_VER = 14;
22
+ const VER = '3.0.9';
23
 
24
  public $plugin_name = 'YouTube Channel';
25
  public $plugin_slug = 'youtube-channel';
26
  public $plugin_option = 'youtube_channel_defaults';
27
  public $plugin_url;
28
 
29
+ public $ytc_html5_js = '';
30
+
31
  /**
32
  * Construct class
33
  */
430
  $js = '';
431
 
432
  // Print YT API only if we have set ytc_html5_js in $_SESSION
433
+ // if ( ! empty( $_SESSION['ytc_html5_js'] ) ) {
434
+ if ( ! empty( $this->ytc_html5_js ) ) {
435
  $js .= "
436
  if (!window['YT']) {
437
  var tag=document.createElement('script');
440
  firstScriptTag.parentNode.insertBefore(tag,firstScriptTag);
441
  }
442
  function ytc_create_ytplayers(){
443
+ {$this->ytc_html5_js}
444
  }
445
  try {
446
  ytc_create_ytplayers();
1154
  if ( ! empty( $instance['norel'] ) ) { $output[] = '&amp;rel=0'; } // disable related videos
1155
  if ( ! empty( $instance['controls'] ) ) { $output[] = '&amp;controls=0'; }
1156
  if ( ! empty( $instance['hideinfo'] ) ) { $output[] = '&amp;showinfo=0'; }
1157
+ if ( ! empty( $instance['autoplay'] ) && 1 == $y ) { $output[] = '&amp;autoplay=1'; }
1158
  if ( ! empty( $instance['hideanno'] ) ) { $output[] = '&amp;iv_load_policy=3'; }
1159
  if ( ! empty( $instance['themelight'] ) ) { $output[] = '&amp;theme=light'; }
1160
  if ( ! empty( $instance['modestbranding'] ) ) { $output[] = '&amp;modestbranding=1'; }
1171
  // youtube API async
1172
  $js_vars = '';
1173
  $js_vars .= ( ! empty( $instance['norel'] ) ) ? 'rel:0,' : '';
1174
+ $js_vars .= ( ! empty( $instance['autoplay'] ) && 1 == $y ) ? 'autoplay:1,' : '';
1175
  $js_vars .= ( ! empty( $instance['hideinfo'] ) ) ? 'showinfo:0,' : '';
1176
  $js_vars .= ( ! empty( $instance['controls'] ) ) ? 'controls:0,' : '';
1177
  $js_vars .= ( ! empty( $instance['themelight'] ) ) ? "theme:'light'," : '';
1182
 
1183
  $js_end = '';
1184
  $js_end .= ( ! empty( $instance['hideanno'] ) ) ? 'iv_load_policy:3,' : '';
1185
+ $js_end .= ( ! empty( $instance['autoplay'] ) && ( 1 == $y ) && ! empty( $instance['autoplay_mute'] ) ) ? "events:{'onReady':ytc_mute}," : '';
1186
  $js_end = rtrim( $js_end, ',' );
1187
 
1188
  $js_player_id = str_replace( '-', '_', $yt_id );
1205
  $ytc_html5_js .= "videoId:'{$yt_id}',enablejsapi:1,playerVars:{{$js_vars}},origin:'{$site_domain}',{$js_end}});";
1206
 
1207
  // prepare JS for footer
1208
+ if ( empty( $this->ytc_html5_js ) ) {
1209
+ $this->ytc_html5_js = $ytc_html5_js;
1210
  } else {
1211
+ $this->ytc_html5_js .= $ytc_html5_js;
1212
  }
1213
  } else { // default is thumbnail
1214
 
1229
  // Do we need thumbnail w/ or w/o tooltip
1230
  $tag_title = ( empty( $instance['no_thumb_title'] ) ) ? $tag_title = "title=\"{$yt_title}\"" : '';
1231
  $output[] = "<a href=\"//www.youtube.com/watch?v=${yt_id}${p}\" ${tag_title} class=\"ytc_thumb ytc-lightbox {$arclass}\"><span style=\"background-image: url({$yt_thumb});\" ${tag_title} id=\"ytc_{$yt_id}\"></span></a>";
 
1232
 
1233
  } // what to show conditions
1234
 
1242
 
1243
  $video_description = $item->snippet->description;
1244
  $etcetera = '';
1245
+ ##TODO: If description should note be shortened, print HTML formatted desc
1246
  if ( $instance['desclen'] > 0 ) {
1247
  if ( strlen( $video_description ) > $instance['desclen'] ) {
1248
  $video_description = substr( $video_description, 0, $instance['desclen'] );