YouTube Channel - Version 3.0.6

Version Description

(2015-05-13/14) =

  • Fix: Prevent Fatal error on PHP<5.3 because required DIR for updater replaced with dirname(FILE)
  • Fix: No retrieved or missing videos from some channels so switch search to playlistItems API call (kudos to @mmirus)
  • Add: Embed As Playlist for all resources
  • Add: Clearfix for crappy themes where clearfix does not exists
  • Add: Option to move video title below video (boolean shortcode parameter titlebelow)
  • Add: PayPal donate button to settings page
  • Improved: Move YouTube Data API Key to plugin settings and add notification to remove YOUTUBE_DATA_API_KEY from wp-config.php (optional)
  • Improved: Updated shortcode explanation in README and Help tab in plugin settings.
  • Improved: Better tips for 'Oops, something went wrong' message.
  • Change: Wording Ups to Oops
  • Remove: Options Embed standard playlist and Show random video from global settings as this should be off by default
  • Remove: Loading of fitVids JS library for test before final removing.
Download this release

Release Info

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

Code changes from version 3.0.5 to 3.0.6

assets/css/youtube-channel.css CHANGED
@@ -1,3 +1,6 @@
 
 
 
1
  .youtube_channel {
2
  float: left;
3
  clear: both;
1
+ .clearfix {
2
+ clear: both;
3
+ }
4
  .youtube_channel {
5
  float: left;
6
  clear: both;
assets/css/youtube-channel.min.css CHANGED
@@ -1 +1 @@
1
- .ytc_thumb>span,.ytc_thumb>span:before{background-position:center center;background-repeat:no-repeat}.youtube_channel{float:left;clear:both;position:relative}.youtube_channel.responsive{width:100%}.widget_youtube-channel:after,.youtube_channel:after{visibility:hidden;display:block;font-size:0;content:" ";clear:both;height:0}.youtube_channel .ytc_video_container{float:left}.youtube_channel.responsive .ytc_video_container{width:100%!important}.youtube_channel .ytc_video_container a{border:none}.ytc_thumb{display:block;overflow:hidden;position:relative;height:0;width:100%;top:0;right:0;bottom:0;left:0}.ytc_thumb>span{height:0;width:100%;display:block;-webkit-background-size:cover;background-size:cover}.ytc_thumb>span:before{content:"";display:block;width:100%;height:0;background-image:url(../img/play.png);background-color:transparent;opacity:.6;transition:.4s}.ytc_thumb:hover>span:before{opacity:1}.ytc_thumb.ar16_9,.ytc_thumb.ar16_9>span,.ytc_thumb.ar16_9>span:before{padding-bottom:56.26%}.ytc_thumb.ar16_10,.ytc_thumb.ar16_10>span,.ytc_thumb.ar16_10>span:before{padding-bottom:62.5%}.ytc_thumb.ar4_3,.ytc_thumb.ar4_3>span,.ytc_thumb.ar4_3>span:before{padding-bottom:75%}.youtube_channel .ytc_video_container iframe{margin-bottom:0}.youtube_channel.responsive .ytc_video_container.ar16_9 .fluid-width-video-wrapper{position:relative;padding-bottom:56.25%;height:0}.youtube_channel.responsive .ytc_video_container.ar16_10 .fluid-width-video-wrapper{position:relative;padding-bottom:62.5%;height:0}.youtube_channel.responsive .ytc_video_container.ar4_3 .fluid-width-video-wrapper{position:relative;padding-bottom:75%;height:0}.youtube_channel.responsive .ytc_video_container .fluid-width-video-wrapper iframe{position:absolute;top:0;left:0;width:100%;height:100%}.youtube_channel .ytc_link{position:relative;clear:both;float:left;width:100%}.youtube_channel .ytc_link>p{padding:0;margin:0}
1
+ .ytc_thumb>span,.ytc_thumb>span:before{background-position:center center;background-repeat:no-repeat}.clearfix{clear:both}.youtube_channel{float:left;clear:both;position:relative}.youtube_channel.responsive{width:100%}.widget_youtube-channel:after,.youtube_channel:after{visibility:hidden;display:block;font-size:0;content:" ";clear:both;height:0}.youtube_channel .ytc_video_container{float:left}.youtube_channel.responsive .ytc_video_container{width:100%!important}.youtube_channel .ytc_video_container a{border:none}.ytc_thumb{display:block;overflow:hidden;position:relative;height:0;width:100%;top:0;right:0;bottom:0;left:0}.ytc_thumb>span{height:0;width:100%;display:block;-webkit-background-size:cover;background-size:cover}.ytc_thumb>span:before{content:"";display:block;width:100%;height:0;background-image:url(../img/play.png);background-color:transparent;opacity:.6;transition:.4s}.ytc_thumb:hover>span:before{opacity:1}.ytc_thumb.ar16_9,.ytc_thumb.ar16_9>span,.ytc_thumb.ar16_9>span:before{padding-bottom:56.26%}.ytc_thumb.ar16_10,.ytc_thumb.ar16_10>span,.ytc_thumb.ar16_10>span:before{padding-bottom:62.5%}.ytc_thumb.ar4_3,.ytc_thumb.ar4_3>span,.ytc_thumb.ar4_3>span:before{padding-bottom:75%}.youtube_channel .ytc_video_container iframe{margin-bottom:0}.youtube_channel.responsive .ytc_video_container.ar16_9 .fluid-width-video-wrapper{position:relative;padding-bottom:56.25%;height:0}.youtube_channel.responsive .ytc_video_container.ar16_10 .fluid-width-video-wrapper{position:relative;padding-bottom:62.5%;height:0}.youtube_channel.responsive .ytc_video_container.ar4_3 .fluid-width-video-wrapper{position:relative;padding-bottom:75%;height:0}.youtube_channel.responsive .ytc_video_container .fluid-width-video-wrapper iframe{position:absolute;top:0;left:0;width:100%;height:100%}.youtube_channel .ytc_link{position:relative;clear:both;float:left;width:100%}.youtube_channel .ytc_link>p{padding:0;margin:0}
inc/settings.php CHANGED
@@ -40,6 +40,20 @@ if ( ! class_exists('WPAU_YOUTUBE_CHANNEL_SETTINGS') ) {
40
  $this->slug . '_general' // Page Name
41
  );
42
  // --- Add Fields to General section ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
43
  // Channel ID
44
  add_settings_field(
45
  $this->option_name . 'channel', // Setting Slug
@@ -118,6 +132,7 @@ if ( ! class_exists('WPAU_YOUTUBE_CHANNEL_SETTINGS') ) {
118
  ) // args
119
  );
120
  // Playlist Only
 
121
  add_settings_field(
122
  $this->option_name . 'only_pl', // id
123
  __('Embed standard playlist', 'wpsk'), // Title
@@ -131,6 +146,7 @@ if ( ! class_exists('WPAU_YOUTUBE_CHANNEL_SETTINGS') ) {
131
  'value' => $this->defaults['only_pl'],
132
  ) // args
133
  );
 
134
  // Cache
135
  add_settings_field(
136
  $this->option_name . 'cache', // id
@@ -211,12 +227,13 @@ if ( ! class_exists('WPAU_YOUTUBE_CHANNEL_SETTINGS') ) {
211
  'ytc_general', // section
212
  array(
213
  'field' => $this->option_name . "[privacy]",
214
- 'description' => __("Enable this option to protect your visitors privacy. http://support.google.com/youtube/bin/answer.py?hl=en-GB&answer=171780", 'wpsk'),
215
  'class' => 'checkbox',
216
  'value' => $this->defaults['privacy'],
217
  ) // args
218
  );
219
  // Random video
 
220
  add_settings_field(
221
  $this->option_name . 'random', // id
222
  __('Show random video', 'wpsk'), // Title
@@ -230,6 +247,7 @@ if ( ! class_exists('WPAU_YOUTUBE_CHANNEL_SETTINGS') ) {
230
  'value' => $this->defaults['random'],
231
  ) // args
232
  );
 
233
  // --- Register setting General so $_POST handling is done ---
234
  register_setting(
235
  'ytc_general', // Setting group
@@ -657,6 +675,17 @@ if ( ! class_exists('WPAU_YOUTUBE_CHANNEL_SETTINGS') ) {
657
 
658
  } // eom settings_field_input_text()
659
 
 
 
 
 
 
 
 
 
 
 
 
660
  /**
661
  * This function provides number inputs for settings fields
662
  */
@@ -802,17 +831,19 @@ if ( ! class_exists('WPAU_YOUTUBE_CHANNEL_SETTINGS') ) {
802
 
803
  // --- General ---
804
  case 'ytc_general':
 
 
805
  $sanitized['channel'] = ( ! empty($options['channel']) ) ? trim($options['channel']) : $this->defaults['channel'];
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;
815
- $sanitized['random'] = ( ! empty($options['random']) && $options['random'] ) ? 1 : 0;
816
  break; // General
817
 
818
  // --- Video ---
@@ -848,8 +879,6 @@ if ( ! class_exists('WPAU_YOUTUBE_CHANNEL_SETTINGS') ) {
848
  break; // Link to Channel
849
 
850
  } // switch
851
- // $sanitized['dashboard_roles'] = ( ! empty($options['dashboard_roles']) && is_array($options['dashboard_roles']) ) ? $options['dashboard_roles'] : array('administrator','editor','client');
852
- // $sanitized['dashboard_redirect_url'] = ( ! empty($options['dashboard_redirect_url']) ) ? $options['dashboard_redirect_url'] : '';
853
 
854
  // --- Update ---
855
  // now return sanitized options to be written to database
40
  $this->slug . '_general' // Page Name
41
  );
42
  // --- Add Fields to General section ---
43
+ // YouTube Data API Key
44
+ add_settings_field(
45
+ $this->option_name . 'apikey', // Setting Slug
46
+ __('YouTube Data API Key', 'wpsk'), // Title
47
+ array(&$this, 'settings_field_input_password'), // Callback
48
+ $this->slug . '_general', // Page Name
49
+ 'ytc_general', // Section Name
50
+ array(
51
+ 'field' => $this->option_name . '[apikey]',
52
+ 'description' => __('Your YouTube Data API Key', 'wpsk'),
53
+ 'class' => 'regular-text password',
54
+ 'value' => $this->defaults['apikey'],
55
+ ) // args
56
+ );
57
  // Channel ID
58
  add_settings_field(
59
  $this->option_name . 'channel', // Setting Slug
132
  ) // args
133
  );
134
  // Playlist Only
135
+ /*
136
  add_settings_field(
137
  $this->option_name . 'only_pl', // id
138
  __('Embed standard playlist', 'wpsk'), // Title
146
  'value' => $this->defaults['only_pl'],
147
  ) // args
148
  );
149
+ */
150
  // Cache
151
  add_settings_field(
152
  $this->option_name . 'cache', // id
227
  'ytc_general', // section
228
  array(
229
  'field' => $this->option_name . "[privacy]",
230
+ 'description' => __(sprintf('Enable this option to protect your visitors privacy. <a href="%s" target="_blank">Learn more here</a>', 'http://support.google.com/youtube/bin/answer.py?hl=en-GB&answer=171780'), 'wpsk'),
231
  'class' => 'checkbox',
232
  'value' => $this->defaults['privacy'],
233
  ) // args
234
  );
235
  // Random video
236
+ /*
237
  add_settings_field(
238
  $this->option_name . 'random', // id
239
  __('Show random video', 'wpsk'), // Title
247
  'value' => $this->defaults['random'],
248
  ) // args
249
  );
250
+ */
251
  // --- Register setting General so $_POST handling is done ---
252
  register_setting(
253
  'ytc_general', // Setting group
675
 
676
  } // eom settings_field_input_text()
677
 
678
+ /**
679
+ * This function provides password inputs for settings fields
680
+ */
681
+ public function settings_field_input_password($args) {
682
+
683
+ extract( $args );
684
+
685
+ echo sprintf('<input type="password" name="%s" id="%s" value="%s" class="%s" /><p class="description">%s</p>', $field, $field, $value, $class, $description);
686
+
687
+ } // eom settings_field_input_text()
688
+
689
  /**
690
  * This function provides number inputs for settings fields
691
  */
831
 
832
  // --- General ---
833
  case 'ytc_general':
834
+ $apikey = ( defined('YOUTUBE_DATA_API_KEY') ) ? YOUTUBE_DATA_API_KEY : '';
835
+ $sanitized['apikey'] = ( ! empty($options['apikey']) ) ? trim($options['apikey']) : $apikey;
836
  $sanitized['channel'] = ( ! empty($options['channel']) ) ? trim($options['channel']) : $this->defaults['channel'];
837
  $sanitized['vanity'] = ( ! empty($options['vanity']) ) ? trim($options['vanity']) : $this->defaults['vanity'];
838
  $sanitized['username'] = ( ! empty($options['username']) ) ? trim($options['username']) : $this->defaults['username'];
839
  $sanitized['playlist'] = ( ! empty($options['playlist']) ) ? trim($options['playlist']) : $this->defaults['playlist'];
840
  $sanitized['resource'] = ( isset($options['resource']) ) ? intval($options['resource']) : $this->defaults['resource'];
841
+ // $sanitized['only_pl'] = ( ! empty($options['only_pl']) && $options['only_pl'] ) ? 1 : 0;
842
  $sanitized['cache'] = ( isset($options['cache']) ) ? intval($options['cache']) : $this->defaults['cache'];
843
  $sanitized['fetch'] = ( ! empty($options['fetch']) ) ? intval($options['fetch']) : $this->defaults['fetch'];
844
  $sanitized['num'] = ( ! empty($options['num']) ) ? intval($options['num']) : $this->defaults['num'];
845
  $sanitized['privacy'] = ( ! empty($options['privacy']) && $options['privacy'] ) ? 1 : 0;
846
+ // $sanitized['random'] = ( ! empty($options['random']) && $options['random'] ) ? 1 : 0;
847
  break; // General
848
 
849
  // --- Video ---
879
  break; // Link to Channel
880
 
881
  } // switch
 
 
882
 
883
  // --- Update ---
884
  // now return sanitized options to be written to database
inc/settings_template.php CHANGED
@@ -2,6 +2,7 @@
2
  global $WPAU_YOUTUBE_CHANNEL;
3
  ?>
4
  <div class="wrap" id="youtube_channel_settings">
 
5
  <h2><?php _e( $WPAU_YOUTUBE_CHANNEL->plugin_name . ' Settings', 'wpsk' ); ?></h2>
6
  <?php
7
 
2
  global $WPAU_YOUTUBE_CHANNEL;
3
  ?>
4
  <div class="wrap" id="youtube_channel_settings">
5
+ <p style="float:right;text-align:center;"><small>Support YTC developer</small><br><a href="https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=Q6Q762MQ97XJ6" target="_blank" title="Donate via PayPal - The safer, easier way to pay online!"><img src="https://www.paypalobjects.com/en_US/i/btn/btn_donateCC_LG.gif" style="width:147px;height:47px;border:0" alt="PayPal - The safer, easier way to pay online!"></a></p>
6
  <h2><?php _e( $WPAU_YOUTUBE_CHANNEL->plugin_name . ' Settings', 'wpsk' ); ?></h2>
7
  <?php
8
 
inc/settings_usage_shortcode.php CHANGED
@@ -14,7 +14,7 @@
14
  <li>&bullet; <code>2</code> Playlist</li>
15
  <li>&bullet; <code>3</code> Liked Videos (for defined channel)</li>
16
  </ul></li>
17
- <li><code>only_pl</code> <em>(bool)</em> If you set to use Playlist as resource, you can embed youtube playlist block instead single video from playlist. Simply set this option to true (<code>1</code> or <code>true</code>)</li>
18
  <li><code>cache</code> <em>(int)</em> Period in seconds for caching feed. You can disable caching by setting this option to <code>0</code>, but if you have a lot of visits, consider at least short caching (couple minutes).</li>
19
 
20
  <li><code>fetch</code> <em>(int)</em> Number of videos that will be used as stack for random pick (min 2, max 50)</li>
@@ -49,17 +49,24 @@
49
  </ul>
50
  <h4>Content Layout</h4>
51
  <ul>
52
- <li><code>showtitle</code> <em>(bool)</em> </li>
53
- <li><code>showdesc</code> <em>(bool)</em> </li>
54
- <li><code>desclen</code> <em>(int)</em> </li>
55
- <li><code>noinfo</code> <em>(bool)</em> </li>
56
- <li><code>noanno</code> <em>(bool)</em> </li>
 
57
  </ul>
58
  <h4>Link to Channel</h4>
59
  <ul>
60
- <li><code>goto</code> <em>(bool)</em> </li>
61
  <li><code>goto_txt</code> <em>(string)</em></li>
62
- <li><code>popup</code> <em>(int)</em></li>
 
 
 
 
 
 
63
  <li><code>link_to</code> <em>(int)</em> URL to link:
64
  <ul>
65
  <li>&bullet; <code>2</code> Vanity custom URL (default)</li>
14
  <li>&bullet; <code>2</code> Playlist</li>
15
  <li>&bullet; <code>3</code> Liked Videos (for defined channel)</li>
16
  </ul></li>
17
+ <li><code>only_pl</code> <em>(bool)</em> You can embed all 4 resources as seekable YouTube playlist block instead to display individual videos. Simply set this option to true (<code>1</code> or <code>true</code>)</li>
18
  <li><code>cache</code> <em>(int)</em> Period in seconds for caching feed. You can disable caching by setting this option to <code>0</code>, but if you have a lot of visits, consider at least short caching (couple minutes).</li>
19
 
20
  <li><code>fetch</code> <em>(int)</em> Number of videos that will be used as stack for random pick (min 2, max 50)</li>
49
  </ul>
50
  <h4>Content Layout</h4>
51
  <ul>
52
+ <li><code>showtitle</code> <em>(bool)</em> Set to <code>1</code> or <code>true</code> to show video title.</li>
53
+ <li><code>titlebelow</code> <em>(bool)</em> Set to <code>1</code> or <code>true</code> to move video title below video.</li>
54
+ <li><code>showdesc</code> <em>(bool)</em> Set to <code>1</code> or <code>true</code> to show video description.</li>
55
+ <li><code>desclen</code> <em>(int)</em> Set number of characters to cut down length of video description. Set to <code>0</code> to use full length description.</li>
56
+ <li><code>noinfo</code> <em>(bool)</em> Set to <code>1</code> or <code>true</code> to hide overlay video infos (from embedded player)</li>
57
+ <li><code>noanno</code> <em>(bool)</em> Set to <code>1</code> or <code>true</code> to hide overlay video annotations (from embedded player)</li>
58
  </ul>
59
  <h4>Link to Channel</h4>
60
  <ul>
61
+ <li><code>goto</code> <em>(bool)</em> Set to <code>1</code> or <code>true</code> to display link to channel at the bottom of YTC block.</li>
62
  <li><code>goto_txt</code> <em>(string)</em></li>
63
+ <li><code>popup</code> <em>(int)</em> Control where link to channel will be opened:
64
+ <ul>
65
+ <li>&bullet; <code>0</code> open link in same window</li>
66
+ <li>&bullet; <code>1</code> open link in new window with JavaScript</li>
67
+ <li>&bullet; <code>2</code> open link in new window with <code>target="_blank"</code> anchor attribute</li>
68
+ </ul>
69
+ </li>
70
  <li><code>link_to</code> <em>(int)</em> URL to link:
71
  <ul>
72
  <li>&bullet; <code>2</code> Vanity custom URL (default)</li>
inc/widget.php CHANGED
@@ -69,6 +69,7 @@ class WPAU_YOUTUBE_CHANNEL_Widget extends WP_Widget {
69
 
70
  // Content Layout
71
  $showtitle = (!empty($instance['showtitle'])) ? esc_attr($instance['showtitle']) : '';
 
72
  $showdesc = (!empty($instance['showdesc'])) ? esc_attr($instance['showdesc']) : '';
73
  $modestbranding = (!empty($instance['modestbranding'])) ? esc_attr($instance['modestbranding']) : '';
74
  $desclen = (!empty($instance['desclen'])) ? esc_attr($instance['desclen']) : 0;
@@ -133,7 +134,7 @@ class WPAU_YOUTUBE_CHANNEL_Widget extends WP_Widget {
133
  </p>
134
 
135
  <p class="playlist-only <?php echo $this->get_field_id('resource'); ?> glue-top">
136
- <label for="<?php echo $this->get_field_id( 'only_pl' ); ?>" id="<?php echo $this->get_field_id( 'only_pl' ); ?>_label"><input class="checkbox" type="checkbox" <?php checked( (bool) $only_pl, true ); ?> id="<?php echo $this->get_field_id( 'only_pl' ); ?>" name="<?php echo $this->get_field_name( 'only_pl' ); ?>" title="<?php _e('Enable this option to embed YouTube playlist instead single video from playlist.', 'youtube-channel'); ?>" /> <?php _e('Embed standard playlist<br /><small>(Please note <em>What to show?</em> have no effect for embedded playlist)</small>', 'youtube-channel'); ?></label>
137
  </p>
138
 
139
  <p class="half left glue-top">
@@ -145,7 +146,7 @@ class WPAU_YOUTUBE_CHANNEL_Widget extends WP_Widget {
145
  <p>
146
  <input class="checkbox" type="checkbox" <?php checked( (bool) $privacy, true ); ?> id="<?php echo $this->get_field_id( 'privacy' ); ?>" name="<?php echo $this->get_field_name( 'privacy' ); ?>" title="<?php _e('Enable this option to protect your visitors privacy', 'youtube-channel'); ?>" /> <label for="<?php echo $this->get_field_id( 'privacy' ); ?>"><?php printf(__('Use <a href="%s" target="_blank">Enhanced Privacy</a>', 'youtube-channel'), 'http://support.google.com/youtube/bin/answer.py?hl=en-GB&answer=171780'); ?></label>
147
  <br />
148
- <input class="checkbox" type="checkbox" <?php checked( (bool) $random, true ); ?> id="<?php echo $this->get_field_id( 'random' ); ?>" name="<?php echo $this->get_field_name( 'random' ); ?>" title="<?php _e('Get random videos of all fetched from channel or playlist', 'youtube-channel'); ?>" /> <label for="<?php echo $this->get_field_id( 'random' ); ?>"><?php _e('Show random video', 'youtube-channel'); ?></label>
149
  </p>
150
 
151
  <h4><?php _e('Video Settings', 'youtube-channel'); ?></h4>
@@ -179,6 +180,7 @@ class WPAU_YOUTUBE_CHANNEL_Widget extends WP_Widget {
179
  <h4><?php _e('Content Layout', 'youtube-channel'); ?></h4>
180
  <p>
181
  <input class="checkbox" type="checkbox" <?php checked( (bool) $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 />
 
182
  <input class="checkbox" type="checkbox" <?php checked( (bool) $showdesc, true ); ?> id="<?php echo $this->get_field_id( 'showdesc' ); ?>" name="<?php echo $this->get_field_name( 'showdesc' ); ?>" /> <label for="<?php echo $this->get_field_id( 'showdesc' ); ?>"><?php _e('Show video description', 'youtube-channel'); ?></label><br />
183
  <label for="<?php echo $this->get_field_id('desclen'); ?>"><?php _e('Description length', 'youtube-channel'); ?>: <input class="small-text" id="<?php echo $this->get_field_id('desclen'); ?>" name="<?php echo $this->get_field_name('desclen'); ?>" type="number" value="<?php echo $desclen; ?>" title="<?php _e('Set number of characters to cut down video description to (0 means full length)', 'youtube-channel');?>" /> (0 = full)</label><br />
184
  <label for="<?php echo $this->get_field_id('descappend'); ?>"><?php _e('Et cetera string', 'youtube-channel'); ?> <input class="small-text" id="<?php echo $this->get_field_id('descappend'); ?>" name="<?php echo $this->get_field_name('descappend'); ?>" type="text" value="<?php echo $descappend; ?>" title="<?php _e('Default: &amp;hellip;', 'youtube-channel'); ?>"/></label><br />
@@ -237,6 +239,7 @@ class WPAU_YOUTUBE_CHANNEL_Widget extends WP_Widget {
237
  $instance['link_to'] = $new_instance['link_to'];
238
 
239
  $instance['showtitle'] = (isset($new_instance['showtitle'])) ? $new_instance['showtitle'] : false;
 
240
  $instance['showdesc'] = (isset($new_instance['showdesc'])) ? $new_instance['showdesc'] : false;
241
  $instance['descappend'] = strip_tags($new_instance['descappend']);
242
  $instance['desclen'] = strip_tags($new_instance['desclen']);
69
 
70
  // Content Layout
71
  $showtitle = (!empty($instance['showtitle'])) ? esc_attr($instance['showtitle']) : '';
72
+ $titlebelow = (!empty($instance['titlebelow'])) ? esc_attr($instance['titlebelow']) : '';
73
  $showdesc = (!empty($instance['showdesc'])) ? esc_attr($instance['showdesc']) : '';
74
  $modestbranding = (!empty($instance['modestbranding'])) ? esc_attr($instance['modestbranding']) : '';
75
  $desclen = (!empty($instance['desclen'])) ? esc_attr($instance['desclen']) : 0;
134
  </p>
135
 
136
  <p class="playlist-only <?php echo $this->get_field_id('resource'); ?> glue-top">
137
+ <label for="<?php echo $this->get_field_id( 'only_pl' ); ?>" id="<?php echo $this->get_field_id( 'only_pl' ); ?>_label"><input class="checkbox" type="checkbox" <?php checked( (bool) $only_pl, true ); ?> id="<?php echo $this->get_field_id( 'only_pl' ); ?>" name="<?php echo $this->get_field_name( 'only_pl' ); ?>" title="<?php _e('Enable this option to embed seek YouTube playlist instead individual videos from selected resource.', 'youtube-channel'); ?>" /> <?php _e('Embed resource as playlist <small>(override "random video")</small>', 'youtube-channel'); ?></label>
138
  </p>
139
 
140
  <p class="half left glue-top">
146
  <p>
147
  <input class="checkbox" type="checkbox" <?php checked( (bool) $privacy, true ); ?> id="<?php echo $this->get_field_id( 'privacy' ); ?>" name="<?php echo $this->get_field_name( 'privacy' ); ?>" title="<?php _e('Enable this option to protect your visitors privacy', 'youtube-channel'); ?>" /> <label for="<?php echo $this->get_field_id( 'privacy' ); ?>"><?php printf(__('Use <a href="%s" target="_blank">Enhanced Privacy</a>', 'youtube-channel'), 'http://support.google.com/youtube/bin/answer.py?hl=en-GB&answer=171780'); ?></label>
148
  <br />
149
+ <input class="checkbox" type="checkbox" <?php checked( (bool) $random, true ); ?> id="<?php echo $this->get_field_id( 'random' ); ?>" name="<?php echo $this->get_field_name( 'random' ); ?>" title="<?php _e('Get random videos of all fetched from channel or playlist', 'youtube-channel'); ?>" /> <label for="<?php echo $this->get_field_id( 'random' ); ?>"><?php _e('Show random video from resource <small>(Have no effect if "Embed resource as playlist" is enabled)</small>', 'youtube-channel'); ?></label>
150
  </p>
151
 
152
  <h4><?php _e('Video Settings', 'youtube-channel'); ?></h4>
180
  <h4><?php _e('Content Layout', 'youtube-channel'); ?></h4>
181
  <p>
182
  <input class="checkbox" type="checkbox" <?php checked( (bool) $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 />
183
+ <input class="checkbox" type="checkbox" <?php checked( (bool) $titlebelow, true ); ?> id="<?php echo $this->get_field_id( 'titlebelow' ); ?>" name="<?php echo $this->get_field_name( 'titlebelow' ); ?>" /> <label for="<?php echo $this->get_field_id( 'titlebelow' ); ?>"><?php _e('Move title below video', 'youtube-channel'); ?></label><br />
184
  <input class="checkbox" type="checkbox" <?php checked( (bool) $showdesc, true ); ?> id="<?php echo $this->get_field_id( 'showdesc' ); ?>" name="<?php echo $this->get_field_name( 'showdesc' ); ?>" /> <label for="<?php echo $this->get_field_id( 'showdesc' ); ?>"><?php _e('Show video description', 'youtube-channel'); ?></label><br />
185
  <label for="<?php echo $this->get_field_id('desclen'); ?>"><?php _e('Description length', 'youtube-channel'); ?>: <input class="small-text" id="<?php echo $this->get_field_id('desclen'); ?>" name="<?php echo $this->get_field_name('desclen'); ?>" type="number" value="<?php echo $desclen; ?>" title="<?php _e('Set number of characters to cut down video description to (0 means full length)', 'youtube-channel');?>" /> (0 = full)</label><br />
186
  <label for="<?php echo $this->get_field_id('descappend'); ?>"><?php _e('Et cetera string', 'youtube-channel'); ?> <input class="small-text" id="<?php echo $this->get_field_id('descappend'); ?>" name="<?php echo $this->get_field_name('descappend'); ?>" type="text" value="<?php echo $descappend; ?>" title="<?php _e('Default: &amp;hellip;', 'youtube-channel'); ?>"/></label><br />
239
  $instance['link_to'] = $new_instance['link_to'];
240
 
241
  $instance['showtitle'] = (isset($new_instance['showtitle'])) ? $new_instance['showtitle'] : false;
242
+ $instance['titlebelow'] = (isset($new_instance['titlebelow'])) ? $new_instance['titlebelow'] : false;
243
  $instance['showdesc'] = (isset($new_instance['showdesc'])) ? $new_instance['showdesc'] : false;
244
  $instance['descappend'] = strip_tags($new_instance['descappend']);
245
  $instance['desclen'] = strip_tags($new_instance['desclen']);
readme.txt CHANGED
@@ -1,10 +1,10 @@
1
  === YouTube Channel ===
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, 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
 
@@ -37,17 +37,25 @@ If you like this extension and you find it useful, please rate it on the right s
37
  For fully functional plugin you need to have PHP 5.3 or newer! If you experience issues on older PHP, we can't help you as we don't have access to such old development platform.
38
 
39
  = Styling =
 
40
  You can use `style.css` from theme to style `YouTube Video` widget content.
41
 
42
- * `.youtube_channel` - main widget wrapper class (non-responsive block have additional class `default`, responsive block have additional class `responsive`)
43
- * `.ytc_title` - class of video title abowe thumbnail/video object
44
- * `.ytc_video_container` - class of container for single item
45
- * `.ytc_video_1`, `.ytc_video_2`, ... - class of container for single item with ordering number of item in widget
46
- * `.ytc_video_first` - class of first container for single item
47
- * `.ytc_video_last` - class of last container for single item
48
- * `.ytc_video_mid` - class of all other containers for single item
49
- * `.ytc_description` - class for video description text
50
- * `.ytc_link` - class of container for link to channel
 
 
 
 
 
 
 
51
 
52
  = Known Issues =
53
 
@@ -109,32 +117,39 @@ Along to Widget, you can add YouTube Channel block inline by using shortcode `[y
109
 
110
  **Content Layout**
111
 
112
- * `showtitle` (bool)
113
- * `showdesc` (bool)
114
- * `desclen` (int)
115
- * `noinfo` (bool)
116
- * `noanno` (bool)
 
117
 
118
  **Link to Channel**
119
 
120
- * `goto` (bool)
121
  * `goto_txt` (string)
122
- * `popup` (int)
123
- * `link_to` (int)
 
 
 
 
 
 
124
 
125
  == Installation ==
126
 
127
  You can use the built in installer and upgrader, or you can install the plugin manually.
128
 
129
  1. You can either use the automatic plugin installer or your FTP program to upload unziped `youtube-channel` directory to your `wp-content/plugins` directory.
130
- 2. Activate the plugin through the `Plugins` menu in WordPress
131
- 3. Add YouTube Channel widget to sidebar
132
- 4. Set channel name and save changes
133
 
134
  If you have to upgrade manually simply repeat the installation steps and re-enable the plugin.
135
 
136
  = YouTube Data API Key =
137
- Main difference since v2.x branch is that now we use [YouTube Data API v3](https://developers.google.com/youtube/v3/) so to make plugin to work, you'll need to generate YouTube Data API Key and insert it to `wp-config.php` file.
138
 
139
  Learn more about [Obtaining authorization credentials](https://developers.google.com/youtube/registering_an_application) and for detailed instructions how to generate your own API Key watch video below.
140
 
@@ -146,23 +161,15 @@ Learn more about [Obtaining authorization credentials](https://developers.google
146
  1. Locate and click **YouTube Data API** under **YouTube API** section
147
  1. Click **Enable API** button
148
  1. When you get enabled YouTube Data API in your project, click **Credentials** item from LHS menu **APIs & auth**
149
- 1. Click **Create New Key** button and select **Browser Key**
150
- 1. Leave empty or enter domain name of your website with wildcards. If you get message **Ups, something went wrong.** try to tune referer with wildcars (I did not success in that) or leave any restriction.
151
  1. Click **Create** button
152
  1. Copy newly created **API Key**
153
 
154
- When you generate your own YouTube Data API Key, edit wp-config.php file and find line
155
-
156
- `/* That's all, stop editing! Happy blogging. */`
157
-
158
- Insert above that line code
159
- `define('YOUTUBE_DATA_API_KEY', 'YOUR_API_KEY');`
160
 
161
- just replace keyword <strong>YOUR_API_KEY</strong> with your real API Key previously generated (surround API key to single quotes). For example, if your key is **AIzaCuBWKZLyQthAgV3ofeYtCwrMSYvm6tX8IEY** then that line should be:
162
- `define('YOUTUBE_DATA_API_KEY', 'AIzaCuBWKZLyQthAgV3ofeYtCwrMSYvm6tX8IEY');`
163
-
164
- Also, do not forget to check and update **Channel ID** in plugin's General Settings, Widgets and shortcodes.
165
- You can get **Channel ID** from page [Account Advanced](https://www.youtube.com/account_advanced) page while you're loagged in to your account.
166
 
167
  == Frequently Asked Questions ==
168
 
@@ -170,17 +177,18 @@ You can get **Channel ID** from page [Account Advanced](https://www.youtube.com/
170
 
171
  Please folllow [Installation](https://wordpress.org/plugins/youtube-channel/installation/) instructions.
172
 
173
- = I set everything correct but receiveing 'Ups, something went wrong' message =
174
 
175
- Right click that message on your website and look for HTML comment below it, message will look like this:
176
 
177
  `<!-- YTC ERROR:
178
- domain: youtube.search
179
- reason: invalidChannelId
180
- message: Invalid channel.
 
181
  -->`
182
 
183
- This means that you have set wrong **Channel ID**. Fix that in **General** plugin settings, Widget and/or shortcode.
184
 
185
  `<!-- YTC ERROR:
186
  domain: usageLimits
@@ -188,7 +196,7 @@ reason: keyInvalid
188
  message: Bad Request
189
  -->`
190
 
191
- If you followed [Installation](https://wordpress.org/plugins/youtube-channel/installation/) instructions, double check **YOUTUBE_DATA_API_KEY** in **wp-config.php** file. Do you have correct key generated by you and allowed to be used on your server/website?
192
 
193
  `<!-- YTC ERROR:
194
  domain: usageLimits
@@ -196,12 +204,24 @@ 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 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? =
207
 
@@ -211,11 +231,17 @@ You'll find your **Vanity Name** as "Your custom URL" in **Channel settins** sec
211
 
212
  **Channel ID** is **YouTube Channel ID** value composed of mixed characters starting with **UC**.
213
 
 
 
 
 
 
 
 
214
  = What is Vanity custom URL? =
215
 
216
  Check out [Channel custom URL](https://support.google.com/youtube/answer/2657968?ref_topic=3024172&hl=en-GB) article.
217
 
218
-
219
  = Where to find Playlist ID? =
220
 
221
  Playlist ID can be manualy extracted from YouTube playlist URL. Part of strings after `&list=` that begins with uppercase letters **PL** represent Playlist ID (not full URL).
@@ -257,7 +283,24 @@ and custom CSS code added to theme style.css or similar customization:
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
@@ -265,6 +308,7 @@ So, we display thumbnails for 7 random videos from default (global) playlist, an
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
269
  * Change: Where to ask for support links in widget
270
  * Change: Timeout for getting feed increased from 2 to 5 seconds
@@ -272,20 +316,24 @@ So, we display thumbnails for 7 random videos from default (global) playlist, an
272
  * Remove: Check for Redux Framework in debug JSON generator
273
 
274
  = 3.0.3 (2015-05-10) =
275
- * Fix: "Ups, something went wrong." when Playlist selected as resource because wrong switch
 
276
  * Fix: Jumping thumbnails in responsive wall on hover in Twenty Fifteen theme because border-bottom for anchors
277
  * Fix: Another deprecated shortcode attribute backward compatibility (`use_res`)
278
  * Add: Example of dynamic responsive wall (1 large + 6 small thumbnails) (to [Description](https://wordpress.org/plugins/youtube-channel/))
279
 
280
  = 3.0.2 (2015-05-10) =
 
281
  * Fix: (typo - experiencing on frontend when no API Key set) PHP Fatal error: Call to undefined function __sprintf() in youtube-channel.php on line 445
282
  * Fix: shortcode deprecated params `res` and `show` not backward compatibile
283
 
284
  = 3.0.1 (2015-05-10) =
 
285
  * Fix: Fatal error: Using $this when not in object context in youtube-channel.php on line 89
286
  * Fix: Link to channel not visible on Twenty Fifteen theme
287
 
288
  = 3.0.0 (2015-05-07/08/09/10) =
 
289
  * Fix: Migraton of global and widget settings to v3.0.0
290
  * Add: New Global Settings page as replacement of Redux Framework solution
291
  * Add: Non-Dismissable Dashboard notice if YouTube Data API Key missing with link to explanation page
@@ -300,6 +348,7 @@ So, we display thumbnails for 7 random videos from default (global) playlist, an
300
  * Remove: option `Fix height taken by controls` as now YouTube displays control bar only when video is hovered
301
 
302
  = 3.0.0alpha2 (2015-03-07/22/24) =
 
303
  * Add: Rewrite plugin to work with YouTube Data API v3
304
  * Add: Vanity link as option to Link to channel (now supports Legacy username, Channel and Vanity URL) with cleanup Vanity ID routine
305
  * Add: Liked videos as resource (now support channel, playlists, favourites and liked videos)
@@ -312,7 +361,8 @@ So, we display thumbnails for 7 random videos from default (global) playlist, an
312
  * Remove: Aspect Ration 16:10 (so support only 16:9 and 4:3, same as modern YouTube)
313
  * Remove: "Fix No Item" option - not required for YouTube API 3.0
314
 
315
- *OLD RELEASES*
 
316
  = 2.4.2.1 (2015-04-24) =
317
  * Fix: devicesupport workaround strip 1st video from playlist and favourites and apply only for channel
318
 
@@ -532,7 +582,7 @@ Responsive, bug fixes, support for WordPress 4.1
532
 
533
  == Screenshots ==
534
 
535
- 1. YouTube Channel plugin default settings
536
  2. YouTube Channel customized widget settings
537
- 3. YouTube Channel in WP Customizer
538
- 4. YouTube Channel preview
1
  === YouTube Channel ===
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, feed, video, thumbnail, embed, sidebar, iframe, html5, responsive
5
  Requires at least: 3.9.0
6
  Tested up to: 4.2.2
7
+ Stable tag: 3.0.6
8
  License: GPLv3
9
  License URI: http://www.gnu.org/licenses/gpl-3.0.html
10
 
37
  For fully functional plugin you need to have PHP 5.3 or newer! If you experience issues on older PHP, we can't help you as we don't have access to such old development platform.
38
 
39
  = Styling =
40
+
41
  You can use `style.css` from theme to style `YouTube Video` widget content.
42
 
43
+ * `.widget_youtube-channel` class of whole widget (parent for widget title and YTC block)
44
+ * `.youtube_channel` YTC block wrapper class. Additional classes are available:
45
+ * `.default` for non-responsive block
46
+ * `.responsive` when you have enabled responsive option
47
+ * `.ytc_title` class of H3 tag for video title above thumbnail/video object
48
+ * `.ytc_video_container` class of container for single item, plus:
49
+ * `.ytc_video_1`, `.ytc_video_2`, … – class of container for single item with ordering number of item in widget
50
+ * `.ytc_video_first` class of first container for single item
51
+ * `.ytc_video_mid` class of all other containers for single item
52
+ * `.ytc_video_last` – class of last container for single item
53
+ * `.ar16_9` – class for Aspect Ratio 16:9
54
+ * `.ar4_3` – class for Aspect Ration 4:3
55
+ * `.ytc_thumb` – class of anchor for Thumbnail mode
56
+ * `.fluid-width-video-wrapper` – class for parent element of IFRAME for enabled responsive
57
+ * `.ytc_description` – class for video description text below thumbnail/video object
58
+ * `.ytc_link` – class of container for link to channel
59
 
60
  = Known Issues =
61
 
117
 
118
  **Content Layout**
119
 
120
+ * `showtitle` (bool) Set to 1 or true to show video title.
121
+ * `titlebelow` (bool) Set to 1 or true to move video title below video.
122
+ * `showdesc` (bool) Set to 1 or true to show video description.
123
+ * `desclen` (int) Set number of characters to cut down length of video description. Set to 0 to use full length description.
124
+ * `noinfo` (bool) Set to 1 or true to hide overlay video infos (from embedded player)
125
+ * `noanno` (bool) Set to 1 or true to hide overlay video annotations (from embedded player)
126
 
127
  **Link to Channel**
128
 
129
+ * `goto` (bool) Set to 1 or true to display link to channel at the bottom of YTC block.
130
  * `goto_txt` (string)
131
+ * `popup` (int) Control where link to channel will be opened:
132
+ * `0` open link in same window
133
+ * `1` open link in new window with JavaScript
134
+ * `2` open link in new window with target="_blank" anchor attribute
135
+ * `link_to` (int) URL to link:
136
+ * `2` Vanity custom URL (default)
137
+ * `1` Channel page
138
+ * `0` Legacy username page
139
 
140
  == Installation ==
141
 
142
  You can use the built in installer and upgrader, or you can install the plugin manually.
143
 
144
  1. You can either use the automatic plugin installer or your FTP program to upload unziped `youtube-channel` directory to your `wp-content/plugins` directory.
145
+ 1. Activate the plugin through the `Plugins` menu in WordPress
146
+ 1. Add YouTube Channel widget to sidebar
147
+ 1. Set Channel ID and save changes
148
 
149
  If you have to upgrade manually simply repeat the installation steps and re-enable the plugin.
150
 
151
  = YouTube Data API Key =
152
+ Main difference since v2.x branch is that now we use [YouTube Data API v3](https://developers.google.com/youtube/v3/) so to make plugin to work, you'll need to generate YouTube Data API Key and insert it to General plugin settings.
153
 
154
  Learn more about [Obtaining authorization credentials](https://developers.google.com/youtube/registering_an_application) and for detailed instructions how to generate your own API Key watch video below.
155
 
161
  1. Locate and click **YouTube Data API** under **YouTube API** section
162
  1. Click **Enable API** button
163
  1. When you get enabled YouTube Data API in your project, click **Credentials** item from LHS menu **APIs & auth**
164
+ 1. Click **Create New Key** button and select **Server Key**
165
+ 1. Leave empty or enter IP of your website. If you get message **Oops, something went wrong.** make sure you set proper IP, or leave any restriction.
166
  1. Click **Create** button
167
  1. Copy newly created **API Key**
168
 
169
+ When you generate your own YouTube Data API Key, from your **Dashboard** go to **Settings** -> **YouTube Channel** -> **General** and paster key in to field **YouTube Data API Key**.
 
 
 
 
 
170
 
171
+ Also, do not forget to check and update **Channel ID** in plugin's General settings, Widgets and/or shortcodes.
172
+ You can get **Channel ID** from page [Account Advanced](https://www.youtube.com/account_advanced) while you're loagged in to your YouTube account.
 
 
 
173
 
174
  == Frequently Asked Questions ==
175
 
177
 
178
  Please folllow [Installation](https://wordpress.org/plugins/youtube-channel/installation/) instructions.
179
 
180
+ = I set everything correct but receiveing 'Oops, something went wrong' message =
181
 
182
+ Right click that message on your website, click *Inspect Element*, expand tag with class *youtube_channel* and look for HTML comment below it, message will look like this:
183
 
184
  `<!-- YTC ERROR:
185
+ domain: youtube.playlistItem
186
+ reason: playlistNotFound
187
+ message: Not Found
188
+ tip: Please check did you set proper Channel ID. We should display videos from channel videos, but YouTube does not recognize your channel ID UCkVThLIHAZVsJc7f28tIsIws as existing and public resource.
189
  -->`
190
 
191
+ Do exactly what tip says - check and correct Channel ID in default settings/widget/shortcode.
192
 
193
  `<!-- YTC ERROR:
194
  domain: usageLimits
196
  message: Bad Request
197
  -->`
198
 
199
+ If you followed [Installation](https://wordpress.org/plugins/youtube-channel/installation/) instructions, double check **YouTube Data API Key** entered to Global settings. Do you have correct key generated by you and allowed to be used on your server?
200
 
201
  `<!-- YTC ERROR:
202
  domain: usageLimits
204
  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.
205
  -->`
206
 
207
+ We still strugling with that Google's restrictions. If you get final solution, please inform us asap. Try with following possible solutions:
208
+
209
+ 1. If you are using **Jetpack** plugin with enabled **Protect** sub plugin, try to disable it. (kudos to [yudhita](https://wordpress.org/support/profile/yudhita) for tip)
210
  1. Try to remove restrictions by referer or IP in your **YouTube Data API Key** and refresh page after couple minutes.
211
+ 1. If that does not help, please try to create new API Key for Server w/o restrictions (not to regenerate existing one).
212
+
213
+ If there is no `YTC ERROR` code in HTML source, visit [Google API Explorer](https://developers.google.com/apis-explorer/#p/youtube/v3/youtube.playlistItems.list?part=snippet&maxResults=5&playlistId=) and append:
214
 
215
+ * for videos from channel replace **UC** with **UU** in Channel ID (so *UCRPqmcpGcJ_gFtTmN_a4aVA* becomes *UURPqmcpGcJ_gFtTmN_a4aVA*)
216
+ * for videos from Favourited videos replace **UC** with **FL** (so *UCRPqmcpGcJ_gFtTmN_a4aVA* becomes *FLRPqmcpGcJ_gFtTmN_a4aVA*)
217
+ * for videos from Liked Videos replace **UC** with **LL** (so *UCRPqmcpGcJ_gFtTmN_a4aVA* becomes *LLRPqmcpGcJ_gFtTmN_a4aVA*)
218
+ * for videos from Playlist simply use Playlist ID (like *PLEC850BE962234400*)
219
+
220
+ Note that all four resources are *playlists* (including channel), so append mentioned ID to field **playlistId** (not to **id**), and click **Execute** button at the bottom of that page.
221
+
222
+ 1. If you receive some error, fix settings.
223
+ 1. If there is no error but you do not get any video in results - contact Google Support
224
+ 1. If there are video results but not displayed with YouTube Channel plugin - [contact us](https://wordpress.org/support/plugin/youtube-channel)
225
 
226
  = Where to find correct Channel ID and/or Vanity custom Name? =
227
 
231
 
232
  **Channel ID** is **YouTube Channel ID** value composed of mixed characters starting with **UC**.
233
 
234
+ = Where to find ID for Favourites and/or Liked Videos? =
235
+
236
+ You will not need that two ID's, in general. But, if you really wish to know, these two ID's are produced from your **Channel ID**. Channel ID start with **UC** (like `UCRPqmcpGcJ_gFtTmN_a4aVA`)
237
+
238
+ * For Favourites ID replace **UC** with **FL** (so you get `FLRPqmcpGcJ_gFtTmN_a4aVA`)
239
+ * For Liked Videos ID replace **UC** with **LL** (so you get `LLRPqmcpGcJ_gFtTmN_a4aVA`)
240
+
241
  = What is Vanity custom URL? =
242
 
243
  Check out [Channel custom URL](https://support.google.com/youtube/answer/2657968?ref_topic=3024172&hl=en-GB) article.
244
 
 
245
  = Where to find Playlist ID? =
246
 
247
  Playlist ID can be manualy extracted from YouTube playlist URL. Part of strings after `&list=` that begins with uppercase letters **PL** represent Playlist ID (not full URL).
283
  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.
284
 
285
  == Changelog ==
286
+
287
+ = 3.0.6 (2015-05-13/14) =
288
+
289
+ * Fix: Prevent Fatal error on PHP<5.3 because required __DIR__ for updater replaced with dirname(__FILE__)
290
+ * Fix: No retrieved or missing videos from some channels so switch `search` to `playlistItems` API call (kudos to @[mmirus](https://wordpress.org/support/profile/mmirus))
291
+ * Add: Embed As Playlist for all resources
292
+ * Add: Clearfix for crappy themes where clearfix does not exists
293
+ * Add: Option to move video title below video (boolean shortcode parameter `titlebelow`)
294
+ * Add: PayPal donate button to settings page
295
+ * Improved: Move YouTube Data API Key to plugin settings and add notification to remove YOUTUBE_DATA_API_KEY from wp-config.php (optional)
296
+ * Improved: Updated shortcode explanation in README and Help tab in plugin settings.
297
+ * Improved: Better tips for 'Oops, something went wrong' message.
298
+ * Change: Wording `Ups` to `Oops`
299
+ * Remove: Options `Embed standard playlist` and `Show random video` from global settings as this should be off by default
300
+ * Remove: Loading of fitVids JS library for test before final removing.
301
+
302
  = 3.0.5 (2015-05-11/12) =
303
+
304
  * 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)
305
  * Add: Option to export global settings to JSON and add to Tools tab in settings button to download global settings JSON
306
  * Change: Update plugin features
308
  * Improved: More micro optimizations
309
 
310
  = 3.0.4 (2015-05-11) =
311
+
312
  * Add: Tip what to do if error ocurred with YouTube Data API Key printed inside YTC ERROR comment
313
  * Change: Where to ask for support links in widget
314
  * Change: Timeout for getting feed increased from 2 to 5 seconds
316
  * Remove: Check for Redux Framework in debug JSON generator
317
 
318
  = 3.0.3 (2015-05-10) =
319
+
320
+ * Fix: "Oops, something went wrong." when Playlist selected as resource because wrong switch
321
  * Fix: Jumping thumbnails in responsive wall on hover in Twenty Fifteen theme because border-bottom for anchors
322
  * Fix: Another deprecated shortcode attribute backward compatibility (`use_res`)
323
  * Add: Example of dynamic responsive wall (1 large + 6 small thumbnails) (to [Description](https://wordpress.org/plugins/youtube-channel/))
324
 
325
  = 3.0.2 (2015-05-10) =
326
+
327
  * Fix: (typo - experiencing on frontend when no API Key set) PHP Fatal error: Call to undefined function __sprintf() in youtube-channel.php on line 445
328
  * Fix: shortcode deprecated params `res` and `show` not backward compatibile
329
 
330
  = 3.0.1 (2015-05-10) =
331
+
332
  * Fix: Fatal error: Using $this when not in object context in youtube-channel.php on line 89
333
  * Fix: Link to channel not visible on Twenty Fifteen theme
334
 
335
  = 3.0.0 (2015-05-07/08/09/10) =
336
+
337
  * Fix: Migraton of global and widget settings to v3.0.0
338
  * Add: New Global Settings page as replacement of Redux Framework solution
339
  * Add: Non-Dismissable Dashboard notice if YouTube Data API Key missing with link to explanation page
348
  * Remove: option `Fix height taken by controls` as now YouTube displays control bar only when video is hovered
349
 
350
  = 3.0.0alpha2 (2015-03-07/22/24) =
351
+
352
  * Add: Rewrite plugin to work with YouTube Data API v3
353
  * Add: Vanity link as option to Link to channel (now supports Legacy username, Channel and Vanity URL) with cleanup Vanity ID routine
354
  * Add: Liked videos as resource (now support channel, playlists, favourites and liked videos)
361
  * Remove: Aspect Ration 16:10 (so support only 16:9 and 4:3, same as modern YouTube)
362
  * Remove: "Fix No Item" option - not required for YouTube API 3.0
363
 
364
+ **OLD RELEASES**
365
+
366
  = 2.4.2.1 (2015-04-24) =
367
  * Fix: devicesupport workaround strip 1st video from playlist and favourites and apply only for channel
368
 
582
 
583
  == Screenshots ==
584
 
585
+ 1. YouTube Channel default plugin settings (General tab)
586
  2. YouTube Channel customized widget settings
587
+ 3. YouTube Channel in WP Customizer and Dynamic Wall layout
588
+ 4. How to add YouTube Data API Key to YouTube Channel
update.php CHANGED
@@ -217,4 +217,33 @@ function au_youtube_channel_update_routine_3() {
217
  update_option('widget_youtube-channel', $ytc_widgets);
218
  unset ($options_matrix, $init, $ytc_widgets, $widget_id, $widget_data);
219
 
220
- } // END function au_youtube_channel_update_routine_3()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
217
  update_option('widget_youtube-channel', $ytc_widgets);
218
  unset ($options_matrix, $init, $ytc_widgets, $widget_id, $widget_data);
219
 
220
+ } // END function au_youtube_channel_update_routine_3()
221
+
222
+ /**
223
+ * Store API Key to DB
224
+ */
225
+ function au_youtube_channel_update_routine_5() {
226
+
227
+ // get options from DB
228
+ $defaults = get_option('youtube_channel_defaults');
229
+ unset($defaults['only_pl']);
230
+
231
+ if ( defined('YOUTUBE_DATA_API_KEY') ) {
232
+
233
+
234
+ if ( empty($defaults['apikey']) ) {
235
+ $defaults['apikey'] = YOUTUBE_DATA_API_KEY;
236
+ }
237
+ unset($defaults);
238
+
239
+ }
240
+
241
+ update_option('youtube_channel_defaults', $defaults);
242
+
243
+ // remove unused keys from DB
244
+ delete_option('youtube_channel_ver');
245
+
246
+ // Update plugin version number
247
+ update_option('youtube_channel_version', WPAU_YOUTUBE_CHANNEL::VER);
248
+
249
+ } //END function au_youtube_channel_update_routine_5()
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.5
8
  Author URI: http://urosevic.net/
9
  */
10
  // @TODO make FitVideo optional
@@ -17,17 +17,16 @@ if ( !class_exists('WPAU_YOUTUBE_CHANNEL') )
17
  class WPAU_YOUTUBE_CHANNEL
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";
25
-
26
  public $plugin_option = "youtube_channel_defaults";
27
 
28
  public $vanity_id = "AleksandarUrosevic";
29
  public $username_id = "urkekg";
30
- public $channel_id = "UCRPqmcpGcJ_gFtTmN_a4aVA"; // user channel UC; favourites list FL; liked list LL
31
  public $playlist_id = "PLEC850BE962234400";
32
  public $plugin_url;
33
 
@@ -94,8 +93,6 @@ if ( !class_exists('WPAU_YOUTUBE_CHANNEL') )
94
  * @return array Global defaults for current plugin version
95
  */
96
  public function init_options() {
97
- update_option('youtube_channel_version', self::VER);
98
- add_option('youtube_channel_db_ver', self::DB_VER);
99
 
100
  $init = array(
101
  'vanity' => $this->vanity_id,
@@ -103,12 +100,12 @@ if ( !class_exists('WPAU_YOUTUBE_CHANNEL') )
103
  'username' => $this->username_id,
104
  'playlist' => $this->playlist_id,
105
  'resource' => 0, // ex use_res
106
- 'only_pl' => 0,
107
  'cache' => 300, // 5 minutes // ex cache_time
108
  'fetch' => 25, // ex maxrnd
109
  'num' => 1, // ex vidqty
110
  'privacy' => 0,
111
- 'random' => 0, // ex getrnd
112
 
113
  'ratio' => 3, // 3 - 16:9, 1 - 4:3 (deprecated: 2 - 16:10)
114
  'width' => 306,
@@ -134,7 +131,7 @@ if ( !class_exists('WPAU_YOUTUBE_CHANNEL') )
134
  'link_to' => 0 // 0 legacy username, 1 channel, 2 vanity
135
  );
136
 
137
- add_option('youtube_channel_ver', self::VER, '', 'no');
138
  add_option('youtube_channel_db_ver', self::DB_VER, '', 'no');
139
  add_option($this->plugin_option, $init, '', 'no');
140
 
@@ -150,7 +147,7 @@ if ( !class_exists('WPAU_YOUTUBE_CHANNEL') )
150
  return;
151
  }
152
 
153
- require_once( __DIR__ . '/update.php' );
154
  au_youtube_channel_update();
155
 
156
  } // END public function maybe_update()
@@ -227,6 +224,10 @@ if ( !class_exists('WPAU_YOUTUBE_CHANNEL') )
227
  $dismissed_notices['old_php'] = 1;
228
  update_option('youtube_channel_dismissed_notices', $dismissed_notices);
229
  }
 
 
 
 
230
  if ( ! empty($_GET['ytc_dismiss_notice_vanity_option']) ) {
231
  $dismissed_notices['vanity_option'] = 1;
232
  update_option('youtube_channel_dismissed_notices', $dismissed_notices);
@@ -240,7 +241,7 @@ if ( !class_exists('WPAU_YOUTUBE_CHANNEL') )
240
  'info' => ''
241
  );
242
 
243
- // Warn if PHP version is lower than 5.3
244
  if ( version_compare(PHP_VERSION, "5.3", "<") && ( empty($dismissed_notices) || ( ! empty($dismissed_notices) && empty($dismissed_notices['old_php']) ) ) ) {
245
  $notice['info'] .= sprintf(
246
  __('<p>Your website running on web server with PHP version %s. Please note that <strong>%s</strong> requires PHP at least 5.3 or newer to work properly. <a href="%s" class="dismiss">Dismiss</a></p>', 'youtube-channel'),
@@ -250,13 +251,23 @@ if ( !class_exists('WPAU_YOUTUBE_CHANNEL') )
250
  );
251
  }
252
 
 
 
 
 
 
 
 
 
 
 
253
  // No YouTube DATA Api Key?
254
- if ( ! defined('YOUTUBE_DATA_API_KEY') ) {
255
  $notice['error'] .= sprintf(
256
- __('<p>Please note, to make <strong>%s</strong> plugin v3+ work, generate <strong>YouTube Data API Key</strong> and add it to <strong>wp-config.php</strong> file as we explained <a href="%s" target="_blank">here</a>.<br>If you already did this during <em>3.0.0-Alpha</em> test period, please rename constant name from <strong>GOOGLE_API_KEY</strong> to <strong>%s</strong>.<br><br>If you have any issue with new version of plugin, please ask for help on official <a href="%s" target="_blank">support forum</a>.<br>This notice will disappear when you add missing key as mentioned above!</p>', 'youtube-channel'),
257
  $this->plugin_name,
258
  'http://urosevic.net/wordpress/plugins/youtube-channel/#youtube_data_api_key',
259
- 'YOUTUBE_DATA_API_KEY',
260
  'https://wordpress.org/support/plugin/youtube-channel'
261
  );
262
  }
@@ -298,7 +309,7 @@ if ( !class_exists('WPAU_YOUTUBE_CHANNEL') )
298
  wp_enqueue_style( 'youtube-channel', plugins_url('assets/css/youtube-channel.min.css', __FILE__), array(), self::VER );
299
 
300
  // enqueue fitVids
301
- wp_enqueue_script( 'fitvids', plugins_url('assets/js/jquery.fitvids.min.js', __FILE__), array('jquery'), self::VER, true );
302
 
303
  // enqueue magnific-popup
304
  wp_enqueue_script( 'magnific-popup-au', plugins_url('assets/lib/magnific-popup/jquery.magnific-popup.min.js', __FILE__), array('jquery'), self::VER, true );
@@ -345,7 +356,7 @@ function ytc_mute(event){
345
  'res' => '', // (deprecated, but leave for back compatibility) ex res
346
  'use_res' => '', // (deprecated, but leave for back compatibility) ex use_res
347
  'resource' => $instance['resource'], // ex use_res
348
- 'only_pl' => $instance['only_pl'],
349
  'cache' => $instance['cache'], // ex cache_time
350
  'privacy' => $instance['privacy'], // ex showvidesc
351
  'fetch' => $instance['fetch'], // ex maxrnd
@@ -367,6 +378,7 @@ function ytc_mute(event){
367
  'norel' => $instance['norel'],
368
 
369
  'showtitle' => $instance['showtitle'],
 
370
  'showdesc' => $instance['showdesc'], // ex showvidesc
371
  'nobrand' => ( ! empty($instance['modestbranding']) ) ? $instance['modestbranding'] : '0',
372
  'desclen' => $instance['desclen'], // ex videsclen
@@ -425,6 +437,7 @@ function ytc_mute(event){
425
 
426
  // Content Layout
427
  $instance['showtitle'] = $showtitle; // show video title, disabled by default
 
428
  $instance['showdesc'] = $showdesc; // show video description, disabled by default
429
  $instance['modestbranding'] = $nobrand; // hide YT logo
430
  $instance['desclen'] = $desclen; // cut video description, number of characters
@@ -448,7 +461,7 @@ function ytc_mute(event){
448
 
449
  // print info about API key to admins
450
  // and "Coming soon..." for visitors
451
- if ( ! defined('YOUTUBE_DATA_API_KEY') ) {
452
  if ( current_user_can('manage_options') ) {
453
  $output[] = sprintf(
454
  __('<strong>%s</strong> version 3+ requires <strong>YouTube DATA API Key</strong> to work. <a href="%s" target="_blank">Learn more here</a>.', 'youtube-channel'),
@@ -514,14 +527,32 @@ function ytc_mute(event){
514
  $class .= ' responsive';
515
  }
516
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
517
  // Start output array
518
  $output = array();
519
 
520
  $output[] = "<div class=\"youtube_channel {$class}\">";
521
 
522
- if ( $instance['only_pl'] && $resource == 2 ) { // print standard playlist
523
 
524
- $output = array_merge($output, self::ytc_only_pl($instance));
525
 
526
  } else { // videos from channel, favourites, liked or playlist
527
 
@@ -530,23 +561,6 @@ function ytc_mute(event){
530
  if ( $fetch < 1 ) { $fetch = 10; } // default 10
531
  elseif ( $fetch > 50 ) { $fetch = 50; } // max 50
532
 
533
- switch ($resource) {
534
- case 1: // Favourites
535
- $resource_name = 'favourites';
536
- $resource_id = preg_replace('/^UC/', 'FL', $channel);
537
- break;
538
- case 2: // Playlist
539
- $resource_name = 'playlist';
540
- $resource_id = $playlist;
541
- break;
542
- case 3: // Liked
543
- $resource_name = 'liked';
544
- $resource_id = preg_replace('/^UC/', 'LL', $channel);
545
- break;
546
- default: // Channel
547
- $resource_name = 'channel';
548
- $resource_id = $channel;
549
- }
550
  $resource_key = "{$resource_id}_{$fetch}";
551
 
552
  // Do we need cache? let we define cache fallback key
@@ -565,7 +579,7 @@ function ytc_mute(event){
565
  if ( false === ($json = get_transient($cache_key)) || empty($json) ) {
566
 
567
  // no cached JSON, get new
568
- $json = $this->fetch_youtube_feed($resource_name, $resource_id, $fetch);
569
 
570
  // set decoded JSON to transient cache_key
571
  set_transient($cache_key, base64_encode($json), $instance['cache']);
@@ -580,7 +594,7 @@ function ytc_mute(event){
580
  } else {
581
 
582
  // just get fresh feed if cache disabled
583
- $json = $this->fetch_youtube_feed($resource_name, $resource_id, $fetch);
584
 
585
  }
586
 
@@ -592,7 +606,7 @@ function ytc_mute(event){
592
 
593
  // if current feed is messed up, try to get it from fallback cache
594
  if ( is_wp_error($json_output) && ! is_object($json_output) && empty($json_output->items) ) {
595
- error_log("[YTC] Get fallback feed for $feed_url");
596
  // do we have fallback cache?!
597
  if ( true === ( $json_fallback = get_transient( $cache_key_fallback ) ) && ! empty($json_fallback) ) {
598
  $json_output = json_decode( base64_decode($json_fallback) );
@@ -627,21 +641,29 @@ function ytc_mute(event){
627
  $output[] = $error_string;
628
  unset($error_string);
629
  } else {
630
- $output[] = __("Ups, something went wrong.", 'youtube-channel');
631
  // append YouTube DATA API error reason as comment
632
  if ( ! empty($json_output) && is_object($json_output) && !empty($json_output->error->errors) ) {
633
  $output[] = "<!-- YTC ERROR:\n";
634
  $output[] = 'domain: ' . $json_output->error->errors[0]->domain . "\n";
635
  $output[] = 'reason: ' . $json_output->error->errors[0]->reason . "\n";
636
  $output[] = 'message: ' . $json_output->error->errors[0]->message . "\n";
637
- if ( $json_output->error->errors[0]->reason == 'invalidChannelId' ) {
638
- $output[] = "tip: You have set wrong Channel ID. Fix that in General plugin settings, Widget and/or shortcode. Check https://wordpress.org/plugins/youtube-channel/faq/\n";
 
 
 
 
 
639
  }
640
- if ( $json_output->error->errors[0]->reason == 'keyInvalid' ) {
641
- $output[] = "tip: Double check YOUTUBE_DATA_API_KEY and make sure it`s correct. Check https://wordpress.org/plugins/youtube-channel/installation/\n";
642
  }
643
- if ( $json_output->error->errors[0]->reason == 'ipRefererBlocked' ) {
644
- $output[] = "tip: Check YouTube Data API Key restrictions and key in wp-config.php, empty cache if enabled and append in browser address bar parameter ?ytc_force_recache=1\n";
 
 
 
645
  }
646
  $output[] = "-->\n";
647
  }
@@ -688,10 +710,15 @@ function ytc_mute(event){
688
 
689
  } // single playlist or ytc way
690
 
691
- $output = array_merge( $output, $this->ytc_channel_link($instance) ); // insert link to channel on bootom of widget
 
 
692
 
693
  $output[] = '</div><!-- .youtube_channel -->';
694
 
 
 
 
695
  return $output;
696
 
697
  } // END public function output($instance)
@@ -700,36 +727,18 @@ function ytc_mute(event){
700
 
701
  /**
702
  * Download YouTube video feed through API 3.0
703
- * @param string $resource Name of resource (channel, playlist, favourites, liked)
704
  * @param string $id ID of resource
705
  * @param integer $items Number of items to fetch (min 2, max 50)
706
  * @return array JSON with videos
707
  */
708
- function fetch_youtube_feed($resource, $resource_id, $items) {
709
-
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(
735
  'timeout' => 5 // five seconds only
@@ -742,7 +751,7 @@ function ytc_mute(event){
742
 
743
  return $json;
744
 
745
- } // END function fetch_youtube_feed($resource, $resource_id, $items)
746
 
747
  // function to calculate height by width and ratio
748
  function height_ratio($width=306, $ratio) {
@@ -860,8 +869,8 @@ function ytc_mute(event){
860
  $themelight = $instance['themelight'];
861
  /* end of video settings */
862
 
863
- // from channel videoId is in own node `id`
864
- $yt_id = ($instance['resource'] == 0) ? $item->id->videoId : $item->snippet->resourceId->videoId;
865
  $yt_url = "v/$yt_id";
866
  $yt_thumb = "//img.youtube.com/vi/$yt_id/0.jpg"; // zero for HD thumb
867
  $yt_video = "//www.youtube.com/watch?v=" . $yt_id;
@@ -891,8 +900,8 @@ function ytc_mute(event){
891
  }
892
  $output[] = "<div class=\"ytc_video_container ytc_video_{$y} ytc_video_{$vnumclass} ${arclass}\" style=\"width:{$width}px\">";
893
 
894
- // show video title?
895
- if ( ! empty($instance['showtitle']) ) {
896
  $output[] = "<h3 class=\"ytc_title\">{$yt_title}</h3>";
897
  }
898
 
@@ -1009,6 +1018,11 @@ JS;
1009
 
1010
  } // what to show conditions
1011
 
 
 
 
 
 
1012
  // do we need to show video description?
1013
  if ( $instance['showdesc'] ) {
1014
 
@@ -1037,33 +1051,25 @@ JS;
1037
  } // end function ytc_print_video
1038
 
1039
  /* function to print standard playlist embed code */
1040
- function ytc_only_pl($instance) {
1041
-
1042
- $width = $instance['width'];
1043
- if ( empty($width) )
1044
- $width = 306;
1045
-
1046
- $playlist = (empty($instance['playlist'])) ? $this->playlist_id : $instance['playlist'];
1047
-
1048
- $height = self::height_ratio($width, $instance['ratio']);
1049
 
1050
- $playlist = $this->clean_playlist_id($playlist);
 
 
 
 
 
1051
 
1052
- $autoplay = (empty($instance['autoplay'])) ? '' : '&autoplay=1';
1053
-
1054
- $theme = (empty($instance['themelight'])) ? '' : '&theme=light';
1055
-
1056
- $modestbranding = (empty($instance['modestbranding'])) ? '' : '&modestbranding=1';
1057
 
1058
- $rel = (empty($instance['norel'])) ? '' : '&rel=0';
 
 
1059
 
1060
- // enhanced privacy
1061
- $youtube_domain = $this->youtube_domain($instance);
1062
- $output[] = '<div class="ytc_video_container ytc_video_1 ytc_video_single">
1063
- <iframe src="//'.$youtube_domain.'/embed/videoseries?list=PL'.$playlist.$autoplay.$theme.$modestbranding.$rel.'"
1064
- width="'.$width.'" height="'.$height.'" frameborder="0"></iframe></div>';
1065
  return $output;
1066
- } // end function ytc_only_pl
 
1067
 
1068
  // Helper function cache_time()
1069
  function cache_time($cache_time)
@@ -1157,6 +1163,9 @@ JS;
1157
  if ( ! is_array($options) )
1158
  return;
1159
 
 
 
 
1160
  } else {
1161
  // for widget
1162
  // prepare option name and widget ID
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.6
8
  Author URI: http://urosevic.net/
9
  */
10
  // @TODO make FitVideo optional
17
  class WPAU_YOUTUBE_CHANNEL
18
  {
19
 
20
+ const DB_VER = 5;
21
+ const VER = '3.0.6';
22
 
23
  public $plugin_name = "YouTube Channel";
24
  public $plugin_slug = "youtube-channel";
 
25
  public $plugin_option = "youtube_channel_defaults";
26
 
27
  public $vanity_id = "AleksandarUrosevic";
28
  public $username_id = "urkekg";
29
+ public $channel_id = "UCRPqmcpGcJ_gFtTmN_a4aVA"; // user channel UC; user uploads UU; favourites list FL; liked list LL
30
  public $playlist_id = "PLEC850BE962234400";
31
  public $plugin_url;
32
 
93
  * @return array Global defaults for current plugin version
94
  */
95
  public function init_options() {
 
 
96
 
97
  $init = array(
98
  'vanity' => $this->vanity_id,
100
  'username' => $this->username_id,
101
  'playlist' => $this->playlist_id,
102
  'resource' => 0, // ex use_res
103
+ // 'only_pl' => 0,
104
  'cache' => 300, // 5 minutes // ex cache_time
105
  'fetch' => 25, // ex maxrnd
106
  'num' => 1, // ex vidqty
107
  'privacy' => 0,
108
+ // 'random' => 0, // ex getrnd
109
 
110
  'ratio' => 3, // 3 - 16:9, 1 - 4:3 (deprecated: 2 - 16:10)
111
  'width' => 306,
131
  'link_to' => 0 // 0 legacy username, 1 channel, 2 vanity
132
  );
133
 
134
+ add_option('youtube_channel_version', self::VER, '', 'no');
135
  add_option('youtube_channel_db_ver', self::DB_VER, '', 'no');
136
  add_option($this->plugin_option, $init, '', 'no');
137
 
147
  return;
148
  }
149
 
150
+ require_once( dirname(__FILE__) . '/update.php' );
151
  au_youtube_channel_update();
152
 
153
  } // END public function maybe_update()
224
  $dismissed_notices['old_php'] = 1;
225
  update_option('youtube_channel_dismissed_notices', $dismissed_notices);
226
  }
227
+ if ( ! empty($_GET['ytc_dismiss_notice_apikey_wpconfig']) ) {
228
+ $dismissed_notices['apikey_wpconfig'] = 1;
229
+ update_option('youtube_channel_dismissed_notices', $dismissed_notices);
230
+ }
231
  if ( ! empty($_GET['ytc_dismiss_notice_vanity_option']) ) {
232
  $dismissed_notices['vanity_option'] = 1;
233
  update_option('youtube_channel_dismissed_notices', $dismissed_notices);
241
  'info' => ''
242
  );
243
 
244
+ // Inform if PHP version is lower than 5.3
245
  if ( version_compare(PHP_VERSION, "5.3", "<") && ( empty($dismissed_notices) || ( ! empty($dismissed_notices) && empty($dismissed_notices['old_php']) ) ) ) {
246
  $notice['info'] .= sprintf(
247
  __('<p>Your website running on web server with PHP version %s. Please note that <strong>%s</strong> requires PHP at least 5.3 or newer to work properly. <a href="%s" class="dismiss">Dismiss</a></p>', 'youtube-channel'),
251
  );
252
  }
253
 
254
+ // Inform if YOUTUBE_DATA_API_KEY is still in wp-config.php
255
+ if ( defined('YOUTUBE_DATA_API_KEY') && empty($dismissed_notices['apikey_wpconfig']) ) {
256
+ $notice['info'] .= sprintf(
257
+ __('<p>Since <strong>%s</strong> v3.0.6 we store <strong>YouTube Data API Key</strong> in plugin settings. So, you can safely remove %s define line from your <strong>wp-config.php</strong> file. <a href="%s" class="dismiss">Dismiss</a></p>', 'youtube-channel'),
258
+ $this->plugin_name,
259
+ 'YOUTUBE_DATA_API_KEY',
260
+ '?ytc_dismiss_notice_apikey_wpconfig=1'
261
+ );
262
+ }
263
+
264
  // No YouTube DATA Api Key?
265
+ if ( empty($this->defaults['apikey']) ) {
266
  $notice['error'] .= sprintf(
267
+ __('<p>Please note, to make <strong>%s</strong> plugin v3+ work, generate <strong>YouTube Data API Key</strong> as explained <a href="%s" target="_blank">here</a> and add it at <a href="%s">General plugin settings tab</a>.<br><br>If you have any issue with new version of plugin, please ask for help on official <a href="%s" target="_blank">support forum</a>.<br>This notice will disappear when you add missing key as mentioned above!</p>', 'youtube-channel'),
268
  $this->plugin_name,
269
  'http://urosevic.net/wordpress/plugins/youtube-channel/#youtube_data_api_key',
270
+ 'options-general.php?page=youtube-channel&tab=general',
271
  'https://wordpress.org/support/plugin/youtube-channel'
272
  );
273
  }
309
  wp_enqueue_style( 'youtube-channel', plugins_url('assets/css/youtube-channel.min.css', __FILE__), array(), self::VER );
310
 
311
  // enqueue fitVids
312
+ // wp_enqueue_script( 'fitvids', plugins_url('assets/js/jquery.fitvids.min.js', __FILE__), array('jquery'), self::VER, true );
313
 
314
  // enqueue magnific-popup
315
  wp_enqueue_script( 'magnific-popup-au', plugins_url('assets/lib/magnific-popup/jquery.magnific-popup.min.js', __FILE__), array('jquery'), self::VER, true );
356
  'res' => '', // (deprecated, but leave for back compatibility) ex res
357
  'use_res' => '', // (deprecated, but leave for back compatibility) ex use_res
358
  'resource' => $instance['resource'], // ex use_res
359
+ 'only_pl' => 0, // disabled by default (was: $instance['only_pl'],)
360
  'cache' => $instance['cache'], // ex cache_time
361
  'privacy' => $instance['privacy'], // ex showvidesc
362
  'fetch' => $instance['fetch'], // ex maxrnd
378
  'norel' => $instance['norel'],
379
 
380
  'showtitle' => $instance['showtitle'],
381
+ 'titlebelow' => 0, // move title below video
382
  'showdesc' => $instance['showdesc'], // ex showvidesc
383
  'nobrand' => ( ! empty($instance['modestbranding']) ) ? $instance['modestbranding'] : '0',
384
  'desclen' => $instance['desclen'], // ex videsclen
437
 
438
  // Content Layout
439
  $instance['showtitle'] = $showtitle; // show video title, disabled by default
440
+ $instance['titlebelow'] = $titlebelow; // show video title, disabled by default
441
  $instance['showdesc'] = $showdesc; // show video description, disabled by default
442
  $instance['modestbranding'] = $nobrand; // hide YT logo
443
  $instance['desclen'] = $desclen; // cut video description, number of characters
461
 
462
  // print info about API key to admins
463
  // and "Coming soon..." for visitors
464
+ if ( empty($this->defaults['apikey']) ) {
465
  if ( current_user_can('manage_options') ) {
466
  $output[] = sprintf(
467
  __('<strong>%s</strong> version 3+ requires <strong>YouTube DATA API Key</strong> to work. <a href="%s" target="_blank">Learn more here</a>.', 'youtube-channel'),
527
  $class .= ' responsive';
528
  }
529
 
530
+ switch ($resource) {
531
+ case 1: // Favourites
532
+ $resource_name = 'favourites';
533
+ $resource_id = preg_replace('/^UC/', 'FL', $channel);
534
+ break;
535
+ case 2: // Playlist
536
+ $resource_name = 'playlist';
537
+ $resource_id = $playlist;
538
+ break;
539
+ case 3: // Liked
540
+ $resource_name = 'liked';
541
+ $resource_id = preg_replace('/^UC/', 'LL', $channel);
542
+ break;
543
+ default: // Channel
544
+ $resource_name = 'channel';
545
+ $resource_id = preg_replace('/^UC/', 'UU', $channel); //$channel;
546
+ }
547
+
548
  // Start output array
549
  $output = array();
550
 
551
  $output[] = "<div class=\"youtube_channel {$class}\">";
552
 
553
+ if ( $instance['only_pl'] ) { // print standard playlist
554
 
555
+ $output = array_merge($output, self::embed_playlist($resource_id, $instance));
556
 
557
  } else { // videos from channel, favourites, liked or playlist
558
 
561
  if ( $fetch < 1 ) { $fetch = 10; } // default 10
562
  elseif ( $fetch > 50 ) { $fetch = 50; } // max 50
563
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
564
  $resource_key = "{$resource_id}_{$fetch}";
565
 
566
  // Do we need cache? let we define cache fallback key
579
  if ( false === ($json = get_transient($cache_key)) || empty($json) ) {
580
 
581
  // no cached JSON, get new
582
+ $json = $this->fetch_youtube_feed($resource_id, $fetch);
583
 
584
  // set decoded JSON to transient cache_key
585
  set_transient($cache_key, base64_encode($json), $instance['cache']);
594
  } else {
595
 
596
  // just get fresh feed if cache disabled
597
+ $json = $this->fetch_youtube_feed($resource_id, $fetch);
598
 
599
  }
600
 
606
 
607
  // if current feed is messed up, try to get it from fallback cache
608
  if ( is_wp_error($json_output) && ! is_object($json_output) && empty($json_output->items) ) {
609
+ // error_log("[YTC] Get fallback feed for $feed_url");
610
  // do we have fallback cache?!
611
  if ( true === ( $json_fallback = get_transient( $cache_key_fallback ) ) && ! empty($json_fallback) ) {
612
  $json_output = json_decode( base64_decode($json_fallback) );
641
  $output[] = $error_string;
642
  unset($error_string);
643
  } else {
644
+ $output[] = __("Oops, something went wrong.", 'youtube-channel');
645
  // append YouTube DATA API error reason as comment
646
  if ( ! empty($json_output) && is_object($json_output) && !empty($json_output->error->errors) ) {
647
  $output[] = "<!-- YTC ERROR:\n";
648
  $output[] = 'domain: ' . $json_output->error->errors[0]->domain . "\n";
649
  $output[] = 'reason: ' . $json_output->error->errors[0]->reason . "\n";
650
  $output[] = 'message: ' . $json_output->error->errors[0]->message . "\n";
651
+
652
+ if ( $json_output->error->errors[0]->reason == 'playlistNotFound' ) {
653
+ if ( $resource_name == 'playlist' ) {
654
+ $output[] = "tip: Please check did you set existing Playlist ID. We should display videos from {$resource_name} videos, but YouTube does not recognize {$resource_id} as existing and public playlist.\n";
655
+ } else {
656
+ $output[] = "tip: Please check did you set proper Channel ID. We should display videos from {$resource_name} videos, but YouTube does not recognize your channel ID {$channel} as existing and public resource.\n";
657
+ }
658
  }
659
+ elseif ( $json_output->error->errors[0]->reason == 'keyInvalid' ) {
660
+ $output[] = "tip: Double check YouTube Data API Key on General plugin tab and make sure it`s correct. Check https://wordpress.org/plugins/youtube-channel/installation/\n";
661
  }
662
+ elseif ( $json_output->error->errors[0]->reason == 'ipRefererBlocked' ) {
663
+ $output[] = "tip: Check YouTube Data API Key restrictions, empty cache if enabled and append in browser address bar parameter ?ytc_force_recache=1\n";
664
+ }
665
+ elseif ( $json_output->error->errors[0]->reason == 'invalidChannelId' ) {
666
+ $output[] = "tip: You have set wrong Channel ID. Fix that in General plugin settings, Widget and/or shortcode. Check https://wordpress.org/plugins/youtube-channel/faq/\n";
667
  }
668
  $output[] = "-->\n";
669
  }
710
 
711
  } // single playlist or ytc way
712
 
713
+ if ( ! empty($instance['showgoto']) ) {
714
+ $output = array_merge( $output, $this->ytc_channel_link($instance) ); // insert link to channel on bootom of widget
715
+ }
716
 
717
  $output[] = '</div><!-- .youtube_channel -->';
718
 
719
+ // fix overflow on crappy themes
720
+ $output[] = '<div class="clearfix"></div>';
721
+
722
  return $output;
723
 
724
  } // END public function output($instance)
727
 
728
  /**
729
  * Download YouTube video feed through API 3.0
 
730
  * @param string $id ID of resource
731
  * @param integer $items Number of items to fetch (min 2, max 50)
732
  * @return array JSON with videos
733
  */
734
+ function fetch_youtube_feed($resource_id, $items) {
 
 
 
 
 
 
 
 
 
 
735
 
736
+ $feed_url = 'https://www.googleapis.com/youtube/v3/playlistItems?';
737
+ $feed_url .= 'part=snippet';
738
+ $feed_url .= "&playlistId={$resource_id}";
739
+ $feed_url .= '&fields=items(snippet(title%2Cdescription%2CpublishedAt%2CresourceId(videoId)))';
 
 
 
 
 
 
 
740
  $feed_url .= "&maxResults={$items}";
741
+ $feed_url .= "&key={$this->defaults['apikey']}";
742
 
743
  $wprga = array(
744
  'timeout' => 5 // five seconds only
751
 
752
  return $json;
753
 
754
+ } // END function fetch_youtube_feed($resource_id, $items)
755
 
756
  // function to calculate height by width and ratio
757
  function height_ratio($width=306, $ratio) {
869
  $themelight = $instance['themelight'];
870
  /* end of video settings */
871
 
872
+ // Prepare Video ID from Resource
873
+ $yt_id = $item->snippet->resourceId->videoId;
874
  $yt_url = "v/$yt_id";
875
  $yt_thumb = "//img.youtube.com/vi/$yt_id/0.jpg"; // zero for HD thumb
876
  $yt_video = "//www.youtube.com/watch?v=" . $yt_id;
900
  }
901
  $output[] = "<div class=\"ytc_video_container ytc_video_{$y} ytc_video_{$vnumclass} ${arclass}\" style=\"width:{$width}px\">";
902
 
903
+ // show video title above video?
904
+ if ( ! empty($instance['showtitle']) && empty($instance['titlebelow']) ) {
905
  $output[] = "<h3 class=\"ytc_title\">{$yt_title}</h3>";
906
  }
907
 
1018
 
1019
  } // what to show conditions
1020
 
1021
+ // show video title below video?
1022
+ if ( ! empty($instance['showtitle']) && ! empty($instance['titlebelow']) ) {
1023
+ $output[] = "<h3 class=\"ytc_title\">{$yt_title}</h3>";
1024
+ }
1025
+
1026
  // do we need to show video description?
1027
  if ( $instance['showdesc'] ) {
1028
 
1051
  } // end function ytc_print_video
1052
 
1053
  /* function to print standard playlist embed code */
1054
+ function embed_playlist($resource_id, $instance) {
 
 
 
 
 
 
 
 
1055
 
1056
+ $width = ( empty($instance['width']) ) ? 306 : $instance['width'];
1057
+ $height = self::height_ratio($width, $instance['ratio']);
1058
+ $autoplay = (empty($instance['autoplay'])) ? '' : '&autoplay=1';
1059
+ $theme = (empty($instance['themelight'])) ? '' : '&theme=light';
1060
+ $modestbranding = (empty($instance['modestbranding'])) ? '' : '&modestbranding=1';
1061
+ $rel = (empty($instance['norel'])) ? '' : '&rel=0';
1062
 
1063
+ // enhanced privacy
1064
+ $youtube_domain = $this->youtube_domain($instance);
 
 
 
1065
 
1066
+ $output[] = "<div class=\"ytc_video_container ytc_video_1 ytc_video_single ytc_playlist_only\">";
1067
+ $output[] = "<iframe src=\"//{$youtube_domain}/embed/videoseries?list={$resource_id}{$autoplay}{$theme}{$modestbranding}{$rel}\"";
1068
+ $output[] = " width=\"{$width}\" height=\"{$height}\" frameborder=\"0\"></iframe></div>";
1069
 
 
 
 
 
 
1070
  return $output;
1071
+
1072
+ } // END function embed_playlist($resource_id, $instance)
1073
 
1074
  // Helper function cache_time()
1075
  function cache_time($cache_time)
1163
  if ( ! is_array($options) )
1164
  return;
1165
 
1166
+ // remove YouTube Data API Key from config JSON
1167
+ unset($options['apikey']);
1168
+
1169
  } else {
1170
  // for widget
1171
  // prepare option name and widget ID