Version Description
- Added width and height to player.
- Reverted name variable prefixes.
Download this release
Release Info
Developer | javitxu123 |
Plugin | Youtube Channel Gallery |
Version | 1.4.1 |
Comparing to | |
See all releases |
Code changes from version 1.4 to 1.4.1
- readme.txt +5 -1
- 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 |
-
|
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['
|
75 |
|
76 |
-
$instance['
|
77 |
-
$instance['
|
78 |
-
$instance['
|
79 |
-
$instance['
|
80 |
-
$instance['
|
81 |
-
$instance['
|
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 |
-
$
|
92 |
-
$
|
93 |
-
$
|
94 |
-
$
|
95 |
-
$
|
96 |
-
$
|
97 |
-
$
|
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( '
|
106 |
-
<input class="widefat" id="<?php echo $this->get_field_id( '
|
107 |
</p>
|
108 |
|
109 |
<p>
|
110 |
-
<input class="checkbox" type="checkbox" <?php checked( (bool) $instance['
|
111 |
-
<label for="<?php echo $this->get_field_id( '
|
112 |
</p>
|
113 |
|
114 |
<p>
|
115 |
-
<label for="
|
116 |
-
<input class="widefat" id="<?php echo $this->get_field_id( '
|
117 |
</p>
|
118 |
|
119 |
<p>
|
120 |
-
<label for="
|
121 |
-
<input class="widefat" id="<?php echo $this->get_field_id( '
|
122 |
</p>
|
123 |
|
124 |
<p>
|
125 |
-
<label for="
|
126 |
-
<input class="widefat" id="<?php echo $this->get_field_id( '
|
127 |
</p>
|
128 |
|
129 |
<p>
|
130 |
-
<label for="
|
131 |
-
<input class="widefat" id="<?php echo $this->get_field_id( '
|
132 |
</p>
|
133 |
|
134 |
<p>
|
135 |
-
<label for="
|
136 |
-
<select class="widefat" id="<?php echo $this->get_field_id( '
|
137 |
-
<option value="dark"<?php selected( $instance['
|
138 |
-
<option value="light"<?php selected( $instance['
|
139 |
</select>
|
140 |
</p>
|
141 |
|
@@ -166,40 +166,40 @@ add_action( 'widgets_init', create_function( '', 'register_widget( "YoutubeChann
|
|
166 |
/* Functions
|
167 |
/*--------------------------------------------------*/
|
168 |
|
169 |
-
function
|
170 |
|
171 |
//$instance variables
|
172 |
-
$
|
173 |
-
$
|
174 |
-
$
|
175 |
-
$
|
176 |
-
$
|
177 |
-
$
|
178 |
-
$
|
179 |
|
180 |
//defaults
|
181 |
-
$
|
182 |
-
$
|
183 |
-
$
|
184 |
-
$
|
185 |
|
186 |
//heights of video and thumbnail
|
187 |
-
$
|
188 |
-
$
|
189 |
|
190 |
-
if( $
|
191 |
|
192 |
// links
|
193 |
-
$
|
194 |
-
$
|
195 |
|
196 |
|
197 |
//RSS Feed
|
198 |
|
199 |
include_once(ABSPATH . WPINC . '/feed.php');
|
200 |
|
201 |
-
$rss = fetch_feed($
|
202 |
-
$maxitems = ( $
|
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($
|
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="
|
243 |
-
<ul class="
|
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 $
|
255 |
</a>
|
256 |
</li>
|
257 |
|
258 |
<?php
|
259 |
-
if($
|
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( $
|
268 |
?>
|
269 |
-
<a href="<?php echo $
|
270 |
<?php
|
271 |
}
|
272 |
}
|
@@ -302,17 +302,17 @@ function ytcg_rss_markup($instance){
|
|
302 |
'theme' => 'dark',
|
303 |
), $atts ) );
|
304 |
|
305 |
-
$instance['
|
306 |
|
307 |
-
$instance['
|
308 |
-
$instance['
|
309 |
-
$instance['
|
310 |
-
$instance['
|
311 |
-
$instance['
|
312 |
-
$instance['
|
313 |
|
314 |
|
315 |
-
|
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 |
?>
|