Youtube Channel Gallery - Version 2.2.1

Version Description

  • Added option to use channel id or username to identify your Youtube channel.
Download this release

Release Info

Developer javitxu123
Plugin Icon 128x128 Youtube Channel Gallery
Version 2.2.1
Comparing to
See all releases

Code changes from version 2.2 to 2.2.1

admin-scripts.js CHANGED
@@ -156,10 +156,14 @@ jQuery(document).ready(function($) {
156
  if(['user', 'favorites', 'likes'].indexOf($(feedSelect + ' option:selected', $widget).val()) !== -1){
157
  $('.feed_user_id_label', $widget).show();
158
  $('.feed_playlist_id_label', $widget).hide();
 
 
159
  }
160
  else if(['playlist'].indexOf($(feedSelect + ' option:selected', $widget).val()) !== -1){
161
  $('.feed_playlist_id_label', $widget).show();
162
  $('.feed_user_id_label', $widget).hide();
 
 
163
  }
164
 
165
  // order
156
  if(['user', 'favorites', 'likes'].indexOf($(feedSelect + ' option:selected', $widget).val()) !== -1){
157
  $('.feed_user_id_label', $widget).show();
158
  $('.feed_playlist_id_label', $widget).hide();
159
+ $('.identify_by', $widget).show();
160
+ $('.user', $widget).removeClass('col-md-12').addClass('col-md-8');
161
  }
162
  else if(['playlist'].indexOf($(feedSelect + ' option:selected', $widget).val()) !== -1){
163
  $('.feed_playlist_id_label', $widget).show();
164
  $('.feed_user_id_label', $widget).hide();
165
+ $('.identify_by', $widget).hide();
166
+ $('.user', $widget).removeClass('col-md-8').addClass('col-md-12');
167
  }
168
 
169
  // order
admin-styles.css CHANGED
@@ -1 +1 @@
1
- .ytchg{margin-bottom:13px}.ytchgtabs *{-webkit-box-sizing:border-box;box-sizing:border-box}.ytchgtabs :before,.ytchgtabs :after{-webkit-box-sizing:border-box;box-sizing:border-box}.ytchgtabs .clearfix:before,.ytchgtabs .clearfix:after{content:'';display:table}.ytchgtabs .clearfix:after{clear:both}.ytchgtabs .clearfix{zoom:1}.ytchgtabs ul{margin:0;padding:0}.ytchgtabs li{display:inline-block;margin:1px .2em 0 0;padding:0;list-style:none;white-space:nowrap;position:relative;background:#f3f3f3;border:1px solid #dfdfdf;border-bottom:none;border-radius:5px 5px 0 0}.ytchgtabs li.active{margin-bottom:-1px;padding-bottom:1px;background:#fafafa}.ytchgtabs .ytchgtabs-tabs a{padding:5px;display:inline-block;text-decoration:none;outline:0}.ytchgtabs .ytchgtabs-tabs a:focus{-webkit-box-shadow:none;box-shadow:none}.ytchgtabs .ytchg-tit-desc a:focus{-webkit-box-shadow:none;box-shadow:none}.ytchgtabs input,.ytchgtabs select{margin:3px 1px 1px}.ytchgtabs select{vertical-align:baseline}.ytchgtabs div.ytchgtabs-content{border:1px solid #dfdfdf;padding:15px 12px;background:#fafafa}.ytchgtabs .ytchgtabs-content p:last-child{margin-bottom:0}.ytchgtabs .feed_playlist_id_label{display:none}.ytchgtabs .ytchg-field-tit-desc{margin:13px 0}.ytchgtabs div.ytchg-title-and-description{border:none;background:0 0;display:none}.ytchgtabs fieldset{border:1px solid transparent;border-radius:5px}.ytchgtabs fieldset.ytchg-fieldborder{border-color:#dfdfdf}.ytchgtabs .align-options{display:none}.ytchgtabs .ytchag_info{background:#D7D7D7;border-radius:20px;font-size:11px;width:15px;height:15px;line-height:14px;display:inline-block;text-align:center;cursor:pointer;position:relative;vertical-align:text-top;margin-top:1px}.ytchgtabs .wideinfo{width:100%;margin-right:-25px;padding-right:25px}.ytchgtabs select+.ytchag_info{margin-left:-12px}.ytchgtabs .player_options{width:100%}.ytchgtabs .row{margin:13px -15px}.ytchgtabs .flex{display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-align-items:flex-end;-ms-flex-align:end;align-items:flex-end}.ytchgtabs .clearfix:before,.ytchgtabs .clearfix:after,.ytchgtabs .row:before,.ytchgtabs .row:after{content:' ';display:table}.ytchgtabs .clearfix:after,.ytchgtabs .row:after{clear:both}.ytchgtabs .col-md-12{position:relative;min-height:1px;padding-left:15px;padding-right:15px;width:100%;float:left}.ytchgtabs .col-md-6{position:relative;min-height:1px;padding-left:15px;padding-right:15px;width:50%;float:left}.ytchgtabs .text-right{text-align:right}.ytchgtabs .thumbs-cols .col-md-6{width:auto}.ytchgtabs .no-w{width:auto}.ytchgtabs .table{display:table}.ytchgtabs .table .table-row{display:table-row}.ytchgtabs .table .table-row>div{display:table-cell}.ytchgtabs .table .table-row>div label{margin-right:5px}
1
+ .ytchg{margin-bottom:13px}.ytchgtabs *{-webkit-box-sizing:border-box;box-sizing:border-box}.ytchgtabs :before,.ytchgtabs :after{-webkit-box-sizing:border-box;box-sizing:border-box}.ytchgtabs .clearfix:before,.ytchgtabs .clearfix:after{content:'';display:table}.ytchgtabs .clearfix:after{clear:both}.ytchgtabs .clearfix{zoom:1}.ytchgtabs ul{margin:0;padding:0}.ytchgtabs li{display:inline-block;margin:1px .2em 0 0;padding:0;list-style:none;white-space:nowrap;position:relative;background:#f3f3f3;border:1px solid #dfdfdf;border-bottom:none;border-radius:5px 5px 0 0}.ytchgtabs li.active{margin-bottom:-1px;padding-bottom:1px;background:#fafafa}.ytchgtabs .ytchgtabs-tabs a{padding:5px;display:inline-block;text-decoration:none;outline:0}.ytchgtabs .ytchgtabs-tabs a:focus{-webkit-box-shadow:none;box-shadow:none}.ytchgtabs .ytchg-tit-desc a:focus{-webkit-box-shadow:none;box-shadow:none}.ytchgtabs input,.ytchgtabs select{margin:3px 1px 1px}.ytchgtabs select{vertical-align:baseline}.ytchgtabs div.ytchgtabs-content{border:1px solid #dfdfdf;padding:15px 12px;background:#fafafa}.ytchgtabs .ytchgtabs-content p:last-child{margin-bottom:0}.ytchgtabs .feed_playlist_id_label{display:none}.ytchgtabs .ytchg-field-tit-desc{margin:13px 0}.ytchgtabs div.ytchg-title-and-description{border:none;background:0 0;display:none}.ytchgtabs fieldset{border:1px solid transparent;border-radius:5px}.ytchgtabs fieldset.ytchg-fieldborder{border-color:#dfdfdf}.ytchgtabs .align-options{display:none}.ytchgtabs .ytchag_info{background:#D7D7D7;border-radius:20px;font-size:11px;width:15px;height:15px;line-height:14px;display:inline-block;text-align:center;cursor:pointer;position:relative;vertical-align:text-top;margin-top:1px}.ytchgtabs .wideinfo{width:100%;margin-right:-25px;padding-right:25px}.ytchgtabs select+.ytchag_info{margin-left:-12px}.ytchgtabs .player_options{width:100%}.ytchgtabs .row{margin:13px -15px}.ytchgtabs .flex{display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-align-items:flex-end;-ms-flex-align:end;align-items:flex-end}.ytchgtabs .clearfix:before,.ytchgtabs .clearfix:after,.ytchgtabs .row:before,.ytchgtabs .row:after{content:' ';display:table}.ytchgtabs .clearfix:after,.ytchgtabs .row:after{clear:both}.ytchgtabs .col-md-12{position:relative;min-height:1px;padding-left:15px;padding-right:15px;width:100%;float:left}.ytchgtabs .col-md-6{position:relative;min-height:1px;padding-left:15px;padding-right:15px;width:50%;float:left}.ytchgtabs .col-md-1,.ytchgtabs .col-md-2,.ytchgtabs .col-md-3,.ytchgtabs .col-md-4,.ytchgtabs .col-md-5,.ytchgtabs .col-md-6,.ytchgtabs .col-md-7,.ytchgtabs .col-md-8,.ytchgtabs .col-md-9,.ytchgtabs .col-md-10,.ytchgtabs .col-md-11,.ytchgtabs .col-md-12{float:left}.ytchgtabs .col-xs-1,.ytchgtabs .col-sm-1,.ytchgtabs .col-md-1,.ytchgtabs .col-lg-1,.ytchgtabs .col-xs-2,.ytchgtabs .col-sm-2,.ytchgtabs .col-md-2,.ytchgtabs .col-lg-2,.ytchgtabs .col-xs-3,.ytchgtabs .col-sm-3,.ytchgtabs .col-md-3,.ytchgtabs .col-lg-3,.ytchgtabs .col-xs-4,.ytchgtabs .col-sm-4,.ytchgtabs .col-md-4,.ytchgtabs .col-lg-4,.ytchgtabs .col-xs-5,.ytchgtabs .col-sm-5,.ytchgtabs .col-md-5,.ytchgtabs .col-lg-5,.ytchgtabs .col-xs-6,.ytchgtabs .col-sm-6,.ytchgtabs .col-md-6,.ytchgtabs .col-lg-6,.ytchgtabs .col-xs-7,.ytchgtabs .col-sm-7,.ytchgtabs .col-md-7,.ytchgtabs .col-lg-7,.ytchgtabs .col-xs-8,.ytchgtabs .col-sm-8,.ytchgtabs .col-md-8,.ytchgtabs .col-lg-8,.ytchgtabs .col-xs-9,.ytchgtabs .col-sm-9,.ytchgtabs .col-md-9,.ytchgtabs .col-lg-9,.ytchgtabs .col-xs-10,.ytchgtabs .col-sm-10,.ytchgtabs .col-md-10,.ytchgtabs .col-lg-10,.ytchgtabs .col-xs-11,.ytchgtabs .col-sm-11,.ytchgtabs .col-md-11,.ytchgtabs .col-lg-11,.ytchgtabs .col-xs-12,.ytchgtabs .col-sm-12,.ytchgtabs .col-md-12,.ytchgtabs .col-lg-12{position:relative;min-height:1px;padding-left:15px;padding-right:15px}.ytchgtabs .col-md-12{width:100%}.ytchgtabs .col-md-11{width:91.66666667%}.ytchgtabs .col-md-10{width:83.33333333%}.ytchgtabs .col-md-9{width:75%}.ytchgtabs .col-md-8{width:66.66666667%}.ytchgtabs .col-md-7{width:58.33333333%}.ytchgtabs .col-md-6{width:50%}.ytchgtabs .col-md-5{width:41.66666667%}.ytchgtabs .col-md-4{width:33.33333333%}.ytchgtabs .col-md-3{width:25%}.ytchgtabs .col-md-2-4{width:20%}.ytchgtabs .col-md-2{width:16.66666667%}.ytchgtabs .col-md-1{width:8.33333333%}.ytchgtabs .text-right{text-align:right}.ytchgtabs .thumbs-cols .col-md-6{width:auto}.ytchgtabs .no-w{width:auto}.ytchgtabs .table{display:table}.ytchgtabs .table .table-row{display:table-row}.ytchgtabs .table .table-row>div{display:table-cell}.ytchgtabs .table .table-row>div label{margin-right:5px}
readme.txt CHANGED
@@ -4,7 +4,7 @@ Donate link: http://poselab.com/
4
  Tags: widget, gallery, youtube, channel, user, sidebar, video, youtube playlist, html5, iframe, Youtube channel, youtube videos, API 3
5
  Requires at least: 2.8
6
  Tested up to: 3.8.8
7
- Stable tag: 2.2
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -49,6 +49,8 @@ Description of the different fields of the plugin:
49
 
50
  * **Video feed type:** option to select the feed type to use to show videos. Yo can select Uploaded by a user, User's favorites, User's likes or Playlist. Shortcode attribute: feed; value: user (default), favorites, likes or playlist. (Optional).
51
 
 
 
52
  * **YouTube user id or playlist id:** the user id of the user's Youtube videos you want to show or the id of the playlist. Shortcode attribute: user; value: String. (Required).
53
  * **Order:** this option appears if you select "Uploaded by a user" as Video feed type. Shortcode attribute: feed_order; value: date (default), rating, relevance, title, videoCount or viewCount. (Optional).
54
  * date: Resources are sorted in reverse chronological order based on the date they were created.
@@ -199,6 +201,9 @@ See [HTTPS Support for YouTube Embeds](http://apiblog.youtube.com/2011/02/https-
199
 
200
  == Changelog ==
201
 
 
 
 
202
  = 2.2 =
203
  * Optimization of cache use.
204
  * Fixed Playlists order option and added the options allowed by YouTube api 3: Date Order, Rating Order, Relevance Order, Title Order, View Count Order.
4
  Tags: widget, gallery, youtube, channel, user, sidebar, video, youtube playlist, html5, iframe, Youtube channel, youtube videos, API 3
5
  Requires at least: 2.8
6
  Tested up to: 3.8.8
7
+ Stable tag: 2.2.2
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
49
 
50
  * **Video feed type:** option to select the feed type to use to show videos. Yo can select Uploaded by a user, User's favorites, User's likes or Playlist. Shortcode attribute: feed; value: user (default), favorites, likes or playlist. (Optional).
51
 
52
+ * **Identify by:** option to select the type you want id to use to identify your channel, your user name or id channel. Shortcode attribute: identify_by; value: username (default) or channelid. (Optional).
53
+
54
  * **YouTube user id or playlist id:** the user id of the user's Youtube videos you want to show or the id of the playlist. Shortcode attribute: user; value: String. (Required).
55
  * **Order:** this option appears if you select "Uploaded by a user" as Video feed type. Shortcode attribute: feed_order; value: date (default), rating, relevance, title, videoCount or viewCount. (Optional).
56
  * date: Resources are sorted in reverse chronological order based on the date they were created.
201
 
202
  == Changelog ==
203
 
204
+ = 2.2.1 =
205
+ * Added option to use channel id or username to identify your Youtube channel.
206
+
207
  = 2.2 =
208
  * Optimization of cache use.
209
  * Fixed Playlists order option and added the options allowed by YouTube api 3: Date Order, Rating Order, Relevance Order, Title Order, View Count Order.
scripts.js CHANGED
@@ -1,7 +1,7 @@
1
  /*------------------------------------------------------------
2
  Plugin Name: Youtube Channel Gallery
3
  Plugin URI: http://www.poselab.com/
4
- Version: 2.2
5
  Description: Show a youtube video and a gallery of thumbnails for a youtube channel.
6
  ------------------------------------------------------------*/
7
  jQuery(document).ready(function($) {
1
  /*------------------------------------------------------------
2
  Plugin Name: Youtube Channel Gallery
3
  Plugin URI: http://www.poselab.com/
4
+ Version: 2.2.1
5
  Description: Show a youtube video and a gallery of thumbnails for a youtube channel.
6
  ------------------------------------------------------------*/
7
  jQuery(document).ready(function($) {
templates/admin_tabs.php CHANGED
@@ -37,13 +37,20 @@
37
  <option value="playlist"<?php selected( $instance['ytchag_feed'], 'playlist' ); ?>><?php _e( 'Playlist', 'youtube-channel-gallery' ); ?></option>
38
  </select>
39
  </p>
40
-
41
- <p>
42
- <label class="feed_user_id_label" for="<?php echo $this->get_field_id( 'ytchag_user' ); ?>"><?php _e( 'YouTube user id:', 'youtube-channel-gallery' ); ?></label>
43
- <label class="feed_playlist_id_label" for="<?php echo $this->get_field_id( 'ytchag_user' ); ?>"><?php _e( 'YouTube playlist id:', 'youtube-channel-gallery' ); ?></label>
44
- <input class="widefat" id="<?php echo $this->get_field_id( 'ytchag_user' ); ?>" name="<?php echo $this->get_field_name( 'ytchag_user' ); ?>" type="text" value="<?php echo esc_attr( $ytchag_user ); ?>" />
45
- [<?php echo esc_attr( $ytchag_user_uploads ); ?>]
46
- </p>
 
 
 
 
 
 
 
47
 
48
  <p class="<?php echo $this->get_field_id( 'ytchag_feed_order' ); ?>">
49
  <label for="<?php echo $this->get_field_id( 'ytchag_feed_order' ); ?>"><?php _e( 'Playlist order:', 'youtube-channel-gallery' ); ?></label>
37
  <option value="playlist"<?php selected( $instance['ytchag_feed'], 'playlist' ); ?>><?php _e( 'Playlist', 'youtube-channel-gallery' ); ?></option>
38
  </select>
39
  </p>
40
+ <div class="row">
41
+ <div class="col-md-4 identify_by">
42
+ <label for="<?php echo $this->get_field_id( 'ytchag_identify_by' ); ?>"><?php _e( 'Identify by:', 'youtube-channel-gallery' ); ?></label>
43
+ <select class="widefat" id="<?php echo $this->get_field_id( 'ytchag_identify_by' ); ?>" name="<?php echo $this->get_field_name( 'ytchag_identify_by' ); ?>">
44
+ <option value="username"<?php selected( $instance['ytchag_identify_by'], 'username' ); ?>><?php _e( 'Username', 'youtube-channel-gallery' ); ?></option>
45
+ <option value="channelid"<?php selected( $instance['ytchag_identify_by'], 'channelid' ); ?>><?php _e( 'Channel ID', 'youtube-channel-gallery' ); ?></option>
46
+ </select>
47
+ </div>
48
+ <div class="col-md-8 user">
49
+ <label class="feed_user_id_label" for="<?php echo $this->get_field_id( 'ytchag_user' ); ?>"><?php _e( 'YouTube id:', 'youtube-channel-gallery' ); ?></label>
50
+ <label class="feed_playlist_id_label" for="<?php echo $this->get_field_id( 'ytchag_user' ); ?>"><?php _e( 'YouTube playlist id:', 'youtube-channel-gallery' ); ?></label>
51
+ <input class="widefat" id="<?php echo $this->get_field_id( 'ytchag_user' ); ?>" name="<?php echo $this->get_field_name( 'ytchag_user' ); ?>" type="text" value="<?php echo esc_attr( $ytchag_user ); ?>" />
52
+ </div>
53
+ </div>
54
 
55
  <p class="<?php echo $this->get_field_id( 'ytchag_feed_order' ); ?>">
56
  <label for="<?php echo $this->get_field_id( 'ytchag_feed_order' ); ?>"><?php _e( 'Playlist order:', 'youtube-channel-gallery' ); ?></label>
youtube-channel-gallery.php CHANGED
@@ -5,7 +5,7 @@
5
  Description: Show a youtube video and a gallery of thumbnails for a youtube channel.
6
  Author: Javier Gómez Pose
7
  Author URI: http://www.poselab.com/
8
- Version: 2.2
9
  License: GPL2
10
 
11
  Copyright 2013 Javier Gómez Pose (email : javierpose@gmail.com)
@@ -300,6 +300,7 @@ class YoutubeChannelGallery_Widget extends WP_Widget {
300
  // Feed options
301
  $instance['ytchag_key'] = strip_tags( $new_instance['ytchag_key'] );
302
  $instance['ytchag_feed'] = strip_tags( $new_instance['ytchag_feed'] );
 
303
  $instance['ytchag_user'] = strip_tags( $new_instance['ytchag_user'] );
304
  //$instance['ytchag_id'] = strip_tags( $new_instance['ytchag_id'] );
305
  //$instance['ytchag_user_uploads'] = strip_tags( $new_instance['ytchag_user_uploads'] );
@@ -364,7 +365,7 @@ class YoutubeChannelGallery_Widget extends WP_Widget {
364
 
365
  if (isset($instance['ytchag_user']) && ($new_instance['ytchag_user'] !== $old_instance['ytchag_user'] || $instance['ytchag_user_uploads'] === '')) {
366
 
367
- $item = $this->getUserPlaylists($instance['ytchag_user'], $instance['ytchag_key'], $instance['ytchag_cache'], $instance['ytchag_cache_time']);
368
  $playlists = $item['contentDetails']['relatedPlaylists'];
369
 
370
  $instance['ytchag_id'] = $item['id'];
@@ -396,6 +397,7 @@ class YoutubeChannelGallery_Widget extends WP_Widget {
396
  // Feed options
397
  'ytchag_key' => 'AIzaSyA0IBAaDqJxfQiqeYg_i2kVKW5P9ZLheVU',
398
  'ytchag_feed' => 'user',
 
399
  'ytchag_user' => 'youtube',
400
  'ytchag_id' => 'UUBR8-60-B28hp2BmDPdntcQ',
401
  'ytchag_user_uploads' => 'UUBR8-60-B28hp2BmDPdntcQ',
@@ -481,6 +483,7 @@ class YoutubeChannelGallery_Widget extends WP_Widget {
481
  // Feed options
482
  $ytchag_key = apply_filters( 'ytchag_key', $instance['ytchag_key'] );
483
  $ytchag_feed = apply_filters( 'ytchag_feed', $instance['ytchag_feed'] );
 
484
  $ytchag_user = apply_filters( 'ytchag_user', $instance['ytchag_user'] );
485
  $ytchag_id = apply_filters( 'ytchag_id', $instance['ytchag_id'] );
486
  $ytchag_user_uploads = apply_filters( 'ytchag_user_uploads', $instance['ytchag_user_uploads'] );
@@ -618,7 +621,7 @@ class YoutubeChannelGallery_Widget extends WP_Widget {
618
 
619
  if ($ytchag_feed !== 'playlist') {
620
 
621
- $item = $this->getUserPlaylists($ytchag_user, $ytchag_key, $ytchag_cache, $ytchag_cache_time);
622
  $playlists = $item['contentDetails']['relatedPlaylists'];
623
 
624
  $ytchag_id = $item['id'];
@@ -676,14 +679,13 @@ class YoutubeChannelGallery_Widget extends WP_Widget {
676
  $videos_result = $this->get_rss_data ( $ytchag_cache, $transientId, $ytchag_feed_url, $ytchag_cache_time );
677
 
678
  ob_start();
679
-
680
  if ($videos_result['response']['code'] != 200) {
681
  if ($ytchag_feed == 'playlist') {
682
  $error_link = '<a href="https://www.youtube.com/playlist?list=' . $ytchag_user . '" target="_blank">' . $ytchag_user . '</a>';
683
  $error_type = $ytchag_feed;
684
  }else{
685
  $error_link = '<a href="https://www.youtube.com/user/' . $ytchag_user . '" target="_blank">' . $ytchag_user . '</a>';
686
- $error_type = 'user';
687
  }
688
 
689
  $content = '<div class="vmcerror">';
@@ -776,9 +778,14 @@ class YoutubeChannelGallery_Widget extends WP_Widget {
776
  return $content;
777
  }
778
 
779
- function getUserPlaylists($user, $key, $cache, $cache_time) {
 
 
 
 
 
780
 
781
- $api = 'https://www.googleapis.com/youtube/v3/channels?part=contentDetails&forUsername=' . $user . '&key=' . $key;
782
 
783
  $transientId = 'ytc-' . md5($api);
784
 
@@ -880,6 +887,7 @@ class YoutubeChannelGallery_Widget extends WP_Widget {
880
  // Feed options
881
  'key' => 'AIzaSyA0IBAaDqJxfQiqeYg_i2kVKW5P9ZLheVU',
882
  'feed' => 'user',
 
883
  'user' => 'youtube',
884
  //'id' => 'UUBR8-60-B28hp2BmDPdntcQ',
885
  //'user_uploads' => 'UUBR8-60-B28hp2BmDPdntcQ',
@@ -947,6 +955,7 @@ class YoutubeChannelGallery_Widget extends WP_Widget {
947
  // Feed options
948
  $instance['ytchag_key'] = $key;
949
  $instance['ytchag_feed'] = $feed;
 
950
  $instance['ytchag_user'] = $user;
951
  //$instance['ytchag_id'] = $id;
952
  //$instance['ytchag_user_uploads'] = $user_uploads;
@@ -1009,7 +1018,7 @@ class YoutubeChannelGallery_Widget extends WP_Widget {
1009
 
1010
  $instance['ytchag_promotion'] = $promotion;
1011
 
1012
- $item = $this->getUserPlaylists($instance['ytchag_user'], $instance['ytchag_key'], $instance['ytchag_cache'], $instance['ytchag_cache_time']);
1013
  $playlists = $item['contentDetails']['relatedPlaylists'];
1014
 
1015
  $instance['ytchag_id'] = $item['id'];
5
  Description: Show a youtube video and a gallery of thumbnails for a youtube channel.
6
  Author: Javier Gómez Pose
7
  Author URI: http://www.poselab.com/
8
+ Version: 2.2.1
9
  License: GPL2
10
 
11
  Copyright 2013 Javier Gómez Pose (email : javierpose@gmail.com)
300
  // Feed options
301
  $instance['ytchag_key'] = strip_tags( $new_instance['ytchag_key'] );
302
  $instance['ytchag_feed'] = strip_tags( $new_instance['ytchag_feed'] );
303
+ $instance['ytchag_identify_by'] = strip_tags( $new_instance['ytchag_identify_by'] );
304
  $instance['ytchag_user'] = strip_tags( $new_instance['ytchag_user'] );
305
  //$instance['ytchag_id'] = strip_tags( $new_instance['ytchag_id'] );
306
  //$instance['ytchag_user_uploads'] = strip_tags( $new_instance['ytchag_user_uploads'] );
365
 
366
  if (isset($instance['ytchag_user']) && ($new_instance['ytchag_user'] !== $old_instance['ytchag_user'] || $instance['ytchag_user_uploads'] === '')) {
367
 
368
+ $item = $this->getUserPlaylists($instance['ytchag_identify_by'], $instance['ytchag_user'], $instance['ytchag_key'], $instance['ytchag_cache'], $instance['ytchag_cache_time']);
369
  $playlists = $item['contentDetails']['relatedPlaylists'];
370
 
371
  $instance['ytchag_id'] = $item['id'];
397
  // Feed options
398
  'ytchag_key' => 'AIzaSyA0IBAaDqJxfQiqeYg_i2kVKW5P9ZLheVU',
399
  'ytchag_feed' => 'user',
400
+ 'ytchag_identify_by' => 'username',
401
  'ytchag_user' => 'youtube',
402
  'ytchag_id' => 'UUBR8-60-B28hp2BmDPdntcQ',
403
  'ytchag_user_uploads' => 'UUBR8-60-B28hp2BmDPdntcQ',
483
  // Feed options
484
  $ytchag_key = apply_filters( 'ytchag_key', $instance['ytchag_key'] );
485
  $ytchag_feed = apply_filters( 'ytchag_feed', $instance['ytchag_feed'] );
486
+ $ytchag_identify_by = apply_filters( 'ytchag_identify_by', $instance['ytchag_identify_by'] );
487
  $ytchag_user = apply_filters( 'ytchag_user', $instance['ytchag_user'] );
488
  $ytchag_id = apply_filters( 'ytchag_id', $instance['ytchag_id'] );
489
  $ytchag_user_uploads = apply_filters( 'ytchag_user_uploads', $instance['ytchag_user_uploads'] );
621
 
622
  if ($ytchag_feed !== 'playlist') {
623
 
624
+ $item = $this->getUserPlaylists($ytchag_identify_by, $ytchag_user, $ytchag_key, $ytchag_cache, $ytchag_cache_time);
625
  $playlists = $item['contentDetails']['relatedPlaylists'];
626
 
627
  $ytchag_id = $item['id'];
679
  $videos_result = $this->get_rss_data ( $ytchag_cache, $transientId, $ytchag_feed_url, $ytchag_cache_time );
680
 
681
  ob_start();
 
682
  if ($videos_result['response']['code'] != 200) {
683
  if ($ytchag_feed == 'playlist') {
684
  $error_link = '<a href="https://www.youtube.com/playlist?list=' . $ytchag_user . '" target="_blank">' . $ytchag_user . '</a>';
685
  $error_type = $ytchag_feed;
686
  }else{
687
  $error_link = '<a href="https://www.youtube.com/user/' . $ytchag_user . '" target="_blank">' . $ytchag_user . '</a>';
688
+ $error_type = $ytchag_identify_by;
689
  }
690
 
691
  $content = '<div class="vmcerror">';
778
  return $content;
779
  }
780
 
781
+ function getUserPlaylists($identify_by, $user, $key, $cache, $cache_time) {
782
+ if ($identify_by == 'username') {
783
+ $identify = 'forUsername';
784
+ }else{
785
+ $identify = 'id';
786
+ }
787
 
788
+ $api = 'https://www.googleapis.com/youtube/v3/channels?part=contentDetails&' . $identify . '=' . $user . '&key=' . $key;
789
 
790
  $transientId = 'ytc-' . md5($api);
791
 
887
  // Feed options
888
  'key' => 'AIzaSyA0IBAaDqJxfQiqeYg_i2kVKW5P9ZLheVU',
889
  'feed' => 'user',
890
+ 'identify_by' => 'username',
891
  'user' => 'youtube',
892
  //'id' => 'UUBR8-60-B28hp2BmDPdntcQ',
893
  //'user_uploads' => 'UUBR8-60-B28hp2BmDPdntcQ',
955
  // Feed options
956
  $instance['ytchag_key'] = $key;
957
  $instance['ytchag_feed'] = $feed;
958
+ $instance['ytchag_identify_by'] = $identify_by;
959
  $instance['ytchag_user'] = $user;
960
  //$instance['ytchag_id'] = $id;
961
  //$instance['ytchag_user_uploads'] = $user_uploads;
1018
 
1019
  $instance['ytchag_promotion'] = $promotion;
1020
 
1021
+ $item = $this->getUserPlaylists($instance['ytchag_identify_by'], $instance['ytchag_user'], $instance['ytchag_key'], $instance['ytchag_cache'], $instance['ytchag_cache_time']);
1022
  $playlists = $item['contentDetails']['relatedPlaylists'];
1023
 
1024
  $instance['ytchag_id'] = $item['id'];