YouTube Channel - Version 0.1.1

Version Description

  • Fixed option to toggle video title visibility
  • Added option to hide controls for iframe and object videos
  • Added option to hide video info
  • Enabled autostart for iframe and object videos
Download this release

Release Info

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

Code changes from version 0.1.0 to 0.1.1

Files changed (5) hide show
  1. readme.txt +18 -8
  2. screenshot-1.png +0 -0
  3. screenshot-2.png +0 -0
  4. screenshot-3.png +0 -0
  5. youtube-channel.php +83 -76
readme.txt CHANGED
@@ -1,10 +1,10 @@
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
 
@@ -22,12 +22,13 @@ If you like this extension and you find it useful, please rate it on the right s
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.
@@ -61,16 +62,25 @@ I could not to find widget with link to channel and thumbnail instead of video o
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
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, iframe, html5
5
  Requires at least: 3.0
6
  Tested up to: 3.1
7
+ Stable tag: 0.1.1
8
 
9
  Sidebar widget that display latest video thumbnail, playable flash object or chromeless video from YouTube Channel.
10
 
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, iframe (HTML5 video), object embed (Flash video) or chromeless video
26
  * Fix height for old and new YouTube embed and Chromeless video object taken by controls
27
+ * Option to enable autoplay video
28
+ * Option to hide video controls
29
+ * Option to hide video info
30
  * Set custom text for link to channel
31
+ * Option to show link to channel
32
 
33
  = Credits =
34
  Chromeless option borrowed from [Chromeless YouTube](http://wordpress.org/extend/plugins/chromeless-youtube/) extension.
62
 
63
  == Changelog ==
64
 
65
+ = 0.1.1 =
66
+ * Fixed option to toggle video title visibility
67
+ * Added option to hide controls for iframe and object videos
68
+ * Added option to hide video info
69
+ * Enabled autostart for iframe and object videos
70
+
71
  = 0.1.0 =
72
  * Initial release
73
 
74
  == Upgrade Notice ==
75
 
76
+ = 0.1.1 =
77
+ After upgrade please reconfigure widget. Some variables are changed and implemented new features.
78
+
79
  = 0.1.0 =
80
  Just try it and rate it. Only initial release is available right now.
81
 
82
  == Screenshots ==
83
 
84
  1. Widget configuration panel
85
+ 2. Widget `YouTube Channel` in action with iframe video w/o controls
86
+ 3. Widget `YouTube Channel` in action with iframe video w/ controls and fixed height
screenshot-1.png CHANGED
Binary file
screenshot-2.png CHANGED
Binary file
screenshot-3.png CHANGED
Binary file
youtube-channel.php CHANGED
@@ -1,10 +1,10 @@
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
 
@@ -20,41 +20,44 @@ class YouTube_Channel_Widget extends WP_Widget {
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
 
@@ -64,15 +67,16 @@ class YouTube_Channel_Widget extends WP_Widget {
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
  }
@@ -81,10 +85,20 @@ class YouTube_Channel_Widget extends WP_Widget {
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);
@@ -92,31 +106,20 @@ class YouTube_Channel_Widget extends WP_Widget {
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;
@@ -142,48 +145,52 @@ class YouTube_Channel_Widget extends WP_Widget {
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>
1
  <?php
2
  /*
3
  Plugin Name: YouTube Channel
4
+ Plugin URI: http://blog.urosevic.net/wordpress/youtube-channel/
5
+ Description: <a href="widgets.php">Widget</a> that display latest video thumbnail, iframe (HTML5 video), object (Flash video) or chromeless video from YouTube Channel.
6
  Author: Aleksandar Urošević
7
+ Version: 0.1.1
8
  Author URI: http://urosevic.net/
9
  */
10
 
20
  $title = esc_attr($instance['title']);
21
  $channel = esc_attr($instance['channel']);
22
  $goto_txt = esc_attr($instance['goto_txt']);
23
+ $showgoto = esc_attr($instance['showgoto']);
24
+ $showtitle = esc_attr($instance['showtitle']);
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
+ $controls = esc_attr($instance['controls']);
30
  $ratio = esc_attr($instance['ratio']);
31
  $fixyt = esc_attr($instance['fixyt']);
32
+ $hideinfo = esc_attr($instance['hideinfo']);
33
  ?>
34
+ <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>
35
+ <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>
36
+ <p><input class="checkbox" type="checkbox" <?php checked( (bool) $instance['showtitle'], true ); ?> id="<?php echo $this->get_field_id( 'showtitle' ); ?>" name="<?php echo $this->get_field_name( 'showtitle' ); ?>" /> <label for="<?php echo $this->get_field_id( 'showtitle' ); ?>"><?php _e('Show video title'); ?></label></p>
37
+ <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>
38
+ <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>
39
+ <p><label for="<?php echo $this->get_field_id('to_show'); ?>"><?php _e('Aspect ratio (relative to width):'); ?>
40
+ <select class="widefat" id="<?php echo $this->get_field_id( 'ratio' ); ?>" name="<?php echo $this->get_field_name( 'ratio' ); ?>">
41
  <option value="0"<?php if ($instance['ratio'] == "0") { echo 'selected="selected"'; } ?>><?php _e('Custom'); ?></option>
42
  <option value="1"<?php if ($instance['ratio'] == "1") { echo 'selected="selected"'; } ?>>4:3</option>
43
  <option value="2"<?php if ($instance['ratio'] == "2") { echo 'selected="selected"'; } ?>>16:10</option>
44
  <option value="3"<?php if ($instance['ratio'] == "3") { echo 'selected="selected"'; } ?>>16:9</option>
45
  </select>
46
+ </p>
47
+ <p><label for="<?php echo $this->get_field_id('to_show'); ?>"><?php _e('What to show?'); ?>
48
+ <select class="widefat" id="<?php echo $this->get_field_id( 'to_show' ); ?>" name="<?php echo $this->get_field_name( 'to_show' ); ?>">
49
+ <option value="thumbnail"<?php if ($instance['to_show'] == "thumbnail") { echo 'selected="selected"'; } ?>><?php _e('Thumbnail'); ?></option>
50
+ <option value="object"<?php if ($instance['to_show'] == "object") { echo 'selected="selected"'; } ?>><?php _e('object (flash player)'); ?></option>
51
+ <option value="iframe"<?php if ($instance['to_show'] == "iframe") { echo 'selected="selected"'; } ?>><?php _e('iframe (HTML5 player)'); ?></option>
52
+ <option value="chromeless"<?php if ($instance['to_show'] == "chromeless") { echo 'selected="selected"'; } ?>><?php _e('chromeless video'); ?></option>
53
  </select>
54
  <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 />
55
+ <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 video'); ?></label><br />
56
+ <input class="checkbox" type="checkbox" <?php checked( (bool) $instance['controls'], true ); ?> id="<?php echo $this->get_field_id( 'controls' ); ?>" name="<?php echo $this->get_field_name( 'controls' ); ?>" /> <label for="<?php echo $this->get_field_id( 'controls' ); ?>"><?php _e('Hide player controls'); ?></label><br />
57
+ <input class="checkbox" type="checkbox" <?php checked( (bool) $instance['hideinfo'], true ); ?> id="<?php echo $this->get_field_id( 'hideinfo' ); ?>" name="<?php echo $this->get_field_name( 'hideinfo' ); ?>" /> <label for="<?php echo $this->get_field_id( 'hideinfo' ); ?>"><?php _e('Hide video info'); ?></label>
58
+ </p>
59
+ <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>
60
+ <input class="checkbox" type="checkbox" <?php checked( (bool) $instance['showgoto'], true ); ?> id="<?php echo $this->get_field_id( 'showgoto' ); ?>" name="<?php echo $this->get_field_name( 'showgoto' ); ?>" /> <label for="<?php echo $this->get_field_id( 'showgoto' ); ?>"><?php _e('Show link to channel'); ?></label></p>
61
  <?php
62
  }
63
 
67
  $instance['title'] = strip_tags($new_instance['title']);
68
  $instance['channel'] = strip_tags($new_instance['channel']);
69
  $instance['goto_txt'] = strip_tags($new_instance['goto_txt']);
70
+ $instance['showgoto'] = $new_instance['showgoto'];
71
+ $instance['showtitle']= $new_instance['showtitle'];
72
  $instance['width'] = strip_tags($new_instance['width']);
73
  $instance['height'] = strip_tags($new_instance['height']);
74
  $instance['to_show'] = strip_tags($new_instance['to_show']);
75
  $instance['autoplay'] = $new_instance['autoplay'];
76
+ $instance['controls'] = $new_instance['controls'];
77
  $instance['ratio'] = strip_tags($new_instance['ratio']);
78
  $instance['fixyt'] = $new_instance['fixyt'];
79
+ $instance['hideinfo'] = $new_instance['hideinfo'];
80
 
81
  return $instance;
82
  }
85
  // outputs the content of the widget
86
  extract( $args );
87
  $title = apply_filters('widget_title', $instance['title']);
88
+
89
+ // set default channel if nothing predefined
90
  $channel = $instance['channel'];
91
  if ( $channel == "" ) { $channel = "urkekg"; }
92
+
93
+ // get hideinfo, autoplay and controls settings
94
+ $hideinfo = $instance['hideinfo'];
95
+ $autoplay = $instance['autoplay'];
96
+ $controls = $instance['controls'];
97
+
98
+ // set width and height
99
  $width = $instance['width'];
100
  if ( $width == "" ) { $width = 220; }
101
+ // use ratio?
102
  $ratio = $instance['ratio'];
103
  if ( $ratio == 1 ) { // 4:3
104
  $height = round(($width / 4 ) * 3);
106
  $height = round(($width / 16 ) * 10);
107
  } else if ( $ratio == 3 ) { // 16:9
108
  $height = round(($width / 16 ) * 9);
109
+ } else { // set default if 0 or ratio not set
110
  $height = $instance['height'];
111
+ if ( $height == "" ) { $height = 165; }
 
 
112
  }
113
 
114
+ // which type to show
115
  $to_show = $instance['to_show'];
116
+ if ( $to_show == "" ) { $to_show = "object"; }
117
+
118
+ // if not thumbnail, increase video height for 25px taken by video controls
119
+ if ( !$instance['thumbnail'] && !$controls ) {
120
  $height += 25;
121
  }
122
 
 
 
 
 
 
 
 
 
 
 
 
123
  echo $before_widget;
124
  if ( $title )
125
  echo $before_title . $title . $after_title;
145
  // $next_id = split(":", $next['guid']);
146
  // $next_id = $yt_id[3];
147
 
148
+ // show video title?
149
+ if ( $instance['showtitle'] ) {
150
  echo "<h3>$yt_title</h3>";
151
+ }
152
+
153
+ // print out video
154
  if ( $to_show == "thumbnail" ) {
155
  echo <<<EOF
156
  <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>
157
  EOF;
158
  } else if ( $to_show == "chromeless" ) {
159
  ?>
160
+ <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; ?>">
161
+ <param name="flashVars" value="video_source=<?php echo $yt_id; ?>&video_width=<?php echo $width; ?>&video_height=<?php echo $height; ?><?php if ( $autoplay ) { echo "&autoplay=Yes"; } if ( !$controls ) { echo "&youtube_controls=Yes"; } ?>" />
162
+ <param name="quality" value="high" />
163
+ <param name="wmode" value="opaque" />
164
+ <param name="swfversion" value="6.0.65.0" />
165
+ <param name="movie" value="<?php echo get_bloginfo('wpurl'); ?>/wp-content/plugins/youtube-channel/chromeless.swf" />
166
+ </object>
167
  <?php
168
+ } else if ( $to_show == "iframe" ) {
169
+ ?>
170
+ <iframe title="YouTube video player" width="<?php echo $width; ?>" height="<?php echo $height; ?>" src="http://www.youtube.com/embed/<?php echo "$yt_id?enablejsapi=1"; if ( $controls ) { echo "&controls=0"; } if ( $hideinfo ) { echo "&showinfo=0"; } if ( $autoplay ) { echo "&amp;autoplay=1"; } ?>" frameborder="0" allowfullscreen></iframe>
171
+ <?php
172
+ } else { // default is object
173
+ ?>
174
+ <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="<?php echo $width; ?>" height="<?php echo $height; ?>">
175
+ <param name="movie" value="http://www.youtube.com/v/<?php echo $yt_id; ?>?version=3<?php if ( $controls ) { echo "&amp;controls=0"; } if ( $hideinfo ) { echo "&amp;showinfo=0"; } if ( $autoplay ) { echo "&amp;autoplay=1"; } ?>" />
176
+ <!--[if !IE]>-->
177
+ <object type="application/x-shockwave-flash" data="http://www.youtube.com/v/<?php echo $yt_id; ?>?version=3<?php if ( $controls ) { echo "&amp;controls=0"; } if ( $hideinfo ) { echo "&amp;showinfo=0"; } if ( $autoplay ) { echo "&amp;autoplay=1"; } ?>" width="<?php echo $width; ?>" height="<?php echo $height; ?>">
178
+ <!--<![endif]-->
179
+ <!--[if !IE]>-->
 
 
180
  </object>
181
+ <!--<![endif]-->
182
+ </object>
183
+ <?php
184
  }
185
 
186
+ // do we need to show goto link?
187
+ if ( $instance['showgoto'] ) {
188
+ $goto_txt = $instance['goto_txt'];
189
+ if ( $goto_txt == "" ) { $goto_txt = __("Visit channel")." $channel"; }
190
+ echo <<<EOF
191
+ <p><a href="javascript: window.open('http://www.youtube.com/user/$channel/'); void 0;" title="$goto_txt">$goto_txt</a></p>
192
+ EOF;
193
+ } // showgoto
194
  }
195
  ?>
196
  </div>