YouTube Channel - Version 0.1.0

Version Description

  • Initial release

=

Download this release

Release Info

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

Version 0.1.0

Files changed (6) hide show
  1. chromeless.swf +0 -0
  2. readme.txt +76 -0
  3. screenshot-1.png +0 -0
  4. screenshot-2.png +0 -0
  5. screenshot-3.png +0 -0
  6. youtube-channel.php +196 -0
chromeless.swf ADDED
Binary file
readme.txt ADDED
@@ -0,0 +1,76 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ === YouTube Channel ===
2
+ Contributors: urkekg
3
+ Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=Q6Q762MQ97XJ6
4
+ Tags: youtube, channel, widget, widgets, youtube player, flash player, rss, feed, video, thumbnail, embed, sidebar, chromeless
5
+ Requires at least: 3.0
6
+ Tested up to: 3.1
7
+ Stable tag: 0.1.0
8
+
9
+ Sidebar widget that display latest video thumbnail, playable flash object or chromeless video from YouTube Channel.
10
+
11
+ == Description ==
12
+
13
+ When you need to display sidebar widget with latest video from some YouTube channel, you can use customisable `YouTube Channel` plugin.
14
+
15
+ Simply insert widget to sidebar, set channel name and if you wish leave all options on default. You will get latesat video from chosen YouTube channel embedded in sidebar widget, with link to channel on bottom of the widget.
16
+
17
+ If you like this extension and you find it useful, please rate it on the right side.
18
+
19
+ = Features =
20
+ * Display latest video from YouTube channel
21
+ * Set custom widget title
22
+ * Display or hide video title on the top of video
23
+ * Custom set of width and height of video thumbnail/embeded object (default 220x165 px)
24
+ * Preferred aspect ratio relative to width (custom, 4:3, 16:10 and 16:9)
25
+ * Choose to display video thumbnail, old YouTube embed, new YouTube embed or chromeless video
26
+ * Fix height for old and new YouTube embed and Chromeless video object taken by controls
27
+ * Option to enable autoplay chromeless video
28
+ * Option to show chromeless controls
29
+ * Set custom text for link to channel
30
+ * Display or hide link to channel
31
+
32
+ = Credits =
33
+ Chromeless option borrowed from [Chromeless YouTube](http://wordpress.org/extend/plugins/chromeless-youtube/) extension.
34
+
35
+ == Installation ==
36
+ = Manual =
37
+ 1. Upload the entire `youtube-channel` folder to the `/wp-content/plugins/` directory.
38
+ 1. Activate the plugin through the `Plugins` menu in WordPress.
39
+ 1. Insert new widget on `Appearance` → `Widgets`.
40
+ 1. Set YouTube channel in proper widget field.
41
+
42
+ = Automatic =
43
+ 1. Go to `Plugins` → `Add New` and search for `youtube-channel`.
44
+ 1. Click on `Install Now` link bellow `YouTube Channel` search result and aswer `Yes` on popup question.
45
+ 1. If you need enter FTP parameters for your host and click on `Proceed`.
46
+ 1. Activate the plugin through the `Plugins` menu in WordPress.
47
+ 1. Insert new widget on `Appearance` → `Widgets`.
48
+ 1. Set YouTube channel in proper widget field.
49
+
50
+ == TODO ==
51
+
52
+ * Enable translations
53
+ * Option to force display of HD video (useless for small sized video?)
54
+ * Add option to show more than one (and how much) latest videos
55
+
56
+ == Frequently Asked Questions ==
57
+
58
+ = Why yet another YouTube widget extension? =
59
+
60
+ I could not to find widget with link to channel and thumbnail instead of video object, so I made this one.
61
+
62
+ == Changelog ==
63
+
64
+ = 0.1.0 =
65
+ * Initial release
66
+
67
+ == Upgrade Notice ==
68
+
69
+ = 0.1.0 =
70
+ Just try it and rate it. Only initial release is available right now.
71
+
72
+ == Screenshots ==
73
+
74
+ 1. Widget configuration panel
75
+ 2. Widget `YouTube Channel` in action with Chromeless video w/o controls
76
+ 3. Widget `YouTube Channel` in action with New YouTube embed and fixed height
screenshot-1.png ADDED
Binary file
screenshot-2.png ADDED
Binary file
screenshot-3.png ADDED
Binary file
youtube-channel.php ADDED
@@ -0,0 +1,196 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ Plugin Name: YouTube Channel
4
+ Plugin URI: http://blog.urosevic.net/wordpress/youtubet-channel/
5
+ Description: <a href="widgets.php">Widget</a> that display latest video thumbnail, playable flash object or chromeless video from YouTube Channel.
6
+ Author: Aleksandar Urošević
7
+ Version: 0.1.0
8
+ Author URI: http://urosevic.net/
9
+ */
10
+
11
+ /* youtube widget */
12
+ class YouTube_Channel_Widget extends WP_Widget {
13
+ function YouTube_Channel_Widget() {
14
+ // widget actual processes
15
+ parent::WP_Widget(false, $name = 'YouTube Channel');
16
+ }
17
+
18
+ function form($instance) {
19
+ // outputs the options form on admin
20
+ $title = esc_attr($instance['title']);
21
+ $channel = esc_attr($instance['channel']);
22
+ $goto_txt = esc_attr($instance['goto_txt']);
23
+ $goto_show = esc_attr($instance['goto_show']);
24
+ $title_show = esc_attr($instance['title_show']);
25
+ $width = esc_attr($instance['width']);
26
+ $height = esc_attr($instance['height']);
27
+ $to_show = esc_attr($instance['to_show']);
28
+ $autoplay = esc_attr($instance['autoplay']);
29
+ $ccontrol = esc_attr($instance['ccontrol']);
30
+ $ratio = esc_attr($instance['ratio']);
31
+ $fixyt = esc_attr($instance['fixyt']);
32
+ ?>
33
+ <p><label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Widget Title:'); ?><input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo $title; ?>" /></label></p>
34
+ <p><label for="<?php echo $this->get_field_id('channel'); ?>"><?php _e('Channel:'); ?> <input class="widefat" id="<?php echo $this->get_field_id('channel'); ?>" name="<?php echo $this->get_field_name('channel'); ?>" type="text" value="<?php echo $channel; ?>" /></label></p>
35
+ <p><input class="checkbox" type="checkbox" <?php checked( (bool) $instance['title_show'], true ); ?> id="<?php echo $this->get_field_id( 'title_show' ); ?>" name="<?php echo $this->get_field_name( 'title_show' ); ?>" /> <label for="<?php echo $this->get_field_id( 'title_show' ); ?>"><?php _e('Show video title'); ?></label></p>
36
+ <p><label for="<?php echo $this->get_field_id('width'); ?>"><?php _e('Width'); ?> (<?php _e('default'); ?> 220):<input class="widefat" id="<?php echo $this->get_field_id('width'); ?>" name="<?php echo $this->get_field_name('width'); ?>" type="text" value="<?php echo $width; ?>" /></label></p>
37
+ <p><label for="<?php echo $this->get_field_id('height'); ?>"><?php _e('Height'); ?> (<?php _e('default'); ?> 165):<input class="widefat" id="<?php echo $this->get_field_id('height'); ?>" name="<?php echo $this->get_field_name('height'); ?>" type="text" value="<?php echo $height; ?>" /></label></p>
38
+ <p><label for="<?php echo $this->get_field_id('to_show'); ?>"><?php _e('Aspect ratio (relative to width):'); ?>
39
+ <select class="widefat" id="<?php echo $this->get_field_id( 'ratio' ); ?>" name="<?php echo $this->get_field_name( 'ratio' ); ?>">
40
+ <option value="0"<?php if ($instance['ratio'] == "0") { echo 'selected="selected"'; } ?>><?php _e('Custom'); ?></option>
41
+ <option value="1"<?php if ($instance['ratio'] == "1") { echo 'selected="selected"'; } ?>>4:3</option>
42
+ <option value="2"<?php if ($instance['ratio'] == "2") { echo 'selected="selected"'; } ?>>16:10</option>
43
+ <option value="3"<?php if ($instance['ratio'] == "3") { echo 'selected="selected"'; } ?>>16:9</option>
44
+ </select>
45
+ </p>
46
+ <p><label for="<?php echo $this->get_field_id('to_show'); ?>"><?php _e('What to show?'); ?>
47
+ <select class="widefat" id="<?php echo $this->get_field_id( 'to_show' ); ?>" name="<?php echo $this->get_field_name( 'to_show' ); ?>">
48
+ <option value="thumbnail"<?php if ($instance['to_show'] == "thumbnail") { echo 'selected="selected"'; } ?>><?php _e('Thumbnail'); ?></option>
49
+ <option value="oldyt"<?php if ($instance['to_show'] == "oldyt") { echo 'selected="selected"'; } ?>><?php _e('Old YouTube embed'); ?></option>
50
+ <option value="newyt"<?php if ($instance['to_show'] == "newyt") { echo 'selected="selected"'; } ?>><?php _e('New YouTube embed'); ?></option>
51
+ <option value="chromeless"<?php if ($instance['to_show'] == "chromeless") { echo 'selected="selected"'; } ?>><?php _e('Chromeless video'); ?></option>
52
+ </select>
53
+ <input class="checkbox" type="checkbox" <?php checked( (bool) $instance['fixyt'], true ); ?> id="<?php echo $this->get_field_id( 'fixyt' ); ?>" name="<?php echo $this->get_field_name( 'fixyt' ); ?>" /> <label for="<?php echo $this->get_field_id( 'fixyt' ); ?>"><?php _e('Fix height taken by controls'); ?></label><br />
54
+ <input class="checkbox" type="checkbox" <?php checked( (bool) $instance['autoplay'], true ); ?> id="<?php echo $this->get_field_id( 'autoplay' ); ?>" name="<?php echo $this->get_field_name( 'autoplay' ); ?>" /> <label for="<?php echo $this->get_field_id( 'autoplay' ); ?>"><?php _e('Autoplay chromeless video'); ?></label><br />
55
+ <input class="checkbox" type="checkbox" <?php checked( (bool) $instance['ccontrol'], true ); ?> id="<?php echo $this->get_field_id( 'ccontrol' ); ?>" name="<?php echo $this->get_field_name( 'ccontrol' ); ?>" /> <label for="<?php echo $this->get_field_id( 'ccontrol' ); ?>"><?php _e('Show chromeless controls'); ?></label></p>
56
+ <p><label for="<?php echo $this->get_field_id('goto_txt'); ?>"><?php _e('Visit YouTube Channel text:'); ?> <input class="widefat" id="<?php echo $this->get_field_id('goto_txt'); ?>" name="<?php echo $this->get_field_name('goto_txt'); ?>" type="text" value="<?php echo $goto_txt; ?>" /></label>
57
+ <input class="checkbox" type="checkbox" <?php checked( (bool) $instance['goto_show'], true ); ?> id="<?php echo $this->get_field_id( 'goto_show' ); ?>" name="<?php echo $this->get_field_name( 'goto_show' ); ?>" /> <label for="<?php echo $this->get_field_id( 'goto_show' ); ?>"><?php _e('Show link to channel'); ?></label></p>
58
+ <?php
59
+ }
60
+
61
+ function update($new_instance, $old_instance) {
62
+ // processes widget options to be saved
63
+ $instance = $old_instance;
64
+ $instance['title'] = strip_tags($new_instance['title']);
65
+ $instance['channel'] = strip_tags($new_instance['channel']);
66
+ $instance['goto_txt'] = strip_tags($new_instance['goto_txt']);
67
+ $instance['goto_show'] = $new_instance['goto_show'];
68
+ $instance['title_show']= $new_instance['goto_show'];
69
+ $instance['width'] = strip_tags($new_instance['width']);
70
+ $instance['height'] = strip_tags($new_instance['height']);
71
+ $instance['to_show'] = strip_tags($new_instance['to_show']);
72
+ $instance['autoplay'] = $new_instance['autoplay'];
73
+ $instance['ccontrl'] = $new_instance['ccontrol'];
74
+ $instance['ratio'] = strip_tags($new_instance['ratio']);
75
+ $instance['fixyt'] = $new_instance['fixyt'];
76
+
77
+ return $instance;
78
+ }
79
+
80
+ function widget($args, $instance) {
81
+ // outputs the content of the widget
82
+ extract( $args );
83
+ $title = apply_filters('widget_title', $instance['title']);
84
+ $channel = $instance['channel'];
85
+ if ( $channel == "" ) { $channel = "urkekg"; }
86
+ $width = $instance['width'];
87
+ if ( $width == "" ) { $width = 220; }
88
+ $ratio = $instance['ratio'];
89
+ if ( $ratio == 1 ) { // 4:3
90
+ $height = round(($width / 4 ) * 3);
91
+ } else if ( $ratio == 2 ) { // 16:10
92
+ $height = round(($width / 16 ) * 10);
93
+ } else if ( $ratio == 3 ) { // 16:9
94
+ $height = round(($width / 16 ) * 9);
95
+ } else { // 0 ili nije postavljeno
96
+ $height = $instance['height'];
97
+ if ( $height == "" ) {
98
+ $height = 165;
99
+ }
100
+ }
101
+
102
+ $to_show = $instance['to_show'];
103
+ if ( $to_show == "" ) { $to_show = "oldyt"; }
104
+ // increase YouTube embed height for 25px taken by controls
105
+ if ( $instance['fixyt'] && ( $to_show == "oldyt" || $to_show == "newyt" || ( $to_show == "chromeless" && $ccontrol ) ) ) {
106
+ $height += 25;
107
+ }
108
+
109
+ $goto_txt = $instance['goto_txt'];
110
+ if ( $goto_txt == "" ) { $goto_txt = __("Visit channel")." $channel"; }
111
+ $goto_show = $instance['goto_show'];
112
+ $title_show = $instance['title_show'];
113
+
114
+ // chromeless autplay and controls
115
+ $autoplay = $instance['autoplay'];
116
+ if ( $autoplay ) { $autoplay = "Yes"; } else { $autoplay = "No"; }
117
+ $ccontrol = $instance['ccontrol'];
118
+ if ( $ccontrol ) { $ccontrol = "Yes"; } else { $ccontrol = "No"; }
119
+
120
+ echo $before_widget;
121
+ if ( $title )
122
+ echo $before_title . $title . $after_title;
123
+ ?>
124
+ <div class="youtube_channel">
125
+ <?php
126
+ include_once(ABSPATH . WPINC . '/rss.php');
127
+
128
+ $rss = fetch_rss('http://gdata.youtube.com/feeds/base/users/'.$channel.'/uploads?alt=rss&v=2&orderby=published&client=ytapi-youtube-profile');
129
+
130
+ if ($rss) { $items = array_slice($rss->items, 0, 1); }
131
+ if (empty($items)) {
132
+ echo "No items";
133
+ } else {
134
+ $item = $items[0];
135
+ $yt_id = split(":", $item['guid']);
136
+ $yt_id = $yt_id[3];
137
+ $yt_thumb = "http://i3.ytimg.com/vi/$yt_id/default.jpg";
138
+ $yt_video = "http://www.youtube.com/watch?v=$yt_id";
139
+ $yt_title = $item['title'];
140
+ $yt_date = $item['pubdate'];
141
+ // $next = $items[1];
142
+ // $next_id = split(":", $next['guid']);
143
+ // $next_id = $yt_id[3];
144
+
145
+ if ( $title_show ) {
146
+ echo "<h3>$yt_title</h3>";
147
+ }
148
+ if ( $to_show == "thumbnail" ) {
149
+ echo <<<EOF
150
+ <a href="$yt_video" title="Watch video $yt_title published on $yt_date"><img src="$yt_thumb" alt="$yt_title" style="width: ${width}px; height: ${height}px; border: 0;" /></a>
151
+ EOF;
152
+ } else if ( $to_show == "chromeless" ) {
153
+ ?>
154
+ <object type="application/x-shockwave-flash" data="<?php echo get_bloginfo('wpurl'); ?>/wp-content/plugins/youtube-channel/chromeless.swf" width="<?php echo $width; ?>" height="<?php echo $height; ?>">
155
+ <param name="flashVars" value="video_source=<?php echo $yt_id; ?>&video_width=<?php echo $width; ?>&video_height=<?php echo $height; ?>&autoplay=<?php echo $autoplay; ?>&youtube_controls=<?php echo $controls; ?>" />
156
+ <param name="quality" value="high" />
157
+ <param name="wmode" value="opaque" />
158
+ <param name="swfversion" value="6.0.65.0" />
159
+ <param name="movie" value="<?php echo get_bloginfo('wpurl'); ?>/wp-content/plugins/youtube-channel/chromeless.swf" />
160
+ </object>
161
+ <?php
162
+ } else if ( $to_show == "newyt" ) {
163
+ echo <<<EOF
164
+ <iframe title="YouTube video player" width="$width" height="$height" src="http://www.youtube.com/embed/$yt_id" frameborder="0" allowfullscreen></iframe>
165
+ EOF;
166
+ } else {
167
+ echo <<<EOF
168
+ <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="$width" height="$height">
169
+ <param name="movie" value="http://www.youtube.com/v/$yt_id&amp;rel=0" />
170
+ <!--[if !IE]>-->
171
+ <object type="application/x-shockwave-flash" data="http://www.youtube.com/v/$yt_id&amp;rel=0" width="$width" height="$height">
172
+ <!--<![endif]-->
173
+ <!--[if !IE]>-->
174
+ </object>
175
+ <!--<![endif]-->
176
+ </object>
177
+ EOF;
178
+ }
179
+
180
+ if ( $goto_show ) {
181
+ ?>
182
+ <p>
183
+ <a href="javascript: window.open('http://www.youtube.com/user/<?php echo $channel; ?>/'); void 0;" title="<?php echo $goto_txt; ?>"><?php echo $goto_txt; ?></a>
184
+ </p>
185
+ <?php
186
+ } // goto_show
187
+ }
188
+ ?>
189
+ </div>
190
+ <?php
191
+ echo $after_widget;
192
+ }
193
+
194
+ }
195
+ add_action('widgets_init', create_function('', 'return register_widget("YouTube_Channel_Widget");'));
196
+ ?>