YouTube Embed - Version 1.4

Version Description

  • Now supports multiple widgets - widget code completely re-written
  • Support for EmbedPlus added
  • Added option to suppress links back to YouTube
  • Added functions and shortcodes for returning and outputting available transcripts
  • Tidied up code

=

Download this release

Release Info

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

Code changes from version 1.3.1 to 1.4

embedplus.png ADDED
Binary file
readme.txt CHANGED
@@ -1,10 +1,10 @@
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
 
@@ -12,13 +12,17 @@ YouTube Embed is a powerful, but simple to use, method of embedding YouTube vide
12
 
13
  YouTube Embed is a powerful, but simple to use, method of embedding YouTube videos in your WordPress theme.
14
 
15
- It works with all the current YouTube API parameters, including HD video, and produces XHTML valid output. It also, unlike many others similar plugins, works with videos with certain characters within their ID (e.g. double dashes).
 
 
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
 
@@ -30,7 +34,7 @@ For those with access (and the requirement) to their theme PHP, a function calls
30
 
31
  Where id is the video ID, paras is a list of parameters (more on this in a minute) and style (optional) is a list of stylesheet elements that you wish to apply to the resulting video.
32
 
33
- The parameters are supplied with an ampersand seperating each. See the "Parameters" section of these instructions for details on what parameters are available, but here's an example where I override the height and width of a video...
34
 
35
  `<?php if (function_exists('youtube_video_embed')) {youtube_video_embed('id','width=100&height=200');} ?>`
36
 
@@ -42,13 +46,11 @@ This is an easy one. Within any post or page, simply type the following...
42
 
43
  Where id is the ID of the video.
44
 
45
- If you wish to override any of the settings, then these must be specified within the opening short code. So, to adjust the width and height, you'd put...
46
 
47
  `[youtube width=100 height=200]id[/youtube]`
48
 
49
- In this case, the width is 100px and the height is 200px.
50
-
51
- For a complete list of the parameters, please see the appropriate tab above. You may also specify a stylesheet override by using the `style` parameter. For example...
52
 
53
  `[youtube style="text-align:center"]id[/youtube]`
54
 
@@ -56,9 +58,20 @@ 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
 
61
- These NEED to be done as you also have to specify the video ID and type (video or playlist).
 
 
 
 
 
 
 
62
 
63
  **Playlists**
64
 
@@ -82,7 +95,7 @@ Use the following function call to add a thumbnail to any part of your theme.
82
 
83
  `<?php if (function_exists('youtube_thumb_embed')) {youtube_thumb_embed('id','paras','style','alt');} ?>`
84
 
85
- Like the video embed equivalent, the ID is the video ID, the style is a list of stylesheet elements (but is optional) and alt is the alternative text for the thumbnail image (also optional). The parameters are different, however, but, again, are seperated by ampersand.
86
 
87
  The parameters are as follows...
88
 
@@ -124,38 +137,84 @@ 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
  == 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
 
@@ -167,9 +226,13 @@ If you play a YouTube video, look at the URL - it will probably look something l
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
 
172
- Feel free to report any problems, or suggestions for enhancements, to me either via [my contact form](http://www.artiss.co.uk/contact "Contact Me") or by [the plugins homepage](http://www.artiss.co.uk/youtube-embed "YouTube Embed").
 
 
 
 
173
 
174
  == Changelog ==
175
 
@@ -190,6 +253,13 @@ Feel free to report any problems, or suggestions for enhancements, to me either
190
  = 1.3.1 =
191
  * New widget option to specify title
192
 
 
 
 
 
 
 
 
193
  == Upgrade Notice ==
194
 
195
  = 1.0 =
@@ -205,4 +275,7 @@ Feel free to report any problems, or suggestions for enhancements, to me either
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
 
 
 
1
  === YouTube Embed ===
2
  Contributors: dartiss
3
  Donate link: http://artiss.co.uk/donate
4
+ Tags: YouTube, embed, XHTML, video, playlist, thumbnail, EmbedPlus, widget, shortcode
5
  Requires at least: 2.0
6
+ Tested up to: 3.1
7
+ Stable tag: 1.4
8
 
9
  YouTube Embed is a powerful, but simple to use, method of embedding YouTube videos in your WordPress theme.
10
 
12
 
13
  YouTube Embed is a powerful, but simple to use, method of embedding YouTube videos in your WordPress theme.
14
 
15
+ It works with all the current YouTube API parameters, including HD video, and produces XHTML valid output. It also, unlike many other similar plugins, works with videos with certain characters within their ID (e.g. double dashes).
16
+
17
+ **For help with this plugin, or simply to comment or get in touch, please read the appropriate section in "Other Notes" for details. This plugin, and all support, is supplied for free, but [donations](http://artiss.co.uk/donate "Donate") are always welcome.**
18
 
19
  Over the coming instructions I'll take you through the various ways to embed video, playlists and other YouTube related abilities.
20
 
21
+ From version 1.4 this plugin also supports [EmbedPlus](http://embedplus.com/ "EmbedPlus"), which adds real-time reactions, chopping, movable zoom, slow motion, annotations, chapter / scene skipping, amongst others.
22
+
23
  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.
24
 
25
+ A video will use the default settings which can be changed via the YouTube Embed options screen within your administration panel. However, you can also change any of these settings on a per-video basis. For a full list of the available parameters, please see the separate section.
26
 
27
  Let's go through each of the 3 methods in turn...
28
 
34
 
35
  Where id is the video ID, paras is a list of parameters (more on this in a minute) and style (optional) is a list of stylesheet elements that you wish to apply to the resulting video.
36
 
37
+ The parameters are supplied with an ampersand separating each. Here's an example where I override the height and width of a video...
38
 
39
  `<?php if (function_exists('youtube_video_embed')) {youtube_video_embed('id','width=100&height=200');} ?>`
40
 
46
 
47
  Where id is the ID of the video.
48
 
49
+ If you wish to override any of the settings then these must be specified within the opening short code. So, to adjust the width and height, you'd put...
50
 
51
  `[youtube width=100 height=200]id[/youtube]`
52
 
53
+ In this case, the width is 100px and the height is 200px. You may also specify a stylesheet override by using the `style` parameter. For example...
 
 
54
 
55
  `[youtube style="text-align:center"]id[/youtube]`
56
 
58
 
59
  **3. Widget**
60
 
61
+ The widget is available from the Appearance->Widgets menu within Administration.
62
+
63
+ Drag it to the appropriate sidebar and click on the down arrow to modify the default options. The options must be set as you have to specify the video ID and type (video or playlist).
64
+
65
+ **EmbedPlus**
66
 
67
+ To use EmbedPlus you can either set this on via the default options screen or, on an individual basis, use the parameter `embedplus`.
68
+
69
+ For example, here is EmbedPlus being used for both a PHP function and a shortcode...
70
+
71
+ `youtube_video_embed('id','width=100&height=200&embedplus=yes');
72
+ [youtube width="100" height="200" embedplus="Yes"]id[/youtube]`
73
+
74
+ When using the widget option, you can select EmbedPlus as the "type" of video, along with a standard video and a playlist.
75
 
76
  **Playlists**
77
 
95
 
96
  `<?php if (function_exists('youtube_thumb_embed')) {youtube_thumb_embed('id','paras','style','alt');} ?>`
97
 
98
+ Like the video embed equivalent, the ID is the video ID, the style is a list of stylesheet elements (but is optional) and alt is the alternative text for the thumbnail image (also optional). The parameters are different, however, but, again, are separated by ampersand.
99
 
100
  The parameters are as follows...
101
 
137
 
138
  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.
139
 
140
+ **Transcripts**
141
+
142
+ Some YouTube videos include transcripts - this is the speech from the video with timings. These are available in XML format and can, via a function call or shortcode, be displayed in your post/page.
143
+
144
+ The shortcode `transcript` will display the transcript in your post/page, along with the start time for each line. Simply supply the video ID as a parameter. For example...
145
+
146
+ `[transcript]id[/transcript]`
147
+
148
+ If no transcript exists, nothing will be output.
149
+
150
+ For style purposes, the `SPAN` around the time has a class of `TranscriptTime`, the `SPAN` around the text has a class of `TranscriptText` and the `DIV` around the whole transcript output has a class of `Transcript`.
151
+
152
+ If you wish to use a PHP function call to get the transcript, then you would use the format...
153
+
154
+ `get_youtube_transcript(ID)`
155
+
156
+ In all of these cases, the original XML format has been changed to a readable output. If, though, you'd like to return the original XML format, then you can use the following call...
157
+
158
+ `get_youtube_transcript_xml(ID)`
159
+
160
  == Parameters ==
161
 
162
  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.
163
 
164
+ The following work with a standard video/playlist and an EmbedPlus video...
165
+
166
+ * *embedplus* - yes or no, whether you wish to use EmbedPlus
167
  * *width* - the width of the video in pixels
168
  * *height* - the height of the video in pixels
169
  * *fullscreen* - yes or no, this adds a button to the video player, allowing the video to be shown fullscreen
170
+ * *start* - this can be specified if you wish for the video not to start at the beginning. Specify a number of seconds
171
+
172
+ The following only work with the standard video/playlist embedding...
173
+
174
+ * *border* - yes or show, this is whether you wish the border to be shown
175
  * *hd* - yes or no, this determines whether a video defaults to HD quality, if available
176
  * *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.
177
  * *color2* - this is the second video player colour. Again, this is a hex RGB format.
178
  * *autoplay* - yes or no, this specifies whether the video automatically starts to play
 
179
  * *loop* - yes or no, this specifies whether the video loops back to the beginning once it completes
180
  * *cc* - yes or no, this turns on or off closed captions (subtitles)
181
  * *annotation* - yes or no, this specifies whether you wish video annotations to be shown
182
  * *egm* - yes or no, this enables or disables the Enhanced Genie Menu
183
  * *related* - yes or no, this specifies whether you wish to display related videos
184
  * *info* - yes or no, this determines whether video information is shown
185
+ * *search* - yes or no, determine whether search box should be shown
186
+ * *link* - yes or no, this determines whether the video links back to YouTube
187
 
188
+ The following are only valid with an EmbedPlus video...
189
 
190
+ * *stop* - this stops the video at a specific time, given in seconds
191
+ * *react* - yes or no, this specified whether you wish to show the Real-time Reactions button
192
+ * *sweetspot* - yes or no, this will find sweet spots for the next/prev buttons
193
 
194
+ For further details on these parameters (with the exception of those added by EmbedPlus), please read the [YouTube documentation](http://code.google.com/apis/youtube/player_parameters.html "YouTube Embedded Player Parameters").
195
+
196
+ == Licence ==
197
+
198
+ This WordPress plugin is licensed under the [GPLv2 (or later)](http://wordpress.org/about/gpl/ "GNU General Public License").
199
+
200
+ == Support ==
201
+
202
+ All of my plugins are supported via [my website](http://www.artiss.co.uk "Artiss.co.uk").
203
+
204
+ Please feel free to visit the site for plugin updates and development news - either visit the site regularly, follow [my news feed](http://www.artiss.co.uk/feed "RSS News Feed") or [follow me on Twitter](http://www.twitter.com/artiss_tech "Artiss.co.uk on Twitter") (@artiss_tech).
205
+
206
+ For problems, suggestions or enhancements for this plugin, there is [a dedicated page](http://www.artiss.co.uk/youtube-embed "YouTube Embed") and [a forum](http://www.artiss.co.uk/forum "WordPress Plugins Forum"). The dedicated page will also list any known issues and planned enhancements.
207
+
208
+ Alternatively, please [contact me directly](http://www.artiss.co.uk/contact "Contact Me").
209
+
210
+ **This plugin, and all support, is supplied for free, but [donations](http://artiss.co.uk/donate "Donate") are always welcome.**
211
 
212
  == Installation ==
213
 
214
  1. Upload the entire `youtube-embed` folder to your `wp-content/plugins/` directory.
215
  2. Activate the plugin through the 'Plugins' menu in WordPress.
216
  3. Visit the YouTube Embed options screen in your Administration menu and set the default parameters
217
+ 4. If using the widget browse to `Appearance->Widgets`, add the widget and configure the options
218
 
219
  == Frequently Asked Questions ==
220
 
226
 
227
  The video ID is the list of letters and numbers after `v=`, in this case `L5Y4qzc_JTg`.
228
 
229
+ = Which version of PHP does this plugin work with? =
230
 
231
+ It has been tested and been found valid from PHP 4 upwards.
232
+
233
+ == Screenshots ==
234
+
235
+ 1. YouTube Embed admin screen, showing demonstration video
236
 
237
  == Changelog ==
238
 
253
  = 1.3.1 =
254
  * New widget option to specify title
255
 
256
+ = 1.4 =
257
+ * Now supports multiple widgets - widget code completely re-written
258
+ * Support for EmbedPlus added
259
+ * Added option to suppress links back to YouTube
260
+ * Added functions and shortcodes for returning and outputting available transcripts
261
+ * Tidied up code
262
+
263
  == Upgrade Notice ==
264
 
265
  = 1.0 =
275
  * Update if you find that the videos are covering up layers
276
 
277
  = 1.3.1 =
278
+ * Update if you wish to change the widget heading
279
+
280
+ = 1.4 =
281
+ * Update to add EmbedPlus, multi-widgets and transcript output capabilities
screenshot-1.png CHANGED
Binary file
youtube-embed-options.php CHANGED
@@ -21,6 +21,11 @@ if(!empty($_POST['Submit'])) {
21
  $options['related']=$_POST['youtube_embed_related'];
22
  $options['info']=$_POST['youtube_embed_info'];
23
  $options['search']=$_POST['youtube_embed_search'];
 
 
 
 
 
24
  update_option("youtube_embed",$options);
25
  }
26
  // Fetch options into an array
@@ -28,25 +33,29 @@ $options=get_option("youtube_embed");
28
  // Set defaults if no array is defined
29
  if (!is_array($options)) {
30
  echo "<div class=\"updated\"><p><strong>Please review the default options below and click \"Save Settings\" to update them.</strong></p></div>\n";
31
- $options = array('width'=>'425','height'=>'355','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');}
32
  ?>
33
 
34
- <form action="https://www.paypal.com/cgi-bin/webscr" method="post" style="float: right;" target="_blank">
35
- <input type="hidden" name="cmd" value="_s-xclick"/>
36
- <input type="hidden" name="hosted_button_id" value="2827258"/>
37
- <input type="image" src="https://www.paypal.com/en_GB/i/btn/btn_donate_SM.gif" name="submit" alt="Donate!"/>
38
- <img alt="" border="0" src="https://www.paypal.com/en_GB/i/scr/pixel.gif" width="1" height="1"/>
39
- </form>
40
 
41
  <p><?php _e('These are the default settings for YouTube videos embedded with YouTube Embed.'); ?></p>
42
- <p><?php _e('Further details about these parameters can be found in <a href="http://code.google.com/apis/youtube/player_parameters.html">the official YouTube documentation</a> for embedded videos.'); ?></p>
43
- <p><?php _e('If you like this plugin, please consider donating.'); ?></p>
 
44
 
45
  <form method="post" action="<?php echo get_bloginfo('wpurl').'/wp-admin/options-general.php?page=youtube-embed-settings&amp;updated=true' ?>">
46
  <table class="form-table">
47
 
48
  <tr valign="top">
49
- <th style="font-weight: bold" scope="row"><?php _e('Video Display Properties'); ?></th>
 
 
 
 
 
 
 
 
50
  </tr><tr>
51
 
52
  <th scope="row"><?php _e('Width'); ?></th>
@@ -56,19 +65,25 @@ if (!is_array($options)) {
56
  <td><input type="text" size="3" maxlength="3" name="youtube_embed_height" value="<?php echo $options['height']; ?>"/>px</td>
57
  </tr><tr>
58
 
59
- <th scope="row"><?php _e('Show Border'); ?></th>
60
- <td><select name="youtube_embed_border">
61
- <option value="0"<?php if ($options['border']=="0") {echo " selected='selected'";} ?>><?php _e('No'); ?></option>
62
- <option value="1"<?php if ($options['border']=="1") {echo " selected='selected'";} ?>><?php _e('Yes'); ?></option>
63
- </select></td>
64
-
65
  <th scope="row"><?php _e('Fullscreen Button'); ?></th>
66
  <td><select name="youtube_embed_fullscreen">
67
  <option value="0"<?php if ($options['fullscreen']=="0") {echo " selected='selected'";} ?>><?php _e('No'); ?></option>
68
  <option value="1"<?php if ($options['fullscreen']=="1") {echo " selected='selected'";} ?>><?php _e('Yes'); ?></option>
69
  </select></td>
 
 
 
 
 
 
70
  </tr><tr>
71
 
 
 
 
 
 
 
72
  <th scope="row"><?php _e('Default to HD Quality'); ?></th>
73
  <td colspan="2"><select name="youtube_embed_hd">
74
  <option value="0"<?php if ($options['hd']=="0") {echo " selected='selected'";} ?>><?php _e('No'); ?></option>
@@ -83,35 +98,24 @@ if (!is_array($options)) {
83
  <td>#<input type="text" size="6" maxlength="6" name="youtube_embed_color2" value="<?php echo $options['color2']; ?>"/>&nbsp;<span style="padding-right: 16px; background-color: #<?php echo $options['color2'] ?>">&nbsp;</span></td>
84
  </tr><tr>
85
 
86
- <th scope="row"><?php _e('Style Information'); ?></th>
87
- <td colspan="2"><input type="text" size="40" name="youtube_embed_style" value="<?php echo $options['style']; ?>"/> e.g. text-align:center</td>
88
- </tr><tr>
89
-
90
- <th style="font-weight: bold" scope="row"><?php _e('Playback'); ?></th>
91
- </tr><tr>
92
-
93
  <th scope="row"><?php _e('Autoplay'); ?></th>
94
  <td><select name="youtube_embed_autoplay">
95
  <option value="0"<?php if ($options['autoplay']=="0") {echo " selected='selected'";} ?>><?php _e('No'); ?></option>
96
  <option value="1"<?php if ($options['autoplay']=="1") {echo " selected='selected'";} ?>><?php _e('Yes'); ?></option>
97
- </select></td>
98
-
99
- <th scope="row"><?php _e('Start'); ?></th>
100
- <td><input type="text" size="3" maxlength="3" name="youtube_embed_start" value="<?php echo $options['start']; ?>"/> seconds</td>
101
- </tr><tr>
102
 
103
  <th scope="row"><?php _e('Loop Video'); ?></th>
104
  <td><select name="youtube_embed_loop">
105
  <option value="0"<?php if ($options['loop']=="0") {echo " selected='selected'";} ?>><?php _e('No'); ?></option>
106
  <option value="1"<?php if ($options['loop']=="1") {echo " selected='selected'";} ?>><?php _e('Yes'); ?></option>
107
  </select></td>
 
108
 
109
  <th scope="row"><?php _e('Show Closed Captions'); ?></th>
110
  <td><select name="youtube_embed_cc">
111
  <option value="0"<?php if ($options['cc']=="0") {echo " selected='selected'";} ?>><?php _e('No'); ?></option>
112
  <option value="1"<?php if ($options['cc']=="1") {echo " selected='selected'";} ?>><?php _e('Yes'); ?></option>
113
  </select></td>
114
- </tr><tr>
115
 
116
  <th scope="row"><?php _e('Show Annotations'); ?></th>
117
  <td><select name="youtube_embed_annotation">
@@ -120,9 +124,6 @@ if (!is_array($options)) {
120
  </select></td>
121
  </tr><tr>
122
 
123
- <th style="font-weight: bold" scope="row"><?php _e('Video Information'); ?></th>
124
- </tr><tr>
125
-
126
  <th scope="row"><?php _e('Enable Enhanced Genie Menu'); ?></th>
127
  <td><select name="youtube_embed_egm">
128
  <option value="0"<?php if ($options['egm']=="0") {echo " selected='selected'";} ?>><?php _e('No'); ?></option>
@@ -147,6 +148,33 @@ if (!is_array($options)) {
147
  <option value="0"<?php if ($options['search']=="0") {echo " selected='selected'";} ?>><?php _e('No'); ?></option>
148
  <option value="1"<?php if ($options['search']=="1") {echo " selected='selected'";} ?>><?php _e('Yes'); ?></option>
149
  </select></td>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
150
 
151
  </tr>
152
  </table>
@@ -155,13 +183,11 @@ if (!is_array($options)) {
155
  </p>
156
  </form>
157
 
158
- <h3>YouTube Video Sample</h3>
159
- <p>This uses the above settings, once they have been saved.</p>
160
- <p><?php youtube_video_embed("Zohjxz8RSyg"); ?></p>
161
-
162
- <h3>Further Help</h3>
163
- <p>Comprehensive instructions can be found on <a href="http://www.artiss.co.uk/youtube-embed">the official site page</a>, along with <a href="http://www.artiss.co.uk/category/software/wordpress">blog updates</a> and a comprehensive <a href="http://www.artiss.co.uk/category/software/wordpress/feed">news feed</a>.</p>
164
- <p>Alternatively, please see <a href="http://wordpress.org/extend/plugins/youtube-embed/">the WordPress plugin page</a>.</p>
165
 
 
 
166
  <p><a href="http://validator.w3.org"><img src="http://www.w3.org/Icons/valid-xhtml10-blue" alt="Valid XHTML 1.0 Transitional" height="31px" width="88px" style="float: right"/></a></p>
167
  </div>
21
  $options['related']=$_POST['youtube_embed_related'];
22
  $options['info']=$_POST['youtube_embed_info'];
23
  $options['search']=$_POST['youtube_embed_search'];
24
+ $options['link']=$_POST['youtube_embed_link'];
25
+ $options['react']=$_POST['youtube_embed_react'];
26
+ $options['stop']=$_POST['youtube_embed_stop'];
27
+ $options['sweetspot']=$_POST['youtube_embed_sweetspot'];
28
+ $options['type']=$_POST['youtube_embed_type'];
29
  update_option("youtube_embed",$options);
30
  }
31
  // Fetch options into an array
33
  // Set defaults if no array is defined
34
  if (!is_array($options)) {
35
  echo "<div class=\"updated\"><p><strong>Please review the default options below and click \"Save Settings\" to update them.</strong></p></div>\n";
36
+ $options = array('width'=>'425','height'=>'355','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','link'=>'1','react'=>'1','stop'=>'0','sweetspot'=>'1','type'=>'v');}
37
  ?>
38
 
39
+ <a href="http://embedplus.com/"><img src="<?php echo WP_PLUGIN_URL.'/'.str_replace(basename( __FILE__),"",plugin_basename(__FILE__)); ?>embedplus.png" alt="EmbedPlus" title="EmbedPlus" align="right" /></a>
 
 
 
 
 
40
 
41
  <p><?php _e('These are the default settings for YouTube videos embedded with YouTube Embed.'); ?></p>
42
+ <p><?php _e('Further details about these parameters can be found in <a href="http://code.google.com/apis/youtube/player_parameters.html">the official YouTube documentation</a> for normal embedded videos.'); ?></p>
43
+ <p><?php _e('You can find about more information about EmbedPlus from <a href="http://embedplus.com/">their website</a>.'); ?></p>
44
+ <p><?php _e('If you like this plugin, please <a href="http://www.artiss.co.uk/donate">consider donating</a>.'); ?></p>
45
 
46
  <form method="post" action="<?php echo get_bloginfo('wpurl').'/wp-admin/options-general.php?page=youtube-embed-settings&amp;updated=true' ?>">
47
  <table class="form-table">
48
 
49
  <tr valign="top">
50
+ <th scope="row"><?php _e('Embed Type'); ?></th>
51
+ <td><select name="youtube_embed_type">
52
+ <option value="v"<?php if ($options['type']=="v") {echo " selected='selected'";} ?>><?php _e('Standard'); ?></option>
53
+ <option value="m"<?php if ($options['type']=="m") {echo " selected='selected'";} ?>><?php _e('EmbedPlus'); ?></option>
54
+ </select></td>
55
+ </tr><tr>
56
+
57
+ <th scope="row"><?php _e('Style Information'); ?></th>
58
+ <td colspan="2"><input type="text" size="40" name="youtube_embed_style" value="<?php echo $options['style']; ?>"/> e.g. text-align:center</td>
59
  </tr><tr>
60
 
61
  <th scope="row"><?php _e('Width'); ?></th>
65
  <td><input type="text" size="3" maxlength="3" name="youtube_embed_height" value="<?php echo $options['height']; ?>"/>px</td>
66
  </tr><tr>
67
 
 
 
 
 
 
 
68
  <th scope="row"><?php _e('Fullscreen Button'); ?></th>
69
  <td><select name="youtube_embed_fullscreen">
70
  <option value="0"<?php if ($options['fullscreen']=="0") {echo " selected='selected'";} ?>><?php _e('No'); ?></option>
71
  <option value="1"<?php if ($options['fullscreen']=="1") {echo " selected='selected'";} ?>><?php _e('Yes'); ?></option>
72
  </select></td>
73
+
74
+ <th scope="row"><?php _e('Start'); ?></th>
75
+ <td><input type="text" size="3" maxlength="3" name="youtube_embed_start" value="<?php echo $options['start']; ?>"/> seconds</td>
76
+ </tr><tr>
77
+
78
+ <th style="font-weight: bold" scope="row"><?php _e('Standard Video/Playlist Only'); ?></th>
79
  </tr><tr>
80
 
81
+ <th scope="row"><?php _e('Show Border'); ?></th>
82
+ <td><select name="youtube_embed_border">
83
+ <option value="0"<?php if ($options['border']=="0") {echo " selected='selected'";} ?>><?php _e('No'); ?></option>
84
+ <option value="1"<?php if ($options['border']=="1") {echo " selected='selected'";} ?>><?php _e('Yes'); ?></option>
85
+ </select></td>
86
+
87
  <th scope="row"><?php _e('Default to HD Quality'); ?></th>
88
  <td colspan="2"><select name="youtube_embed_hd">
89
  <option value="0"<?php if ($options['hd']=="0") {echo " selected='selected'";} ?>><?php _e('No'); ?></option>
98
  <td>#<input type="text" size="6" maxlength="6" name="youtube_embed_color2" value="<?php echo $options['color2']; ?>"/>&nbsp;<span style="padding-right: 16px; background-color: #<?php echo $options['color2'] ?>">&nbsp;</span></td>
99
  </tr><tr>
100
 
 
 
 
 
 
 
 
101
  <th scope="row"><?php _e('Autoplay'); ?></th>
102
  <td><select name="youtube_embed_autoplay">
103
  <option value="0"<?php if ($options['autoplay']=="0") {echo " selected='selected'";} ?>><?php _e('No'); ?></option>
104
  <option value="1"<?php if ($options['autoplay']=="1") {echo " selected='selected'";} ?>><?php _e('Yes'); ?></option>
105
+ </select></td>
 
 
 
 
106
 
107
  <th scope="row"><?php _e('Loop Video'); ?></th>
108
  <td><select name="youtube_embed_loop">
109
  <option value="0"<?php if ($options['loop']=="0") {echo " selected='selected'";} ?>><?php _e('No'); ?></option>
110
  <option value="1"<?php if ($options['loop']=="1") {echo " selected='selected'";} ?>><?php _e('Yes'); ?></option>
111
  </select></td>
112
+ </tr><tr>
113
 
114
  <th scope="row"><?php _e('Show Closed Captions'); ?></th>
115
  <td><select name="youtube_embed_cc">
116
  <option value="0"<?php if ($options['cc']=="0") {echo " selected='selected'";} ?>><?php _e('No'); ?></option>
117
  <option value="1"<?php if ($options['cc']=="1") {echo " selected='selected'";} ?>><?php _e('Yes'); ?></option>
118
  </select></td>
 
119
 
120
  <th scope="row"><?php _e('Show Annotations'); ?></th>
121
  <td><select name="youtube_embed_annotation">
124
  </select></td>
125
  </tr><tr>
126
 
 
 
 
127
  <th scope="row"><?php _e('Enable Enhanced Genie Menu'); ?></th>
128
  <td><select name="youtube_embed_egm">
129
  <option value="0"<?php if ($options['egm']=="0") {echo " selected='selected'";} ?>><?php _e('No'); ?></option>
148
  <option value="0"<?php if ($options['search']=="0") {echo " selected='selected'";} ?>><?php _e('No'); ?></option>
149
  <option value="1"<?php if ($options['search']=="1") {echo " selected='selected'";} ?>><?php _e('Yes'); ?></option>
150
  </select></td>
151
+ </tr><tr>
152
+
153
+ <th scope="row"><?php _e('Link back to YouTube'); ?></th>
154
+ <td><select name="youtube_embed_link">
155
+ <option value="0"<?php if (($options['link']=="0")&&($options['link']!="")) {echo " selected='selected'";} ?>><?php _e('No'); ?></option>
156
+ <option value="1"<?php if (($options['link']=="1")or($options['link']=="")) {echo " selected='selected'";} ?>><?php _e('Yes'); ?></option>
157
+ </select></td>
158
+ </tr><tr>
159
+
160
+ <th style="font-weight: bold" scope="row"><?php _e('EmbedPlus Video Only'); ?></th>
161
+ </tr><tr>
162
+
163
+ <th scope="row"><?php _e('Stop'); ?></th>
164
+ <td><input type="text" size="3" maxlength="3" name="youtube_embed_stop" value="<?php echo $options['stop']; ?>"/> seconds</td>
165
+ </tr><tr>
166
+
167
+ <th scope="row"><?php _e('Show Real-time Reactions Button'); ?></th>
168
+ <td><select name="youtube_embed_react">
169
+ <option value="1"<?php if ($options['react']=="1") {echo " selected='selected'";} ?>><?php _e('Yes'); ?></option>
170
+ <option value="0"<?php if ($options['react']=="0") {echo " selected='selected'";} ?>><?php _e('No'); ?></option>
171
+ </select></td>
172
+
173
+ <th scope="row"><?php _e('Find Sweet Spots for Next/Prev Buttons'); ?></th>
174
+ <td><select name="youtube_embed_sweetspot">
175
+ <option value="1"<?php if ($options['sweetspot']=="1") {echo " selected='selected'";} ?>><?php _e('Yes'); ?></option>
176
+ <option value="0"<?php if ($options['sweetspot']=="0") {echo " selected='selected'";} ?>><?php _e('No'); ?></option>
177
+ </select></td>
178
 
179
  </tr>
180
  </table>
183
  </p>
184
  </form>
185
 
186
+ <h3><?php _e('YouTube Video Sample'); ?></h3>
187
+ <p><?php _e('This uses the above settings, once they have been saved. <b>Would you like this to be your video? If so, <a href="http://www.artiss.co.uk/contact">contact me</a>!</b>'); ?></p>
188
+ <p><?php youtube_video_embed("ru6219KIKS0"); ?></p>
 
 
 
 
189
 
190
+ <h3><?php _e('Further Help'); ?></h3>
191
+ <?php _e('<p>All of my plugins are supported via <a title="Artiss.co.uk" href="http://www.artiss.co.uk" target="_blank">my website</a>.</p><p>Please feel free to visit the site for plugin updates and development news - either visit the site regularly, follow <a title="RSS News Feed" href="http://www.artiss.co.uk/feed" target="_blank">my news feed</a> or <a title="Artiss.co.uk on Twitter" href="http://www.twitter.com/artiss_tech" target="_blank">follow me on Twitter</a> (@artiss_tech).</p><p>For problems, suggestions or enhancements for this plugin, there is <a title="YouTube Embed" href="http://www.artiss.co.uk/youtube-embed" target="_blank">a dedicated page</a> and <a title="WordPress Plugins Forum" href="http://www.artiss.co.uk/forum" target="_blank">a forum</a>. The dedicated page will also list any known issues and planned enhancements.</p><p>Alternatively, please <a title="Contact Me" href="http://www.artiss.co.uk/contact" target="_blank">contact me directly</a>.</p><p style="font-weight: bold">This plugin, and all support, is supplied for free, but <a title="Donate" href="http://artiss.co.uk/donate" target="_blank">donations</a> are always welcome.</p>'); ?>
192
  <p><a href="http://validator.w3.org"><img src="http://www.w3.org/Icons/valid-xhtml10-blue" alt="Valid XHTML 1.0 Transitional" height="31px" width="88px" style="float: right"/></a></p>
193
  </div>
youtube-embed.php CHANGED
@@ -3,45 +3,62 @@
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');
14
  add_shortcode('youtube_thumb','youtube_thumbnail_sc');
15
  add_shortcode('youtube_url','youtube_url_sc');
 
16
  add_action('admin_menu','youtube_embed_menu');
17
- add_action('plugins_loaded','youtube_widget_init');
18
 
19
- // Shortcode function to embed a YouTube video
 
 
 
 
20
  function youtube_video_sc($paras="",$content="") {
21
- extract(shortcode_atts(array('width'=>'','height'=>'','fullscreen'=>'','related'=>'','autoplay'=>'','loop'=>'','egm'=>'','border'=>'','color1'=>'','color2'=>'','start'=>'','hd'=>'','search'=>'','info'=>'','annotation'=>'','cc'=>'','style'=>''),$paras));
22
- $youtube_code=generate_youtube_code($content,"v",$width,$height,ye_convert($fullscreen),ye_convert($related),ye_convert($autoplay),ye_convert($loop),ye_convert($egm),ye_convert($border),$color1,$color2,$start,ye_convert($hd),ye_convert($search),ye_convert($info),ye_convert_3($annotation),ye_convert($cc),$style);
 
 
 
23
  return $youtube_code;
24
  }
25
 
26
- // Shortcode function to embed a YouTube playlist
27
  function youtube_playlist_sc($paras="",$content="") {
28
- extract(shortcode_atts(array('width'=>'','height'=>'','fullscreen'=>'','related'=>'','autoplay'=>'','loop'=>'','egm'=>'','border'=>'','color1'=>'','color2'=>'','start'=>'','hd'=>'','search'=>'','info'=>'','annotation'=>'','cc'=>'','style'=>''),$paras));
29
- return generate_youtube_code($content,"p",$width,$height,ye_convert($fullscreen),ye_convert($related),ye_convert($autoplay),ye_convert($loop),ye_convert($egm),ye_convert($border),$color1,$color2,$start,ye_convert($hd),ye_convert($search),ye_convert($info),ye_convert_3($annotation),ye_convert($cc),$style);
30
  }
31
 
32
- // TShortcode function to embed a YouTube playlist
33
  function youtube_thumbnail_sc($paras="",$content="") {
34
  extract(shortcode_atts(array('style'=>'','class'=>'','rel'=>'','target'=>'','width'=>'','height'=>'','alt'=>''),$paras));
35
  return generate_thumbnail_code($content,$style,$class,$rel,$target,$width,$height,$alt);
36
  }
37
 
38
- // Shortcode function to return a short YouTube URL
39
  function youtube_url_sc($paras="",$content="") {
40
  if ($content=="") {return youtube_embed_error("No video ID has been supplied");} else {return "http://youtu.be/".$content;}
41
  }
42
 
43
- // Embed a video via your own function call
44
- function youtube_video_embed($content,$paras="",$style="",$type="v") {
 
 
 
 
 
 
 
 
 
45
  $width=youtube_get_parameters($paras,"width");
46
  $height=youtube_get_parameters($paras,"height");
47
  $fullscreen=youtube_get_parameters($paras,"fullscreen");
@@ -53,22 +70,29 @@ function youtube_video_embed($content,$paras="",$style="",$type="v") {
53
  $color1=youtube_get_parameters($paras,"color1");
54
  $color2=youtube_get_parameters($paras,"color2");
55
  $start=youtube_get_parameters($paras,"start");
56
- $hd=youtube_get_parameters($paras,"hd");
57
  $search=youtube_get_parameters($paras,"search");
58
  $info=youtube_get_parameters($paras,"info");
59
  $annotation=youtube_get_parameters($paras,"annotation");
60
  $cc=youtube_get_parameters($paras,"cc");
61
- echo generate_youtube_code($content,$type,$width,$height,ye_convert($fullscreen),ye_convert($related),ye_convert($autoplay),ye_convert($loop),ye_convert($egm),ye_convert($border),$color1,$color2,$start,ye_convert($hd),ye_convert($search),ye_convert($info),ye_convert_3($annotation),ye_convert($cc),$style);
 
 
 
 
 
 
 
62
  return;
63
  }
64
 
65
- // Embed a playlist via your own function call
66
  function youtube_playlist_embed($content,$paras="",$style="") {
67
  youtube_video_embed($content,$paras="",$style="","p");
68
  return;
69
  }
70
 
71
- // Display a video thumbnail via your own function call
72
  function youtube_thumb_embed($content,$paras="",$style="",$alt="") {
73
  $class=youtube_get_parameters($paras,"class");
74
  $rel=youtube_get_parameters($paras,"rel");
@@ -79,28 +103,111 @@ function youtube_thumb_embed($content,$paras="",$style="",$alt="") {
79
  return;
80
  }
81
 
82
- // Display a short YouTube URL via your own function call
83
- function youtube_short_url($id) {return "http://youtu.be/".$id;}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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");
90
  } else {
91
- // Get default values if no override values are supplied
92
- if (strtolower($widget)=="yes") {
93
- $options=get_option("youtube_widget");
94
- if (!is_array($options)) {
95
- $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');
96
- }
97
- $id=$options['id'];
98
- $type=$options['type'];
99
- } else {
100
- $options=get_option("youtube_embed");
101
- if (!is_array($options)) {
102
- $options = array('width'=>'425','height'=>'355','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');
103
- }
104
  }
105
  if ($width=="") {$width=$options['width'];}
106
  if ($height=="") {$height=$options['height'];}
@@ -119,27 +226,67 @@ function generate_youtube_code($id,$type,$width,$height,$fullscreen,$related,$au
119
  if ($annotation=="") {$annotation=$options['annotation'];}
120
  if ($cc=="") {$cc=$options['cc'];}
121
  if ($style=="") {$style=$options['style'];}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
122
  // Convert video ID characters
123
  $id=str_replace("&#8211;","--",$id);
124
  $id=str_replace("&#215;","x",$id);
 
125
  // Generate parameters to add to URL
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";
133
- $result.="<param name=\"wmode\" value=\"transparent\" />\n";
134
- if ($fullscreen==1) {$result.="<param name=\"allowFullScreen\" value=\"true\" />\n";}
135
- $result.="</object>\n";
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
136
  if ($style!="") {$result.="</div>\n";}
137
  $result.="<!-- End of YouTube Embed code -->\n";
138
  return $result;
139
  }
140
  }
141
 
142
- // Function to generate XHTML compatible YouTube video thumbnail
143
  function generate_thumbnail_code($id,$style,$class,$rel,$target,$width,$height,$alt) {
144
  if ($alt=="") {$alt="YouTube Video ".$id;}
145
  $youtube_code="<a href=\"http://www.youtube.com/watch?v=".$id."\"";
@@ -154,17 +301,52 @@ function generate_thumbnail_code($id,$style,$class,$rel,$target,$width,$height,$
154
  return $youtube_code."/></a>";
155
  }
156
 
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
  }
167
 
 
 
 
 
168
  // Function to extract parameters from an input string (1.0)
169
  function youtube_get_parameters($input,$para) {
170
  $start=strpos(strtolower($input),$para."=");
@@ -199,11 +381,27 @@ function ye_convert_3($input) {
199
  return $output;
200
  }
201
 
202
- function youtube_embed_menu() {add_options_page('YouTube Embed Settings','YouTube Embed',10, 'youtube-embed-settings', 'youtube_embed_options');}
203
- function youtube_embed_options() {include_once(WP_PLUGIN_DIR."/youtube-embed/youtube-embed-options.php");}
204
- function youtube_widget_init() {
205
- register_sidebar_widget(__('YouTube Embed'),'youtube_widget');
206
- register_widget_control('YouTube Embed','youtube_widget_options');
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
207
  }
208
- function youtube_widget_options() {include_once(WP_PLUGIN_DIR."/youtube-embed/youtube-widget-options.php");}
209
  ?>
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.4
7
  Author: David Artiss
8
  Author URI: http://www.artiss.co.uk
9
  */
10
+ define('youtube_embed_version','1.4');
11
+
12
  // Set up WordPress shortcodes and actions
13
  add_shortcode('youtube','youtube_video_sc');
14
  add_shortcode('youtube_playlist','youtube_playlist_sc');
15
  add_shortcode('youtube_thumb','youtube_thumbnail_sc');
16
  add_shortcode('youtube_url','youtube_url_sc');
17
+ add_shortcode('transcript','youtube_transcript');
18
  add_action('admin_menu','youtube_embed_menu');
 
19
 
20
+ /*
21
+ Shortcodes
22
+ */
23
+
24
+ // Embed a YouTube video
25
  function youtube_video_sc($paras="",$content="") {
26
+ extract(shortcode_atts(array('width'=>'','height'=>'','fullscreen'=>'','related'=>'','autoplay'=>'','loop'=>'','egm'=>'','border'=>'','color1'=>'','color2'=>'','start'=>'','hd'=>'','search'=>'','info'=>'','annotation'=>'','cc'=>'','style'=>'','link'=>'','react'=>'','stop'=>'','sweetspot'=>'','embedplus'=>''),$paras));
27
+ $embedplus=ye_convert($embedplus);
28
+ if ($embedplus=="1") {$type="m";}
29
+ if ($embedplus=="0") {$type="v";}
30
+ $youtube_code=generate_youtube_code($content,$type,$width,$height,ye_convert($fullscreen),ye_convert($related),ye_convert($autoplay),ye_convert($loop),ye_convert($egm),ye_convert($border),$color1,$color2,$start,ye_convert($hd),ye_convert($search),ye_convert($info),ye_convert_3($annotation),ye_convert($cc),$style,ye_convert($link),ye_convert($react),$stop,ye_convert($sweetspot));
31
  return $youtube_code;
32
  }
33
 
34
+ // Embed a YouTube playlist
35
  function youtube_playlist_sc($paras="",$content="") {
36
+ extract(shortcode_atts(array('width'=>'','height'=>'','fullscreen'=>'','related'=>'','autoplay'=>'','loop'=>'','egm'=>'','border'=>'','color1'=>'','color2'=>'','start'=>'','hd'=>'','search'=>'','info'=>'','annotation'=>'','cc'=>'','style'=>'','link'=>'','react'=>'','stop'=>'','sweetspot'=>''),$paras));
37
+ return generate_youtube_code($content,"p",$width,$height,ye_convert($fullscreen),ye_convert($related),ye_convert($autoplay),ye_convert($loop),ye_convert($egm),ye_convert($border),$color1,$color2,$start,ye_convert($hd),ye_convert($search),ye_convert($info),ye_convert_3($annotation),ye_convert($cc),$style,ye_convert($link),ye_convert($react),$stop,ye_convert($sweetspot));
38
  }
39
 
40
+ // Return a thumbnail URL
41
  function youtube_thumbnail_sc($paras="",$content="") {
42
  extract(shortcode_atts(array('style'=>'','class'=>'','rel'=>'','target'=>'','width'=>'','height'=>'','alt'=>''),$paras));
43
  return generate_thumbnail_code($content,$style,$class,$rel,$target,$width,$height,$alt);
44
  }
45
 
46
+ // Return a short YouTube URL
47
  function youtube_url_sc($paras="",$content="") {
48
  if ($content=="") {return youtube_embed_error("No video ID has been supplied");} else {return "http://youtu.be/".$content;}
49
  }
50
 
51
+ // Shortcode to return YouTube transcripts
52
+ function youtube_transcript($paras="",$content="") {
53
+ return get_youtube_transcript($content);
54
+ }
55
+
56
+ /*
57
+ Function calls
58
+ */
59
+
60
+ // Embed a YouTube video
61
+ function youtube_video_embed($content,$paras="",$style="") {
62
  $width=youtube_get_parameters($paras,"width");
63
  $height=youtube_get_parameters($paras,"height");
64
  $fullscreen=youtube_get_parameters($paras,"fullscreen");
70
  $color1=youtube_get_parameters($paras,"color1");
71
  $color2=youtube_get_parameters($paras,"color2");
72
  $start=youtube_get_parameters($paras,"start");
73
+ $hd=youtube_get_parameters($paras,"hd");
74
  $search=youtube_get_parameters($paras,"search");
75
  $info=youtube_get_parameters($paras,"info");
76
  $annotation=youtube_get_parameters($paras,"annotation");
77
  $cc=youtube_get_parameters($paras,"cc");
78
+ $link=youtube_get_parameters($paras,"link");
79
+ $react=youtube_get_parameters($paras,"react");
80
+ $stop=youtube_get_parameters($paras,"stop");
81
+ $sweetspot=youtube_get_parameters($paras,"sweetspot");
82
+ $embedplus=ye_convert(youtube_get_parameters($paras,"embedplus"));
83
+ if ($embedplus=="1") {$type="m";}
84
+ if ($embedplus=="0") {$type="v";}
85
+ echo generate_youtube_code($content,$type,$width,$height,ye_convert($fullscreen),ye_convert($related),ye_convert($autoplay),ye_convert($loop),ye_convert($egm),ye_convert($border),$color1,$color2,$start,ye_convert($hd),ye_convert($search),ye_convert($info),ye_convert_3($annotation),ye_convert($cc),$style,ye_convert($link),ye_convert($react),$stop,ye_convert($sweetspot));
86
  return;
87
  }
88
 
89
+ // Embed a playlist
90
  function youtube_playlist_embed($content,$paras="",$style="") {
91
  youtube_video_embed($content,$paras="",$style="","p");
92
  return;
93
  }
94
 
95
+ // Display a video thumbnail
96
  function youtube_thumb_embed($content,$paras="",$style="",$alt="") {
97
  $class=youtube_get_parameters($paras,"class");
98
  $rel=youtube_get_parameters($paras,"rel");
103
  return;
104
  }
105
 
106
+ // Display a short YouTube URL
107
+ function youtube_short_url($id) {
108
+ return "http://youtu.be/".$id;
109
+ }
110
+
111
+ // Return XML formatted YouTube transcript
112
+ function get_youtube_transcript_xml($id="") {
113
+ $return=youtube_get_file("http://video.google.com/timedtext?lang=en&v=".$id);
114
+ if ($return['rc']<0) {return false;} else {return $return['file'];}
115
+ }
116
+
117
+ /*
118
+ Admin Menu
119
+ */
120
+
121
+ function youtube_embed_menu() {
122
+ add_options_page('YouTube Embed Settings','YouTube Embed',10, 'youtube-embed-settings', 'youtube_embed_options');
123
+ }
124
+
125
+ function youtube_embed_options() {
126
+ include_once(WP_PLUGIN_DIR."/youtube-embed/youtube-embed-options.php");
127
+ }
128
+
129
+ /*
130
+ Widgets
131
+ */
132
+
133
+ global $wp_version;
134
+ if((float)$wp_version>=2.8){
135
+
136
+ class YouTubeEmbedWidget extends WP_Widget {
137
+
138
+ // Constructor
139
+ function YouTubeEmbedWidget() {
140
+ parent::WP_Widget('youtube_embed_widget', 'YouTube Embed', array('description' => 'Embed YouTube Widget.', 'class' => 'my-widget-class'));
141
+ }
142
+
143
+ // Display widget
144
+ function widget($args, $instance) {
145
+ extract($args, EXTR_SKIP);
146
+ echo $before_widget;
147
+ $title=$instance['titles'];
148
+ $id=$instance['id'];
149
+ if (!empty($title)) {echo $before_title.$title.$after_title;}
150
+ echo generate_youtube_code($instance['id'],$instance['type'],$instance['width'],$instance['height'],$instance['fullscreen'],$instance['related'],$instance['autoplay'],$instance['loop'],$instance['egm'],$instance['border'],$instance['color1'],$instance['color2'],$instance['start'],$instance['hd'],$instance['search'],$instance['info'],$instance['annotation'],$instance['cc'],$instance['style'],$instance['link'],$instance['react'],$instance['stop'],$instance['sweetspot']);
151
+ echo $after_widget;
152
+ }
153
+
154
+ // Update/save function
155
+ function update($new_instance, $old_instance) {
156
+ $instance=$old_instance;
157
+ $instance['titles']=strip_tags($new_instance['titles']);
158
+ $instance['id']=$new_instance['id'];
159
+ $instance['type']=$new_instance['type'];
160
+ $instance['width']=$new_instance['width'];
161
+ $instance['height']=$new_instance['height'];
162
+ $instance['border']=$new_instance['border'];
163
+ $instance['fullscreen']=$new_instance['fullscreen'];
164
+ $instance['hd']=$new_instance['hd'];
165
+ $instance['color1']=$new_instance['color1'];
166
+ $instance['color2']=$new_instance['color2'];
167
+ $instance['style']=$new_instance['style'];
168
+ $instance['autoplay']=$new_instance['autoplay'];
169
+ $instance['start']=$new_instance['start'];
170
+ $instance['loop']=$new_instance['loop'];
171
+ $instance['cc']=$new_instance['cc'];
172
+ $instance['annotation']=$new_instance['annotation'];
173
+ $instance['egm']=$new_instance['egm'];
174
+ $instance['related']=$new_instance['related'];
175
+ $instance['info']=$new_instance['info'];
176
+ $instance['search']=$new_instance['search'];
177
+ $instance['link']=$new_instance['link'];
178
+ $instance['react']=$new_instance['react'];
179
+ $instance['stop']=$new_instance['stop'];
180
+ $instance['sweetspot']=$new_instance['sweetspot'];
181
+ return $instance;
182
+ }
183
+
184
+ // Admin control form
185
+ function form($instance) {
186
+ include_once(WP_PLUGIN_DIR."/youtube-embed/youtube-widget-options.php");
187
+ }
188
+ }
189
+
190
+ // Register widget when loading the WP core
191
+ add_action('widgets_init',youtube_embed_register_widgets);
192
+ function youtube_embed_register_widgets() {register_widget('YouTubeEmbedWidget');}
193
+ }
194
+
195
+ /*
196
+ Generate Embed code
197
+ */
198
 
199
  // Generate XHTML compatible YouTube embed code
200
+ function generate_youtube_code($id,$type,$width,$height,$fullscreen,$related,$autoplay,$loop,$egm,$border,$color1,$color2,$start,$hd,$search,$info,$annotation,$cc,$style,$link,$react,$stop,$sweetspot) {
201
+
202
  // Ensure an ID is passed
203
  if (($id=="")&&(strtolower($widget)!="yes")) {
204
  return youtube_embed_error("No video/playlist ID has been supplied");
205
  } else {
206
+
207
+ // Get default values if no values are supplied
208
+ $options=get_option("youtube_embed");
209
+ if (!is_array($options)) {
210
+ $options = array('width'=>'425','height'=>'355','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','link'=>'1','react'=>'1','stop'=>'0','sweetspot'=>'1','type'=>'0');
 
 
 
 
 
 
 
 
211
  }
212
  if ($width=="") {$width=$options['width'];}
213
  if ($height=="") {$height=$options['height'];}
226
  if ($annotation=="") {$annotation=$options['annotation'];}
227
  if ($cc=="") {$cc=$options['cc'];}
228
  if ($style=="") {$style=$options['style'];}
229
+ if ($link=="") {$link=$options['link'];}
230
+ if ($react=="") {$react=$options['react'];}
231
+ if ($stop=="") {$stop=$options['stop'];}
232
+ if ($sweetspot=="") {$sweetspot=$options['sweetspot'];}
233
+ if ($type=="") {$type=$options['type'];}
234
+
235
+ // Set up EmbedPlus
236
+ if ($type=="m") {
237
+ $type="v";
238
+ $embedplus=true;
239
+ $tab="\t";
240
+ $embedheight=$height+32;
241
+ $objectclass=' class="cantembedplus"';
242
+ } else {
243
+ $embedplus=false;
244
+ $tab="";
245
+ $objectclass="";
246
+ }
247
+
248
  // Convert video ID characters
249
  $id=str_replace("&#8211;","--",$id);
250
  $id=str_replace("&#215;","x",$id);
251
+
252
  // Generate parameters to add to URL
253
  $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;
254
+ $paras_ep="&amp;width=".$width."&amp;height=".$height."&amp;hd=".$hd."&amp;react=".$react."&amp;sweetspot=".$sweetspot;
255
+ if ($start!=0) {$paras.="&amp;start=".$start; $paras_ep.="&amp;start=".$start;}
256
+ if ($stop!=0) {$paras_ep.="&amp;stop=".$stop;}
257
+
258
+ // Code header
259
  $result="<!-- YouTube Embed v".youtube_embed_version." | http://www.artiss.co.uk/youtube-embed -->\n";
260
  if ($style!="") {$result.="<div style=\"".$style."\">\n";}
261
+
262
+ // Add EmbedPlus code (if required)
263
+ if ($embedplus) {
264
+ $result.="<object type=\"application/x-shockwave-flash\" width=\"".$width."\" height=\"".$embedheight."\" data=\"http://getembedplus.com/embedplus.swf\">\n";
265
+ $result.="<param value=\"http://getembedplus.com/embedplus.swf\" name=\"movie\" />\n";
266
+ $result.="<param value=\"high\" name=\"quality\" />\n";
267
+ $result.="<param value=\"transparent\" name=\"wmode\" />\n";
268
+ $result.="<param value=\"always\" name=\"allowscriptaccess\" />\n";
269
+ if ($fullscreen==1) {$result.="<param name=\"allowFullScreen\" value=\"true\" />\n";}
270
+ $result.="<param name=\"flashvars\" value=\"ytid=".$id.$paras_ep."\" />\n";
271
+ }
272
+
273
+ // Add standard YouTube embed code
274
+ $result.=$tab."<object".$objectclass." type=\"application/x-shockwave-flash\" data=\"http://www.youtube.com/".$type."/".$id.$paras."\" width=\"".$width."\" height=\"".$height."\" wmode=\"transparent\">\n";
275
+ $result.=$tab."<param name=\"movie\" value=\"http://www.youtube.com/".$type."/".$id.$paras."\" />\n";
276
+ $result.=$tab."<param name=\"wmode\" value=\"transparent\" />\n";
277
+ if ($fullscreen==1) {$result.=$tab."<param name=\"allowFullScreen\" value=\"true\" />\n";}
278
+ if (($link!=1)&&($link!="")) {$result.=$tab."<param name=\"allowNetworking\" value=\"internal\" />\n";}
279
+
280
+ // Code footer
281
+ $result.=$tab."</object>\n";
282
+ if ($embedplus) {$result.="</object>\n<!--[if lte IE 6]> <style type=\"text/css\">.cantembedplus{display:none;}</style><![endif]-->\n";}
283
  if ($style!="") {$result.="</div>\n";}
284
  $result.="<!-- End of YouTube Embed code -->\n";
285
  return $result;
286
  }
287
  }
288
 
289
+ // Generate XHTML compatible YouTube video thumbnail
290
  function generate_thumbnail_code($id,$style,$class,$rel,$target,$width,$height,$alt) {
291
  if ($alt=="") {$alt="YouTube Video ".$id;}
292
  $youtube_code="<a href=\"http://www.youtube.com/watch?v=".$id."\"";
301
  return $youtube_code."/></a>";
302
  }
303
 
304
+ // Generate re-encoded YouTube transcript
305
+ function get_youtube_transcript($id) {
306
+
307
+ // Get transcript file
308
+ $return=youtube_get_file("http://video.google.com/timedtext?lang=en&v=".$id);
309
+ $xml=$return['file'];
310
+ $output="";
311
+
312
+ // If transcript file exists, strip and output
313
+ if ($return['rc']>0) {
314
+ $output="<!-- YouTube Embed v".youtube_embed_version." | http://www.artiss.co.uk/youtube-embed -->\n";
315
+ $pos=0;
316
+ $eof=false;
317
+ while (!$eof) {
318
+ $text_start=strpos($xml,"<text ",$pos);
319
+ if ($text_start!==false) {
320
+
321
+ // Extract the start time
322
+ $start_start=strpos($xml,'start="',$text_start)+7;
323
+ $start_end=strpos($xml,'"',$start_start)-1;
324
+ $start=substr($xml,$start_start,$start_end-$start_start+1);
325
+
326
+ // Convert time format
327
+ $start=str_pad(floor($start),3,"0",STR_PAD_LEFT);
328
+ $start=substr($start,0,-2).":".substr($start,-2,2);
329
+ // Now extract the text
330
+ $text_start=strpos($xml,">",$text_start)+1;
331
+ $text_end=strpos($xml,"</text>",$text_start)-1;
332
+ $text=substr($xml,$text_start,$text_end-$text_start+1);
333
+
334
+ // Now return the output
335
+ $output.="<div class=\"Transcript\"><span class=\"TranscriptTime\">".$start."</span> <span class=\"TranscriptText\">".htmlspecialchars_decode($text)."</span></div>";
336
+ $pos=$text_end+7;
337
+ } else {
338
+ $eof=true;
339
+ }
340
+ }
341
+ $output.="<!-- End of YouTube Embed code -->\n";
342
+ }
343
+ return $output;
344
  }
345
 
346
+ /*
347
+ Shared Functions
348
+ */
349
+
350
  // Function to extract parameters from an input string (1.0)
351
  function youtube_get_parameters($input,$para) {
352
  $start=strpos(strtolower($input),$para."=");
381
  return $output;
382
  }
383
 
384
+ // Function to get a file using CURL or alternative (1.4)
385
+ function youtube_get_file($filein) {
386
+ $fileout="";
387
+ // Try to get with CURL, if installed
388
+ if (in_array('curl',get_loaded_extensions())===true) {
389
+ $cURL = curl_init();
390
+ curl_setopt($cURL,CURLOPT_URL,$filein);
391
+ curl_setopt($cURL,CURLOPT_RETURNTRANSFER,1);
392
+ $fileout=curl_exec($cURL);
393
+ curl_close($cURL);
394
+ if ($fileout=="") {$rc=-1;} else {$rc=1;}
395
+ }
396
+ // If CURL failed and a url_fopen is allowed, use that
397
+ $fopen_status=strtolower(ini_get('allow_url_fopen'));
398
+ if (($fileout=="")&&(($fopen_status===true)or($fopen_status=="yes")or($fopen_status=="on")or($fopen_status=="1"))) {
399
+ $fileout=file_get_contents($filein);
400
+ if ($fileout=="") {$rc=-2;} else {$rc=2;}
401
+ }
402
+ if ((in_array('curl',get_loaded_extensions())!==true)&&(ini_get('allow_url_fopen')==1)) {$rc==-3;}
403
+ $file_return['file']=$fileout;
404
+ $file_return['rc']=$rc;
405
+ return $file_return;
406
  }
 
407
  ?>
youtube-widget-options.php CHANGED
@@ -1,134 +1,170 @@
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'];
11
- $options['height']=$_POST['youtube_widget_height'];
12
- $options['border']=$_POST['youtube_widget_border'];
13
- $options['fullscreen']=$_POST['youtube_widget_fullscreen'];
14
- $options['hd']=$_POST['youtube_widget_hd'];
15
- $options['color1']=$_POST['youtube_widget_color1'];
16
- $options['color2']=$_POST['youtube_widget_color2'];
17
- $options['style']=$_POST['youtube_widget_style'];
18
- $options['autoplay']=$_POST['youtube_widget_autoplay'];
19
- $options['start']=$_POST['youtube_widget_start'];
20
- $options['loop']=$_POST['youtube_widget_loop'];
21
- $options['cc']=$_POST['youtube_widget_cc'];
22
- $options['annotation']=$_POST['youtube_widget_annotation'];
23
- $options['egm']=$_POST['youtube_widget_egm'];
24
- $options['related']=$_POST['youtube_widget_related'];
25
- $options['info']=$_POST['youtube_widget_info'];
26
- $options['search']=$_POST['youtube_widget_search'];
27
- update_option("youtube_widget",$options);
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
-
37
- <label for="youtube_widget_type"><?php _e('Embed Type'); ?>: </label>
38
- <select name="youtube_widget_type">
39
- <option value="v"<?php if ($options['type']=="v") {echo " selected='selected'";} ?>><?php _e('Video'); ?></option>
40
- <option value="p"<?php if ($options['type']=="p") {echo " selected='selected'";} ?>><?php _e('Playlist'); ?></option>
41
- </select><br/>
42
-
43
- <h3><?php _e('Video Display Properties'); ?></h3>
44
-
45
- <label for="youtube_widget_width"><?php _e('Width'); ?>: </label>
46
- <input type="text" size="3" maxlength="3" name="youtube_widget_width" value="<?php echo $options['width']; ?>"/>px<br/>
47
-
48
- <label for="youtube_widget_height"><?php _e('Height'); ?>: </label>
49
- <input type="text" size="3" maxlength="3" name="youtube_widget_height" value="<?php echo $options['height']; ?>"/>px<br/>
50
-
51
- <label for="youtube_widget_border"><?php _e('Show Border'); ?>: </label>
52
- <select name="youtube_widget_border">
53
- <option value="0"<?php if ($options['border']=="0") {echo " selected='selected'";} ?>><?php _e('No'); ?></option>
54
- <option value="1"<?php if ($options['border']=="1") {echo " selected='selected'";} ?>><?php _e('Yes'); ?></option>
55
- </select><br/>
56
-
57
- <label for="youtube_widget_fullscreen"><?php _e('Fullscreen Button'); ?>: </label>
58
- <select name="youtube_widget_fullscreen">
59
- <option value="0"<?php if ($options['fullscreen']=="0") {echo " selected='selected'";} ?>><?php _e('No'); ?></option>
60
- <option value="1"<?php if ($options['fullscreen']=="1") {echo " selected='selected'";} ?>><?php _e('Yes'); ?></option>
61
- </select><br/>
62
-
63
- <label for="youtube_widget_hd"><?php _e('Default to HD Quality'); ?>: </label>
64
- <select name="youtube_widget_hd">
65
- <option value="0"<?php if ($options['hd']=="0") {echo " selected='selected'";} ?>><?php _e('No'); ?></option>
66
- <option value="1"<?php if ($options['hd']=="1") {echo " selected='selected'";} ?>><?php _e('Yes'); ?></option>
67
- </select><br/>
68
-
69
- <label for="youtube_widget_color1"><?php _e('Color 1'); ?>: </label>
70
- #<input type="text" size="6" maxlength="6" name="youtube_widget_color1" value="<?php echo $options['color1']; ?>"/>&nbsp;<span style="padding-right: 16px; background-color: #<?php echo $options['color1']; ?>">&nbsp;</span><br/>
71
-
72
- <label for="youtube_widget_color2"><?php _e('Color 2'); ?>: </label>
73
- #<input type="text" size="6" maxlength="6" name="youtube_widget_color2" value="<?php echo $options['color2']; ?>"/>&nbsp;<span style="padding-right: 16px; background-color: #<?php echo $options['color2'] ?>">&nbsp;</span><br/>
74
-
75
- <label for="youtube_widget_style"><?php _e('Style'); ?>: </label>
76
- <input type="text" size="20" name="youtube_widget_style" value="<?php echo $options['style']; ?>"/><br/>
77
-
78
- <h3><?php _e('Playback'); ?></h3>
79
-
80
- <label for="youtube_widget_autoplay"><?php _e('Autoplay'); ?>: </label>
81
- <select name="youtube_widget_autoplay">
82
- <option value="0"<?php if ($options['autoplay']=="0") {echo " selected='selected'";} ?>><?php _e('No'); ?></option>
83
- <option value="1"<?php if ($options['autoplay']=="1") {echo " selected='selected'";} ?>><?php _e('Yes'); ?></option>
84
- </select><br/>
85
-
86
- <label for="youtube_widget_start"><?php _e('Start'); ?>: </label>
87
- <input type="text" size="3" maxlength="3" name="youtube_widget_start" value="<?php echo $options['start']; ?>"/> seconds<br/>
88
-
89
- <label for="youtube_widget_loop"><?php _e('Loop Video'); ?>: </label>
90
- <select name="youtube_widget_loop">
91
- <option value="0"<?php if ($options['loop']=="0") {echo " selected='selected'";} ?>><?php _e('No'); ?></option>
92
- <option value="1"<?php if ($options['loop']=="1") {echo " selected='selected'";} ?>><?php _e('Yes'); ?></option>
93
- </select><br/>
94
-
95
- <label for="youtube_widget_cc"><?php _e('Show Closed Captions'); ?>: </label>
96
- <select name="youtube_widget_cc">
97
- <option value="0"<?php if ($options['cc']=="0") {echo " selected='selected'";} ?>><?php _e('No'); ?></option>
98
- <option value="1"<?php if ($options['cc']=="1") {echo " selected='selected'";} ?>><?php _e('Yes'); ?></option>
99
- </select><br/>
100
-
101
- <label for="youtube_widget_annotation"><?php _e('Show Annotations'); ?>: </label>
102
- <select name="youtube_widget_annotation">
103
- <option value="3"<?php if ($options['annotation']=="3") {echo " selected='selected'";} ?>><?php _e('No'); ?></option>
104
- <option value="1"<?php if ($options['annotation']=="1") {echo " selected='selected'";} ?>><?php _e('Yes'); ?></option>
105
- </select><br/>
106
-
107
- <h3><?php _e('Video Information'); ?></h3>
108
-
109
- <label for="youtube_widget_egm"><?php _e('Enable Enhanced Genie Menu'); ?>: </label>
110
- <select name="youtube_widget_egm">
111
- <option value="0"<?php if ($options['egm']=="0") {echo " selected='selected'";} ?>><?php _e('No'); ?></option>
112
- <option value="1"<?php if ($options['egm']=="1") {echo " selected='selected'";} ?>><?php _e('Yes'); ?></option>
113
- </select><br/>
114
-
115
- <label for="youtube_widget_related"><?php _e('Show Related Videos'); ?>: </label>
116
- <select name="youtube_widget_related">
117
- <option value="0"<?php if ($options['related']=="0") {echo " selected='selected'";} ?>><?php _e('No'); ?></option>
118
- <option value="1"<?php if ($options['related']=="1") {echo " selected='selected'";} ?>><?php _e('Yes'); ?></option>
119
- </select><br/>
120
-
121
- <label for="youtube_widget_info"><?php _e('Show Video Information'); ?>: </label>
122
- <select name="youtube_widget_info">
123
- <option value="0"<?php if ($options['info']=="0") {echo " selected='selected'";} ?>><?php _e('No'); ?></option>
124
- <option value="1"<?php if ($options['info']=="1") {echo " selected='selected'";} ?>><?php _e('Yes'); ?></option>
125
- </select><br/>
126
-
127
- <label for="youtube_widget_search"><?php _e('Show Search Box'); ?>: </label>
128
- <select name="youtube_widget_search">
129
- <option value="0"<?php if ($options['search']=="0") {echo " selected='selected'";} ?>><?php _e('No'); ?></option>
130
- <option value="1"<?php if ($options['search']=="1") {echo " selected='selected'";} ?>><?php _e('Yes'); ?></option>
131
- </select>
132
-
133
- <input type="hidden" id="youtube-widget-submit" name="youtube-widget-submit" value="1" />
134
- </p>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  <?php
2
+ $default=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','link'=>'1','react'=>'1','stop'=>'0','sweetspot'=>'1');
3
+ $instance=wp_parse_args( (array) $instance, $default);
4
+
5
+ $field_id=$this->get_field_id('titles');
6
+ $field_name=$this->get_field_name('titles');
7
+ echo "\r\n".'<p><label for="'.$field_id.'">'.__('Title').': </label><input type="text" class="widefat" id="'.$field_id.'" name="'.$field_name.'" value="'.attribute_escape( $instance['titles'] ).'" /></p>';
8
+
9
+ $field_id=$this->get_field_id('id');
10
+ $field_name=$this->get_field_name('id');
11
+ echo "\r\n".'<p><label for="'.$field_id.'">'.__('Video ID').': </label><input type="text" class="widefat" id="'.$field_id.'" name="'.$field_name.'" value="'.attribute_escape( $instance['id'] ).'" /></p>';
12
+
13
+ $field_id=$this->get_field_id('type');
14
+ $field_name=$this->get_field_name('type');
15
+ echo "\r\n".'<p><label for="'.$field_id.'">'.__('Embed Type').': </label><select name="'.$field_name.'" class="widefat" id="'.$field_id.'"><option value="v"';
16
+ if (attribute_escape( $instance['type'] )=="v") {echo " selected='selected'";}
17
+ echo '>'.__('Video (Standard)').'</option><option value="m"';
18
+ if (attribute_escape( $instance['type'] )=="m") {echo " selected='selected'";}
19
+ echo '>'.__('Video (EmbedPlus)').'</option><option value="p"';
20
+ if (attribute_escape( $instance['type'] )=="p") {echo " selected='selected'";}
21
+ echo '>'.__('Playlist').'</option></select></p>';
22
+
23
+ $field_id=$this->get_field_id('style');
24
+ $field_name=$this->get_field_name('style');
25
+ echo "\r\n".'<p><label for="'.$field_id.'">'.__('Style').': </label><input type="text" class="widefat" id="'.$field_id.'" name="'.$field_name.'" value="'.attribute_escape( $instance['style'] ).'" /></p>';
26
+
27
+ $field_id=$this->get_field_id('width');
28
+ $field_name=$this->get_field_name('width');
29
+ echo "\r\n".'<p><label for="'.$field_id.'">'.__('Width').': </label><input type="text" size="3" maxlength="3" id="'.$field_id.'" name="'.$field_name.'" value="'.attribute_escape( $instance['width'] ).'" />px</p>';
30
+
31
+ $field_id=$this->get_field_id('height');
32
+ $field_name=$this->get_field_name('height');
33
+ echo "\r\n".'<p><label for="'.$field_id.'">'.__('Height').': </label><input type="text" size="3" maxlength="3" id="'.$field_id.'" name="'.$field_name.'" value="'.attribute_escape( $instance['height'] ).'" />px</p>';
34
+
35
+ $field_id=$this->get_field_id('fullscreen');
36
+ $field_name=$this->get_field_name('fullscreen');
37
+ echo "\r\n".'<p><label for="'.$field_id.'">'.__('Fullscreen Button').': </label><select name="'.$field_name.'" class="widefat" id="'.$field_id.'"><option value="1"';
38
+ if (attribute_escape( $instance['fullscreen'] )=="1") {echo " selected='selected'";}
39
+ echo '>'.__('Yes').'</option><option value="0"';
40
+ if (attribute_escape( $instance['fullscreen'] )=="0") {echo " selected='selected'";}
41
+ echo '>'.__('No').'</option></select></p>';
42
+
43
+ $field_id=$this->get_field_id('start');
44
+ $field_name=$this->get_field_name('start');
45
+ echo "\r\n".'<p><label for="'.$field_id.'">'.__('Start').': </label><input type="text" size="3" maxlength="3" id="'.$field_id.'" name="'.$field_name.'" value="'.attribute_escape( $instance['start'] ).'" /> seconds</p>';
46
+
47
  ?>
48
+ <h3><?php _e('Standard Video/Playlist Only'); ?></h3>
49
+ <?php
50
+
51
+ $field_id=$this->get_field_id('border');
52
+ $field_name=$this->get_field_name('border');
53
+ echo "\r\n".'<p><label for="'.$field_id.'">'.__('Show Border').': </label><select name="'.$field_name.'" class="widefat" id="'.$field_id.'"><option value="1"';
54
+ if (attribute_escape( $instance['border'] )=="1") {echo " selected='selected'";}
55
+ echo '>'.__('Yes').'</option><option value="0"';
56
+ if (attribute_escape( $instance['border'] )=="0") {echo " selected='selected'";}
57
+ echo '>'.__('No').'</option></select></p>';
58
+
59
+ $field_id=$this->get_field_id('hd');
60
+ $field_name=$this->get_field_name('hd');
61
+ echo "\r\n".'<p><label for="'.$field_id.'">'.__('Default to HD Quality').': </label><select name="'.$field_name.'" class="widefat" id="'.$field_id.'"><option value="1"';
62
+ if (attribute_escape( $instance['hd'] )=="1") {echo " selected='selected'";}
63
+ echo '>'.__('Yes').'</option><option value="0"';
64
+ if (attribute_escape( $instance['hd'] )=="0") {echo " selected='selected'";}
65
+ echo '>'.__('No').'</option></select></p>';
66
+
67
+ $field_id=$this->get_field_id('color1');
68
+ $field_name=$this->get_field_name('color1');
69
+ echo "\r\n".'<p><label for="'.$field_id.'">'.__('Color 1').': #</label><input type="text" size="6" maxlength="6" id="'.$field_id.'" name="'.$field_name.'" value="'.attribute_escape( $instance['color1'] ).'" /></p>';
70
+
71
+ $field_id=$this->get_field_id('color2');
72
+ $field_name=$this->get_field_name('color2');
73
+ echo "\r\n".'<p><label for="'.$field_id.'">'.__('Color 2').': #</label><input type="text" size="6" maxlength="6" id="'.$field_id.'" name="'.$field_name.'" value="'.attribute_escape( $instance['color2'] ).'" /></p>';
74
+
75
+ $field_id=$this->get_field_id('autoplay');
76
+ $field_name=$this->get_field_name('autoplay');
77
+ echo "\r\n".'<p><label for="'.$field_id.'">'.__('Autoplay').': </label><select name="'.$field_name.'" class="widefat" id="'.$field_id.'"><option value="1"';
78
+ if (attribute_escape( $instance['autoplay'] )=="1") {echo " selected='selected'";}
79
+ echo '>'.__('Yes').'</option><option value="0"';
80
+ if (attribute_escape( $instance['autoplay'] )=="0") {echo " selected='selected'";}
81
+ echo '>'.__('No').'</option></select></p>';
82
+
83
+ $field_id=$this->get_field_id('loop');
84
+ $field_name=$this->get_field_name('loop');
85
+ echo "\r\n".'<p><label for="'.$field_id.'">'.__('Loop Video').': </label><select name="'.$field_name.'" class="widefat" id="'.$field_id.'"><option value="1"';
86
+ if (attribute_escape( $instance['loop'] )=="1") {echo " selected='selected'";}
87
+ echo '>'.__('Yes').'</option><option value="0"';
88
+ if (attribute_escape( $instance['loop'] )=="0") {echo " selected='selected'";}
89
+ echo '>'.__('No').'</option></select></p>';
90
+
91
+ $field_id=$this->get_field_id('cc');
92
+ $field_name=$this->get_field_name('cc');
93
+ echo "\r\n".'<p><label for="'.$field_id.'">'.__('Show Closed Captions').': </label><select name="'.$field_name.'" class="widefat" id="'.$field_id.'"><option value="1"';
94
+ if (attribute_escape( $instance['cc'] )=="1") {echo " selected='selected'";}
95
+ echo '>'.__('Yes').'</option><option value="0"';
96
+ if (attribute_escape( $instance['cc'] )=="0") {echo " selected='selected'";}
97
+ echo '>'.__('No').'</option></select></p>';
98
+
99
+ $field_id=$this->get_field_id('annotation');
100
+ $field_name=$this->get_field_name('annotation');
101
+ echo "\r\n".'<p><label for="'.$field_id.'">'.__('Show Annotations').': </label><select name="'.$field_name.'" class="widefat" id="'.$field_id.'"><option value="1"';
102
+ if (attribute_escape( $instance['annotation'] )=="1") {echo " selected='selected'";}
103
+ echo '>'.__('Yes').'</option><option value="3"';
104
+ if (attribute_escape( $instance['annotation'] )=="3") {echo " selected='selected'";}
105
+ echo '>'.__('No').'</option></select></p>';
106
+
107
+ $field_id=$this->get_field_id('egm');
108
+ $field_name=$this->get_field_name('egm');
109
+ echo "\r\n".'<p><label for="'.$field_id.'">'.__('Enable Enhanced Genie Menu').': </label><select name="'.$field_name.'" class="widefat" id="'.$field_id.'"><option value="1"';
110
+ if (attribute_escape( $instance['egm'] )=="1") {echo " selected='selected'";}
111
+ echo '>'.__('Yes').'</option><option value="0"';
112
+ if (attribute_escape( $instance['egm'] )=="0") {echo " selected='selected'";}
113
+ echo '>'.__('No').'</option></select></p>';
114
+
115
+ $field_id=$this->get_field_id('related');
116
+ $field_name=$this->get_field_name('related');
117
+ echo "\r\n".'<p><label for="'.$field_id.'">'.__('Show Related Videos').': </label><select name="'.$field_name.'" class="widefat" id="'.$field_id.'"><option value="1"';
118
+ if (attribute_escape( $instance['related'] )=="1") {echo " selected='selected'";}
119
+ echo '>'.__('Yes').'</option><option value="0"';
120
+ if (attribute_escape( $instance['related'] )=="0") {echo " selected='selected'";}
121
+ echo '>'.__('No').'</option></select></p>';
122
+
123
+ $field_id=$this->get_field_id('info');
124
+ $field_name=$this->get_field_name('info');
125
+ echo "\r\n".'<p><label for="'.$field_id.'">'.__('Show Video Information').': </label><select name="'.$field_name.'" class="widefat" id="'.$field_id.'"><option value="1"';
126
+ if (attribute_escape( $instance['info'] )=="1") {echo " selected='selected'";}
127
+ echo '>'.__('Yes').'</option><option value="0"';
128
+ if (attribute_escape( $instance['info'] )=="0") {echo " selected='selected'";}
129
+ echo '>'.__('No').'</option></select></p>';
130
+
131
+ $field_id=$this->get_field_id('search');
132
+ $field_name=$this->get_field_name('search');
133
+ echo "\r\n".'<p><label for="'.$field_id.'">'.__('Show Search Box').': </label><select name="'.$field_name.'" class="widefat" id="'.$field_id.'"><option value="1"';
134
+ if (attribute_escape( $instance['search'] )=="1") {echo " selected='selected'";}
135
+ echo '>'.__('Yes').'</option><option value="0"';
136
+ if (attribute_escape( $instance['search'] )=="0") {echo " selected='selected'";}
137
+ echo '>'.__('No').'</option></select></p>';
138
+
139
+ $field_id=$this->get_field_id('link');
140
+ $field_name=$this->get_field_name('link');
141
+ echo "\r\n".'<p><label for="'.$field_id.'">'.__('Link Back to YouTube').': </label><select name="'.$field_name.'" class="widefat" id="'.$field_id.'"><option value="1"';
142
+ if (attribute_escape( $instance['link'] )=="1") {echo " selected='selected'";}
143
+ echo '>'.__('Yes').'</option><option value="0"';
144
+ if (attribute_escape( $instance['link'] )=="0") {echo " selected='selected'";}
145
+ echo '>'.__('No').'</option></select></p>';
146
+
147
+ ?>
148
+ <h3><?php _e('EmbedPlus Video Only'); ?></h3>
149
+ <?php
150
+
151
+ $field_id=$this->get_field_id('stop');
152
+ $field_name=$this->get_field_name('stop');
153
+ echo "\r\n".'<p><label for="'.$field_id.'">'.__('Stop').': </label><input type="text" size="3" maxlength="3" id="'.$field_id.'" name="'.$field_name.'" value="'.attribute_escape( $instance['stop'] ).'" /> seconds</p>';
154
+
155
+ $field_id=$this->get_field_id('react');
156
+ $field_name=$this->get_field_name('react');
157
+ echo "\r\n".'<p><label for="'.$field_id.'">'.__('Show Reactions Button').': </label><select name="'.$field_name.'" class="widefat" id="'.$field_id.'"><option value="1"';
158
+ if (attribute_escape( $instance['react'] )=="1") {echo " selected='selected'";}
159
+ echo '>'.__('Yes').'</option><option value="0"';
160
+ if (attribute_escape( $instance['react'] )=="0") {echo " selected='selected'";}
161
+ echo '>'.__('No').'</option></select></p>';
162
+
163
+ $field_id=$this->get_field_id('sweetspot');
164
+ $field_name=$this->get_field_name('sweetspot');
165
+ echo "\r\n".'<p><label for="'.$field_id.'">'.__('Find Sweet Spots').': </label><select name="'.$field_name.'" class="widefat" id="'.$field_id.'"><option value="1"';
166
+ if (attribute_escape( $instance['sweetspot'] )=="1") {echo " selected='selected'";}
167
+ echo '>'.__('Yes').'</option><option value="0"';
168
+ if (attribute_escape( $instance['sweetspot'] )=="0") {echo " selected='selected'";}
169
+ echo '>'.__('No').'</option></select></p>';
170
+ ?>