Youtube Channel Gallery - Version 1.4.1

Version Description

  • Added width and height to player.
  • Reverted name variable prefixes.
Download this release

Release Info

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

Code changes from version 1.4 to 1.4.1

Files changed (2) hide show
  1. readme.txt +5 -1
  2. youtube-channel-gallery.php +66 -66
readme.txt CHANGED
@@ -4,7 +4,7 @@ Donate link: http://poselab.com/
4
Tags: widget, gallery, youtube, channel, user
5
Requires at least: 2.8
6
Tested up to: 3.4.1
7
- Stable tag: 1.4
8
License: GPLv2 or later
9
License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
@@ -81,6 +81,10 @@ The username who uploaded a video to Youtube is located below each video, where
81
82
== Changelog ==
83
84
= 1.4 =
85
* Added shortcode feature.
86
* Multiple instances of the plugin on the same page.
4
Tags: widget, gallery, youtube, channel, user
5
Requires at least: 2.8
6
Tested up to: 3.4.1
7
+ Stable tag: 1.4.1
8
License: GPLv2 or later
9
License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
81
82
== Changelog ==
83
84
+ = 1.4.1 =
85
+ * Added width and height to player.
86
+ * Reverted name variable prefixes.
87
+
88
= 1.4 =
89
* Added shortcode feature.
90
* Multiple instances of the plugin on the same page.
youtube-channel-gallery.php CHANGED
@@ -5,7 +5,7 @@ Plugin URI: http://www.poselab.com/
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: 1.4
9
License: GPL2
10
11
Copyright 2010 Javier Gómez Pose (email : javierpose@gmail.com)
@@ -60,7 +60,7 @@ class YoutubeChannelGallery_Widget extends WP_Widget {
60
if ( ! empty( $title ) )
61
echo $before_title . $title . $after_title;
62
63
- ytcg_rss_markup($instance);
64
65
echo $after_widget;
66
}
@@ -71,14 +71,14 @@ class YoutubeChannelGallery_Widget extends WP_Widget {
71
public function update( $new_instance, $old_instance ) {
72
$instance = $old_instance;
73
$instance['title'] = strip_tags( $new_instance['title'] );
74
- $instance['ytcg_user'] = strip_tags( $new_instance['ytcg_user'] );
75
76
- $instance['ytcg_link'] = $new_instance['ytcg_link'];
77
- $instance['ytcg_maxitems'] = strip_tags( $new_instance['ytcg_maxitems'] );
78
- $instance['ytcg_video_width'] = strip_tags( $new_instance['ytcg_video_width'] );
79
- $instance['ytcg_thumb_width'] = strip_tags( $new_instance['ytcg_thumb_width'] );
80
- $instance['ytcg_thumb_columns'] = strip_tags( $new_instance['ytcg_thumb_columns'] );
81
- $instance['ytcg_theme'] = strip_tags( $new_instance['ytcg_theme'] );
82
83
return $instance;
84
}
@@ -88,13 +88,13 @@ class YoutubeChannelGallery_Widget extends WP_Widget {
88
*/
89
public function form( $instance ) {
90
$title = esc_attr($instance['title']);
91
- $ytcg_user = strip_tags($instance['ytcg_user']);
92
- $ytcg_link = esc_attr($instance['ytcg_link']);
93
- $ytcg_maxitems = strip_tags($instance['ytcg_maxitems']);
94
- $ytcg_video_width = strip_tags($instance['ytcg_video_width']);
95
- $ytcg_thumb_width = strip_tags($instance['ytcg_thumb_width']);
96
- $ytcg_thumb_columns = strip_tags($instance['ytcg_thumb_columns']);
97
- $ytcg_theme = strip_tags($instance['ytcg_theme']);
98
?>
99
<p>
100
<label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php _e( 'Title:', 'youtube-channel-gallery' ); ?></label>
@@ -102,40 +102,40 @@ class YoutubeChannelGallery_Widget extends WP_Widget {
102
</p>
103
104
<p>
105
- <label for="<?php echo $this->get_field_id( 'ytcg_user' ); ?>"><?php _e( 'YouTube user name:', 'youtube-channel-gallery' ); ?></label>
106
- <input class="widefat" id="<?php echo $this->get_field_id( 'ytcg_user' ); ?>" name="<?php echo $this->get_field_name( 'ytcg_user' ); ?>" type="text" value="<?php echo esc_attr( $ytcg_user ); ?>" />
107
</p>
108
109
<p>
110
- <input class="checkbox" type="checkbox" <?php checked( (bool) $instance['ytcg_link'], true ); ?> id="<?php echo $this->get_field_id( 'ytcg_link' ); ?>" name="<?php echo $this->get_field_name( 'ytcg_link' ); ?>" />
111
- <label for="<?php echo $this->get_field_id( 'ytcg_link' ); ?>"><?php _e('Show link to channel:', 'youtube-channel-gallery'); ?></label><br />
112
</p>
113
114
<p>
115
- <label for="ytcg_maxitems"><?php _e( 'Number of videos to show:', 'youtube-channel-gallery' ); ?></label>
116
- <input class="widefat" id="<?php echo $this->get_field_id( 'ytcg_maxitems' ); ?>" name="<?php echo $this->get_field_name( 'ytcg_maxitems' ); ?>" type="text" value="<?php echo esc_attr( $ytcg_maxitems ); ?>" />
117
</p>
118
119
<p>
120
- <label for="ytcg_video_width"><?php _e( 'Video width:', 'youtube-channel-gallery' ); ?></label>
121
- <input class="widefat" id="<?php echo $this->get_field_id( 'ytcg_video_width' ); ?>" name="<?php echo $this->get_field_name( 'ytcg_video_width' ); ?>" type="text" value="<?php echo esc_attr( $ytcg_video_width ); ?>" />
122
</p>
123
124
<p>
125
- <label for="ytcg_thumb_width"><?php _e( 'Thumbnail width:', 'youtube-channel-gallery' ); ?></label>
126
- <input class="widefat" id="<?php echo $this->get_field_id( 'ytcg_thumb_width' ); ?>" name="<?php echo $this->get_field_name( 'ytcg_thumb_width' ); ?>" type="text" value="<?php echo esc_attr( $ytcg_thumb_width ); ?>" />
127
</p>
128
129
<p>
130
- <label for="ytcg_thumb_columns"><?php _e( 'Thumbnail columns:', 'youtube-channel-gallery' ); ?></label>
131
- <input class="widefat" id="<?php echo $this->get_field_id( 'ytcg_thumb_columns' ); ?>" name="<?php echo $this->get_field_name( 'ytcg_thumb_columns' ); ?>" type="text" value="<?php echo esc_attr( $ytcg_thumb_columns ); ?>" />
132
</p>
133
134
<p>
135
- <label for="ytcg_theme"><?php _e( 'Theme:', 'youtube-channel-gallery' ); ?></label>
136
- <select class="widefat" id="<?php echo $this->get_field_id( 'ytcg_theme' ); ?>" name="<?php echo $this->get_field_name( 'ytcg_theme' ); ?>">
137
- <option value="dark"<?php selected( $instance['ytcg_theme'], 'dark' ); ?>><?php _e( 'Dark', 'youtube-channel-gallery' ); ?></option>
138
- <option value="light"<?php selected( $instance['ytcg_theme'], 'light' ); ?>><?php _e( 'Light', 'youtube-channel-gallery' ); ?></option>
139
</select>
140
</p>
141
@@ -166,40 +166,40 @@ add_action( 'widgets_init', create_function( '', 'register_widget( "YoutubeChann
166
/* Functions
167
/*--------------------------------------------------*/
168
169
- function ytcg_rss_markup($instance){
170
171
//$instance variables
172
- $ytcg_user = apply_filters('ytcg_user', $instance['ytcg_user']);
173
- $ytcg_link = apply_filters('ytcg_link', $instance['ytcg_link']);
174
- $ytcg_maxitems = apply_filters('ytcg_maxitems', $instance['ytcg_maxitems']);
175
- $ytcg_video_width = apply_filters('ytcg_video_width', $instance['ytcg_video_width']);
176
- $ytcg_thumb_width = apply_filters('ytcg_thumb_width', $instance['ytcg_thumb_width']);
177
- $ytcg_thumb_columns = apply_filters('ytcg_thumb_columns', $instance['ytcg_thumb_columns']);
178
- $ytcg_theme = apply_filters('ytcg_theme', $instance['ytcg_theme']);
179
180
//defaults
181
- $ytcg_video_width = ( $ytcg_video_width ) ? $ytcg_video_width : 250;
182
- $ytcg_thumb_width = ( $ytcg_thumb_width ) ? $ytcg_thumb_width : 85;
183
- $ytcg_thumb_columns = ( $ytcg_thumb_columns ) ? $ytcg_thumb_columns : 0;
184
- $ytcg_theme = ( $ytcg_theme ) ? $ytcg_theme : 'dark';
185
186
//heights of video and thumbnail
187
- $ytcg_video_heigh = round($ytcg_video_width/(16/9) + 32);
188
- $ytcg_thumb_height = $ytcg_thumb_width*75/100; // 75% 'cos sizes of thumbnail in xml file are 480x360 and 120x90
189
190
- if( $ytcg_user ) { // only if user name inserted
191
192
// links
193
- $ytcg_rss_url = "http://gdata.youtube.com/feeds/api/users/" . $ytcg_user . "/uploads";
194
- $ytcg_link_url = "http://www.youtube.com/user/" . $ytcg_user;
195
196
197
//RSS Feed
198
199
include_once(ABSPATH . WPINC . '/feed.php');
200
201
- $rss = fetch_feed($ytcg_rss_url);
202
- $maxitems = ( $ytcg_maxitems ) ? $ytcg_maxitems : 9;
203
$items = $rss->get_items(0, $maxitems);
204
205
@@ -221,7 +221,7 @@ function ytcg_rss_markup($instance){
221
$big = 0;
222
$small = 1;
223
$size = $small;
224
- if($ytcg_thumb_width > '120'){
225
$size = $big;
226
}
227
@@ -239,8 +239,8 @@ function ytcg_rss_markup($instance){
239
STATIC $plugincount = 0;
240
$plugincount++;
241
?>
242
- <iframe id="ytcplayer<?php echo $plugincount; ?>" type="text/html" width="250" height="200" src="http://www.youtube.com/embed/<?php echo $youtubeid; ?>?&autoplay=0&theme=<?php echo $ytcg_theme; ?>&enablejsapi=1&origin=<?php echo site_url(); ?>" frameborder="0"></iframe>
243
- <ul class="ytcgallery">
244
245
<?php
246
} // if player end
@@ -251,12 +251,12 @@ function ytcg_rss_markup($instance){
251
?>
252
<li class="ytccell-<?php echo $column; ?>">
253
<a class="ytcthumb" href="javascript: ytcplayVideo('ytcplayer<?php echo $plugincount; ?>', '<?php echo $youtubeid; ?>');" alt="<?php echo $title; ?>" title="<?php echo $title; ?>" style="background-image: url(<?php echo $thumb; ?>);">
254
- <div class="ytcplay" style="width: <?php echo $ytcg_thumb_width; ?>px; height: <?php echo $ytcg_thumb_height; ?>px"></div>
255
</a>
256
</li>
257
258
<?php
259
- if($ytcg_thumb_columns !=0 && $column%$ytcg_thumb_columns === 0){
260
$column = 0;
261
}
262
} //foreach end
@@ -264,9 +264,9 @@ function ytcg_rss_markup($instance){
264
</ul>
265
<?php
266
//link to youtube.com gallery
267
- if( $ytcg_link) {
268
?>
269
- <a href="<?php echo $ytcg_link_url ?>" class="more"><?php _e('Show more videos»', 'youtube-channel-gallery') ?></a>
270
<?php
271
}
272
}
@@ -302,17 +302,17 @@ function ytcg_rss_markup($instance){
302
'theme' => 'dark',
303
), $atts ) );
304
305
- $instance['ytcg_user'] = $user;
306
307
- $instance['ytcg_link'] = $link;
308
- $instance['ytcg_maxitems'] = $maxitems;
309
- $instance['ytcg_video_width'] = $videowidth;
310
- $instance['ytcg_thumb_width'] = $thumbwidth;
311
- $instance['ytcg_thumb_columns'] = $thumbcolumns;
312
- $instance['ytcg_theme'] = $theme;
313
314
315
- ytcg_rss_markup($instance);
316
}
317
add_shortcode('Youtube_Channel_Gallery', 'YoutubeChannelGallery_Shortcode');
318
?>
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: 1.4.1
9
License: GPL2
10
11
Copyright 2010 Javier Gómez Pose (email : javierpose@gmail.com)
60
if ( ! empty( $title ) )
61
echo $before_title . $title . $after_title;
62
63
+ ytchag_rss_markup($instance);
64
65
echo $after_widget;
66
}
71
public function update( $new_instance, $old_instance ) {
72
$instance = $old_instance;
73
$instance['title'] = strip_tags( $new_instance['title'] );
74
+ $instance['ytchag_user'] = strip_tags( $new_instance['ytchag_user'] );
75
76
+ $instance['ytchag_link'] = $new_instance['ytchag_link'];
77
+ $instance['ytchag_maxitems'] = strip_tags( $new_instance['ytchag_maxitems'] );
78
+ $instance['ytchag_video_width'] = strip_tags( $new_instance['ytchag_video_width'] );
79
+ $instance['ytchag_thumb_width'] = strip_tags( $new_instance['ytchag_thumb_width'] );
80
+ $instance['ytchag_thumb_columns'] = strip_tags( $new_instance['ytchag_thumb_columns'] );
81
+ $instance['ytchag_theme'] = strip_tags( $new_instance['ytchag_theme'] );
82
83
return $instance;
84
}
88
*/
89
public function form( $instance ) {
90
$title = esc_attr($instance['title']);
91
+ $ytchag_user = strip_tags($instance['ytchag_user']);
92
+ $ytchag_link = esc_attr($instance['ytchag_link']);
93
+ $ytchag_maxitems = strip_tags($instance['ytchag_maxitems']);
94
+ $ytchag_video_width = strip_tags($instance['ytchag_video_width']);
95
+ $ytchag_thumb_width = strip_tags($instance['ytchag_thumb_width']);
96
+ $ytchag_thumb_columns = strip_tags($instance['ytchag_thumb_columns']);
97
+ $ytchag_theme = strip_tags($instance['ytchag_theme']);
98
?>
99
<p>
100
<label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php _e( 'Title:', 'youtube-channel-gallery' ); ?></label>
102
</p>
103
104
<p>
105
+ <label for="<?php echo $this->get_field_id( 'ytchag_user' ); ?>"><?php _e( 'YouTube user name:', 'youtube-channel-gallery' ); ?></label>
106
+ <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 ); ?>" />
107
</p>
108
109
<p>
110
+ <input class="checkbox" type="checkbox" <?php checked( (bool) $instance['ytchag_link'], true ); ?> id="<?php echo $this->get_field_id( 'ytchag_link' ); ?>" name="<?php echo $this->get_field_name( 'ytchag_link' ); ?>" />
111
+ <label for="<?php echo $this->get_field_id( 'ytchag_link' ); ?>"><?php _e('Show link to channel:', 'youtube-channel-gallery'); ?></label><br />
112
</p>
113
114
<p>
115
+ <label for="ytchag_maxitems"><?php _e( 'Number of videos to show:', 'youtube-channel-gallery' ); ?></label>
116
+ <input class="widefat" id="<?php echo $this->get_field_id( 'ytchag_maxitems' ); ?>" name="<?php echo $this->get_field_name( 'ytchag_maxitems' ); ?>" type="text" value="<?php echo esc_attr( $ytchag_maxitems ); ?>" />
117
</p>
118
119
<p>
120
+ <label for="ytchag_video_width"><?php _e( 'Video width:', 'youtube-channel-gallery' ); ?></label>
121
+ <input class="widefat" id="<?php echo $this->get_field_id( 'ytchag_video_width' ); ?>" name="<?php echo $this->get_field_name( 'ytchag_video_width' ); ?>" type="text" value="<?php echo esc_attr( $ytchag_video_width ); ?>" />
122
</p>
123
124
<p>
125
+ <label for="ytchag_thumb_width"><?php _e( 'Thumbnail width:', 'youtube-channel-gallery' ); ?></label>
126
+ <input class="widefat" id="<?php echo $this->get_field_id( 'ytchag_thumb_width' ); ?>" name="<?php echo $this->get_field_name( 'ytchag_thumb_width' ); ?>" type="text" value="<?php echo esc_attr( $ytchag_thumb_width ); ?>" />
127
</p>
128
129
<p>
130
+ <label for="ytchag_thumb_columns"><?php _e( 'Thumbnail columns:', 'youtube-channel-gallery' ); ?></label>
131
+ <input class="widefat" id="<?php echo $this->get_field_id( 'ytchag_thumb_columns' ); ?>" name="<?php echo $this->get_field_name( 'ytchag_thumb_columns' ); ?>" type="text" value="<?php echo esc_attr( $ytchag_thumb_columns ); ?>" />
132
</p>
133
134
<p>
135
+ <label for="ytchag_theme"><?php _e( 'Theme:', 'youtube-channel-gallery' ); ?></label>
136
+ <select class="widefat" id="<?php echo $this->get_field_id( 'ytchag_theme' ); ?>" name="<?php echo $this->get_field_name( 'ytchag_theme' ); ?>">
137
+ <option value="dark"<?php selected( $instance['ytchag_theme'], 'dark' ); ?>><?php _e( 'Dark', 'youtube-channel-gallery' ); ?></option>
138
+ <option value="light"<?php selected( $instance['ytchag_theme'], 'light' ); ?>><?php _e( 'Light', 'youtube-channel-gallery' ); ?></option>
139
</select>
140
</p>
141
166
/* Functions
167
/*--------------------------------------------------*/
168
169
+ function ytchag_rss_markup($instance){
170
171
//$instance variables
172
+ $ytchag_user = apply_filters('ytchag_user', $instance['ytchag_user']);
173
+ $ytchag_link = apply_filters('ytchag_link', $instance['ytchag_link']);
174
+ $ytchag_maxitems = apply_filters('ytchag_maxitems', $instance['ytchag_maxitems']);
175
+ $ytchag_video_width = apply_filters('ytchag_video_width', $instance['ytchag_video_width']);
176
+ $ytchag_thumb_width = apply_filters('ytchag_thumb_width', $instance['ytchag_thumb_width']);
177
+ $ytchag_thumb_columns = apply_filters('ytchag_thumb_columns', $instance['ytchag_thumb_columns']);
178
+ $ytchag_theme = apply_filters('ytchag_theme', $instance['ytchag_theme']);
179
180
//defaults
181
+ $ytchag_video_width = ( $ytchag_video_width ) ? $ytchag_video_width : 250;
182
+ $ytchag_thumb_width = ( $ytchag_thumb_width ) ? $ytchag_thumb_width : 85;
183
+ $ytchag_thumb_columns = ( $ytchag_thumb_columns ) ? $ytchag_thumb_columns : 0;
184
+ $ytchag_theme = ( $ytchag_theme ) ? $ytchag_theme : 'dark';
185
186
//heights of video and thumbnail
187
+ $ytchag_video_heigh = round($ytchag_video_width/(16/9) + 32);
188
+ $ytchag_thumb_height = $ytchag_thumb_width*75/100; // 75% 'cos sizes of thumbnail in xml file are 480x360 and 120x90
189
190
+ if( $ytchag_user ) { // only if user name inserted
191
192
// links
193
+ $ytchag_rss_url = "http://gdata.youtube.com/feeds/api/users/" . $ytchag_user . "/uploads";
194
+ $ytchag_link_url = "http://www.youtube.com/user/" . $ytchag_user;
195
196
197
//RSS Feed
198
199
include_once(ABSPATH . WPINC . '/feed.php');
200
201
+ $rss = fetch_feed($ytchag_rss_url);
202
+ $maxitems = ( $ytchag_maxitems ) ? $ytchag_maxitems : 9;
203
$items = $rss->get_items(0, $maxitems);
204
205
221
$big = 0;
222
$small = 1;
223
$size = $small;
224
+ if($ytchag_thumb_width > '120'){
225
$size = $big;
226
}
227
239
STATIC $plugincount = 0;
240
$plugincount++;
241
?>
242
+ <iframe id="ytcplayer<?php echo $plugincount; ?>" type="text/html" width="<?php echo $ytchag_video_width; ?>" height="<?php echo $ytchag_video_heigh; ?>" src="http://www.youtube.com/embed/<?php echo $youtubeid; ?>?&autoplay=0&theme=<?php echo $ytchag_theme; ?>&enablejsapi=1&origin=<?php echo site_url(); ?>" frameborder="0"></iframe>
243
+ <ul class="ytchagallery">
244
245
<?php
246
} // if player end
251
?>
252
<li class="ytccell-<?php echo $column; ?>">
253
<a class="ytcthumb" href="javascript: ytcplayVideo('ytcplayer<?php echo $plugincount; ?>', '<?php echo $youtubeid; ?>');" alt="<?php echo $title; ?>" title="<?php echo $title; ?>" style="background-image: url(<?php echo $thumb; ?>);">
254
+ <div class="ytcplay" style="width: <?php echo $ytchag_thumb_width; ?>px; height: <?php echo $ytchag_thumb_height; ?>px"></div>
255
</a>
256
</li>
257
258
<?php
259
+ if($ytchag_thumb_columns !=0 && $column%$ytchag_thumb_columns === 0){
260
$column = 0;
261
}
262
} //foreach end
264
</ul>
265
<?php
266
//link to youtube.com gallery
267
+ if( $ytchag_link) {
268
?>
269
+ <a href="<?php echo $ytchag_link_url ?>" class="more"><?php _e('Show more videos»', 'youtube-channel-gallery') ?></a>
270
<?php
271
}
272
}
302
'theme' => 'dark',
303
), $atts ) );
304
305
+ $instance['ytchag_user'] = $user;
306
307
+ $instance['ytchag_link'] = $link;
308
+ $instance['ytchag_maxitems'] = $maxitems;
309
+ $instance['ytchag_video_width'] = $videowidth;
310
+ $instance['ytchag_thumb_width'] = $thumbwidth;
311
+ $instance['ytchag_thumb_columns'] = $thumbcolumns;
312
+ $instance['ytchag_theme'] = $theme;
313
314
315
+ ytchag_rss_markup($instance);
316
}
317
add_shortcode('Youtube_Channel_Gallery', 'YoutubeChannelGallery_Shortcode');
318
?>