YouTube Channel - Version 3.0.5

Version Description

(2015-05-11/12) = * Fix: Setting back dropdown options with 0 ID does not work on Settings page (Channel as resource to use, Cache timeout, Aspect ratio, What to show, Open link to, Link to) * Add: Option to export global settings to JSON and add to Tools tab in settings button to download global settings JSON * Change: Update plugin features * Improved: Retrieve only fields which will be used for output w/o unused items to reduce * Improved: More micro optimizations

Download this release

Release Info

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

Code changes from version 3.0.4 to 3.0.5

Files changed (4) hide show
  1. inc/settings.php +6 -6
  2. inc/settings_tools.php +7 -1
  3. readme.txt +18 -9
  4. youtube-channel.php +42 -28
inc/settings.php CHANGED
@@ -806,9 +806,9 @@ if ( ! class_exists('WPAU_YOUTUBE_CHANNEL_SETTINGS') ) {
806
  $sanitized['vanity'] = ( ! empty($options['vanity']) ) ? trim($options['vanity']) : $this->defaults['vanity'];
807
  $sanitized['username'] = ( ! empty($options['username']) ) ? trim($options['username']) : $this->defaults['username'];
808
  $sanitized['playlist'] = ( ! empty($options['playlist']) ) ? trim($options['playlist']) : $this->defaults['playlist'];
809
- $sanitized['resource'] = ( ! empty($options['resource']) ) ? intval($options['resource']) : $this->defaults['resource'];
810
  $sanitized['only_pl'] = ( ! empty($options['only_pl']) && $options['only_pl'] ) ? 1 : 0;
811
- $sanitized['cache'] = ( ! empty($options['cache']) ) ? intval($options['cache']) : $this->defaults['cache'];
812
  $sanitized['fetch'] = ( ! empty($options['fetch']) ) ? intval($options['fetch']) : $this->defaults['fetch'];
813
  $sanitized['num'] = ( ! empty($options['num']) ) ? intval($options['num']) : $this->defaults['num'];
814
  $sanitized['privacy'] = ( ! empty($options['privacy']) && $options['privacy'] ) ? 1 : 0;
@@ -818,9 +818,9 @@ if ( ! class_exists('WPAU_YOUTUBE_CHANNEL_SETTINGS') ) {
818
  // --- Video ---
819
  case 'ytc_video':
820
  $sanitized['width'] = ( ! empty($options['width']) ) ? intval($options['width']) : $this->defaults['width'];
821
- $sanitized['ratio'] = ( ! empty($options['ratio']) ) ? intval($options['ratio']) : $this->defaults['ratio'];
822
  $sanitized['responsive'] = ( ! empty($options['responsive']) && $options['responsive'] ) ? 1 : 0;
823
- $sanitized['display'] = ( ! empty($options['display']) ) ? intval($options['display']) : $this->defaults['display'];
824
  $sanitized['themelight'] = ( ! empty($options['themelight']) && $options['themelight'] ) ? 1 : 0;
825
  $sanitized['controls'] = ( ! empty($options['controls']) && $options['controls'] ) ? 1 : 0;
826
  $sanitized['autoplay'] = ( ! empty($options['autoplay']) && $options['autoplay'] ) ? 1 : 0;
@@ -843,8 +843,8 @@ if ( ! class_exists('WPAU_YOUTUBE_CHANNEL_SETTINGS') ) {
843
  case 'ytc_link':
844
  $sanitized['showgoto'] = ( ! empty($options['showgoto']) && $options['showgoto'] ) ? 1 : 0;
845
  $sanitized['goto_txt'] = ( ! empty($options['goto_txt']) ) ? $options['goto_txt'] : $this->defaults['goto_txt'];
846
- $sanitized['popup_goto'] = ( ! empty($options['popup_goto']) ) ? intval($options['popup_goto']) : $this->defaults['popup_goto'];
847
- $sanitized['link_to'] = ( ! empty($options['link_to']) ) ? intval($options['link_to']) : $this->defaults['link_to'];
848
  break; // Link to Channel
849
 
850
  } // switch
806
  $sanitized['vanity'] = ( ! empty($options['vanity']) ) ? trim($options['vanity']) : $this->defaults['vanity'];
807
  $sanitized['username'] = ( ! empty($options['username']) ) ? trim($options['username']) : $this->defaults['username'];
808
  $sanitized['playlist'] = ( ! empty($options['playlist']) ) ? trim($options['playlist']) : $this->defaults['playlist'];
809
+ $sanitized['resource'] = ( isset($options['resource']) ) ? intval($options['resource']) : $this->defaults['resource'];
810
  $sanitized['only_pl'] = ( ! empty($options['only_pl']) && $options['only_pl'] ) ? 1 : 0;
811
+ $sanitized['cache'] = ( isset($options['cache']) ) ? intval($options['cache']) : $this->defaults['cache'];
812
  $sanitized['fetch'] = ( ! empty($options['fetch']) ) ? intval($options['fetch']) : $this->defaults['fetch'];
813
  $sanitized['num'] = ( ! empty($options['num']) ) ? intval($options['num']) : $this->defaults['num'];
814
  $sanitized['privacy'] = ( ! empty($options['privacy']) && $options['privacy'] ) ? 1 : 0;
818
  // --- Video ---
819
  case 'ytc_video':
820
  $sanitized['width'] = ( ! empty($options['width']) ) ? intval($options['width']) : $this->defaults['width'];
821
+ $sanitized['ratio'] = ( isset($options['ratio']) ) ? intval($options['ratio']) : $this->defaults['ratio'];
822
  $sanitized['responsive'] = ( ! empty($options['responsive']) && $options['responsive'] ) ? 1 : 0;
823
+ $sanitized['display'] = ( ! empty($options['display']) ) ? trim($options['display']) : $this->defaults['display'];
824
  $sanitized['themelight'] = ( ! empty($options['themelight']) && $options['themelight'] ) ? 1 : 0;
825
  $sanitized['controls'] = ( ! empty($options['controls']) && $options['controls'] ) ? 1 : 0;
826
  $sanitized['autoplay'] = ( ! empty($options['autoplay']) && $options['autoplay'] ) ? 1 : 0;
843
  case 'ytc_link':
844
  $sanitized['showgoto'] = ( ! empty($options['showgoto']) && $options['showgoto'] ) ? 1 : 0;
845
  $sanitized['goto_txt'] = ( ! empty($options['goto_txt']) ) ? $options['goto_txt'] : $this->defaults['goto_txt'];
846
+ $sanitized['popup_goto'] = ( isset($options['popup_goto']) ) ? intval($options['popup_goto']) : $this->defaults['popup_goto'];
847
+ $sanitized['link_to'] = ( isset($options['link_to']) ) ? intval($options['link_to']) : $this->defaults['link_to'];
848
  break; // Link to Channel
849
 
850
  } // switch
inc/settings_tools.php CHANGED
@@ -1,3 +1,5 @@
 
 
1
  <p>To avoid page load slowdown, we provide internal YouTube Channel caching functionality. You can enable caching per widget or shortcode, and set how long cached feed for particular widget or shortcode will live.</p>
2
  <p>If you wish to force clear cache before it expires (for example, you have set cache timeout to 2 days, but wish to force loading of fresh channel or playlist feed), you can use form below instead to manually remove transients from database.</p>
3
 
@@ -16,4 +18,8 @@ jQuery(document).ready(function($){
16
  }
17
  });
18
  });
19
- </script>
 
 
 
 
1
+ <h3>Clear YTC Cache</h3>
2
+
3
  <p>To avoid page load slowdown, we provide internal YouTube Channel caching functionality. You can enable caching per widget or shortcode, and set how long cached feed for particular widget or shortcode will live.</p>
4
  <p>If you wish to force clear cache before it expires (for example, you have set cache timeout to 2 days, but wish to force loading of fresh channel or playlist feed), you can use form below instead to manually remove transients from database.</p>
5
 
18
  }
19
  });
20
  });
21
+ </script>
22
+
23
+ <h3>Export global settings to JSON</h3>
24
+ <p>If you experienced any error while you using shortcode <code>[youtube_channel]</code> please provide to <a href="https://wordpress.org/support/plugin/youtube-channel" target="_blank">support forum</a> exact shortcode syntax and JSON of global settings.</p>
25
+ <a href="?ytc_debug_json_for=global" class="button">Download plugin's global settings JSON</a>
readme.txt CHANGED
@@ -4,7 +4,7 @@ Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_i
4
  Tags: youtube, channel, playlist, single, widget, widgets, youtube player, flash player, rss, feed, video, thumbnail, embed, sidebar, chromeless, iframe, html5, responsive
5
  Requires at least: 3.9.0
6
  Tested up to: 4.2.2
7
- Stable tag: 3.0.4
8
  License: GPLv3
9
  License URI: http://www.gnu.org/licenses/gpl-3.0.html
10
 
@@ -19,16 +19,16 @@ Simply insert widget to sidebar, set channel name and if you wish leave all othe
19
  If you like this extension and you find it useful, please rate it on the right side.
20
 
21
  = Features =
22
- * Display latest videos from YouTube channel, favorites or playlist
23
- * Option to get random video from resources mentioned above
24
- * Responsive (one full width video per row) or non responsive (video wall)
25
- * Preferred aspect ratio relative to width (16:9, 16:10 and 4:3)
26
  * Custom width for video embeded object (default is 306px)
27
  * Enhanced Privacy
28
- * Choose to display video as thumbnail, HTML5 (iframe), HTML5 Asynchronous (iframe2), Flash (object) or Chromeless video
29
  * Thumbnail mode opens video in lightbox
30
  * Custom caching timeout
31
- * Optimized gdata feeds
32
  * Optional video autoplay with optional muted audio
33
  * Show customized link to channel below videos
34
 
@@ -196,8 +196,11 @@ reason: ipRefererBlocked
196
  message: There is a per-IP or per-Referer restriction configured on your API key and the request does not match these restrictions. Please use the Google Developers Console to update your API key configuration if request from this IP or referer should be allowed.
197
  -->`
198
 
199
- Try to remove restrictions by referer or IP in your **YouTube Data API Key** and refresh page after couple minutes.
200
- If that does not help, please try to create new API Key for Browser w/o restrictions (not to regenerate existing one).
 
 
 
201
  We still strugling with that Google's restrictions. If you get final solution, please inform us asap.
202
 
203
  = Where to find correct Channel ID and/or Vanity custom Name? =
@@ -254,6 +257,12 @@ and custom CSS code added to theme style.css or similar customization:
254
  So, we display thumbnails for 7 random videos from default (global) playlist, and distribute small thumbnails to 3 columns on wide screens, 2 columns under 768px and single thumbnail per row under 480px.
255
 
256
  == Changelog ==
 
 
 
 
 
 
257
 
258
  = 3.0.4 (2015-05-11) =
259
  * Add: Tip what to do if error ocurred with YouTube Data API Key printed inside YTC ERROR comment
4
  Tags: youtube, channel, playlist, single, widget, widgets, youtube player, flash player, rss, feed, video, thumbnail, embed, sidebar, chromeless, iframe, html5, responsive
5
  Requires at least: 3.9.0
6
  Tested up to: 4.2.2
7
+ Stable tag: 3.0.5
8
  License: GPLv3
9
  License URI: http://www.gnu.org/licenses/gpl-3.0.html
10
 
19
  If you like this extension and you find it useful, please rate it on the right side.
20
 
21
  = Features =
22
+ * Display latest videos from YouTube Channel (resources are sorted in reverse chronological order based on the date they were created) or videos naturaly sorted from Favorited Videos, Liked Videos and Playlist
23
+ * Option to get random video from any of 4 resources
24
+ * Responsive (one full width video per row) or non responsive
25
+ * Preferred aspect ratio relative to width (16:9 and 4:3)
26
  * Custom width for video embeded object (default is 306px)
27
  * Enhanced Privacy
28
+ * Choose to display video as thumbnail (default), HTML5 (iframe) or HTML5 Asynchronous (iframe2)
29
  * Thumbnail mode opens video in lightbox
30
  * Custom caching timeout
31
+ * Optimized data feeds
32
  * Optional video autoplay with optional muted audio
33
  * Show customized link to channel below videos
34
 
196
  message: There is a per-IP or per-Referer restriction configured on your API key and the request does not match these restrictions. Please use the Google Developers Console to update your API key configuration if request from this IP or referer should be allowed.
197
  -->`
198
 
199
+ Try with following possible solutions:
200
+ 1. If you are using **Jetpack** plugin with enabled **Protect** sub plugin, disable it. (kudos to [yudhita](https://wordpress.org/support/profile/yudhita) for tip)
201
+ 1. Try to remove restrictions by referer or IP in your **YouTube Data API Key** and refresh page after couple minutes.
202
+ 1. If that does not help, please try to create new API Key for Browser w/o restrictions (not to regenerate existing one).
203
+
204
  We still strugling with that Google's restrictions. If you get final solution, please inform us asap.
205
 
206
  = Where to find correct Channel ID and/or Vanity custom Name? =
257
  So, we display thumbnails for 7 random videos from default (global) playlist, and distribute small thumbnails to 3 columns on wide screens, 2 columns under 768px and single thumbnail per row under 480px.
258
 
259
  == Changelog ==
260
+ = 3.0.5 (2015-05-11/12) =
261
+ * Fix: Setting back dropdown options with `0` ID does not work on Settings page (Channel as resource to use, Cache timeout, Aspect ratio, What to show, Open link to, Link to)
262
+ * Add: Option to export global settings to JSON and add to Tools tab in settings button to download global settings JSON
263
+ * Change: Update plugin features
264
+ * Improved: Retrieve only fields which will be used for output w/o unused items to reduce
265
+ * Improved: More micro optimizations
266
 
267
  = 3.0.4 (2015-05-11) =
268
  * Add: Tip what to do if error ocurred with YouTube Data API Key printed inside YTC ERROR comment
youtube-channel.php CHANGED
@@ -4,7 +4,7 @@ Plugin Name: YouTube Channel
4
  Plugin URI: http://urosevic.net/wordpress/plugins/youtube-channel/
5
  Description: <a href="widgets.php">Widget</a> that display latest video thumbnail or iframe (HTML5) video from YouTube Channel, Liked Videos, Favourites or Playlist.
6
  Author: Aleksandar Urošević
7
- Version: 3.0.4
8
  Author URI: http://urosevic.net/
9
  */
10
  // @TODO make FitVideo optional
@@ -18,7 +18,7 @@ if ( !class_exists('WPAU_YOUTUBE_CHANNEL') )
18
  {
19
 
20
  const DB_VER = 3;
21
- const VER = '3.0.4';
22
 
23
  public $plugin_name = "YouTube Channel";
24
  public $plugin_slug = "youtube-channel";
@@ -710,24 +710,25 @@ function ytc_mute(event){
710
  if ( $resource == 'channel' ) {
711
 
712
  // channel
713
- $feed_url = "https://www.googleapis.com/youtube/v3/search?";
714
- $feed_url .= "part=snippet";
715
- $feed_url .= "&channelId=" . $resource_id;
716
- $feed_url .= "&order=date";
717
- $feed_url .= "&type=video";
 
718
 
719
  } else if ( in_array($resource, array('playlist','favourites','liked')) ) {
720
 
721
  // playlist
722
- $feed_url = "https://www.googleapis.com/youtube/v3/playlistItems?";
723
- $feed_url .= "part=snippet";
724
- $feed_url .= "&playlistId=" . $resource_id;
 
725
 
726
  }
727
 
728
  // universal
729
- $feed_url .= "&maxResults=" . $items;
730
- $feed_url .= "&fields=items(id%2Csnippet)";
731
  $feed_url .= "&key=" . YOUTUBE_DATA_API_KEY;
732
 
733
  $wprga = array(
@@ -736,6 +737,9 @@ function ytc_mute(event){
736
  $response = wp_remote_get($feed_url, $wprga);
737
  $json = wp_remote_retrieve_body( $response );
738
 
 
 
 
739
  return $json;
740
 
741
  } // END function fetch_youtube_feed($resource, $resource_id, $items)
@@ -814,13 +818,13 @@ function ytc_mute(event){
814
  $output[] = '<p>';
815
  switch ( $instance['popup_goto'] ) {
816
  case 1:
817
- $output[] = '<a href="javascript: window.open(\''.$goto_url.'\'); void 0;" title="'.$goto_txt.' '.$newtab.'">'.$goto_txt.'</a>';
818
  break;
819
  case 2:
820
- $output[] = '<a href="'.$goto_url.'" target="_blank" title="'.$goto_txt.' '.$newtab.'">'.$goto_txt.'</a>';
821
  break;
822
  default:
823
- $output[] = '<a href="'.$goto_url.'" title="'.$goto_txt.'">'.$goto_txt.'</a>';
824
  } // switch popup_goto
825
  $output[] = '</p>';
826
  $output[] = '</div>';
@@ -883,7 +887,6 @@ function ytc_mute(event){
883
  switch ($instance['ratio'])
884
  {
885
  case 1: $arclass = 'ar4_3'; break;
886
- case 2: $arclass = 'ar16_10'; break;
887
  default: $arclass = 'ar16_9';
888
  }
889
  $output[] = "<div class=\"ytc_video_container ytc_video_{$y} ytc_video_{$vnumclass} ${arclass}\" style=\"width:{$width}px\">";
@@ -1004,8 +1007,6 @@ JS;
1004
  $output[] = "<a href=\"${yt_video}${p}\" class=\"ytc_thumb ytc-lightbox {$arclass}\"><span style=\"background-image: url({$yt_thumb});\" id=\"{$ytc_vid}\"></span></a>";
1005
  }
1006
 
1007
- // $output[] = '<a href="'.$yt_video.$p.'" title="'.$yt_title.'" class="ytc_thumb ytc-lightbox '.$arclass.'"><span style="background-image: url('.$yt_thumb.');" title="'.$title.'" id="'.$ytc_vid.'"></span></a>';
1008
-
1009
  } // what to show conditions
1010
 
1011
  // do we need to show video description?
@@ -1149,15 +1150,28 @@ JS;
1149
  // get widget ID from parameter
1150
  $for = $_GET['ytc_debug_json_for'];
1151
 
1152
- // prepare option name and widget ID
1153
- $option_name = "widget_".substr($for,0,strrpos($for,"-"));
1154
- $widget_id = substr($for,strrpos($for,"-")+1);
1155
 
1156
- // get YTC widgets options
1157
- $widget_options = get_option($option_name);
1158
 
1159
- if (!is_array($widget_options[$widget_id]))
1160
- return;
 
 
 
 
 
 
 
 
 
 
 
 
 
1161
 
1162
  // prepare debug data with settings of current widget
1163
  $data = array_merge(
@@ -1168,9 +1182,9 @@ JS;
1168
  'wp' => $wp_version,
1169
  'ytc' => self::VER,
1170
  'url' => get_site_url(),
1171
- 'widget_id' => $for
1172
  ),
1173
- $widget_options[$widget_id]
1174
  );
1175
 
1176
  // return JSON file
@@ -1179,7 +1193,7 @@ JS;
1179
  echo json_encode($data);
1180
 
1181
  // destroy vars
1182
- unset($data,$widget_options,$widget_id,$option_name,$for);
1183
 
1184
  // exit now, because we need only debug data in JSON file, not settings or any other page
1185
  exit;
4
  Plugin URI: http://urosevic.net/wordpress/plugins/youtube-channel/
5
  Description: <a href="widgets.php">Widget</a> that display latest video thumbnail or iframe (HTML5) video from YouTube Channel, Liked Videos, Favourites or Playlist.
6
  Author: Aleksandar Urošević
7
+ Version: 3.0.5
8
  Author URI: http://urosevic.net/
9
  */
10
  // @TODO make FitVideo optional
18
  {
19
 
20
  const DB_VER = 3;
21
+ const VER = '3.0.5';
22
 
23
  public $plugin_name = "YouTube Channel";
24
  public $plugin_slug = "youtube-channel";
710
  if ( $resource == 'channel' ) {
711
 
712
  // channel
713
+ $feed_url = 'https://www.googleapis.com/youtube/v3/search?';
714
+ $feed_url .= 'part=snippet';
715
+ $feed_url .= "&channelId={$resource_id}";
716
+ $feed_url .= '&order=date';
717
+ $feed_url .= '&type=video';
718
+ $feed_url .= '&fields=items(id(videoId)%2Csnippet(title%2Cdescription%2CpublishedAt))';
719
 
720
  } else if ( in_array($resource, array('playlist','favourites','liked')) ) {
721
 
722
  // playlist
723
+ $feed_url = 'https://www.googleapis.com/youtube/v3/playlistItems?';
724
+ $feed_url .= 'part=snippet';
725
+ $feed_url .= "&playlistId={$resource_id}";
726
+ $feed_url .= '&fields=items(snippet(title%2Cdescription%2CpublishedAt%2CresourceId(videoId)))';
727
 
728
  }
729
 
730
  // universal
731
+ $feed_url .= "&maxResults={$items}";
 
732
  $feed_url .= "&key=" . YOUTUBE_DATA_API_KEY;
733
 
734
  $wprga = array(
737
  $response = wp_remote_get($feed_url, $wprga);
738
  $json = wp_remote_retrieve_body( $response );
739
 
740
+ // free some memory
741
+ unset($response);
742
+
743
  return $json;
744
 
745
  } // END function fetch_youtube_feed($resource, $resource_id, $items)
818
  $output[] = '<p>';
819
  switch ( $instance['popup_goto'] ) {
820
  case 1:
821
+ $output[] = "<a href=\"javascript: window.open('{$goto_url}'); void 0;\" title=\"{$goto_txt} {$newtab}\">{$goto_txt}</a>";
822
  break;
823
  case 2:
824
+ $output[] = "<a href=\"{$goto_url}\" target=\"_blank\" title=\"{$goto_txt} {$newtab}\">{$goto_txt}</a>";
825
  break;
826
  default:
827
+ $output[] = "<a href=\"{$goto_url}\" title=\"{$goto_txt}\">$goto_txt</a>";
828
  } // switch popup_goto
829
  $output[] = '</p>';
830
  $output[] = '</div>';
887
  switch ($instance['ratio'])
888
  {
889
  case 1: $arclass = 'ar4_3'; break;
 
890
  default: $arclass = 'ar16_9';
891
  }
892
  $output[] = "<div class=\"ytc_video_container ytc_video_{$y} ytc_video_{$vnumclass} ${arclass}\" style=\"width:{$width}px\">";
1007
  $output[] = "<a href=\"${yt_video}${p}\" class=\"ytc_thumb ytc-lightbox {$arclass}\"><span style=\"background-image: url({$yt_thumb});\" id=\"{$ytc_vid}\"></span></a>";
1008
  }
1009
 
 
 
1010
  } // what to show conditions
1011
 
1012
  // do we need to show video description?
1150
  // get widget ID from parameter
1151
  $for = $_GET['ytc_debug_json_for'];
1152
 
1153
+ if ( $for == 'global' ) {
1154
+ // global settings
1155
+ $options = get_option('youtube_channel_defaults');
1156
 
1157
+ if ( ! is_array($options) )
1158
+ return;
1159
 
1160
+ } else {
1161
+ // for widget
1162
+ // prepare option name and widget ID
1163
+ $option_name = "widget_".substr($for,0,strrpos($for,"-"));
1164
+ $widget_id = substr($for,strrpos($for,"-")+1);
1165
+
1166
+ // get YTC widgets options
1167
+ $widget_options = get_option($option_name);
1168
+
1169
+ if ( ! is_array($widget_options[$widget_id]) )
1170
+ return;
1171
+
1172
+ $options = $widget_options[$widget_id];
1173
+ unset ($widget_options);
1174
+ }
1175
 
1176
  // prepare debug data with settings of current widget
1177
  $data = array_merge(
1182
  'wp' => $wp_version,
1183
  'ytc' => self::VER,
1184
  'url' => get_site_url(),
1185
+ 'for' => $for
1186
  ),
1187
+ $options
1188
  );
1189
 
1190
  // return JSON file
1193
  echo json_encode($data);
1194
 
1195
  // destroy vars
1196
+ unset($data,$options,$widget_id,$option_name,$for);
1197
 
1198
  // exit now, because we need only debug data in JSON file, not settings or any other page
1199
  exit;