YouTube Embed - Version 2.1

Version Description

  • Enhancement: New option to switch API options (where HTTP or HTTPS, display messages or not or even switch off)
    • Enhancement: Output video playback errors as XHTML comments. Output to post a generic message which can be changed in the options
    • Enhancement: Video information is shown in lists screen when first entering (no need to press Save button to display)
    • Enhancement: Added new color parameter, which allows you to specify the colour of the progress bar
    • Enhancement: Added new theme parameter, allowing you to specify if the player is dark or light skinned
    • Enhancement: Added new https parameter, allowing you to use HTTPS instead of HTTP for the video display
    • Enhancement: Added new version parameter to thumbnails, allowing different versions (including a high resolution one) to be displayed
    • Enhancement: Added new administration option to allow the thumbnail used in RSS feeds to be specified
    • Enhancement: Log the current plugin version into the database. This may be of use in future upgrades to detect which version the user is upgrading from
    • Bug: Fixed video title no longer being fetched since 2.0.3 (because of using v2 of API)
    • Bug: Fixed some error output - due to changes made in an earlier release some errors would not display

=

Download this release

Release Info

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

Code changes from version 2.0.4 to 2.1

images/Thumbs.db ADDED
Binary file
includes/artiss-dashboard-widget.php CHANGED
@@ -1,6 +1,6 @@
1
  <?php
2
  /**
3
- * Artiss Dashboard Widget
4
  *
5
  * Add a box to the dashboard to display Artiss plugin news and support links
6
  *
@@ -42,6 +42,8 @@ function artiss_plugin_help() {
42
  // No cache found
43
  if (!$output) {
44
 
 
 
45
  // Use MagpieRSS to fetch the feed
46
  include_once( ABSPATH . WPINC . '/rss.php' );
47
  $array = fetch_rss( 'http://www.artiss.co.uk/category/wordpress/feed' );
1
  <?php
2
  /**
3
+ * Artiss Dashboard Widget (v1.1)
4
  *
5
  * Add a box to the dashboard to display Artiss plugin news and support links
6
  *
42
  // No cache found
43
  if (!$output) {
44
 
45
+ $output = '<img src="http://www.artiss.co.uk/wp-content/themes/artiss-1/images/head.png" alt="Artiss.co.uk logo" title="Artiss.co.uk logo" style="float: right; margin-right: 8px; margin-bottom: 4px; padding:2px; padding-bottom: 8px; border: 1px solid #ddd; background-color: #fff;" />';
46
+
47
  // Use MagpieRSS to fetch the feed
48
  include_once( ABSPATH . WPINC . '/rss.php' );
49
  $array = fetch_rss( 'http://www.artiss.co.uk/category/wordpress/feed' );
includes/function-calls.php CHANGED
@@ -50,6 +50,9 @@ function youtube_video_embed( $content, $paras = '', $style = '' ) {
50
  $audio = ye_get_parameters( $paras, 'audio' );
51
  $template = ye_get_parameters( $paras, 'template' );
52
  $hd = ye_get_parameters( $paras, 'hd' );
 
 
 
53
 
54
  // Get Embed type
55
  $type = ye_get_embed_type( $type, $embedplus );
@@ -57,7 +60,7 @@ function youtube_video_embed( $content, $paras = '', $style = '' ) {
57
  // Set up Autohide parameter
58
  $autohide = ye_set_autohide( $autohide );
59
 
60
- echo ye_generate_youtube_code( $content, $type, $width, $height, ye_convert( $fullscreen ), ye_convert( $related ), ye_convert( $autoplay ), ye_convert( $loop ), $start, ye_convert( $info ), ye_convert_3( $annotation ), ye_convert( $cc ), $style, ye_convert( $link ), ye_convert( $react ), $stop, ye_convert( $sweetspot ), ye_convert( $disablekb ), $ratio, $autohide, ye_convert( $controls ), $profile, $list, ye_convert( $audio ), $template, ye_convert( $hd ) );
61
  return;
62
  }
63
 
@@ -84,8 +87,9 @@ function youtube_thumb_embed( $content, $paras = '', $style = '', $alt = '' ) {
84
  $target = ye_get_parameters( $paras, 'target' );
85
  $width = ye_get_parameters( $paras, 'width' );
86
  $height = ye_get_parameters( $paras, 'height' );
 
87
 
88
- echo ye_generate_thumbnail_code( $content, $style, $class, $rel, $target, $width, $height, $alt );
89
 
90
  return;
91
  }
@@ -148,7 +152,7 @@ function get_youtube_transcript_xml ( $id ) {
148
  // Check what type of video it is and whether it's valid
149
  $embed_type = ye_validate_id( $id );
150
  if ( $embed_type != 'v' ) {
151
- if ( strlen( $embed_type ) != 1 ) {
152
  echo ye_error( $embed_type );
153
  } else {
154
  echo ye_error( 'The YouTube ID of ' . $id . ' is invalid.' );
@@ -208,8 +212,12 @@ function get_youtube_name( $id ) {
208
 
209
  // Check what type of video it is and whether it's valid
210
  $return = ye_validate_id( $id, true );
211
- if ( !$return[ 'type' ] ) { return ye_error( 'The YouTube ID of ' . $id . ' is invalid.' ); }
212
- if ( strlen( $return[ 'type' ] ) != 1 ) { return ye_error( $return[ 'type' ] ); }
 
 
 
 
213
 
214
  // Return the video title
215
  return $return['title'];
50
  $audio = ye_get_parameters( $paras, 'audio' );
51
  $template = ye_get_parameters( $paras, 'template' );
52
  $hd = ye_get_parameters( $paras, 'hd' );
53
+ $color = ye_get_parameters( $paras, 'color' );
54
+ $theme = ye_get_parameters( $paras, 'theme' );
55
+ $https = ye_get_parameters( $paras, 'https' );
56
 
57
  // Get Embed type
58
  $type = ye_get_embed_type( $type, $embedplus );
60
  // Set up Autohide parameter
61
  $autohide = ye_set_autohide( $autohide );
62
 
63
+ echo ye_generate_youtube_code( $content, $type, $width, $height, ye_convert( $fullscreen ), ye_convert( $related ), ye_convert( $autoplay ), ye_convert( $loop ), $start, ye_convert( $info ), ye_convert_3( $annotation ), ye_convert( $cc ), $style, ye_convert( $link ), ye_convert( $react ), $stop, ye_convert( $sweetspot ), ye_convert( $disablekb ), $ratio, $autohide, ye_convert( $controls ), $profile, $list, ye_convert( $audio ), $template, ye_convert( $hd ), $color, $theme, $https );
64
  return;
65
  }
66
 
87
  $target = ye_get_parameters( $paras, 'target' );
88
  $width = ye_get_parameters( $paras, 'width' );
89
  $height = ye_get_parameters( $paras, 'height' );
90
+ $version = ye_get_parameters( $paras, 'version' );
91
 
92
+ echo ye_generate_thumbnail_code( $content, $style, $class, $rel, $target, $width, $height, $alt, $version );
93
 
94
  return;
95
  }
152
  // Check what type of video it is and whether it's valid
153
  $embed_type = ye_validate_id( $id );
154
  if ( $embed_type != 'v' ) {
155
+ if ( strlen( $embed_type ) > 1 ) {
156
  echo ye_error( $embed_type );
157
  } else {
158
  echo ye_error( 'The YouTube ID of ' . $id . ' is invalid.' );
212
 
213
  // Check what type of video it is and whether it's valid
214
  $return = ye_validate_id( $id, true );
215
+ $embed_type = $return[ 'type' ];
216
+ if ( strlen( $embed_type ) > 1 ) {
217
+ echo ye_error( $embed_type );
218
+ } else {
219
+ echo ye_error( 'The YouTube ID of ' . $id . ' is invalid.' );
220
+ }
221
 
222
  // Return the video title
223
  return $return['title'];
includes/generate-download-code.php CHANGED
@@ -28,7 +28,7 @@ function ye_generate_download_code( $id ) {
28
  // Check what type of video it is and whether it's valid
29
  $embed_type = ye_validate_id( $id );
30
  if ( $embed_type != 'v' ) {
31
- if ( strlen( $embed_type ) != 1 ) {
32
  return ye_error( $embed_type );
33
  } else {
34
  return ye_error( 'The YouTube ID of ' . $id . ' is invalid.' );
28
  // Check what type of video it is and whether it's valid
29
  $embed_type = ye_validate_id( $id );
30
  if ( $embed_type != 'v' ) {
31
+ if ( strlen( $embed_type ) > 1 ) {
32
  return ye_error( $embed_type );
33
  } else {
34
  return ye_error( 'The YouTube ID of ' . $id . ' is invalid.' );
includes/generate-embed-code.php CHANGED
@@ -12,7 +12,7 @@
12
  *
13
  * Generate XHTML compatible YouTube embed code
14
  *
15
- * @since 2.0
16
  *
17
  * @uses ye_convert_id Convert special characters in ID
18
  * @uses ye_error Display an error
@@ -48,17 +48,21 @@
48
  * @param string $list_style How to use a list, if used
49
  * @param string $audio Only show controls, for audio playback
50
  * @param string $template Display template
 
 
 
 
51
  * @return string Code output
52
  */
53
 
54
- function ye_generate_youtube_code( $id = '', $type = '', $width = '', $height = '', $fullscreen = '', $related = '', $autoplay = '', $loop = '', $start = '', $info = '', $annotation = '', $cc = '', $style = '', $link = '', $react = '', $stop = '', $sweetspot = '', $disablekb = '', $ratio = '', $autohide = '', $controls = '', $profile = '', $list_style = '', $audio = '', $template = '', $hd = '' ) {
55
 
56
  // Ensure an ID is passed
57
  if ( $id == '' ) { return ye_error( 'No video/playlist ID has been supplied' ); }
58
 
59
  // Get general options
60
  $general = ye_set_general_defaults();
61
-
62
  // Find the profile, if one is specified
63
  $profile = ye_validate_profile( $profile, $general[ 'profile_no' ] );
64
 
@@ -88,8 +92,17 @@ function ye_generate_youtube_code( $id = '', $type = '', $width = '', $height =
88
  $title = $return['title'];
89
  $embed_type = $return[ 'type' ];
90
 
91
- if ( $embed_type == '' ) { return ye_error( 'The YouTube ID of ' . $id . ' is invalid.' ); }
92
- if ( strlen ( $embed_type ) != 1 ) { return ye_error( $embed_type ); }
 
 
 
 
 
 
 
 
 
93
 
94
  } else {
95
 
@@ -121,13 +134,19 @@ function ye_generate_youtube_code( $id = '', $type = '', $width = '', $height =
121
  }
122
 
123
  // Generate a cache key for the above passed parameters
124
- $cache_key = 'ye_video_' . base64_encode( sha1( $id . $type . $width . $height . $fullscreen . $related . $autoplay . $loop . $start . $info . $annotation . $cc . $style . $link . $react . $stop . $sweetspot . $disablekb . $ratio . $autohide . $controls . $profile . $list_style . $audio . $template . $hd . print_r( $general, true ) . print_r( $options, true ) . print_r( $list, true ) ) );
125
 
126
  // Try and get the output from cache. If it exists, return the code
127
  if ( ( $general[ 'embed_cache' ] != 0 ) && ( !is_feed() ) ) {
128
  $result = get_transient( $cache_key );
129
  if ( $result !== false) { return $result; }
130
- }
 
 
 
 
 
 
131
 
132
  // If this is a feed then display a thumbnail and/or text link to the original video
133
  if ( is_feed () ) {
@@ -135,15 +154,13 @@ function ye_generate_youtube_code( $id = '', $type = '', $width = '', $height =
135
  if ( $playlist_ids != '' ) {
136
  $result .= '<p>'.__('A video list cannot be viewed within this feed - please view the original content').".</p>\n";
137
  } else {
138
- $youtube_url = 'http://www.youtube.com/watch?' . $embed_type . '=' . $id;
139
- if ( ( $embed_type == 'v' ) && ( $general[ 'feed' ] != 't' ) ) { $result .= '<p><a href="' . $youtube_url . '"><img src="http://img.youtube.com/vi/' . $id . "/2.jpg\"></a></p>\n"; }
140
  if ( ( $general ['feed'] != 'v' ) or ( $embed_type != 'v' ) ) { $result .= '<p><a href="' . $youtube_url . '">' . __( 'Click here</a> to view the video on YouTube' ) . ".</p>\n"; }
141
  }
142
  return $result;
143
  }
144
 
145
- $metadata = $general[ 'metadata' ];
146
-
147
  // Only set width and height from defaults if both are missing
148
  if ( ( $width == '' ) && ( $height == '' ) ) {
149
  $width = $options[ 'width' ];
@@ -167,6 +184,8 @@ function ye_generate_youtube_code( $id = '', $type = '', $width = '', $height =
167
  if ( $audio == '' ) { $audio = $options[ 'audio' ]; }
168
  if ( $hd == '' ) { $hd = $options[ 'hd' ]; }
169
  if ( $style == '' ) { $style = $options[ 'style' ]; }
 
 
170
 
171
  $wmode = $options[ 'wmode' ];
172
  $shadow = $options[ 'shadow' ];
@@ -180,7 +199,7 @@ function ye_generate_youtube_code( $id = '', $type = '', $width = '', $height =
180
 
181
  // If looping and no playlist has been generated, add the current ID
182
  // This is a workaround for the AS3 player which won't otherwise loop
183
- if ( ( $loop == 1 ) && ( $embed_type != 'p' ) && ( $playlist_ids == '' ) ) { $playlist_ids = $id; }
184
 
185
  // If no type was specified, depending on whether this is a video or playlist, set the specific default
186
  if ( $type == '' ) {
@@ -253,6 +272,8 @@ function ye_generate_youtube_code( $id = '', $type = '', $width = '', $height =
253
  if ( $disablekb == 1 ) { $paras .= '&amp;disablekb=1'; }
254
  if ( $autohide != 2 ) { $paras .= '&amp;autohide=' . $autohide; }
255
  if ( $controls != 1 ) { $paras .= '&amp;controls=0'; }
 
 
256
 
257
  // If not a playlist, add the playlist parameter
258
  if ( $playlist_ids != '' ) { $paras .= '&amp;playlist=' . $playlist_ids; }
@@ -282,11 +303,11 @@ function ye_generate_youtube_code( $id = '', $type = '', $width = '', $height =
282
 
283
  // Add AS3 YouTube embed code
284
  if ( ( $swf ) or ( ( $embedplus ) && ( ( $fallback == 'o' ) or ( $fallback == 'p' ) ) ) ) {
285
- $result .= $tab . "<object class=\"" . $class . "\" type=\"application/x-shockwave-flash\" data=\"http://www.youtube.com/" . $embed_type . "/" . $id . $paras . "\" width=\"" . $width . "\" height=\"" . $height . "\" style=\"" . $style . "\"";
286
- if ( $metadata != 0 ) { $result .= " rel=\"media:video\" resource=\"http://www.youtube.com/" . $embed_type . "/" . $id ."\" xmlns:media=\"http://search.yahoo.com/searchmonkey/media/\""; }
287
  $result .= ">\n";
288
  if ( $metadata != 0 ) { $result .= $tab . "\t<a rel=\"media:thumbnail\" href=\"http://img.youtube.com/vi/" . $id . "/default.jpg\" />\n"; }
289
- $result .= $tab . "\t<param name=\"movie\" value=\"http://www.youtube.com/" . $embed_type . "/" . $id . $paras . "\" />\n";
290
  $result .= $tab . "\t<param name=\"wmode\" value=\"" . $wmode . "\" />\n";
291
  if ( $fullscreen == 1 ) { $result .= $tab . "\t<param name=\"allowFullScreen\" value=\"true\" />\n"; }
292
  if ( ( $link != 1 ) && ( $link != '' ) ) { $result .= $tab . "\t<param name=\"allowNetworking\" value=\"internal\" />\n"; }
@@ -297,7 +318,7 @@ function ye_generate_youtube_code( $id = '', $type = '', $width = '', $height =
297
  // Add IFRAME embed code
298
  if ( ( $iframe ) or ( ( $embedplus ) && ( $fallback == "v" ) ) ) {
299
  if ( $embed_type == "p" ) { $playlist_para = "p/"; } else { $playlist_para = ''; }
300
- $result .= $tab . '<iframe style="border: 0;' . $style . '" class="' . $class . '" width="' . $width . '" height="' . $height . '" src="http://www.youtube.com/embed/' . $playlist_para . $id . '?' . substr( $paras, 1 ) . '&amp;wmode=' . $wmode . '"';
301
  if ( $fullscreen == 1 ) { $result .= ' allowfullscreen="allowfullscreen"'; }
302
  $result .= "></iframe>\n";
303
  }
@@ -326,7 +347,7 @@ function ye_generate_youtube_code( $id = '', $type = '', $width = '', $height =
326
  *
327
  * Returns a profile number for a supplied name
328
  *
329
- * @since 2.0
330
  *
331
  * @param string $name The name of the profile to find
332
  * @param string $number The number of profiles available
@@ -361,10 +382,10 @@ function ye_validate_profile( $name, $number ) {
361
  *
362
  * Returns a list for a supplied list number or name name - blank if not a valid list
363
  *
364
- * @since 2.0
365
  *
366
  * @param string $name The name of the list to find
367
- * @param string $number The number of lists available
368
  * @return string The list (defaults to blank)
369
  */
370
 
@@ -397,7 +418,7 @@ function ye_validate_list( $name, $number ) {
397
  }
398
  if ( $list != '' ) { $list = explode( "\n", $list ); }
399
  }
400
- return $list;
401
  }
402
 
403
  /**
@@ -405,16 +426,16 @@ function ye_validate_list( $name, $number ) {
405
  *
406
  * Extract a requested parameter from a URL
407
  *
408
- * @since 2.0
409
  *
410
  * @param string $id The ID of the video
411
  * @param string $para The parameter to extract
412
- * @param string $current The current parameter value
413
  * @return string The parameter value
414
  */
415
 
416
  function ye_get_url_para( $id, $para, $current ) {
417
-
418
  // Look for an ampersand
419
  $start_pos = false;
420
  if ( strpos( $id, '&amp;' . $para . '=' ) !== false ) { $start_pos = strpos( $id, '&amp;' . $para . '=' ) + 6 + strlen( $para ); }
12
  *
13
  * Generate XHTML compatible YouTube embed code
14
  *
15
+ * @since 2.0
16
  *
17
  * @uses ye_convert_id Convert special characters in ID
18
  * @uses ye_error Display an error
48
  * @param string $list_style How to use a list, if used
49
  * @param string $audio Only show controls, for audio playback
50
  * @param string $template Display template
51
+ * @param string $hd Use HD, if available
52
+ * @param string $color Progress bar colour
53
+ * @param string $theme Use dark or light theme
54
+ * @param string $https Use HTTPS for links
55
  * @return string Code output
56
  */
57
 
58
+ function ye_generate_youtube_code( $id = '', $type = '', $width = '', $height = '', $fullscreen = '', $related = '', $autoplay = '', $loop = '', $start = '', $info = '', $annotation = '', $cc = '', $style = '', $link = '', $react = '', $stop = '', $sweetspot = '', $disablekb = '', $ratio = '', $autohide = '', $controls = '', $profile = '', $list_style = '', $audio = '', $template = '', $hd = '', $color = '', $theme = '', $https = '' ) {
59
 
60
  // Ensure an ID is passed
61
  if ( $id == '' ) { return ye_error( 'No video/playlist ID has been supplied' ); }
62
 
63
  // Get general options
64
  $general = ye_set_general_defaults();
65
+
66
  // Find the profile, if one is specified
67
  $profile = ye_validate_profile( $profile, $general[ 'profile_no' ] );
68
 
92
  $title = $return['title'];
93
  $embed_type = $return[ 'type' ];
94
 
95
+ // If the video is invalid, output an appropriate error
96
+ if ( ( $embed_type == '' ) or ( strlen ( $embed_type ) != 1 ) ) {
97
+ if ( $embed_type == '' ) {
98
+ $error = 'The YouTube ID of ' . $id . ' is invalid.';
99
+ } else {
100
+ $error = $embed_type;
101
+ }
102
+ $result = "\n<!-- YouTube Embed v" . youtube_embed_version . " | http://www.artiss.co.uk/artiss-youtube-embed -->\n";
103
+ $result .= "<!-- " . $error . " -->\n" . ye_decode( $general[ 'error_message' ] ) . "\n<!-- End of YouTube Embed code -->\n";
104
+ return $result;
105
+ }
106
 
107
  } else {
108
 
134
  }
135
 
136
  // Generate a cache key for the above passed parameters
137
+ $cache_key = 'ye_video_' . base64_encode( sha1( $id . $type . $width . $height . $fullscreen . $related . $autoplay . $loop . $start . $info . $annotation . $cc . $style . $link . $react . $stop . $sweetspot . $disablekb . $ratio . $autohide . $controls . $profile . $list_style . $audio . $template . $hd . $color . $theme . $https . print_r( $general, true ) . print_r( $options, true ) . print_r( $list, true ) ) );
138
 
139
  // Try and get the output from cache. If it exists, return the code
140
  if ( ( $general[ 'embed_cache' ] != 0 ) && ( !is_feed() ) ) {
141
  $result = get_transient( $cache_key );
142
  if ( $result !== false) { return $result; }
143
+ }
144
+
145
+ $metadata = $general[ 'metadata' ];
146
+
147
+ // Work out correct protocol to use - HTTP or HTTPS
148
+ if ( $https == '' ) { $https = $options[ 'https' ]; }
149
+ if ( $https == 1 ) { $https = 's'; } else { $https = ''; }
150
 
151
  // If this is a feed then display a thumbnail and/or text link to the original video
152
  if ( is_feed () ) {
154
  if ( $playlist_ids != '' ) {
155
  $result .= '<p>'.__('A video list cannot be viewed within this feed - please view the original content').".</p>\n";
156
  } else {
157
+ $youtube_url = 'http' . $https . '://www.youtube.com/watch?' . $embed_type . '=' . $id;
158
+ if ( ( $embed_type == 'v' ) && ( $general[ 'feed' ] != 't' ) ) { $result .= '<p><a href="' . $youtube_url . '"><img src="http://img.youtube.com/vi/' . $id . '/' . $general[ 'thumbnail' ] . ".jpg\"></a></p>\n"; }
159
  if ( ( $general ['feed'] != 'v' ) or ( $embed_type != 'v' ) ) { $result .= '<p><a href="' . $youtube_url . '">' . __( 'Click here</a> to view the video on YouTube' ) . ".</p>\n"; }
160
  }
161
  return $result;
162
  }
163
 
 
 
164
  // Only set width and height from defaults if both are missing
165
  if ( ( $width == '' ) && ( $height == '' ) ) {
166
  $width = $options[ 'width' ];
184
  if ( $audio == '' ) { $audio = $options[ 'audio' ]; }
185
  if ( $hd == '' ) { $hd = $options[ 'hd' ]; }
186
  if ( $style == '' ) { $style = $options[ 'style' ]; }
187
+ if ( $color == '' ) { $color = $options[ 'color' ]; }
188
+ if ( $theme == '' ) { $theme = $options[ 'theme' ]; }
189
 
190
  $wmode = $options[ 'wmode' ];
191
  $shadow = $options[ 'shadow' ];
199
 
200
  // If looping and no playlist has been generated, add the current ID
201
  // This is a workaround for the AS3 player which won't otherwise loop
202
+ if ( ( $loop == 1 ) && ( $embed_type != 'p' ) && ( $playlist_ids == '' ) ) { $playlist_ids = $id; }
203
 
204
  // If no type was specified, depending on whether this is a video or playlist, set the specific default
205
  if ( $type == '' ) {
272
  if ( $disablekb == 1 ) { $paras .= '&amp;disablekb=1'; }
273
  if ( $autohide != 2 ) { $paras .= '&amp;autohide=' . $autohide; }
274
  if ( $controls != 1 ) { $paras .= '&amp;controls=0'; }
275
+ if ( strtolower( $color ) != 'red' ) { $paras .= '&amp;color=' . strtolower( $color ); }
276
+ if ( strtolower( $theme ) != 'dark' ) { $paras .= '&amp;theme=' . strtolower( $theme ); }
277
 
278
  // If not a playlist, add the playlist parameter
279
  if ( $playlist_ids != '' ) { $paras .= '&amp;playlist=' . $playlist_ids; }
303
 
304
  // Add AS3 YouTube embed code
305
  if ( ( $swf ) or ( ( $embedplus ) && ( ( $fallback == 'o' ) or ( $fallback == 'p' ) ) ) ) {
306
+ $result .= $tab . "<object class=\"" . $class . "\" type=\"application/x-shockwave-flash\" data=\"http" . $https . "://www.youtube.com/" . $embed_type . "/" . $id . $paras . "\" width=\"" . $width . "\" height=\"" . $height . "\" style=\"" . $style . "\"";
307
+ if ( $metadata != 0 ) { $result .= " rel=\"media:video\" resource=\"http" . $https . "://www.youtube.com/" . $embed_type . "/" . $id ."\" xmlns:media=\"http://search.yahoo.com/searchmonkey/media/\""; }
308
  $result .= ">\n";
309
  if ( $metadata != 0 ) { $result .= $tab . "\t<a rel=\"media:thumbnail\" href=\"http://img.youtube.com/vi/" . $id . "/default.jpg\" />\n"; }
310
+ $result .= $tab . "\t<param name=\"movie\" value=\"http" . $https . "://www.youtube.com/" . $embed_type . "/" . $id . $paras . "\" />\n";
311
  $result .= $tab . "\t<param name=\"wmode\" value=\"" . $wmode . "\" />\n";
312
  if ( $fullscreen == 1 ) { $result .= $tab . "\t<param name=\"allowFullScreen\" value=\"true\" />\n"; }
313
  if ( ( $link != 1 ) && ( $link != '' ) ) { $result .= $tab . "\t<param name=\"allowNetworking\" value=\"internal\" />\n"; }
318
  // Add IFRAME embed code
319
  if ( ( $iframe ) or ( ( $embedplus ) && ( $fallback == "v" ) ) ) {
320
  if ( $embed_type == "p" ) { $playlist_para = "p/"; } else { $playlist_para = ''; }
321
+ $result .= $tab . '<iframe style="border: 0;' . $style . '" class="' . $class . '" width="' . $width . '" height="' . $height . '" src="http' . $https . '://www.youtube.com/embed/' . $playlist_para . $id . '?' . substr( $paras, 1 ) . '&amp;wmode=' . $wmode . '"';
322
  if ( $fullscreen == 1 ) { $result .= ' allowfullscreen="allowfullscreen"'; }
323
  $result .= "></iframe>\n";
324
  }
347
  *
348
  * Returns a profile number for a supplied name
349
  *
350
+ * @since 2.0
351
  *
352
  * @param string $name The name of the profile to find
353
  * @param string $number The number of profiles available
382
  *
383
  * Returns a list for a supplied list number or name name - blank if not a valid list
384
  *
385
+ * @since 2.0
386
  *
387
  * @param string $name The name of the list to find
388
+ * @param string $number The number of lists available
389
  * @return string The list (defaults to blank)
390
  */
391
 
418
  }
419
  if ( $list != '' ) { $list = explode( "\n", $list ); }
420
  }
421
+ return $list;
422
  }
423
 
424
  /**
426
  *
427
  * Extract a requested parameter from a URL
428
  *
429
+ * @since 2.0
430
  *
431
  * @param string $id The ID of the video
432
  * @param string $para The parameter to extract
433
+ * @param string $current The current parameter value
434
  * @return string The parameter value
435
  */
436
 
437
  function ye_get_url_para( $id, $para, $current ) {
438
+
439
  // Look for an ampersand
440
  $start_pos = false;
441
  if ( strpos( $id, '&amp;' . $para . '=' ) !== false ) { $start_pos = strpos( $id, '&amp;' . $para . '=' ) + 6 + strlen( $para ); }
includes/generate-shorturl-code.php CHANGED
@@ -28,7 +28,7 @@ function ye_generate_shorturl_code( $id ) {
28
  // Check what type of video it is and whether it's valid
29
  $embed_type = ye_validate_id( $id );
30
  if ( $embed_type != 'v' ) {
31
- if ( strlen( $embed_type ) != 1 ) {
32
  return ye_error( $embed_type );
33
  } else {
34
  return ye_error( 'The YouTube ID of ' . $id . ' is invalid.' );
28
  // Check what type of video it is and whether it's valid
29
  $embed_type = ye_validate_id( $id );
30
  if ( $embed_type != 'v' ) {
31
+ if ( strlen( $embed_type ) > 1 ) {
32
  return ye_error( $embed_type );
33
  } else {
34
  return ye_error( 'The YouTube ID of ' . $id . ' is invalid.' );
includes/generate-thumbnail-code.php CHANGED
@@ -22,20 +22,28 @@
22
  * @return string $youtube_code Code
23
  */
24
 
25
- function ye_generate_thumbnail_code( $id, $style, $class, $rel, $target, $width, $height, $alt ) {
26
 
27
  // Extract the ID if a full URL has been specified
28
  $id = ye_extract_id( $id );
29
 
30
  // Check what type of video it is and whether it's valid
31
  $embed_type = ye_validate_id( $id );
 
32
  if ( $embed_type != 'v' ) {
33
- if ( strlen( $embed_type ) != 1 ) {
34
  return ye_error( $embed_type );
35
  } else {
36
  return ye_error( 'The YouTube ID of ' . $id . ' is invalid.' );
37
  }
38
  }
 
 
 
 
 
 
 
39
 
40
  // Now create the required code
41
  if ( $alt == '' ) { $alt = 'YouTube Video ' . $id; }
@@ -44,7 +52,7 @@ function ye_generate_thumbnail_code( $id, $style, $class, $rel, $target, $width,
44
  if ( $class != '' ) { $youtube_code .= ' class="' . $class . '"'; }
45
  if ( $rel != '' ) { $youtube_code .= ' rel="' . $rel . '"'; }
46
  if ( $target != '' ) { $youtube_code .= ' target="' . $target . '"'; }
47
- $youtube_code .= '><img src="http://img.youtube.com/vi/' . $id . '/2.jpg"';
48
  if ( $width != '' ) { $youtube_code .= ' width="' . $width . 'px"'; }
49
  if ( $height != '' ) { $youtube_code .= ' height="' . $height . 'px"'; }
50
  $youtube_code .= ' alt="' . $alt . '"/></a>';
22
  * @return string $youtube_code Code
23
  */
24
 
25
+ function ye_generate_thumbnail_code( $id, $style, $class, $rel, $target, $width, $height, $alt, $version ) {
26
 
27
  // Extract the ID if a full URL has been specified
28
  $id = ye_extract_id( $id );
29
 
30
  // Check what type of video it is and whether it's valid
31
  $embed_type = ye_validate_id( $id );
32
+
33
  if ( $embed_type != 'v' ) {
34
+ if ( strlen( $embed_type ) > 1 ) {
35
  return ye_error( $embed_type );
36
  } else {
37
  return ye_error( 'The YouTube ID of ' . $id . ' is invalid.' );
38
  }
39
  }
40
+
41
+ $version = strtolower( $version );
42
+ if ( ( $version != 'default' ) && ( $version != 'hq' ) && ( $version != 'start' ) && ( $version != 'middle' ) && ( $version != 'end' ) ) { $version = 'default'; }
43
+ if ( $version == 'hq' ) { $version = 'hqdefault'; }
44
+ if ( $version == 'start' ) { $version = 1; }
45
+ if ( $version == 'middle' ) { $version = 2; }
46
+ if ( $version == 'end' ) { $version = 3; }
47
 
48
  // Now create the required code
49
  if ( $alt == '' ) { $alt = 'YouTube Video ' . $id; }
52
  if ( $class != '' ) { $youtube_code .= ' class="' . $class . '"'; }
53
  if ( $rel != '' ) { $youtube_code .= ' rel="' . $rel . '"'; }
54
  if ( $target != '' ) { $youtube_code .= ' target="' . $target . '"'; }
55
+ $youtube_code .= '><img src="http://img.youtube.com/vi/' . $id . '/' . $version . '.jpg"';
56
  if ( $width != '' ) { $youtube_code .= ' width="' . $width . 'px"'; }
57
  if ( $height != '' ) { $youtube_code .= ' height="' . $height . 'px"'; }
58
  $youtube_code .= ' alt="' . $alt . '"/></a>';
includes/generate-transcript-code.php CHANGED
@@ -29,7 +29,7 @@ function ye_generate_transcript( $id ) {
29
  // Check what type of video it is and whether it's valid
30
  $embed_type = ye_validate_id( $id );
31
  if ( $embed_type != 'v' ) {
32
- if ( strlen( $embed_type ) != 1 ) {
33
  return ye_error( $embed_type );
34
  } else {
35
  return ye_error( 'The YouTube ID of ' . $id . ' is invalid.' );
29
  // Check what type of video it is and whether it's valid
30
  $embed_type = ye_validate_id( $id );
31
  if ( $embed_type != 'v' ) {
32
+ if ( strlen( $embed_type ) > 1 ) {
33
  return ye_error( $embed_type );
34
  } else {
35
  return ye_error( 'The YouTube ID of ' . $id . ' is invalid.' );
includes/options-general.php CHANGED
@@ -43,7 +43,9 @@ if ( ( !empty( $_POST ) ) && ( check_admin_referer( 'youtube-embed-general', 'yo
43
  $options[ 'comments_profile' ] = $_POST[ 'youtube_embed_comments_profile' ];
44
  $options[ 'metadata' ] = $_POST[ 'youtube_embed_metadata' ];
45
  $options[ 'feed' ] = $_POST[ 'youtube_embed_feed' ];
46
- $options[ 'api_errors' ] = $_POST[ 'youtube_embed_api_errors' ];
 
 
47
 
48
  // Update the options
49
  update_option( 'youtube_embed_general', $options );
@@ -107,7 +109,18 @@ $url = ye_set_url_option();
107
  <option value="t"<?php if ( $options[ 'feed' ] == "t" ) { echo " selected='selected'"; } ?>><?php _e ( 'Text link' ); ?></option>
108
  <option value="v"<?php if ( $options[ 'feed' ] == "v" ) { echo " selected='selected'"; } ?>><?php _e ( 'Thumbnail' ); ?></option>
109
  <option value="b"<?php if ( $options[ 'feed' ] == "b" ) { echo " selected='selected'"; } ?>><?php _e ( 'Thumbnail &amp; Text Link' ); ?></option>
110
- </select>&nbsp;<span class="description"><?php _e( 'Videos cannot be embedded in feeds. Select how you wish them to be shown instead.' ); ?></span></td>
 
 
 
 
 
 
 
 
 
 
 
111
  </tr>
112
  </table>
113
 
@@ -207,15 +220,33 @@ $url = ye_set_url_option();
207
  </tr>
208
  </table>
209
 
210
- <br/><span class="yt_heading"><?php _e( 'Error Reporting' ); ?></span>
 
 
211
 
212
  <table class="form-table">
213
  <tr>
214
- <th scope="row"><?php _e( 'Report API Errors' ); ?></th>
215
- <td><input type="checkbox" name="youtube_embed_api_errors" value="1"<?php if ( $options[ 'api_errors' ] == "1" ) { echo ' checked="checked"'; } ?>/>&nbsp;<span class="description"><?php _e( 'If switched off errors with the YouTube API will not be reported. Read the plugin FAQ for more details about this before proceeding' ); ?></span></td>
 
 
 
 
 
 
216
  </tr>
217
  </table>
218
 
 
 
 
 
 
 
 
 
 
 
219
  <?php wp_nonce_field( 'youtube-embed-general','youtube_embed_general_nonce', true, true ); ?>
220
 
221
  <p class="submit"><input type="submit" name="Submit" class="button-primary" value="<?php _e( 'Save Settings' ); ?>"/></p>
43
  $options[ 'comments_profile' ] = $_POST[ 'youtube_embed_comments_profile' ];
44
  $options[ 'metadata' ] = $_POST[ 'youtube_embed_metadata' ];
45
  $options[ 'feed' ] = $_POST[ 'youtube_embed_feed' ];
46
+ $options[ 'api' ] = $_POST[ 'youtube_embed_api' ];
47
+ $options[ 'error_message' ] = htmlspecialchars( $_POST[ 'youtube_embed_error_message' ] );
48
+ $options[ 'thumbnail' ] = $_POST[ 'youtube_embed_thumbnail' ];
49
 
50
  // Update the options
51
  update_option( 'youtube_embed_general', $options );
109
  <option value="t"<?php if ( $options[ 'feed' ] == "t" ) { echo " selected='selected'"; } ?>><?php _e ( 'Text link' ); ?></option>
110
  <option value="v"<?php if ( $options[ 'feed' ] == "v" ) { echo " selected='selected'"; } ?>><?php _e ( 'Thumbnail' ); ?></option>
111
  <option value="b"<?php if ( $options[ 'feed' ] == "b" ) { echo " selected='selected'"; } ?>><?php _e ( 'Thumbnail &amp; Text Link' ); ?></option>
112
+ </select>&nbsp;<span class="description"><?php _e( 'Videos cannot be embedded in feeds. Select how you wish them to be shown instead' ); ?></span></td>
113
+ </tr>
114
+
115
+ <tr>
116
+ <th scope="row">&nbsp;&nbsp;&nbsp;&nbsp;<?php _e( 'Thumbnail to use' ); ?></th>
117
+ <td><select name="youtube_embed_thumbnail">
118
+ <option value="default"<?php if ( $options[ 'thumbnail' ] == "default" ) { echo " selected='selected'"; } ?>><?php _e ( 'Default' ); ?></option>
119
+ <option value="hqdefault"<?php if ( $options[ 'thumbnail' ] == "hqdefault" ) { echo " selected='selected'"; } ?>><?php _e ( 'Default (HQ)' ); ?></option>
120
+ <option value="1"<?php if ( $options[ 'thumbnail' ] == "1" ) { echo " selected='selected'"; } ?>><?php _e ( 'Start' ); ?></option>
121
+ <option value="2"<?php if ( $options[ 'thumbnail' ] == "2" ) { echo " selected='selected'"; } ?>><?php _e ( 'Middle' ); ?></option>
122
+ <option value="3"<?php if ( $options[ 'thumbnail' ] == "3" ) { echo " selected='selected'"; } ?>><?php _e ( 'End' ); ?></option>
123
+ </select>&nbsp;<span class="description"><?php _e( 'Which thumbnail to use' ); ?></span></td>
124
  </tr>
125
  </table>
126
 
220
  </tr>
221
  </table>
222
 
223
+ <br/><span class="yt_heading"><?php _e( 'YouTube API' ); ?></span>
224
+
225
+ <p><?php _e( 'The YouTube API is used to validate video IDs and to determine if it is a video or playlist.' ); ?></p>
226
 
227
  <table class="form-table">
228
  <tr>
229
+ <th scope="row"><?php _e( 'API State' ); ?></th>
230
+ <td><select name="youtube_embed_api">
231
+ <option value="0"<?php if ( $options[ 'api' ] == "0" ) { echo " selected='selected'"; } ?>><?php _e ( 'API should not be used' ); ?></option>
232
+ <option value="1"<?php if ( $options[ 'api' ] == "1" ) { echo " selected='selected'"; } ?>><?php _e ( 'HTTP API used and errors are reported' ); ?></option>
233
+ <option value="2"<?php if ( $options[ 'api' ] == "2" ) { echo " selected='selected'"; } ?>><?php _e ( 'HTTPS API used and errors are reported' ); ?></option>
234
+ <option value="3"<?php if ( $options[ 'api' ] == "3" ) { echo " selected='selected'"; } ?>><?php _e ( 'HTTP API used and no errors are reported' ); ?></option>
235
+ <option value="4"<?php if ( $options[ 'api' ] == "4" ) { echo " selected='selected'"; } ?>><?php _e ( 'HTTPS API used and no errors are reported' ); ?></option>
236
+ </select>&nbsp;<span class="description"><?php _e( '' ); ?></span></td>
237
  </tr>
238
  </table>
239
 
240
+ <br/><span class="yt_heading"><?php _e( 'Error Reporting' ); ?></span>
241
+
242
+ <p><?php _e( 'Playback errors are within the XHTML source code as comments - parameter errors and other types are displayed on the post output.' ); ?></p>
243
+
244
+ <table class="form-table">
245
+ <tr>
246
+ <th scope="row"><?php _e( 'Video Playback Error Message' ); ?></th>
247
+ <td><input type="text" size="60" name="youtube_embed_error_message" value="<?php echo $options[ 'error_message' ]; ?>"/>&nbsp;<span class="description"><?php _e( 'This is the message that will be shown on the post' ); ?></span></td>
248
+ </table>
249
+
250
  <?php wp_nonce_field( 'youtube-embed-general','youtube_embed_general_nonce', true, true ); ?>
251
 
252
  <p class="submit"><input type="submit" name="Submit" class="button-primary" value="<?php _e( 'Save Settings' ); ?>"/></p>
includes/options-lists.php CHANGED
@@ -18,14 +18,12 @@
18
  // Set current list number
19
  if ( isset( $_POST[ 'youtube_embed_list_no' ] ) ) { $list_no = $_POST[ 'youtube_embed_list_no' ]; } else { $list_no = 0; }
20
  if ( $list_no == '' ) { $list_no = 1; }
21
- $id_nums = 0;
22
 
23
  // If options have been updated on screen, update the database
24
  if ( ( !empty( $_POST[ 'Submit' ] ) ) && ( check_admin_referer( 'youtube-embed-general', 'youtube_embed_general_nonce' ) ) ) {
25
-
26
  $class = 'updated fade';
27
  $message = 'Settings Saved.';
28
- $id_nums = 0;
29
  $new_id_list = '';
30
 
31
  if ( ( $_POST[ 'youtube_embed_video_list' ] == '' ) or ( $_POST[ 'youtube_embed_name' ] == '' ) ) {
@@ -38,41 +36,13 @@ if ( ( !empty( $_POST[ 'Submit' ] ) ) && ( check_admin_referer( 'youtube-embed-g
38
 
39
  // Loop through the video IDs
40
  while ( $loop < count( $id_array ) ) {
41
-
42
  // Extract the ID from the provided data
43
  $id = trim( ye_extract_id( $id_array[ $loop ] ) );
 
44
  if ( $id != '' ) {
45
-
46
- // Validate the video type - store results in an array
47
- $video_out[ $loop ][ 1 ] = $id;
48
  $video_info = ye_validate_id( $id, true );
49
- $type = $video_info[ 'type' ];
50
- $video_out[ $loop ][ 2 ] = $video_info[ 'title' ];
51
-
52
- if ( $type == 'p' ) {
53
- $video_out[ $loop ][ 3 ] = 'This is a playlist';
54
- $video_out[ $loop ][ 4 ] = '-1';
55
- $valid = false;
56
- } else {
57
-
58
- if ( $type == '' ) {
59
- $video_out[ $loop ][ 3 ] = 'Invalid video ID';
60
- $video_out[ $loop ][ 4 ] = '-2';
61
- $valid = false;
62
- } else {
63
- if ( strlen( $type ) != 1 ) {
64
- $video_out[ $loop ][ 3 ] = 'YouTube API error';
65
- $video_out[ $loop ][ 4 ] = '-3';
66
- $valid = false;
67
- } else {
68
- $video_out[ $loop ][ 3 ] = 'Valid video';
69
- $video_out[ $loop ][ 4 ] = '0';
70
- }
71
- }
72
- }
73
-
74
- $new_id_list .= $video_out[ $loop ][ 1 ]."\n";
75
- $id_nums ++;
76
  }
77
  $loop ++;
78
  }
@@ -86,14 +56,14 @@ if ( ( !empty( $_POST[ 'Submit' ] ) ) && ( check_admin_referer( 'youtube-embed-g
86
 
87
  // Update the options
88
  $options[ 'name' ] = $_POST[ 'youtube_embed_name' ];
89
-
90
  if ( $new_id_list == '' ) {
91
  $options[ 'list' ] = $_POST[ 'youtube_embed_video_list' ];
92
  } else {
93
  $options[ 'list' ] = substr( $new_id_list, 0, strlen( $new_id_list ) - 1 );
94
- }
95
 
96
- if ( substr( $class, 0, 7 ) == 'updated' ) { update_option( 'youtube_embed_list' . $list_no, $options ); }
97
  echo '<div class="' . $class.'"><p><strong>' . __( $message ) . "</strong></p></div>\n";
98
  } else {
99
  $class = '';
@@ -111,7 +81,7 @@ $general = ye_set_general_defaults();
111
  <?php
112
  $loop = 1;
113
  while ( $loop <= $general[ 'list_no' ] ) {
114
-
115
  $listfiles = get_option( 'youtube_embed_list' . $loop );
116
  $listname = $listfiles[ 'name' ];
117
 
@@ -152,29 +122,62 @@ while ( $loop <= $general[ 'list_no' ] ) {
152
  <?php
153
 
154
  // If video IDs exist display them on screen along with their status'
155
- if ( $id_nums > 0 ) {
 
 
156
 
157
  echo "<table class=\"widefat\">\n<thead>\n\t<tr>\n\t\t<th>Video ID</th>\n\t\t<th>Video Title</th>\n\t\t<th>Status</th>\n\t</tr>\n</thead>\n<tbody>\n";
158
  $loop = 0;
159
 
160
- while ( $loop < $id_nums ) {
161
 
162
- echo "\t<tr>\n\t\t<td>" . $video_out[ $loop ][ 1 ] . "</td>\n";
163
- echo "\t\t<td>" . $video_out[ $loop ][ 2 ] . "</td>\n";
164
- echo "\t\t<td style=\"";
165
 
166
- if ( $video_out[ $loop ][ 4 ] != 0 ) {
167
- echo 'font-weight: bold; color: #f00;';
168
- }
169
 
170
- echo '"><img src="' . WP_PLUGIN_URL . '/youtube-embed/images/';
171
- if ( $video_out[ $loop ][ 4 ] == 0 ) {
172
- echo 'tick.png" alt="The video ID is valid" title="The video ID is valid" ';
173
- } else {
174
- echo 'cross.png" alt="The video ID is invalid" title="The video ID is invalid" ';
175
- }
176
 
177
- echo "height=\"16px\" width=\"16px\"/>&nbsp;" . $video_out[ $loop ][ 3 ] . "</td>\n\t</tr>\n";
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
178
  $loop ++;
179
  }
180
  echo "</tbody>\n</table>\n";
18
  // Set current list number
19
  if ( isset( $_POST[ 'youtube_embed_list_no' ] ) ) { $list_no = $_POST[ 'youtube_embed_list_no' ]; } else { $list_no = 0; }
20
  if ( $list_no == '' ) { $list_no = 1; }
 
21
 
22
  // If options have been updated on screen, update the database
23
  if ( ( !empty( $_POST[ 'Submit' ] ) ) && ( check_admin_referer( 'youtube-embed-general', 'youtube_embed_general_nonce' ) ) ) {
24
+
25
  $class = 'updated fade';
26
  $message = 'Settings Saved.';
 
27
  $new_id_list = '';
28
 
29
  if ( ( $_POST[ 'youtube_embed_video_list' ] == '' ) or ( $_POST[ 'youtube_embed_name' ] == '' ) ) {
36
 
37
  // Loop through the video IDs
38
  while ( $loop < count( $id_array ) ) {
 
39
  // Extract the ID from the provided data
40
  $id = trim( ye_extract_id( $id_array[ $loop ] ) );
41
+ // Now check its validity
42
  if ( $id != '' ) {
 
 
 
43
  $video_info = ye_validate_id( $id, true );
44
+ if ( $video_info[ 'type' ] != 'v' ) { $valid = false; }
45
+ $new_id_list .= $id . "\n";
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
46
  }
47
  $loop ++;
48
  }
56
 
57
  // Update the options
58
  $options[ 'name' ] = $_POST[ 'youtube_embed_name' ];
59
+
60
  if ( $new_id_list == '' ) {
61
  $options[ 'list' ] = $_POST[ 'youtube_embed_video_list' ];
62
  } else {
63
  $options[ 'list' ] = substr( $new_id_list, 0, strlen( $new_id_list ) - 1 );
64
+ }
65
 
66
+ if ( substr( $class, 0, 7 ) == 'updated' ) { update_option( 'youtube_embed_list' . $list_no, $options ); }
67
  echo '<div class="' . $class.'"><p><strong>' . __( $message ) . "</strong></p></div>\n";
68
  } else {
69
  $class = '';
81
  <?php
82
  $loop = 1;
83
  while ( $loop <= $general[ 'list_no' ] ) {
84
+
85
  $listfiles = get_option( 'youtube_embed_list' . $loop );
86
  $listname = $listfiles[ 'name' ];
87
 
122
  <?php
123
 
124
  // If video IDs exist display them on screen along with their status'
125
+ if ( $options[ 'list' ] != '' ) {
126
+
127
+ $id_array = explode( "\n", $options[ 'list' ] );
128
 
129
  echo "<table class=\"widefat\">\n<thead>\n\t<tr>\n\t\t<th>Video ID</th>\n\t\t<th>Video Title</th>\n\t\t<th>Status</th>\n\t</tr>\n</thead>\n<tbody>\n";
130
  $loop = 0;
131
 
132
+ while ( $loop < count( $id_array ) ) {
133
 
134
+ // Extract the ID from the provided data
 
 
135
 
136
+ $id = trim( ye_extract_id( $id_array[ $loop ] ) );
137
+ if ( $id != '' ) {
 
138
 
139
+ // Validate the video type
 
 
 
 
 
140
 
141
+ $video_info = ye_validate_id( $id, true );
142
+ $type = $video_info[ 'type' ];
143
+
144
+ if ( $type == 'p' ) {
145
+ $text = 'This is a playlist';
146
+ $status = '-1';
147
+ } else {
148
+ if ( $type == '' ) {
149
+ $text = 'Invalid video ID';
150
+ $status = '-2';
151
+ } else {
152
+ if ( strlen( $type ) != 1 ) {
153
+ $text = 'YouTube API error';
154
+ $status = '-3';
155
+ } else {
156
+ $text = 'Valid video';
157
+ $status = '0';
158
+ }
159
+ }
160
+ }
161
+
162
+ // Output the video information
163
+
164
+ echo "\t<tr>\n\t\t<td>" . $id . "</td>\n";
165
+ echo "\t\t<td>" . $video_info[ 'title' ] . "</td>\n";
166
+ echo "\t\t<td style=\"";
167
+
168
+ if ( $status != 0 ) {
169
+ echo 'font-weight: bold; color: #f00;';
170
+ }
171
+
172
+ echo '"><img src="' . WP_PLUGIN_URL . '/youtube-embed/images/';
173
+ if ( $status == 0 ) {
174
+ echo 'tick.png" alt="The video ID is valid" title="The video ID is valid" ';
175
+ } else {
176
+ echo 'cross.png" alt="The video ID is invalid" title="The video ID is invalid" ';
177
+ }
178
+
179
+ echo "height=\"16px\" width=\"16px\"/>&nbsp;" . $text . "</td>\n\t</tr>\n";
180
+ }
181
  $loop ++;
182
  }
183
  echo "</tbody>\n</table>\n";
includes/options-profiles.php CHANGED
@@ -50,6 +50,9 @@ if ( ( !empty( $_POST[ 'Submit' ] ) ) && ( check_admin_referer( 'youtube-embed-p
50
  $options[ 'shadow'] = $_POST[ 'youtube_embed_shadow' ];
51
  $options[ 'audio'] = $_POST[ 'youtube_embed_audio' ];
52
  $options[ 'hd'] = $_POST[ 'youtube_embed_hd' ];
 
 
 
53
 
54
  $default_size = $_POST[ 'youtube_embed_size' ];
55
 
@@ -182,10 +185,23 @@ _e( '<br/>Use the drop-down on the right hand side to swap between profiles.' );
182
  <td><input type="checkbox" name="youtube_embed_controls" value="1"<?php if ( $options[ 'controls' ] == "1" ) { echo ' checked="checked"'; } ?>/>&nbsp;<span class="description"><?php _e( 'Video player controls will display' ); ?></span></td>
183
  </tr>
184
 
 
 
 
 
 
185
  <tr>
186
  <th scope="row"><?php _e( 'Loop Video' ); ?></th>
187
  <td><input type="checkbox" name="youtube_embed_loop" value="1"<?php if ( $options[ 'loop' ] == "1" ) { echo ' checked="checked"'; } ?>/>&nbsp;<span class="description"><?php _e( 'Play the initial video again and again. In the case of a playlist, this will play the entire playlist and then start again at the first video' ); ?></span></td>
188
  </tr>
 
 
 
 
 
 
 
 
189
  </table>
190
 
191
  <br/><span class="yt_heading"><?php _e( 'Non-EmbedPlus &amp; HTML5 Options' ); ?></span>
@@ -222,6 +238,14 @@ _e( '<br/>Use the drop-down on the right hand side to swap between profiles.' );
222
  <td><input type="checkbox" name="youtube_embed_link" value="1"<?php if ( $options[ 'link' ] == "1" ) { echo ' checked="checked"'; } ?>/>&nbsp;<span class="description"><?php _e( 'Video links back to YouTube when clicked' ); ?></span></td>
223
  </tr>
224
 
 
 
 
 
 
 
 
 
225
  <tr>
226
  <th scope="row"><?php _e( 'Related Videos' ); ?></th>
227
  <td><input type="checkbox" name="youtube_embed_related" value="1"<?php if ( $options[ 'related' ] == "1" ) { echo ' checked="checked"'; } ?>/>&nbsp;<span class="description"><?php _e( 'Load related videos once playback starts. Also toggles the search option.' ); ?></span></td>
50
  $options[ 'shadow'] = $_POST[ 'youtube_embed_shadow' ];
51
  $options[ 'audio'] = $_POST[ 'youtube_embed_audio' ];
52
  $options[ 'hd'] = $_POST[ 'youtube_embed_hd' ];
53
+ $options[ 'color' ] = $_POST[ 'youtube_embed_color' ];
54
+ $options[ 'theme' ] = $_POST[ 'youtube_embed_theme' ];
55
+ $options[ 'https' ] = $_POST[ 'youtube_embed_https' ];
56
 
57
  $default_size = $_POST[ 'youtube_embed_size' ];
58
 
185
  <td><input type="checkbox" name="youtube_embed_controls" value="1"<?php if ( $options[ 'controls' ] == "1" ) { echo ' checked="checked"'; } ?>/>&nbsp;<span class="description"><?php _e( 'Video player controls will display' ); ?></span></td>
186
  </tr>
187
 
188
+ <tr>
189
+ <th scope="row"><?php _e( 'HTTPS' ); ?></th>
190
+ <td><input type="checkbox" name="youtube_embed_https" value="1"<?php if ( $options[ 'https' ] == "1" ) { echo ' checked="checked"'; } ?>/>&nbsp;<span class="description"><?php _e( 'Use HTTPS? <a href="http://www.google.com/support/youtube/bin/answer.py?answer=171780&expand=UseHTTPS#HTTPS">Read more</a>' ); ?></span></td>
191
+ </tr>
192
+
193
  <tr>
194
  <th scope="row"><?php _e( 'Loop Video' ); ?></th>
195
  <td><input type="checkbox" name="youtube_embed_loop" value="1"<?php if ( $options[ 'loop' ] == "1" ) { echo ' checked="checked"'; } ?>/>&nbsp;<span class="description"><?php _e( 'Play the initial video again and again. In the case of a playlist, this will play the entire playlist and then start again at the first video' ); ?></span></td>
196
  </tr>
197
+
198
+ <tr>
199
+ <th scope="row"><?php _e( 'Theme' ); ?></th>
200
+ <td><select name="youtube_embed_theme">
201
+ <option value="dark"<?php if ( $options[ 'theme' ] == "dark" ) { echo " selected='selected'"; } ?>><?php _e( 'Dark' ); ?></option>
202
+ <option value="light"<?php if ( $options[ 'theme' ] == "light" ) { echo " selected='selected'"; } ?>><?php _e( 'Light' ); ?></option>
203
+ </select>&nbsp;<span class="description"><?php _e( 'Display player controls within a dark or light control bar' ); ?></span></td>
204
+ </tr>
205
  </table>
206
 
207
  <br/><span class="yt_heading"><?php _e( 'Non-EmbedPlus &amp; HTML5 Options' ); ?></span>
238
  <td><input type="checkbox" name="youtube_embed_link" value="1"<?php if ( $options[ 'link' ] == "1" ) { echo ' checked="checked"'; } ?>/>&nbsp;<span class="description"><?php _e( 'Video links back to YouTube when clicked' ); ?></span></td>
239
  </tr>
240
 
241
+ <tr>
242
+ <th scope="row"><?php _e( 'Progress Bar Colour' ); ?></th>
243
+ <td><select name="youtube_embed_color">
244
+ <option value="red"<?php if ( $options[ 'color' ] == "red" ) { echo " selected='selected'"; } ?>><?php _e( 'Red' ); ?></option>
245
+ <option value="white"<?php if ( $options[ 'color' ] == "white" ) { echo " selected='selected'"; } ?>><?php _e( 'White (desaturated)' ); ?></option>
246
+ </select>&nbsp;<span class="description"><?php _e( 'The colour that will be used in the player\'s video progress bar to highlight the amount of the video that\'s already been seen' ); ?></span></td>
247
+ </tr>
248
+
249
  <tr>
250
  <th scope="row"><?php _e( 'Related Videos' ); ?></th>
251
  <td><input type="checkbox" name="youtube_embed_related" value="1"<?php if ( $options[ 'related' ] == "1" ) { echo ' checked="checked"'; } ?>/>&nbsp;<span class="description"><?php _e( 'Load related videos once playback starts. Also toggles the search option.' ); ?></span></td>
includes/set-option-defaults.php CHANGED
@@ -64,6 +64,7 @@ function ye_set_url_option() {
64
  function ye_set_general_defaults() {
65
  $options = get_option( 'youtube_embed_general' );
66
  $changed = false;
 
67
 
68
  if ( !is_array( $options ) ) {
69
  if ( get_option( 'youtube_embed_editor' ) ) {
@@ -72,16 +73,23 @@ function ye_set_general_defaults() {
72
  $options[ 'editor_button' ] = $old_opts[ 'youtube' ];
73
  delete_option( 'youtube_embed_editor' );
74
  $changed = true;
75
- } else {
76
  // If array doesn't exist, set defaults
77
- $options = array( 'editor_button' => 1, 'admin_bar' => 1, 'profile_no' => 5, 'list_no' => 5, 'info_cache' => 1, 'embed_cache' => 24, 'transcript_cache' => 24, 'alt_profile' => 0, 'alt_profile2' => 0, 'bracket' => '', 'alt' => 0, 'url_profile' => 0, 'other_profile' => 0, 'comments' => '', 'comments_profile' => 0, 'metadata' => 1, 'feed' => 'b', 'api_errors' => 1 );
78
  $changed = true;
79
  }
80
  }
81
 
 
 
 
 
 
 
 
82
  // Because of upgrading, check each option - if not set, apply default
83
  if ( !array_key_exists( 'editor_button', $options ) ) { $options[ 'editor_button' ] = 1; $changed = true; }
84
- if ( !array_key_exists( 'admin_bar', $options ) ) { $options[ 'admin_bar' ] = 1; $changed = true; }
85
  if ( !array_key_exists( 'profile_no', $options ) ) { $options[ 'profile_no' ] = 5; $changed = true; }
86
  if ( !array_key_exists( 'list_no', $options ) ) { $options[ 'list_no' ] = 5; $changed = true; }
87
  if ( !array_key_exists( 'info_cache', $options ) ) { $options[ 'info_cache' ] = 1; $changed = true; }
@@ -89,12 +97,14 @@ function ye_set_general_defaults() {
89
  if ( !array_key_exists( 'transcript_cache', $options ) ) { $options[ 'transcript_cache' ] = 24; $changed = true; }
90
  if ( !array_key_exists( 'alt_profile', $options ) ) { $options[ 'alt_profile' ] = 0; $changed = true; }
91
  if ( !array_key_exists( 'alt_profile2', $options ) ) { $options[ 'alt_profile2' ] = 0; $changed = true; }
92
- if ( !array_key_exists( 'url_profile', $options ) ) { $options[ 'url_profile' ] = 0; $changed = true; }
93
  if ( !array_key_exists( 'other_profile', $options ) ) { $options[ 'other_profile' ] = 0; $changed = true; }
94
  if ( !array_key_exists( 'comments_profile', $options ) ) { $options[ 'comments_profile' ] = 0; $changed = true; }
95
  if ( !array_key_exists( 'metadata', $options ) ) { $options[ 'metadata' ] = 1; $changed = true; }
96
- if ( !array_key_exists( 'feed', $options ) ) { $options[ 'feed' ] = 'b'; $changed = true; }
97
- if ( !array_key_exists( 'api_errors', $options ) ) { $options[ 'api_errors' ] = 1; $changed = true; }
 
 
98
 
99
  // Update the options, if changed, and return the result
100
  if ( $changed ) { update_option( 'youtube_embed_general', $options ); }
@@ -132,7 +142,7 @@ function ye_set_profile_defaults( $profile ) {
132
  }
133
  $height = round( ( $width / 16 ) * 9, 0 );
134
 
135
- if ( !is_array( $options ) ) {
136
  if ( ( $profile == 0 ) && ( get_option( 'youtube_embed' ) ) ) {
137
  // If the old options exist, import them and then delete them
138
  $old_opts = get_option( 'youtube_embed' );
@@ -141,7 +151,7 @@ function ye_set_profile_defaults( $profile ) {
141
  $changed = true;
142
  } else {
143
  // If array doesn't exist, set defaults
144
- $options = array( 'width' => $width, 'height' => $height, 'fullscreen' => '', 'template' => '%video%', 'autoplay' => '', 'start' => '0', 'loop' => '', 'cc' => '', 'annotation' => '1', 'related' => '', 'info' => '1', 'link' => '1', 'react' => '1', 'stop' => '0', 'sweetspot' => '1', 'type' => 'v', 'disablekb' => '', 'autohide' => '2', 'controls' => '1', 'playlist' => 'v', 'fallback' => 'v', 'wmode' => 'opaque', 'shadow' => '0', 'audio' => '', 'hd' => '1', 'style' => '' );
145
  $changed = true;
146
  }
147
  }
@@ -166,18 +176,20 @@ function ye_set_profile_defaults( $profile ) {
166
  if ( !array_key_exists( 'autohide', $options ) ) { $options[ 'autohide' ] = '2'; $changed = true; }
167
  if ( !array_key_exists( 'controls', $options ) ) { $options[ 'controls' ] = '1'; $changed = true; }
168
  if ( !array_key_exists( 'playlist', $options ) ) { $options[ 'playlist' ] = 'v'; $changed = true; }
169
- if ( !array_key_exists( 'fallback', $options ) ) { $options[ 'fallback' ] = 'v'; $changed = true; }
170
  if ( !array_key_exists( 'wmode', $options ) ) { $options[ 'wmode' ] = 'opaque'; $changed = true; }
171
- if ( !array_key_exists( 'shadow', $options ) ) { $options[ 'shadow' ] = '0'; $changed = true; }
172
  if ( !array_key_exists( 'template', $options ) ) { $options[ 'template' ] = '%video%'; $changed = true; }
173
  if ( !array_key_exists( 'hd', $options ) ) { $options[ 'hd' ] = '1'; $changed = true; }
 
 
174
 
175
  // Update the options, if changed, and return the result
176
  if ( $changed ) { update_option( 'youtube_embed_profile' . $profile, $options ); }
177
-
178
  // Remove added slashes from template XHTML
179
  $options[ 'template' ] = stripslashes( $options[ 'template' ] );
180
-
181
  return $options;
182
  }
183
 
64
  function ye_set_general_defaults() {
65
  $options = get_option( 'youtube_embed_general' );
66
  $changed = false;
67
+ $default_error = htmlspecialchars( '<p>The video cannot be shown at the moment. Please try again later.</p>' );
68
 
69
  if ( !is_array( $options ) ) {
70
  if ( get_option( 'youtube_embed_editor' ) ) {
73
  $options[ 'editor_button' ] = $old_opts[ 'youtube' ];
74
  delete_option( 'youtube_embed_editor' );
75
  $changed = true;
76
+ } else {
77
  // If array doesn't exist, set defaults
78
+ $options = array( 'editor_button' => 1, 'admin_bar' => 1, 'profile_no' => 5, 'list_no' => 5, 'info_cache' => 1, 'embed_cache' => 24, 'transcript_cache' => 24, 'alt_profile' => 0, 'alt_profile2' => 0, 'bracket' => '', 'alt' => 0, 'url_profile' => 0, 'other_profile' => 0, 'comments' => '', 'comments_profile' => 0, 'metadata' => 1, 'feed' => 'b', 'api' => 1, 'error_message' => $default_error, 'thumbnail' => 2 );
79
  $changed = true;
80
  }
81
  }
82
 
83
+ // Set current version level. Because this can be used to detect version changes (and to what extent), this
84
+ // information may be useful in future upgrades
85
+ if ( $options[ 'current_version' ] != youtube_embed_version ) {
86
+ $options[ 'current_version' ] = youtube_embed_version;
87
+ $changed = true;
88
+ }
89
+
90
  // Because of upgrading, check each option - if not set, apply default
91
  if ( !array_key_exists( 'editor_button', $options ) ) { $options[ 'editor_button' ] = 1; $changed = true; }
92
+ if ( !array_key_exists( 'admin_bar', $options ) ) { $options[ 'admin_bar' ] = 1; $changed = true; }
93
  if ( !array_key_exists( 'profile_no', $options ) ) { $options[ 'profile_no' ] = 5; $changed = true; }
94
  if ( !array_key_exists( 'list_no', $options ) ) { $options[ 'list_no' ] = 5; $changed = true; }
95
  if ( !array_key_exists( 'info_cache', $options ) ) { $options[ 'info_cache' ] = 1; $changed = true; }
97
  if ( !array_key_exists( 'transcript_cache', $options ) ) { $options[ 'transcript_cache' ] = 24; $changed = true; }
98
  if ( !array_key_exists( 'alt_profile', $options ) ) { $options[ 'alt_profile' ] = 0; $changed = true; }
99
  if ( !array_key_exists( 'alt_profile2', $options ) ) { $options[ 'alt_profile2' ] = 0; $changed = true; }
100
+ if ( !array_key_exists( 'url_profile', $options ) ) { $options[ 'url_profile' ] = 0; $changed = true; }
101
  if ( !array_key_exists( 'other_profile', $options ) ) { $options[ 'other_profile' ] = 0; $changed = true; }
102
  if ( !array_key_exists( 'comments_profile', $options ) ) { $options[ 'comments_profile' ] = 0; $changed = true; }
103
  if ( !array_key_exists( 'metadata', $options ) ) { $options[ 'metadata' ] = 1; $changed = true; }
104
+ if ( !array_key_exists( 'feed', $options ) ) { $options[ 'feed' ] = 'b'; $changed = true; }
105
+ if ( !array_key_exists( 'api', $options ) ) { $options[ 'api' ] = 1; $changed = true; }
106
+ if ( !array_key_exists( 'error_message', $options ) ) { $options[ 'error_message' ] = $default_error; $changed = true; }
107
+ if ( !array_key_exists( 'thumbnail', $options ) ) { $options[ 'thumbnail' ] = 2; $changed = true; }
108
 
109
  // Update the options, if changed, and return the result
110
  if ( $changed ) { update_option( 'youtube_embed_general', $options ); }
142
  }
143
  $height = round( ( $width / 16 ) * 9, 0 );
144
 
145
+ if ( !is_array( $options ) ) {
146
  if ( ( $profile == 0 ) && ( get_option( 'youtube_embed' ) ) ) {
147
  // If the old options exist, import them and then delete them
148
  $old_opts = get_option( 'youtube_embed' );
151
  $changed = true;
152
  } else {
153
  // If array doesn't exist, set defaults
154
+ $options = array( 'width' => $width, 'height' => $height, 'fullscreen' => '', 'template' => '%video%', 'autoplay' => '', 'start' => '0', 'loop' => '', 'cc' => '', 'annotation' => '1', 'related' => '', 'info' => '1', 'link' => '1', 'react' => '1', 'stop' => '0', 'sweetspot' => '1', 'type' => 'v', 'disablekb' => '', 'autohide' => '2', 'controls' => '1', 'playlist' => 'v', 'fallback' => 'v', 'wmode' => 'opaque', 'shadow' => '0', 'audio' => '', 'hd' => '1', 'style' => '', 'color' => 'red', 'theme' => 'dark', 'https' => '0' );
155
  $changed = true;
156
  }
157
  }
176
  if ( !array_key_exists( 'autohide', $options ) ) { $options[ 'autohide' ] = '2'; $changed = true; }
177
  if ( !array_key_exists( 'controls', $options ) ) { $options[ 'controls' ] = '1'; $changed = true; }
178
  if ( !array_key_exists( 'playlist', $options ) ) { $options[ 'playlist' ] = 'v'; $changed = true; }
179
+ if ( !array_key_exists( 'fallback', $options ) ) { $options[ 'fallback' ] = 'v'; $changed = true; }
180
  if ( !array_key_exists( 'wmode', $options ) ) { $options[ 'wmode' ] = 'opaque'; $changed = true; }
181
+ if ( !array_key_exists( 'shadow', $options ) ) { $options[ 'shadow' ] = '0'; $changed = true; }
182
  if ( !array_key_exists( 'template', $options ) ) { $options[ 'template' ] = '%video%'; $changed = true; }
183
  if ( !array_key_exists( 'hd', $options ) ) { $options[ 'hd' ] = '1'; $changed = true; }
184
+ if ( !array_key_exists( 'color', $options ) ) { $options[ 'color' ] = 'red'; $changed = true; }
185
+ if ( !array_key_exists( 'theme', $options ) ) { $options[ 'theme' ] = 'dark'; $changed = true; }
186
 
187
  // Update the options, if changed, and return the result
188
  if ( $changed ) { update_option( 'youtube_embed_profile' . $profile, $options ); }
189
+
190
  // Remove added slashes from template XHTML
191
  $options[ 'template' ] = stripslashes( $options[ 'template' ] );
192
+
193
  return $options;
194
  }
195
 
includes/shared.php CHANGED
@@ -130,40 +130,45 @@ function ye_validate_id( $id, $title_needed = false ) {
130
 
131
  // Check if items are cached
132
  $cache = true;
133
- if ( ( !$type ) or ( !$title) ) { $cache = false; }
134
 
135
  // Get video information if not cached
136
  if ( !$cache ) {
137
 
138
  $type = '-';
139
-
140
- // Check with YouTube API as to whether the ID is a video
141
- $id_check = ye_get_file( 'http://gdata.youtube.com/feeds/api/videos/' . $id . '?v=2', false );
142
- if ( $id_check[ 'rc' ] == 0 ) {
143
- if ( $id_check[ 'response' ] != 200 ) {
144
-
145
- // Check with YouTube API as to whether the ID is a playlist
146
- $id_check = ye_get_file( 'http://gdata.youtube.com/feeds/api/playlists/' . $id . '?v=2', false );
147
- if ( $id_check[ 'rc' ] == 0 ) {
148
- if ( $id_check[ 'response' ] != 200 ) {
149
- $type = '';
150
- } else {
151
- $type = 'p';
 
 
 
 
 
152
  }
 
 
153
  }
154
- } else {
155
- $type = 'v';
156
  }
157
  }
158
 
159
  // If no type has been assigned then an API error must have occured
160
  if ( $type == '-' ) {
161
 
162
- if ( $options[ 'api_errors' ] == 1 ) {
163
  // If reporting API errors, output it
164
  $type = 'An error occured accessing the YouTube API for video ID ' . $id . ' - ' . $id_check[ 'error' ];
165
  } else {
166
- // If not reporting errors, work out whether a video or playlist
167
  $type = '';
168
  if ( strlen( $id ) == 11 ) {
169
  $type = 'v';
@@ -182,14 +187,11 @@ function ye_validate_id( $id, $title_needed = false ) {
182
  if ( ( $title_needed) && ( $id_check[ 'file' ] != '' ) ) {
183
 
184
  // Find title in XML
185
- $tag_start = strpos( $id_check[ 'file' ], '<title ', 1 );
186
  if ( $tag_start !== false ) {
187
- $tag_end = strpos( $id_check[ 'file' ], '>', $tag_start + 1 );
188
  if ( $tag_end !== false ) {
189
- $end_tag = strpos( $id_check[ 'file' ], '</title>', $tag_start );
190
- if ( $end_tag !== false ) {
191
- $title = substr( $id_check[ 'file' ], $tag_end + 1, $end_tag - $tag_end - 1 );
192
- }
193
  }
194
  }
195
 
@@ -200,7 +202,7 @@ function ye_validate_id( $id, $title_needed = false ) {
200
 
201
  if ( !$title_needed ) { return $type; }
202
 
203
- $return[ 'type' ] = $type;
204
  $return[ 'title' ] = $title;
205
  return $return;
206
  }
130
 
131
  // Check if items are cached
132
  $cache = true;
133
+ if ( ( !$type ) or ( !$title ) ) { $cache = false; }
134
 
135
  // Get video information if not cached
136
  if ( !$cache ) {
137
 
138
  $type = '-';
139
+
140
+ if ( $options [ 'api' ] != 0 ) {
141
+
142
+ if ( ( $options[ 'api' ] == 2 ) or ( $options[ 'api' ] == 4 ) ) { $https = 's'; } else { $https = ''; }
143
+
144
+ // Check with YouTube API as to whether the ID is a video
145
+ $id_check = ye_get_file( 'http' . $https . '://gdata.youtube.com/feeds/api/videos/' . $id . '?v=2', false );
146
+ if ( $id_check[ 'rc' ] == 0 ) {
147
+ if ( $id_check[ 'response' ] != 200 ) {
148
+
149
+ // Check with YouTube API as to whether the ID is a playlist
150
+ $id_check = ye_get_file( 'http' . $https . '://gdata.youtube.com/feeds/api/playlists/' . $id . '?v=2', false );
151
+ if ( $id_check[ 'rc' ] == 0 ) {
152
+ if ( $id_check[ 'response' ] != 200 ) {
153
+ $type = '';
154
+ } else {
155
+ $type = 'p';
156
+ }
157
  }
158
+ } else {
159
+ $type = 'v';
160
  }
 
 
161
  }
162
  }
163
 
164
  // If no type has been assigned then an API error must have occured
165
  if ( $type == '-' ) {
166
 
167
+ if ( ( $options[ 'api' ] == 1 ) or ( $options[ 'api' ] == 2 ) ) {
168
  // If reporting API errors, output it
169
  $type = 'An error occured accessing the YouTube API for video ID ' . $id . ' - ' . $id_check[ 'error' ];
170
  } else {
171
+ // If not reporting errors or API switched off, work out whether a video or playlist
172
  $type = '';
173
  if ( strlen( $id ) == 11 ) {
174
  $type = 'v';
187
  if ( ( $title_needed) && ( $id_check[ 'file' ] != '' ) ) {
188
 
189
  // Find title in XML
190
+ $tag_start = strpos( $id_check[ 'file' ], '<title>', 1 );
191
  if ( $tag_start !== false ) {
192
+ $tag_end = strpos( $id_check[ 'file' ], '</title>', $tag_start );
193
  if ( $tag_end !== false ) {
194
+ $title = substr( $id_check[ 'file' ], $tag_start + 7, $tag_end - $tag_start + 6 );
 
 
 
195
  }
196
  }
197
 
202
 
203
  if ( !$title_needed ) { return $type; }
204
 
205
+ $return[ 'type' ] = $type;
206
  $return[ 'title' ] = $title;
207
  return $return;
208
  }
includes/shortcodes.php CHANGED
@@ -85,7 +85,7 @@ if ( $shortcode[ 2 ] != '' ) { add_shortcode( $shortcode[ 2 ], 'ye_video_shortco
85
 
86
  function ye_video_shortcode( $paras = '', $content = '', $callback = '', $alt_shortcode = '' ) {
87
 
88
- extract( shortcode_atts( array( 'type' => '', 'width' => '', 'height' => '', 'fullscreen' => '', 'related' => '', 'autoplay' => '', 'loop' => '', 'start' => '', 'info' => '', 'annotation' => '', 'cc' => '', 'style' => '', 'link' => '', 'react' => '', 'stop' => '', 'sweetspot' => '', 'disablekb' => '', 'ratio' => '', 'autohide' => '', 'controls' => '', 'profile' => '', 'embedplus' => '', 'audio' => '', 'id' => '', 'url' => '', 'rel' => '', 'fs' => '', 'cc_load_policy' => '', 'iv_load_policy' => '', 'showinfo' => '', 'youtubeurl' => '', 'template' => '', 'list' => '', 'hd' => '' ), $paras ) );
89
 
90
  // If no profile specified and an alternative shortcode used, get that shortcodes default profile
91
  if ( ( $profile == '' ) && ( $alt_shortcode != '' ) ) {
@@ -122,7 +122,7 @@ function ye_video_shortcode( $paras = '', $content = '', $callback = '', $alt_sh
122
  $autohide = ye_set_autohide( $autohide );
123
 
124
  // Create YouTube code
125
- $youtube_code = ye_generate_youtube_code( $content, $type, $width, $height, ye_convert( $fullscreen ), ye_convert( $related ), ye_convert( $autoplay ), ye_convert( $loop ), $start, ye_convert( $info ), ye_convert_3( $annotation ), ye_convert( $cc ), $style, ye_convert( $link ), ye_convert( $react ), $stop, ye_convert( $sweetspot ), ye_convert( $disablekb ), $ratio, $autohide, ye_convert( $controls ), $profile, $list, ye_convert( $audio ), $template, ye_convert( $hd ) );
126
 
127
  return $youtube_code;
128
  }
@@ -142,8 +142,8 @@ function ye_video_shortcode( $paras = '', $content = '', $callback = '', $alt_sh
142
  */
143
 
144
  function ye_thumbnail_sc( $paras = '', $content = '' ) {
145
- extract( shortcode_atts( array( 'style' => '', 'class' => '', 'rel' => '', 'target' => '', 'width' => '', 'height' => '', 'alt' => '' ), $paras ) );
146
- return ye_generate_thumbnail_code( $content, $style, $class, $rel, $target, $width, $height, $alt );
147
  }
148
  add_shortcode( 'youtube_thumb', 'ye_thumbnail_sc' );
149
 
85
 
86
  function ye_video_shortcode( $paras = '', $content = '', $callback = '', $alt_shortcode = '' ) {
87
 
88
+ extract( shortcode_atts( array( 'type' => '', 'width' => '', 'height' => '', 'fullscreen' => '', 'related' => '', 'autoplay' => '', 'loop' => '', 'start' => '', 'info' => '', 'annotation' => '', 'cc' => '', 'style' => '', 'link' => '', 'react' => '', 'stop' => '', 'sweetspot' => '', 'disablekb' => '', 'ratio' => '', 'autohide' => '', 'controls' => '', 'profile' => '', 'embedplus' => '', 'audio' => '', 'id' => '', 'url' => '', 'rel' => '', 'fs' => '', 'cc_load_policy' => '', 'iv_load_policy' => '', 'showinfo' => '', 'youtubeurl' => '', 'template' => '', 'list' => '', 'hd' => '', 'color' => '', 'theme' => '', 'https' => '' ), $paras ) );
89
 
90
  // If no profile specified and an alternative shortcode used, get that shortcodes default profile
91
  if ( ( $profile == '' ) && ( $alt_shortcode != '' ) ) {
122
  $autohide = ye_set_autohide( $autohide );
123
 
124
  // Create YouTube code
125
+ $youtube_code = ye_generate_youtube_code( $content, $type, $width, $height, ye_convert( $fullscreen ), ye_convert( $related ), ye_convert( $autoplay ), ye_convert( $loop ), $start, ye_convert( $info ), ye_convert_3( $annotation ), ye_convert( $cc ), $style, ye_convert( $link ), ye_convert( $react ), $stop, ye_convert( $sweetspot ), ye_convert( $disablekb ), $ratio, $autohide, ye_convert( $controls ), $profile, $list, ye_convert( $audio ), $template, ye_convert( $hd ), $color, $theme, ye_convert( $https ) );
126
 
127
  return $youtube_code;
128
  }
142
  */
143
 
144
  function ye_thumbnail_sc( $paras = '', $content = '' ) {
145
+ extract( shortcode_atts( array( 'style' => '', 'class' => '', 'rel' => '', 'target' => '', 'width' => '', 'height' => '', 'alt' => '', 'version' => '' ), $paras ) );
146
+ return ye_generate_thumbnail_code( $content, $style, $class, $rel, $target, $width, $height, $alt, $version );
147
  }
148
  add_shortcode( 'youtube_thumb', 'ye_thumbnail_sc' );
149
 
readme.txt CHANGED
@@ -4,7 +4,7 @@ Donate link: http://artiss.co.uk/donate
4
  Tags: admin, annotations, artiss, automatic, editor, embed, embedding, embedplus, flash, flv, google, hd, height, iframe, manage, media, plugin, page, play, playlist, post, profile, sidebar, simple, url, valid, video, widget,width, xhtml, youtube, youtuber
5
  Requires at least: 2.9
6
  Tested up to: 3.2.1
7
- Stable tag: 2.0.4
8
 
9
  A simple to use method of embedding YouTube videos into your posts and pages but with powerful features for those that need them.
10
 
@@ -60,12 +60,15 @@ The following parameters will not work with EmbedPlus:
60
 
61
  * **autohide** - 0, 1 or 2, this parameter indicates whether the video controls will automatically hide after a video begins playing. The default behaviour, a value of 2, is for the video progress bar to fade out while the player controls (play button, volume control, etc.) remain visible. If this parameter is set to 0, the video progress bar and the video player controls will be visible throughout the video. If this parameter is set to 1, then the video progress bar and the player controls will slide out of view a couple of seconds after the video starts playing. They will only reappear if the user moves her mouse over the video player or presses a key on her keyboard.
62
  * **controls** - yes or no, should the controls be shown?
 
63
  * **loop** - yes or no, whether to start the video again once it ends
 
64
 
65
  The following parameters will not work with EmbedPlus or if IFRAME uses HTML5:
66
 
67
  * **annotation** - yes or no, this determines if annotations are shown
68
  * **cc** - yes or no, decided whether closed captions (subtitles) are displayed
 
69
  * **disablekb** - yes or no, disable keyboard controls
70
  * **fullscreen** - yes or no, this will add the fullscreen button to the toolbar. This also works with EmbedPlus.
71
  * **info** - yes or no, show video information
@@ -154,7 +157,7 @@ There is also a parameter, named `list`, that lets you modify the playback of th
154
 
155
  Some YouTube videos include transcripts - this is a text output of the speech from the video with timings added. These are available in XML format and can, via a function call or shortcode, be displayed in your post.
156
 
157
- The shortcode `transcript` will display the transcript in your post along with the start time for each line. Simply supply the video ID as a parameter.
158
 
159
  e.g. `[transcript]MSPsrhCPt-0[/transcript]`
160
 
@@ -194,6 +197,7 @@ The parameters are as follows...
194
  * **target** - specify a TARGET override, e.g. target="_blank"
195
  * **width** - this specifies the width of the thumbnail image
196
  * **height** - this specifies the height of the thumbnail image
 
197
 
198
  e.g. `youtube_thumb_embed( 'id', 'rel=nofollow&target=_blank', '', 'Demo Video' )`
199
 
@@ -315,6 +319,12 @@ Equally, some options are not supported depending on whether you use the IFRAME
315
 
316
  [Read more about which options are supported](http://www.artiss.co.uk/artiss-youtube-embed/further-help#ye-api "API Support").
317
 
 
 
 
 
 
 
318
  = How do I add a border to the video =
319
 
320
  The border option is no longer available with the YouTube player. However, you can use the `style` option to mimic it. Simply add a style of `border: 10px solid #b1b1b1`.
@@ -380,8 +390,8 @@ That's correct - all Artiss plugins will now add this feature to keep you up-to-
380
  5. The About screen
381
  6. The default widget options
382
 
383
- == Changelog ==
384
-
385
  = 1.0 =
386
  * Initial release
387
 
@@ -441,12 +451,12 @@ That's correct - all Artiss plugins will now add this feature to keep you up-to-
441
  = 2.0.1 =
442
  * Enhancement: Changed cache key encoding so that it was compatible with PHP 4
443
  * Enhancement: Added autoplay option to EmbedPlus
444
- * Enhancement: Re-instated `style` option, allowing you to apply a direct set of CSS elements to the output - a requirement if you wish to add a border to the video, for instance
445
- * Maintenance: Updated screens and documentation to show the `start` parameter works with EmbedPlus
446
  * Bug: Fixed incorrect caching of options - was only changing if override parameters were modified
447
  * Bug: Video Information Cache will no longer reset to zero if the Embed cache is greater
448
  * Bug: Added random ID to EmbedPlus output to resolve a bug that can affect IE users
449
-
450
  = 2.0.2 =
451
  * Enhancement: Strip tags from video ID, in case any have crept in
452
  * Enhancement: Tidied some of the widget controls
@@ -457,17 +467,30 @@ That's correct - all Artiss plugins will now add this feature to keep you up-to-
457
  * Bug: Fixed problem with list where one video was being ignored and another repeated
458
  * Bug: Modified widget code to allow for all states to be allowable. Defaults updated
459
  * Bug: YouTube documentation states that if you don't specify the fullscreen parameter it will default to off. It doesn't. Corrected in the code
460
-
461
  = 2.0.3 =
462
  * Enhancement: Decode any passed `template` parameters, as WP may have encoded the content first
463
  * Enhancement: Improved file handling
464
  * Enhancement: Now using HTTPS and version 2 of YouTube gdata API
465
  * Enhancement: New general option to switch off reporting of API errors - will simply accept ID and work out type
466
  * Maintenance: Added details to the README to cover issues with `style` backwards compatibility and YouTube API
467
-
468
  = 2.0.4 =
469
  * Enhancement: Removed HTTPS access to gdata API - will add a switchable option for this in a later release
470
 
 
 
 
 
 
 
 
 
 
 
 
 
 
471
  == Upgrade Notice ==
472
 
473
  = 1.0 =
@@ -507,4 +530,10 @@ That's correct - all Artiss plugins will now add this feature to keep you up-to-
507
  * Further update to fix a few minor bugs found in 2.0. A few small enhancements have also been made
508
 
509
  = 2.0.3 =
510
- * Removed secure API access as this was causing some users issues
 
 
 
 
 
 
4
  Tags: admin, annotations, artiss, automatic, editor, embed, embedding, embedplus, flash, flv, google, hd, height, iframe, manage, media, plugin, page, play, playlist, post, profile, sidebar, simple, url, valid, video, widget,width, xhtml, youtube, youtuber
5
  Requires at least: 2.9
6
  Tested up to: 3.2.1
7
+ Stable tag: 2.1
8
 
9
  A simple to use method of embedding YouTube videos into your posts and pages but with powerful features for those that need them.
10
 
60
 
61
  * **autohide** - 0, 1 or 2, this parameter indicates whether the video controls will automatically hide after a video begins playing. The default behaviour, a value of 2, is for the video progress bar to fade out while the player controls (play button, volume control, etc.) remain visible. If this parameter is set to 0, the video progress bar and the video player controls will be visible throughout the video. If this parameter is set to 1, then the video progress bar and the player controls will slide out of view a couple of seconds after the video starts playing. They will only reappear if the user moves her mouse over the video player or presses a key on her keyboard.
62
  * **controls** - yes or no, should the controls be shown?
63
+ * **https** - yes or no, whether to use HTTPS for the video
64
  * **loop** - yes or no, whether to start the video again once it ends
65
+ * **theme** - dark or light, display player controls (like a 'play' button or volume control) within a dark or light control bar
66
 
67
  The following parameters will not work with EmbedPlus or if IFRAME uses HTML5:
68
 
69
  * **annotation** - yes or no, this determines if annotations are shown
70
  * **cc** - yes or no, decided whether closed captions (subtitles) are displayed
71
+ * **color** - white or red, the colour of the progress bar (see the FAQ about having a white progress bar with the light theme)
72
  * **disablekb** - yes or no, disable keyboard controls
73
  * **fullscreen** - yes or no, this will add the fullscreen button to the toolbar. This also works with EmbedPlus.
74
  * **info** - yes or no, show video information
157
 
158
  Some YouTube videos include transcripts - this is a text output of the speech from the video with timings added. These are available in XML format and can, via a function call or shortcode, be displayed in your post.
159
 
160
+ The shortcode `transcript` will display the transcript in your post along with the start time for each line. Simply supply the video ID as a parameter.
161
 
162
  e.g. `[transcript]MSPsrhCPt-0[/transcript]`
163
 
197
  * **target** - specify a TARGET override, e.g. target="_blank"
198
  * **width** - this specifies the width of the thumbnail image
199
  * **height** - this specifies the height of the thumbnail image
200
+ * **version** - which version of the thumbnail to use. This can be `default`, `hq` (for a high quality version of the default image), `start`, `middle` or `end`. The latter 3 indicate where from the video the thumbnails are taken from
201
 
202
  e.g. `youtube_thumb_embed( 'id', 'rel=nofollow&target=_blank', '', 'Demo Video' )`
203
 
319
 
320
  [Read more about which options are supported](http://www.artiss.co.uk/artiss-youtube-embed/further-help#ye-api "API Support").
321
 
322
+ = The progress bar doesn't appear as white when I'm using the light coloured theme =
323
+
324
+ You can set the progress bar as red or white and the general theme to be dark or light. According to YouTube documentation all variations on this should be possible. However, the white / light combination does not appear to work.
325
+
326
+ I have reported this to Google as a bug in their API and, at the time of publishing this, am still awaiting a response.
327
+
328
  = How do I add a border to the video =
329
 
330
  The border option is no longer available with the YouTube player. However, you can use the `style` option to mimic it. Simply add a style of `border: 10px solid #b1b1b1`.
390
  5. The About screen
391
  6. The default widget options
392
 
393
+ == Changelog ==
394
+
395
  = 1.0 =
396
  * Initial release
397
 
451
  = 2.0.1 =
452
  * Enhancement: Changed cache key encoding so that it was compatible with PHP 4
453
  * Enhancement: Added autoplay option to EmbedPlus
454
+ * Enhancement: Re-instated `style` option, allowing you to apply a direct set of CSS elements to the output - a requirement if you wish to add a border to the video, for instance
455
+ * Maintenance: Updated screens and documentation to show the `start` parameter works with EmbedPlus
456
  * Bug: Fixed incorrect caching of options - was only changing if override parameters were modified
457
  * Bug: Video Information Cache will no longer reset to zero if the Embed cache is greater
458
  * Bug: Added random ID to EmbedPlus output to resolve a bug that can affect IE users
459
+
460
  = 2.0.2 =
461
  * Enhancement: Strip tags from video ID, in case any have crept in
462
  * Enhancement: Tidied some of the widget controls
467
  * Bug: Fixed problem with list where one video was being ignored and another repeated
468
  * Bug: Modified widget code to allow for all states to be allowable. Defaults updated
469
  * Bug: YouTube documentation states that if you don't specify the fullscreen parameter it will default to off. It doesn't. Corrected in the code
470
+
471
  = 2.0.3 =
472
  * Enhancement: Decode any passed `template` parameters, as WP may have encoded the content first
473
  * Enhancement: Improved file handling
474
  * Enhancement: Now using HTTPS and version 2 of YouTube gdata API
475
  * Enhancement: New general option to switch off reporting of API errors - will simply accept ID and work out type
476
  * Maintenance: Added details to the README to cover issues with `style` backwards compatibility and YouTube API
477
+
478
  = 2.0.4 =
479
  * Enhancement: Removed HTTPS access to gdata API - will add a switchable option for this in a later release
480
 
481
+ = 2.1 =
482
+ * Enhancement: New option to switch API options (where HTTP or HTTPS, display messages or not or even switch off)
483
+ * Enhancement: Output video playback errors as XHTML comments. Output to post a generic message which can be changed in the options
484
+ * Enhancement: Video information is shown in lists screen when first entering (no need to press Save button to display)
485
+ * Enhancement: Added new `color` parameter, which allows you to specify the colour of the progress bar
486
+ * Enhancement: Added new `theme` parameter, allowing you to specify if the player is dark or light skinned
487
+ * Enhancement: Added new `https` parameter, allowing you to use HTTPS instead of HTTP for the video display
488
+ * Enhancement: Added new `version` parameter to thumbnails, allowing different versions (including a high resolution one) to be displayed
489
+ * Enhancement: Added new administration option to allow the thumbnail used in RSS feeds to be specified
490
+ * Enhancement: Log the current plugin version into the database. This may be of use in future upgrades to detect which version the user is upgrading from
491
+ * Bug: Fixed video title no longer being fetched since 2.0.3 (because of using v2 of API)
492
+ * Bug: Fixed some error output - due to changes made in an earlier release some errors would not display
493
+
494
  == Upgrade Notice ==
495
 
496
  = 1.0 =
530
  * Further update to fix a few minor bugs found in 2.0. A few small enhancements have also been made
531
 
532
  = 2.0.3 =
533
+ * Removed secure API access as this was causing some users issues
534
+
535
+ = 2.0.4 =
536
+ * Fixed SSL bug by removing HTTPS access to API
537
+
538
+ = 2.1 =
539
+ * New options to change player colours, chose your thumbnails and control API usage
screenshot-2.png CHANGED
Binary file
screenshot-3.png CHANGED
Binary file
youtube-embed.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: Artiss YouTube Embed
4
  Plugin URI: http://www.artiss.co.uk/artiss-youtube-embed
5
  Description: Embed YouTube Videos in WordPress
6
- Version: 2.0.4
7
  Author: David Artiss
8
  Author URI: http://www.artiss.co.uk
9
  */
@@ -17,7 +17,7 @@ Author URI: http://www.artiss.co.uk
17
  * @since 2.0
18
  */
19
 
20
- define( 'youtube_embed_version', '2.0.4' );
21
 
22
  $functions_dir = WP_PLUGIN_DIR . '/youtube-embed/includes/';
23
 
3
  Plugin Name: Artiss YouTube Embed
4
  Plugin URI: http://www.artiss.co.uk/artiss-youtube-embed
5
  Description: Embed YouTube Videos in WordPress
6
+ Version: 2.1
7
  Author: David Artiss
8
  Author URI: http://www.artiss.co.uk
9
  */
17
  * @since 2.0
18
  */
19
 
20
+ define( 'youtube_embed_version', '2.1' );
21
 
22
  $functions_dir = WP_PLUGIN_DIR . '/youtube-embed/includes/';
23