YouTube Embed - Version 1.3.1

Version Description

  • New widget option to specify title

=

Download this release

Release Info

Developer dartiss
Plugin Icon 128x128 YouTube Embed
Version 1.3.1
Comparing to
See all releases

Code changes from version 1.3 to 1.3.1

readme.txt CHANGED
@@ -1,10 +1,10 @@
1
  === YouTube Embed ===
2
  Contributors: dartiss
3
- Donate link: http://tinyurl.com/bdc4uu
4
- Tags: YouTube, XHTML, Video, Embed, Playlist, Thumbnail
5
  Requires at least: 2.0
6
  Tested up to: 3.0.1
7
- Stable tag: 1.3
8
 
9
  YouTube Embed is a powerful, but simple to use, method of embedding YouTube videos in your WordPress theme.
10
 
@@ -16,15 +16,13 @@ It works with all the current YouTube API parameters, including HD video, and pr
16
 
17
  Over the coming instructions I'll take you through the various ways to embed video, playlists and other YouTube related abilities.
18
 
19
- == Usage ==
20
-
21
  There are 3 ways to embed a video - a function call (requires PHP coding, but can be placed anywhere), a short code (which can be easily placed in a post or page) or with a sidebar widget.
22
 
23
  A video will use the default settings - these can be changed via the YouTube Embed options screen within your administration panel. However, with the exception of the widget, you can also change any of these settings on a per-video basis.
24
 
25
  Let's go through each of the 3 methods in turn...
26
 
27
- *1. Function Call*
28
 
29
  For those with access (and the requirement) to their theme PHP, a function calls adds total flexibility as it can be added anywhere within your theme.
30
 
@@ -36,7 +34,7 @@ The parameters are supplied with an ampersand seperating each. See the "Paramete
36
 
37
  `<?php if (function_exists('youtube_video_embed')) {youtube_video_embed('id','width=100&height=200');} ?>`
38
 
39
- *2. Short Code*
40
 
41
  This is an easy one. Within any post or page, simply type the following...
42
 
@@ -56,7 +54,7 @@ For a complete list of the parameters, please see the appropriate tab above. You
56
 
57
  This will centre the resulting video.
58
 
59
- *3. Widget*
60
 
61
  The Widget is available from the Appearance->Widgets menu within Administation. Drag it to the appropriate sidebar and click on the down arrow to modify the default options.
62
 
@@ -104,7 +102,9 @@ Like the function call above, you can specify a number of parameters. They are t
104
  * *style* - allows you to specify any stylesheet elements that you'd like applied
105
  * *alt* - specify some "ALT" text for the thumbnail image
106
 
107
- e.g. `[youtube_thumb target="_blank" alt="Demo video"]id[/youtube_thumb]`
 
 
108
 
109
  This overrides the TARGET and ALT elements of the thumbnail.
110
 
@@ -124,12 +124,38 @@ This will create a link to a video using the short URL standard.
124
 
125
  To use the shortcode method simply insert `[youtube_url]id[/youtube_url]` anywhere within a post or page to return a shortened URL. As with other examples, id is the ID of the video.
126
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
127
  == Installation ==
128
 
129
- 1. Upload the entire youtube-embed folder to your wp-content/plugins/ directory.
130
- 2. Activate the plugin through the Plugins menu in WordPress.
131
  3. Visit the YouTube Embed options screen in your Administration menu and set the default parameters
132
- 4. If using the widget, browse to Appearance->Widgets, add the widget, and configure the options
133
 
134
  == Frequently Asked Questions ==
135
 
@@ -139,7 +165,7 @@ If you play a YouTube video, look at the URL - it will probably look something l
139
 
140
  `http://www.youtube.com/watch?v=L5Y4qzc_JTg`
141
 
142
- The video ID is the list of letters and numbers after `v=`, in this case L5Y4qzc_JTg.
143
 
144
  = How can I get help or request possible changes =
145
 
@@ -161,6 +187,9 @@ Feel free to report any problems, or suggestions for enhancements, to me either
161
  = 1.3 =
162
  * Added transparency option so that videos won't cover up layers
163
 
 
 
 
164
  == Upgrade Notice ==
165
 
166
  = 1.0 =
@@ -175,24 +204,5 @@ Feel free to report any problems, or suggestions for enhancements, to me either
175
  = 1.3 =
176
  * Update if you find that the videos are covering up layers
177
 
178
- == Parameters ==
179
-
180
- The following parameters can be specified for any embedded YouTube video. Some of these will also work with playlists but, due to a lack of YouTube documentation on the subject, I'm unable to say which they are.
181
-
182
- * *width* - the width of the video in pixels
183
- * *height* - the height of the video in pixels
184
- * *fullscreen* - yes or no, this adds a button to the video player, allowing the video to be shown fullscreen
185
- * *hd* - yes or no, this determines whether a video defaults to HD quality, if available
186
- * *color1* - this is 1 of 2 colors that can be used on the video player. It is in a hex RGB format, and should be 6 letters long.
187
- * *color2* - this is the second video player colour. Again, this is a hex RGB format.
188
- * *autoplay* - yes or no, this specifies whether the video automatically starts to play
189
- * *start* - this can be specified if you wish for the video not to start at the beginning. Specify a number of seconds.
190
- * *loop* - yes or no, this specifies whether the video loops back to the beginning once it completes
191
- * *cc* - yes or no, this turns on or off closed captions (subtitles)
192
- * *annotation* - yes or no, this specifies whether you wish video annotations to be shown
193
- * *egm* - yes or no, this enables or disables the Enhanced Genie Menu
194
- * *related* - yes or no, this specifies whether you wish to display related videos
195
- * *info* - yes or no, this determines whether video information is shown
196
- * *search* - yes or no, this specifies whether the search box is shown
197
-
198
- For further details on these parameters, please read the [YouTube documentation](http://code.google.com/apis/youtube/player_parameters.html "YouTube Embedded Player Parameters").
1
  === YouTube Embed ===
2
  Contributors: dartiss
3
+ Donate link: http://artiss.co.uk/donate
4
+ Tags: YouTube, Embed, XHTML, Video, Playlist, Thumbnail
5
  Requires at least: 2.0
6
  Tested up to: 3.0.1
7
+ Stable tag: 1.3.1
8
 
9
  YouTube Embed is a powerful, but simple to use, method of embedding YouTube videos in your WordPress theme.
10
 
16
 
17
  Over the coming instructions I'll take you through the various ways to embed video, playlists and other YouTube related abilities.
18
 
 
 
19
  There are 3 ways to embed a video - a function call (requires PHP coding, but can be placed anywhere), a short code (which can be easily placed in a post or page) or with a sidebar widget.
20
 
21
  A video will use the default settings - these can be changed via the YouTube Embed options screen within your administration panel. However, with the exception of the widget, you can also change any of these settings on a per-video basis.
22
 
23
  Let's go through each of the 3 methods in turn...
24
 
25
+ **1. Function Call**
26
 
27
  For those with access (and the requirement) to their theme PHP, a function calls adds total flexibility as it can be added anywhere within your theme.
28
 
34
 
35
  `<?php if (function_exists('youtube_video_embed')) {youtube_video_embed('id','width=100&height=200');} ?>`
36
 
37
+ **2. Short Code**
38
 
39
  This is an easy one. Within any post or page, simply type the following...
40
 
54
 
55
  This will centre the resulting video.
56
 
57
+ **3. Widget**
58
 
59
  The Widget is available from the Appearance->Widgets menu within Administation. Drag it to the appropriate sidebar and click on the down arrow to modify the default options.
60
 
102
  * *style* - allows you to specify any stylesheet elements that you'd like applied
103
  * *alt* - specify some "ALT" text for the thumbnail image
104
 
105
+ For example...
106
+
107
+ `[youtube_thumb target="_blank" alt="Demo video"]id[/youtube_thumb]`
108
 
109
  This overrides the TARGET and ALT elements of the thumbnail.
110
 
124
 
125
  To use the shortcode method simply insert `[youtube_url]id[/youtube_url]` anywhere within a post or page to return a shortened URL. As with other examples, id is the ID of the video.
126
 
127
+ == Parameters ==
128
+
129
+ The following parameters can be specified for any embedded YouTube video. Some of these will also work with playlists but, due to a lack of YouTube documentation on the subject, I'm unable to say which they are.
130
+
131
+ * *width* - the width of the video in pixels
132
+ * *height* - the height of the video in pixels
133
+ * *fullscreen* - yes or no, this adds a button to the video player, allowing the video to be shown fullscreen
134
+ * *hd* - yes or no, this determines whether a video defaults to HD quality, if available
135
+ * *color1* - this is 1 of 2 colors that can be used on the video player. It is in a hex RGB format, and should be 6 letters long.
136
+ * *color2* - this is the second video player colour. Again, this is a hex RGB format.
137
+ * *autoplay* - yes or no, this specifies whether the video automatically starts to play
138
+ * *start* - this can be specified if you wish for the video not to start at the beginning. Specify a number of seconds.
139
+ * *loop* - yes or no, this specifies whether the video loops back to the beginning once it completes
140
+ * *cc* - yes or no, this turns on or off closed captions (subtitles)
141
+ * *annotation* - yes or no, this specifies whether you wish video annotations to be shown
142
+ * *egm* - yes or no, this enables or disables the Enhanced Genie Menu
143
+ * *related* - yes or no, this specifies whether you wish to display related videos
144
+ * *info* - yes or no, this determines whether video information is shown
145
+ * *search* - yes or no, this specifies whether the search box is shown
146
+
147
+ For further details on these parameters, please read the [YouTube documentation](http://code.google.com/apis/youtube/player_parameters.html "YouTube Embedded Player Parameters").
148
+
149
+ == Screenshots ==
150
+
151
+ 1. YouTube Embed admin screen, showing demonstration video
152
+
153
  == Installation ==
154
 
155
+ 1. Upload the entire `youtube-embed` folder to your `wp-content/plugins/` directory.
156
+ 2. Activate the plugin through the 'Plugins' menu in WordPress.
157
  3. Visit the YouTube Embed options screen in your Administration menu and set the default parameters
158
+ 4. If using the widget, browse to `Appearance->Widgets`, add the widget, and configure the options
159
 
160
  == Frequently Asked Questions ==
161
 
165
 
166
  `http://www.youtube.com/watch?v=L5Y4qzc_JTg`
167
 
168
+ The video ID is the list of letters and numbers after `v=`, in this case `L5Y4qzc_JTg`.
169
 
170
  = How can I get help or request possible changes =
171
 
187
  = 1.3 =
188
  * Added transparency option so that videos won't cover up layers
189
 
190
+ = 1.3.1 =
191
+ * New widget option to specify title
192
+
193
  == Upgrade Notice ==
194
 
195
  = 1.0 =
204
  = 1.3 =
205
  * Update if you find that the videos are covering up layers
206
 
207
+ = 1.3.1 =
208
+ * Update if you wish to change the widget heading
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
screenshot-1.png ADDED
Binary file
youtube-embed.php CHANGED
@@ -3,10 +3,11 @@
3
  Plugin Name: YouTube Embed
4
  Plugin URI: http://www.artiss.co.uk/youtube-embed
5
  Description: Embed YouTube Videos in WordPress
6
- Version: 1.3
7
  Author: David Artiss
8
  Author URI: http://www.artiss.co.uk
9
  */
 
10
  // Set up WordPress shortcodes and actions
11
  add_shortcode('youtube','youtube_video_sc');
12
  add_shortcode('youtube_playlist','youtube_playlist_sc');
@@ -83,7 +84,6 @@ function youtube_short_url($id) {return "http://youtu.be/".$id;}
83
 
84
  // Generate XHTML compatible YouTube embed code
85
  function generate_youtube_code($id,$type,$width,$height,$fullscreen,$related,$autoplay,$loop,$egm,$border,$color1,$color2,$start,$hd,$search,$info,$annotation,$cc,$style,$widget="") {
86
- $version=1.3;
87
  // Ensure an ID is passed
88
  if (($id=="")&&(strtolower($widget)!="yes")) {
89
  return youtube_embed_error("No video/playlist ID has been supplied");
@@ -126,7 +126,7 @@ function generate_youtube_code($id,$type,$width,$height,$fullscreen,$related,$au
126
  $paras="&amp;fs=".$fullscreen."&amp;rel=".$related."&amp;autoplay=".$autoplay."&amp;loop=".$loop."&amp;egm=".$egm."&amp;border=".$border."&amp;color1=0x".$color1."&amp;color2=0x".$color2."&amp;hd=".$hd."&amp;showsearch=".$search."&amp;showinfo=".$info."&amp;iv_load_policy=".$annotation."&amp;cc_load_policy=".$cc;
127
  if ($start!=0) {$paras=$paras."&amp;start=".$start;}
128
  // Write out code
129
- $result="<!-- YouTube Embed v".$version." | http://www.artiss.co.uk/youtube-embed -->\n";
130
  if ($style!="") {$result.="<div style=\"".$style."\">\n";}
131
  $result.="<object type=\"application/x-shockwave-flash\" data=\"http://www.youtube.com/".$type."/".$id.$paras."\" width=\"".$width."\" height=\"".$height."\" wmode=\"transparent\">\n";
132
  $result.="<param name=\"movie\" value=\"http://www.youtube.com/".$type."/".$id.$paras."\" />\n";
@@ -157,8 +157,10 @@ function generate_thumbnail_code($id,$style,$class,$rel,$target,$width,$height,$
157
  // Function to generate YouTube widget
158
  function youtube_widget($args) {
159
  extract($args);
 
 
160
  echo $before_widget;
161
- echo $before_title."YouTube".$after_title;
162
  echo generate_youtube_code("","","","","","","","","","","","","","","","","","","","yes");
163
  echo $after_widget;
164
  }
3
  Plugin Name: YouTube Embed
4
  Plugin URI: http://www.artiss.co.uk/youtube-embed
5
  Description: Embed YouTube Videos in WordPress
6
+ Version: 1.3.1
7
  Author: David Artiss
8
  Author URI: http://www.artiss.co.uk
9
  */
10
+ define('youtube_embed_version','1.3.1');
11
  // Set up WordPress shortcodes and actions
12
  add_shortcode('youtube','youtube_video_sc');
13
  add_shortcode('youtube_playlist','youtube_playlist_sc');
84
 
85
  // Generate XHTML compatible YouTube embed code
86
  function generate_youtube_code($id,$type,$width,$height,$fullscreen,$related,$autoplay,$loop,$egm,$border,$color1,$color2,$start,$hd,$search,$info,$annotation,$cc,$style,$widget="") {
 
87
  // Ensure an ID is passed
88
  if (($id=="")&&(strtolower($widget)!="yes")) {
89
  return youtube_embed_error("No video/playlist ID has been supplied");
126
  $paras="&amp;fs=".$fullscreen."&amp;rel=".$related."&amp;autoplay=".$autoplay."&amp;loop=".$loop."&amp;egm=".$egm."&amp;border=".$border."&amp;color1=0x".$color1."&amp;color2=0x".$color2."&amp;hd=".$hd."&amp;showsearch=".$search."&amp;showinfo=".$info."&amp;iv_load_policy=".$annotation."&amp;cc_load_policy=".$cc;
127
  if ($start!=0) {$paras=$paras."&amp;start=".$start;}
128
  // Write out code
129
+ $result="<!-- YouTube Embed v".youtube_embed_version." | http://www.artiss.co.uk/youtube-embed -->\n";
130
  if ($style!="") {$result.="<div style=\"".$style."\">\n";}
131
  $result.="<object type=\"application/x-shockwave-flash\" data=\"http://www.youtube.com/".$type."/".$id.$paras."\" width=\"".$width."\" height=\"".$height."\" wmode=\"transparent\">\n";
132
  $result.="<param name=\"movie\" value=\"http://www.youtube.com/".$type."/".$id.$paras."\" />\n";
157
  // Function to generate YouTube widget
158
  function youtube_widget($args) {
159
  extract($args);
160
+ $options=get_option("youtube_widget");
161
+ if ($options['title']=="") {$title="YouTube";} else {$title=$options['title'];}
162
  echo $before_widget;
163
+ echo $before_title.$title.$after_title;
164
  echo generate_youtube_code("","","","","","","","","","","","","","","","","","","","yes");
165
  echo $after_widget;
166
  }
youtube-widget-options.php CHANGED
@@ -1,9 +1,10 @@
1
  <?php
2
  $options=get_option("youtube_widget");
3
  if (!is_array($options)) {
4
- $options=array('id'=>'','type'=>'v','width'=>'170','height'=>'142','border'=>'0','fullscreen'=>'0','hd'=>'1','color1'=>'2b405b','color2'=>'6b8ab6','style'=>'','autoplay'=>'0','start'=>'0','loop'=>'0','cc'=>'0','annotation'=>'1','egm'=>'0','related'=>'0','info'=>'1','search'=>'1');
5
  }
6
  if ($_POST['youtube-widget-submit']) {
 
7
  $options['id']=$_POST['youtube_widget_id'];
8
  $options['type']=$_POST['youtube_widget_type'];
9
  $options['width']=$_POST['youtube_widget_width'];
@@ -27,6 +28,9 @@ if ($_POST['youtube-widget-submit']) {
27
  }
28
  ?>
29
  <p>
 
 
 
30
  <label for="youtube_widget_id"><?php _e('Video ID'); ?>: </label>
31
  <input type="text" name="youtube_widget_id" value="<?php echo $options['id'];?>" /><br/>
32
 
1
  <?php
2
  $options=get_option("youtube_widget");
3
  if (!is_array($options)) {
4
+ $options=array('titles'=>'YouTube','id'=>'','type'=>'v','width'=>'170','height'=>'142','border'=>'0','fullscreen'=>'0','hd'=>'1','color1'=>'2b405b','color2'=>'6b8ab6','style'=>'','autoplay'=>'0','start'=>'0','loop'=>'0','cc'=>'0','annotation'=>'1','egm'=>'0','related'=>'0','info'=>'1','search'=>'1');
5
  }
6
  if ($_POST['youtube-widget-submit']) {
7
+ $options['title']=$_POST['youtube_widget_title'];
8
  $options['id']=$_POST['youtube_widget_id'];
9
  $options['type']=$_POST['youtube_widget_type'];
10
  $options['width']=$_POST['youtube_widget_width'];
28
  }
29
  ?>
30
  <p>
31
+ <label for="youtube_widget_title"><?php _e('Title'); ?>: </label>
32
+ <input type="text" name="youtube_widget_title" value="<?php echo $options['title']; ?>"/><br/>
33
+
34
  <label for="youtube_widget_id"><?php _e('Video ID'); ?>: </label>
35
  <input type="text" name="youtube_widget_id" value="<?php echo $options['id'];?>" /><br/>
36