Youtube Channel Gallery - Version 1.4.6

Version Description

  • Tweak on CSS.
  • Trying to to correct issue that some users have with the player origin parameter.
Download this release

Release Info

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

Code changes from version 1.5.2 to 1.4.6

Files changed (6) hide show
  1. admin-script.js +0 -15
  2. admin-styles.css +0 -6
  3. readme.txt +5 -1
  4. scripts.js +10 -18
  5. uninstall.php +0 -7
  6. youtube-channel-gallery.php +128 -315
admin-script.js DELETED
@@ -1,15 +0,0 @@
1
- jQuery(document).ready(function($) {
2
- $('.edit-player-options').live('click',function(){
3
- $(".player-options-select").slideToggle("fast");
4
- });
5
-
6
-
7
- $('.edit-thumbnails-options').live('click',function(){
8
- $(".thumbnails-options-select").slideToggle("fast");
9
- });
10
-
11
-
12
- $('.edit-link-options').live('click',function(){
13
- $(".link-options-select").slideToggle("fast");
14
- });
15
- });
admin-styles.css DELETED
@@ -1,6 +0,0 @@
1
- fieldset{
2
- border-radius: 5px;
3
- background: #F3F3F3;
4
- border: 1px solid #DFDFDF;
5
- padding: 10px
6
- }
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.5.2
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.5 =
85
* Tweaks on CSS.
86
* Now the CSS and JS files are loaded only on the page in which appears the plugin.
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.6
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.6 =
85
+ * Tweak on CSS.
86
+ * Trying to to correct issue that some users have with the player origin parameter.
87
+
88
= 1.4.5 =
89
* Tweaks on CSS.
90
* Now the CSS and JS files are loaded only on the page in which appears the plugin.
scripts.js CHANGED
@@ -1,25 +1,17 @@
1
var ytcplayer = {};
2
3
- function ytcplayVideo (e, iframeid, youtubeid) {
4
- if (!e) var e = window.event;
5
- try {
6
7
- if(iframeid in ytcplayer) {
8
- ytcplayer[iframeid].loadVideoById(youtubeid);
9
- }else{
10
- ytcplayer[iframeid] = new YT.Player(iframeid, {
11
- events: {
12
- 'onReady': function(){
13
- ytcplayer[iframeid].loadVideoById(youtubeid);
14
- }
15
}
16
- });
17
- }
18
- e.preventDefault();
19
- }
20
-
21
- catch (err) {
22
- console.log('error with API. Try unchecking extra security option in the widget options')
23
}
24
25
}
1
var ytcplayer = {};
2
3
+ function ytcplayVideo (iframeid, youtubeid) {
4
5
+ if(iframeid in ytcplayer) {
6
+ ytcplayer[iframeid].loadVideoById(youtubeid);
7
+ }else{
8
+ ytcplayer[iframeid] = new YT.Player(iframeid, {
9
+ events: {
10
+ 'onReady': function(){
11
+ ytcplayer[iframeid].loadVideoById(youtubeid);
12
}
13
+ }
14
+ });
15
}
16
17
}
uninstall.php DELETED
@@ -1,7 +0,0 @@
1
- <?php
2
- if( !defined( ‘WP_UNINSTALL_PLUGIN’ ) )
3
- exit ();
4
-
5
- // Delete options
6
- delete_option( 'YoutubeChannelGallery_Widget' );
7
- ?>
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.5.2
9
License: GPL2
10
11
Copyright 2010 Javier Gómez Pose (email : javierpose@gmail.com)
@@ -40,9 +40,6 @@ class YoutubeChannelGallery_Widget extends WP_Widget {
40
load_plugin_textdomain('youtube-channel-gallery', false, dirname(plugin_basename( __FILE__ ) ) . '/languages/' );
41
add_shortcode('Youtube_Channel_Gallery', array($this, 'YoutubeChannelGallery_Shortcode'));
42
43
- //load admin scripts
44
- add_action('admin_print_scripts', array($this, 'register_admin_scripts_and_styles'));
45
-
46
parent::__construct(
47
'youtubechannelgallery_widget', // Base ID
48
__( 'Youtube Channel Gallery', 'youtube-channel-gallery' ), // Name
@@ -58,7 +55,6 @@ class YoutubeChannelGallery_Widget extends WP_Widget {
58
// Load JavaScript and stylesheets
59
$this->register_scripts_and_styles();
60
61
-
62
extract( $args );
63
$title = apply_filters( 'widget_title', $instance['title'] );
64
@@ -66,7 +62,7 @@ class YoutubeChannelGallery_Widget extends WP_Widget {
66
if ( ! empty( $title ) )
67
echo $before_title . $title . $after_title;
68
69
- echo $this->ytchag_rss_markup($instance);
70
71
echo $after_widget;
72
}
@@ -78,24 +74,13 @@ class YoutubeChannelGallery_Widget extends WP_Widget {
78
$instance = $old_instance;
79
$instance['title'] = strip_tags( $new_instance['title'] );
80
$instance['ytchag_user'] = strip_tags( $new_instance['ytchag_user'] );
81
-
82
- // Player options
83
- $instance['ytchag_video_width'] = strip_tags( $new_instance['ytchag_video_width'] );
84
- $instance['ytchag_ratio'] = strip_tags( $new_instance['ytchag_ratio'] );
85
- $instance['ytchag_theme'] = strip_tags( $new_instance['ytchag_theme'] );
86
- $instance['ytchag_color'] = strip_tags( $new_instance['ytchag_color'] );
87
- $instance['ytchag_autoplay'] = strip_tags( $new_instance['ytchag_autoplay'] );
88
- $instance['ytchag_rel'] = strip_tags( $new_instance['ytchag_rel'] );
89
- $instance['ytchag_showinfo'] = ( isset( $new_instance['ytchag_showinfo'] ) ? 0 : 1 );
90
- $instance['ytchag_origin'] = strip_tags( $new_instance['ytchag_origin'] );
91
-
92
- // Thumbnail options
93
$instance['ytchag_maxitems'] = strip_tags( $new_instance['ytchag_maxitems'] );
94
$instance['ytchag_thumb_width'] = strip_tags( $new_instance['ytchag_thumb_width'] );
95
- $instance['ytchag_link_tx'] = strip_tags( $new_instance['ytchag_link_tx'] );
96
-
97
- // Link options
98
- $instance['ytchag_link'] = $new_instance['ytchag_link'];
99
100
return $instance;
101
}
@@ -106,28 +91,13 @@ class YoutubeChannelGallery_Widget extends WP_Widget {
106
public function form( $instance ) {
107
$title = esc_attr($instance['title']);
108
$ytchag_user = strip_tags($instance['ytchag_user']);
109
-
110
- // Player options
111
- $ytchag_video_width = strip_tags($instance['ytchag_video_width']);
112
- $ytchag_ratio = strip_tags($instance['ytchag_ratio']);
113
- $ytchag_theme = strip_tags($instance['ytchag_theme']);
114
- $ytchag_color = strip_tags($instance['ytchag_color']);
115
- $ytchag_autoplay = strip_tags($instance['ytchag_autoplay']);
116
- $ytchag_rel = strip_tags($instance['ytchag_rel']);
117
- $ytchag_showinfo = strip_tags($instance['ytchag_showinfo']);
118
- $ytchag_origin = strip_tags($instance['ytchag_origin']);
119
-
120
- // Thumbnails options
121
$ytchag_maxitems = strip_tags($instance['ytchag_maxitems']);
122
$ytchag_thumb_width = strip_tags($instance['ytchag_thumb_width']);
123
- $ytchag_link_tx = strip_tags($instance['ytchag_link_tx']);
124
-
125
- // Link options
126
- $ytchag_link = esc_attr($instance['ytchag_link']);
127
-
128
?>
129
-
130
-
131
<p>
132
<label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php _e( 'Title:', 'youtube-channel-gallery' ); ?></label>
133
<input class="widefat" id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" type="text" value="<?php echo esc_attr( $title ); ?>" />
@@ -137,113 +107,39 @@ class YoutubeChannelGallery_Widget extends WP_Widget {
137
<label for="<?php echo $this->get_field_id( 'ytchag_user' ); ?>"><?php _e( 'YouTube user name:', 'youtube-channel-gallery' ); ?></label>
138
<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 ); ?>" />
139
</p>
140
-
141
<p>
142
- <a class="edit-player-options hide-if-no-js">Change player options...</a>
143
- <fieldset class="player-options-select" style="display: none; ">
144
- <legend >Player options:</legend>
145
-
146
- <p>
147
- <label for="ytchag_video_width"><?php _e( 'Video width:', 'youtube-channel-gallery' ); ?></label>
148
- <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 ); ?>" />
149
- </p>
150
-
151
- <p>
152
-
153
- <label for="ytchag_ratio"><?php _e( 'Aspect ratio:', 'youtube-channel-gallery' ); ?></label>
154
- <select class="widefat" id="<?php echo $this->get_field_id( 'ytchag_ratio' ); ?>" name="<?php echo $this->get_field_name( 'ytchag_ratio' ); ?>">
155
- <option value="4x3"<?php selected( $instance['ytchag_ratio'], '4x3' ); ?>><?php _e( 'Standard (4x3)', 'youtube-channel-gallery' ); ?></option>
156
- <option value="16x9"<?php selected( $instance['ytchag_ratio'], '16x9' ); ?>><?php _e( 'Widescreen (16x9)', 'youtube-channel-gallery' ); ?></option>
157
- </select>
158
- </p>
159
-
160
- <p>
161
-
162
- <label for="ytchag_theme"><?php _e( 'Theme:', 'youtube-channel-gallery' ); ?></label>
163
- <select class="widefat" id="<?php echo $this->get_field_id( 'ytchag_theme' ); ?>" name="<?php echo $this->get_field_name( 'ytchag_theme' ); ?>">
164
- <option value="dark"<?php selected( $instance['ytchag_theme'], 'dark' ); ?>><?php _e( 'Dark', 'youtube-channel-gallery' ); ?></option>
165
- <option value="light"<?php selected( $instance['ytchag_theme'], 'light' ); ?>><?php _e( 'Light', 'youtube-channel-gallery' ); ?></option>
166
- </select>
167
- </p>
168
-
169
- <p>
170
-
171
- <label for="ytchag_color"><?php _e( 'Progress bar color:', 'youtube-channel-gallery' ); ?></label>
172
- <select class="widefat" id="<?php echo $this->get_field_id( 'ytchag_color' ); ?>" name="<?php echo $this->get_field_name( 'ytchag_color' ); ?>">
173
- <option value="red"<?php selected( $instance['ytchag_color'], 'red' ); ?>><?php _e( 'Red', 'youtube-channel-gallery' ); ?></option>
174
- <option value="white"<?php selected( $instance['ytchag_color'], 'white' ); ?>><?php _e( 'White', 'youtube-channel-gallery' ); ?></option>
175
- </select>
176
- </p>
177
-
178
- <input class="checkbox" type="checkbox" <?php checked( (bool) $instance['ytchag_autoplay'], true ); ?> id="<?php echo $this->get_field_id( 'ytchag_autoplay' ); ?>" name="<?php echo $this->get_field_name( 'ytchag_autoplay' ); ?>" />
179
- <label for="<?php echo $this->get_field_id( 'ytchag_autoplay' ); ?>"><?php _e('Autoplay', 'youtube-channel-gallery'); ?></label>
180
-
181
- <br>
182
-
183
- <input class="checkbox" type="checkbox" <?php checked( (bool) $instance['ytchag_rel'], true ); ?> id="<?php echo $this->get_field_id( 'ytchag_rel' ); ?>" name="<?php echo $this->get_field_name( 'ytchag_rel' ); ?>" />
184
- <label for="<?php echo $this->get_field_id( 'ytchag_rel' ); ?>"><?php _e('Show related videos', 'youtube-channel-gallery'); ?></label>
185
-
186
- <br>
187
-
188
- <input class="checkbox" type="checkbox" <?php checked( (bool) $instance['ytchag_showinfo'], false ); ?> id="<?php echo $this->get_field_id( 'ytchag_showinfo' ); ?>" name="<?php echo $this->get_field_name( 'ytchag_showinfo' ); ?>" />
189
- <label for="<?php echo $this->get_field_id( 'ytchag_showinfo' ); ?>"><?php _e('Show info (title, uploader)', 'youtube-channel-gallery'); ?></label>
190
-
191
- <br>
192
-
193
- <input class="checkbox" type="checkbox" <?php checked( (bool) $instance['ytchag_origin'], true ); ?> id="<?php echo $this->get_field_id( 'ytchag_origin' ); ?>" name="<?php echo $this->get_field_name( 'ytchag_origin' ); ?>" />
194
- <label for="<?php echo $this->get_field_id( 'ytchag_origin' ); ?>"><?php _e('Extra security (Uncheck if it does not work properly)', 'youtube-channel-gallery'); ?></label>
195
-
196
-
197
- </fieldset>
198
</p>
199
-
200
-
201
-
202
<p>
203
- <a class="edit-thumbnails-options hide-if-no-js">Change thumbnails options...</a>
204
- <fieldset class="thumbnails-options-select" style="display: none; ">
205
- <legend >Thumbnails options:</legend>
206
-
207
208
- <p>
209
- <label for="ytchag_maxitems"><?php _e( 'Number of videos to show:', 'youtube-channel-gallery' ); ?></label>
210
- <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 ); ?>" />
211
- </p>
212
-
213
- <p>
214
- <label for="ytchag_thumb_width"><?php _e( 'Thumbnail width:', 'youtube-channel-gallery' ); ?></label>
215
- <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 ); ?>" />
216
- </p>
217
-
218
- <p>
219
- <label for="ytchag_link_tx"><?php _e( 'Thumbnail columns:', 'youtube-channel-gallery' ); ?></label>
220
- <input class="widefat" id="<?php echo $this->get_field_id( 'ytchag_link_tx' ); ?>" name="<?php echo $this->get_field_name( 'ytchag_link_tx' ); ?>" type="text" value="<?php echo esc_attr( $ytchag_link_tx ); ?>" />
221
- </p>
222
-
223
- </fieldset>
224
</p>
225
226
-
227
-
228
<p>
229
- <a class="edit-link-options hide-if-no-js">Change link options...</a>
230
- <fieldset class="link-options-select" style="display: none; ">
231
- <legend >Thumbnails options:</legend>
232
-
233
-
234
- <p>
235
- <label for="ytchag_link_tx"><?php _e( 'Link text:', 'youtube-channel-gallery' ); ?></label>
236
- <input class="widefat" id="<?php echo $this->get_field_id( 'ytchag_link_tx' ); ?>" name="<?php echo $this->get_field_name( 'ytchag_link_tx' ); ?>" type="text" value="<?php echo esc_attr( $ytchag_link_tx ); ?>" />
237
- </p>
238
-
239
- <p>
240
- <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' ); ?>" />
241
- <label for="<?php echo $this->get_field_id( 'ytchag_link' ); ?>"><?php _e('Show link to channel', 'youtube-channel-gallery'); ?></label>
242
- </p>
243
-
244
- </fieldset>
245
- </p>
246
-
247
248
<?php
249
}
@@ -255,149 +151,112 @@ class YoutubeChannelGallery_Widget extends WP_Widget {
255
private function ytchag_rss_markup($instance){
256
257
//$instance variables
258
- //----------------
259
- $ytchag_user = apply_filters('ytchag_user', $instance['ytchag_user']);
260
-
261
- // Player options
262
- $ytchag_video_width = apply_filters('ytchag_video_width', $instance['ytchag_video_width']);
263
- $ytchag_ratio = apply_filters('ytchag_ratio', $instance['ytchag_ratio']);
264
- $ytchag_theme = apply_filters('ytchag_theme', $instance['ytchag_theme']);
265
- $ytchag_color = apply_filters('ytchag_color', $instance['ytchag_color']);
266
- $ytchag_autoplay = apply_filters('ytchag_autoplay', $instance['ytchag_autoplay']);
267
- $ytchag_rel = apply_filters('ytchag_rel', $instance['ytchag_rel']);
268
- $ytchag_showinfo = apply_filters('ytchag_showinfo', $instance['ytchag_showinfo']);
269
- $ytchag_origin = apply_filters('ytchag_origin', $instance['ytchag_origin']);
270
-
271
- // Thumbnail options
272
- $ytchag_maxitems = apply_filters('ytchag_maxitems', $instance['ytchag_maxitems']);
273
- $ytchag_thumb_width = apply_filters('ytchag_thumb_width', $instance['ytchag_thumb_width']);
274
- $ytchag_link_tx = apply_filters('ytchag_link_tx', $instance['ytchag_link_tx']);
275
- $ytchag_link_tx = apply_filters('ytchag_link_tx', $instance['ytchag_link_tx']);
276
-
277
- // Link options
278
- $ytchag_link = apply_filters('ytchag_link', $instance['ytchag_link']);
279
-
280
- //end $instance variables
281
282
//defaults
283
- //----------------
284
- // Player options
285
- $ytchag_video_width = ( $ytchag_video_width ) ? $ytchag_video_width : 250;
286
- $ytchag_theme = ( $ytchag_theme ) ? '&theme='. $ytchag_theme : '';
287
- $ytchag_color = ( $ytchag_color ) ? '&color='. $ytchag_color : '';
288
- $ytchag_autoplay = ( $ytchag_autoplay ) ? '&autoplay=1' : '';
289
- $ytchag_rel = ( $ytchag_rel ) ? '' : '&rel=0';
290
- $ytchag_showinfo = ( $ytchag_showinfo ) ? '&showinfo=0' : '';
291
- $ytchag_origin = ( $ytchag_origin ) ? '&origin='. site_url() : '';
292
-
293
- // Thumbnail options
294
- $ytchag_thumb_width = ( $ytchag_thumb_width ) ? $ytchag_thumb_width : 85;
295
- $ytchag_link_tx = ( $ytchag_link_tx ) ? $ytchag_link_tx : 0;
296
- $ytchag_link_tx = ( $ytchag_link_tx ) ? $ytchag_link_tx : __('Show more videos»', 'youtube-channel-gallery');
297
-
298
- //end defaults
299
-
300
-
301
302
//heights of video and thumbnail
303
- if ($ytchag_ratio == '16x9') {
304
- $ytchag_video_heigh = round( ($ytchag_video_width * 9) / 16);
305
- } else {
306
- $ytchag_video_heigh = round( ($ytchag_video_width * 3) / 4);
307
- }
308
-
309
$ytchag_thumb_height = $ytchag_thumb_width*75/100; // 75% 'cos sizes of thumbnail in xml file are 480x360 and 120x90
310
311
if( $ytchag_user ) { // only if user name inserted
312
313
// links
314
- $ytchag_rss_url = "http://gdata.youtube.com/feeds/api/users/" . $ytchag_user . "/uploads";
315
$ytchag_link_url = "http://www.youtube.com/user/" . $ytchag_user;
316
317
- if ( file_get_contents($ytchag_rss_url) == '' ) { // check if correct user name
318
-
319
- $content.= '<p class="empty">' . __('You must insert a valid YouTube user name.', 'youtube-channel-gallery') . '</p>';
320
321
- } else{
322
-
323
- //RSS Feed
324
-
325
- include_once(ABSPATH . WPINC . '/feed.php');
326
-
327
- $rss = fetch_feed($ytchag_rss_url);
328
- $maxitems = ( $ytchag_maxitems ) ? $ytchag_maxitems : 9;
329
- $items = $rss->get_items(0, $maxitems);
330
-
331
-
332
- if (!empty($items)) {
333
- $i = 0;
334
- $column = 0;
335
- foreach ( $items as $item ) {
336
337
- $url = $item->get_permalink();
338
- $youtubeid = $this->youtubeid($url);
339
- $title = $item->get_title();
340
341
- if ($enclosure = $item->get_enclosure()){
342
343
- //extract thumbnail
344
- //-----------------
345
346
- //thumbnail index in xml
347
- $big = 0;
348
- $small = 1;
349
- $size = $small;
350
- if($ytchag_thumb_width > '120'){
351
- $size = $big;
352
- }
353
354
- $allThumbs = $enclosure->get_thumbnails();
355
- foreach ($allThumbs as $index => $allThumb) {
356
- if ($index == $size) {
357
- $thumb = $allThumbs[$index];
358
- }
359
- }
360
}
361
362
- //Show the player: iframe player
363
- if($i == 0) {
364
- //count the plugin occurrences on page
365
- STATIC $plugincount = 0;
366
- $plugincount++;
367
-
368
- $content = '<iframe id="ytcplayer' . $plugincount . '" class="ytcplayer" allowfullscreen width="' . $ytchag_video_width . '" height="' . $ytchag_video_heigh . '" src="http://www.youtube.com/embed/' . $youtubeid . '?version=3' . $ytchag_theme . $ytchag_color . $ytchag_autoplay . $ytchag_rel . $ytchag_showinfo . $ytchag_origin .'&enablejsapi=1" frameborder="0"></iframe>';
369
- $content.= '<ul class="ytchagallery">';
370
-
371
-
372
- } // if player end
373
- $i++;
374
-
375
- $column++;
376
-
377
- // list of thumbnail videos
378
- $content.= '<li class="ytccell-' . $column . '">';
379
- $content.= '<a class="ytcthumb" href="http://www.youtube.com/watch?v=' . $youtubeid . '" target="_blank" onclick="ytcplayVideo(event, \'ytcplayer' . $plugincount . '\', \'' . $youtubeid . '\');" alt="' . $title . '" title="' . $title . '" style="background-image: url(' . $thumb . ');">';
380
- $content.= '<div class="ytcplay" style="width: ' . $ytchag_thumb_width . 'px; height: ' . $ytchag_thumb_height . 'px"></div></a></li>';
381
-
382
-
383
- if($ytchag_link_tx !=0 && $column%$ytchag_link_tx === 0){
384
- $column = 0;
385
}
386
- } //foreach end
387
-
388
- $content.= '</ul>';
389
-
390
- //link to youtube.com gallery
391
- if( $ytchag_link) {
392
- $content.= '<a href="' . $ytchag_link_url . '" class="more">' . $ytchag_link_tx . '</a>';
393
}
394
- }
395
396
}
397
} else {
398
- $content.= '<p class="empty">' . __('You must insert a YouTube user name.', 'youtube-channel-gallery') . '</p>';
399
}
400
- return $content;
401
}//ytchag_rss_markup
402
403
//parse youtube url to extract id
@@ -415,17 +274,6 @@ class YoutubeChannelGallery_Widget extends WP_Widget {
415
wp_enqueue_style('youtube-channel-gallery', plugins_url('/styles.css', __FILE__), false, false, 'all');
416
}//register_scripts_and_styles
417
418
-
419
- public function register_admin_scripts_and_styles($hook) {
420
- // load in admin > widgets.php
421
- //if( 'widgets.php' != $hook )
422
- // return;
423
- wp_enqueue_script('youtube-channel-gallery', plugins_url('/admin-script.js', __FILE__), false, false, true);
424
- wp_enqueue_style('youtube-channel-gallery', plugins_url('/admin-styles.css', __FILE__), false, false, 'all');
425
- }
426
-
427
-
428
-
429
/*--------------------------------------------------*/
430
/* Shortcode
431
/*--------------------------------------------------*/
@@ -437,49 +285,25 @@ class YoutubeChannelGallery_Widget extends WP_Widget {
437
438
extract( shortcode_atts( array(
439
'user' => '',
440
-
441
- // Player options
442
- 'videowidth' => '250',
443
- 'ratio' => '',
444
- 'theme' => '',
445
- 'color' => '',
446
- 'autoplay' => '',
447
- 'rel' => '',
448
- 'showinfo' => '',
449
- 'origin' => '',
450
-
451
- // Thumbnail options
452
'maxitems' => '9',
453
'thumbwidth' => '85',
454
'thumbcolumns' => '0',
455
- 'link' => '',
456
- 'link_tx' => ''
457
-
458
), $atts ) );
459
460
$instance['ytchag_user'] = $user;
461
-
462
- // Player options
463
- $instance['ytchag_video_width'] = $videowidth;
464
- $instance['ytchag_ratio'] = $ratio;
465
- $instance['ytchag_theme'] = $theme;
466
- $instance['ytchag_color'] = $color;
467
- $instance['ytchag_autoplay'] = $autoplay;
468
- $instance['ytchag_rel'] = $rel;
469
- $instance['ytchag_showinfo'] = $showinfo;
470
- $instance['ytchag_origin'] = $origin;
471
-
472
- // Thumbnail options
473
$instance['ytchag_maxitems'] = $maxitems;
474
$instance['ytchag_thumb_width'] = $thumbwidth;
475
- $instance['ytchag_link_tx'] = $thumbcolumns;
476
-
477
- // Link options
478
- $instance['ytchag_link'] = $link;
479
- $instance['ytchag_link_tx'] = $link_tx;
480
481
482
- return $this->ytchag_rss_markup($instance);
483
484
} // YoutubeChannelGallery_Shortcode
485
@@ -489,16 +313,5 @@ class YoutubeChannelGallery_Widget extends WP_Widget {
489
// register YoutubeChannelGallery_Widget widget
490
add_action( 'widgets_init', create_function( '', 'register_widget( "YoutubeChannelGallery_Widget" );' ) );
491
492
- //check valid user name
493
- //correct bug in shortcode position
494
- //correct css hover thumbnails
495
- //added new fields to control other Youtube player options
496
- //Added video url on thumbnails to improve link syntax, accessibility and SEO
497
- //Redesign of widget interface for managing so many fields
498
- //improved control of height player
499
- //improved error handling in javascript. Now, if the API fails it uses the link to Youtube
500
- //added field to customize the text link to youtube
501
-
502
503
- //uninstall
504
- ?>
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.6
9
License: GPL2
10
11
Copyright 2010 Javier Gómez Pose (email : javierpose@gmail.com)
40
load_plugin_textdomain('youtube-channel-gallery', false, dirname(plugin_basename( __FILE__ ) ) . '/languages/' );
41
add_shortcode('Youtube_Channel_Gallery', array($this, 'YoutubeChannelGallery_Shortcode'));
42
43
parent::__construct(
44
'youtubechannelgallery_widget', // Base ID
45
__( 'Youtube Channel Gallery', 'youtube-channel-gallery' ), // Name
55
// Load JavaScript and stylesheets
56
$this->register_scripts_and_styles();
57
58
extract( $args );
59
$title = apply_filters( 'widget_title', $instance['title'] );
60
62
if ( ! empty( $title ) )
63
echo $before_title . $title . $after_title;
64
65
+ $this->ytchag_rss_markup($instance);
66
67
echo $after_widget;
68
}
74
$instance = $old_instance;
75
$instance['title'] = strip_tags( $new_instance['title'] );
76
$instance['ytchag_user'] = strip_tags( $new_instance['ytchag_user'] );
77
+
78
+ $instance['ytchag_link'] = $new_instance['ytchag_link'];
79
$instance['ytchag_maxitems'] = strip_tags( $new_instance['ytchag_maxitems'] );
80
+ $instance['ytchag_video_width'] = strip_tags( $new_instance['ytchag_video_width'] );
81
$instance['ytchag_thumb_width'] = strip_tags( $new_instance['ytchag_thumb_width'] );
82
+ $instance['ytchag_thumb_columns'] = strip_tags( $new_instance['ytchag_thumb_columns'] );
83
+ $instance['ytchag_theme'] = strip_tags( $new_instance['ytchag_theme'] );
84
85
return $instance;
86
}
91
public function form( $instance ) {
92
$title = esc_attr($instance['title']);
93
$ytchag_user = strip_tags($instance['ytchag_user']);
94
+ $ytchag_link = esc_attr($instance['ytchag_link']);
95
$ytchag_maxitems = strip_tags($instance['ytchag_maxitems']);
96
+ $ytchag_video_width = strip_tags($instance['ytchag_video_width']);
97
$ytchag_thumb_width = strip_tags($instance['ytchag_thumb_width']);
98
+ $ytchag_thumb_columns = strip_tags($instance['ytchag_thumb_columns']);
99
+ $ytchag_theme = strip_tags($instance['ytchag_theme']);
100
?>
101
<p>
102
<label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php _e( 'Title:', 'youtube-channel-gallery' ); ?></label>
103
<input class="widefat" id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" type="text" value="<?php echo esc_attr( $title ); ?>" />
107
<label for="<?php echo $this->get_field_id( 'ytchag_user' ); ?>"><?php _e( 'YouTube user name:', 'youtube-channel-gallery' ); ?></label>
108
<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 ); ?>" />
109
</p>
110
+
111
<p>
112
+ <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' ); ?>" />
113
+ <label for="<?php echo $this->get_field_id( 'ytchag_link' ); ?>"><?php _e('Show link to channel:', 'youtube-channel-gallery'); ?></label><br />
114
+ </p>
115
+
116
+ <p>
117
+ <label for="ytchag_maxitems"><?php _e( 'Number of videos to show:', 'youtube-channel-gallery' ); ?></label>
118
+ <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 ); ?>" />
119
+ </p>
120
+
121
+ <p>
122
+ <label for="ytchag_video_width"><?php _e( 'Video width:', 'youtube-channel-gallery' ); ?></label>
123
+ <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 ); ?>" />
124
</p>
125
+
126
<p>
127
+ <label for="ytchag_thumb_width"><?php _e( 'Thumbnail width:', 'youtube-channel-gallery' ); ?></label>
128
+ <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 ); ?>" />
129
+ </p>
130
131
+ <p>
132
+ <label for="ytchag_thumb_columns"><?php _e( 'Thumbnail columns:', 'youtube-channel-gallery' ); ?></label>
133
+ <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 ); ?>" />
134
</p>
135
136
<p>
137
+ <label for="ytchag_theme"><?php _e( 'Theme:', 'youtube-channel-gallery' ); ?></label>
138
+ <select class="widefat" id="<?php echo $this->get_field_id( 'ytchag_theme' ); ?>" name="<?php echo $this->get_field_name( 'ytchag_theme' ); ?>">
139
+ <option value="dark"<?php selected( $instance['ytchag_theme'], 'dark' ); ?>><?php _e( 'Dark', 'youtube-channel-gallery' ); ?></option>
140
+ <option value="light"<?php selected( $instance['ytchag_theme'], 'light' ); ?>><?php _e( 'Light', 'youtube-channel-gallery' ); ?></option>
141
+ </select>
142
+ </p>
143
144
<?php
145
}
151
private function ytchag_rss_markup($instance){
152
153
//$instance variables
154
+ $ytchag_user = apply_filters('ytchag_user', $instance['ytchag_user']);
155
+ $ytchag_link = apply_filters('ytchag_link', $instance['ytchag_link']);
156
+ $ytchag_maxitems = apply_filters('ytchag_maxitems', $instance['ytchag_maxitems']);
157
+ $ytchag_video_width = apply_filters('ytchag_video_width', $instance['ytchag_video_width']);
158
+ $ytchag_thumb_width = apply_filters('ytchag_thumb_width', $instance['ytchag_thumb_width']);
159
+ $ytchag_thumb_columns = apply_filters('ytchag_thumb_columns', $instance['ytchag_thumb_columns']);
160
+ $ytchag_theme = apply_filters('ytchag_theme', $instance['ytchag_theme']);
161
162
//defaults
163
+ $ytchag_video_width = ( $ytchag_video_width ) ? $ytchag_video_width : 250;
164
+ $ytchag_thumb_width = ( $ytchag_thumb_width ) ? $ytchag_thumb_width : 85;
165
+ $ytchag_thumb_columns = ( $ytchag_thumb_columns ) ? $ytchag_thumb_columns : 0;
166
+ $ytchag_theme = ( $ytchag_theme ) ? $ytchag_theme : 'dark';
167
168
//heights of video and thumbnail
169
+ $ytchag_video_heigh = round($ytchag_video_width/(16/9) + 32);
170
$ytchag_thumb_height = $ytchag_thumb_width*75/100; // 75% 'cos sizes of thumbnail in xml file are 480x360 and 120x90
171
172
if( $ytchag_user ) { // only if user name inserted
173
174
// links
175
+ $ytchag_rss_url = "http://gdata.youtube.com/feeds/api/users/" . $ytchag_user . "/uploads";
176
$ytchag_link_url = "http://www.youtube.com/user/" . $ytchag_user;
177
178
179
+ //RSS Feed
180
+
181
+ include_once(ABSPATH . WPINC . '/feed.php');
182
+
183
+ $rss = fetch_feed($ytchag_rss_url);
184
+ $maxitems = ( $ytchag_maxitems ) ? $ytchag_maxitems : 9;
185
+ $items = $rss->get_items(0, $maxitems);
186
+
187
188
+ if (!empty($items)) {
189
+ $i = 0;
190
+ $column = 0;
191
+ foreach ( $items as $item ) {
192
193
+ $url = $item->get_permalink();
194
+ $youtubeid = $this->youtubeid($url);
195
+ $title = $item->get_title();
196
197
+ if ($enclosure = $item->get_enclosure()){
198
199
+ //extract thumbnail
200
+ //-----------------
201
202
+ //thumbnail index in xml
203
+ $big = 0;
204
+ $small = 1;
205
+ $size = $small;
206
+ if($ytchag_thumb_width > '120'){
207
+ $size = $big;
208
}
209
210
+ $allThumbs = $enclosure->get_thumbnails();
211
+ foreach ($allThumbs as $index => $allThumb) {
212
+ if ($index == $size) {
213
+ $thumb = $allThumbs[$index];
214
+ }
215
}
216
}
217
218
+ //Show me the player: iframe player
219
+ if($i == 0) {
220
+ //count the plugin occurrences on page
221
+ STATIC $plugincount = 0;
222
+ $plugincount++;
223
+ ?>
224
+ <iframe id="ytcplayer<?php echo $plugincount; ?>" class="ytcplayer" 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 home_url(); ?>" frameborder="0"></iframe>
225
+ <ul class="ytchagallery">
226
+
227
+ <?php
228
+ } // if player end
229
+ $i++;
230
+
231
+ $column++;
232
+ // list of thumbnail videos
233
+ ?>
234
+ <li class="ytccell-<?php echo $column; ?>">
235
+ <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; ?>);">
236
+ <div class="ytcplay" style="width: <?php echo $ytchag_thumb_width; ?>px; height: <?php echo $ytchag_thumb_height; ?>px"></div>
237
+ </a>
238
+ </li>
239
+
240
+ <?php
241
+ if($ytchag_thumb_columns !=0 && $column%$ytchag_thumb_columns === 0){
242
+ $column = 0;
243
+ }
244
+ } //foreach end
245
+ ?>
246
+ </ul>
247
+ <?php
248
+ //link to youtube.com gallery
249
+ if( $ytchag_link) {
250
+ ?>
251
+ <a href="<?php echo $ytchag_link_url ?>" class="more"><?php _e('Show more videos»', 'youtube-channel-gallery') ?></a>
252
+ <?php
253
+ }
254
}
255
} else {
256
+ ?>
257
+ <p class="empty"><?php _e('There is no video to show.', 'youtube-channel-gallery') ?></p>
258
+ <?php
259
}
260
}//ytchag_rss_markup
261
262
//parse youtube url to extract id
274
wp_enqueue_style('youtube-channel-gallery', plugins_url('/styles.css', __FILE__), false, false, 'all');
275
}//register_scripts_and_styles
276
277
/*--------------------------------------------------*/
278
/* Shortcode
279
/*--------------------------------------------------*/
285
286
extract( shortcode_atts( array(
287
'user' => '',
288
+ 'link' => '0',
289
'maxitems' => '9',
290
+ 'videowidth' => '280',
291
'thumbwidth' => '85',
292
'thumbcolumns' => '0',
293
+ 'theme' => 'dark',
294
), $atts ) );
295
296
$instance['ytchag_user'] = $user;
297
+
298
+ $instance['ytchag_link'] = $link;
299
$instance['ytchag_maxitems'] = $maxitems;
300
+ $instance['ytchag_video_width'] = $videowidth;
301
$instance['ytchag_thumb_width'] = $thumbwidth;
302
+ $instance['ytchag_thumb_columns'] = $thumbcolumns;
303
+ $instance['ytchag_theme'] = $theme;
304
305
306
+ $this->ytchag_rss_markup($instance);
307
308
} // YoutubeChannelGallery_Shortcode
309
313
// register YoutubeChannelGallery_Widget widget
314
add_action( 'widgets_init', create_function( '', 'register_widget( "YoutubeChannelGallery_Widget" );' ) );
315
316
317
+ ?>