Version Description
- Enhancement: Decode any passed
template
parameters, as WP may have encoded the content first- Enhancement: Improved file handling
- Enhancement: Now using HTTPS and version 2 of YouTube gdata API
- Enhancement: New general option to switch off reporting of API errors - will simply accept ID and work out type
- Maintenance: Added details to the README to cover issues with
style
backwards compatibility and YouTube API
=
Download this release
Release Info
Developer | dartiss |
Plugin | YouTube Embed |
Version | 2.0.3 |
Comparing to | |
See all releases |
Code changes from version 2.0.2 to 2.0.3
- includes/function-calls.php +11 -3
- includes/generate-download-code.php +7 -1
- includes/generate-embed-code.php +24 -1
- includes/generate-shorturl-code.php +7 -1
- includes/generate-thumbnail-code.php +7 -1
- includes/generate-transcript-code.php +7 -1
- includes/options-general.php +10 -0
- includes/options-lists.php +9 -3
- includes/set-option-defaults.php +2 -1
- includes/shared.php +61 -26
- includes/shortcodes.php +2 -1
- readme.txt +29 -1
- youtube-embed.php +2 -2
includes/function-calls.php
CHANGED
@@ -147,7 +147,14 @@ function get_youtube_transcript_xml ( $id ) {
|
|
147 |
|
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 |
|
152 |
// Get transcript file
|
153 |
$filename = 'http://video.google.com/timedtext?lang=en&v=' . $id;
|
@@ -157,7 +164,7 @@ function get_youtube_transcript_xml ( $id ) {
|
|
157 |
if ( $xml[ 'rc' ] > 0 ) {
|
158 |
echo ye_error( 'Could not fetch the transcript file ' . $filename . '.' );
|
159 |
return;
|
160 |
-
} else {
|
161 |
return $xml;
|
162 |
}
|
163 |
}
|
@@ -201,7 +208,8 @@ function get_youtube_name( $id ) {
|
|
201 |
|
202 |
// Check what type of video it is and whether it's valid
|
203 |
$return = ye_validate_id( $id, true );
|
204 |
-
if ( !$return['type'] ) { return ye_error( 'The YouTube ID of ' . $id . ' is invalid.' ); }
|
|
|
205 |
|
206 |
// Return the video title
|
207 |
return $return['title'];
|
147 |
|
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.' );
|
155 |
+
}
|
156 |
+
return;
|
157 |
+
}
|
158 |
|
159 |
// Get transcript file
|
160 |
$filename = 'http://video.google.com/timedtext?lang=en&v=' . $id;
|
164 |
if ( $xml[ 'rc' ] > 0 ) {
|
165 |
echo ye_error( 'Could not fetch the transcript file ' . $filename . '.' );
|
166 |
return;
|
167 |
+
} else {
|
168 |
return $xml;
|
169 |
}
|
170 |
}
|
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'];
|
includes/generate-download-code.php
CHANGED
@@ -27,7 +27,13 @@ function ye_generate_download_code( $id ) {
|
|
27 |
|
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 |
|
32 |
// Create the link
|
33 |
return 'http://www.savevid.com/?url=http://www.youtube.com/watch?' . $embed_type . '=' . $id;
|
27 |
|
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.' );
|
35 |
+
}
|
36 |
+
}
|
37 |
|
38 |
// Create the link
|
39 |
return 'http://www.savevid.com/?url=http://www.youtube.com/watch?' . $embed_type . '=' . $id;
|
includes/generate-embed-code.php
CHANGED
@@ -89,6 +89,7 @@ function ye_generate_youtube_code( $id = '', $type = '', $width = '', $height =
|
|
89 |
$embed_type = $return[ 'type' ];
|
90 |
|
91 |
if ( $embed_type == '' ) { return ye_error( 'The YouTube ID of ' . $id . ' is invalid.' ); }
|
|
|
92 |
|
93 |
} else {
|
94 |
|
@@ -171,7 +172,7 @@ function ye_generate_youtube_code( $id = '', $type = '', $width = '', $height =
|
|
171 |
$shadow = $options[ 'shadow' ];
|
172 |
|
173 |
// Build the required template
|
174 |
-
if ( $template == '' ) { $template = $options[ 'template' ]; }
|
175 |
if ( strpos( $template, '%video%' ) === false ) { $template = '%video%'; }
|
176 |
|
177 |
// If a multi-play list has been specified and EmbedPlus selected, use fallback embedding method instead
|
@@ -429,4 +430,26 @@ function ye_get_url_para( $id, $para, $current ) {
|
|
429 |
|
430 |
return $current;
|
431 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
432 |
?>
|
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 |
|
172 |
$shadow = $options[ 'shadow' ];
|
173 |
|
174 |
// Build the required template
|
175 |
+
if ( $template == '' ) { $template = $options[ 'template' ]; } else { $template = ye_decode( $template ); }
|
176 |
if ( strpos( $template, '%video%' ) === false ) { $template = '%video%'; }
|
177 |
|
178 |
// If a multi-play list has been specified and EmbedPlus selected, use fallback embedding method instead
|
430 |
|
431 |
return $current;
|
432 |
}
|
433 |
+
|
434 |
+
/**
|
435 |
+
* Decode a string
|
436 |
+
*
|
437 |
+
* Decode an HTML encoded string. I'm not using htmlspecialchars_decode to maintain
|
438 |
+
* PHP 4 compatibility.
|
439 |
+
*
|
440 |
+
* @since 2.0.3
|
441 |
+
*
|
442 |
+
* @param string $encoded The encoded string
|
443 |
+
* @return string The decoded string
|
444 |
+
*/
|
445 |
+
|
446 |
+
function ye_decode( $encoded ) {
|
447 |
+
|
448 |
+
$find = array( '&', '"', ''', '<', '>' );
|
449 |
+
$replace = array( '&', '"', "'", '<', '>' );
|
450 |
+
|
451 |
+
$decoded = str_replace($find,$replace,$encoded);
|
452 |
+
|
453 |
+
return $decoded;
|
454 |
+
}
|
455 |
?>
|
includes/generate-shorturl-code.php
CHANGED
@@ -27,7 +27,13 @@ function ye_generate_shorturl_code( $id ) {
|
|
27 |
|
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 |
|
32 |
return 'http://youtu.be/' . $id;
|
33 |
}
|
27 |
|
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.' );
|
35 |
+
}
|
36 |
+
}
|
37 |
|
38 |
return 'http://youtu.be/' . $id;
|
39 |
}
|
includes/generate-thumbnail-code.php
CHANGED
@@ -29,7 +29,13 @@ function ye_generate_thumbnail_code( $id, $style, $class, $rel, $target, $width,
|
|
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 |
|
34 |
// Now create the required code
|
35 |
if ( $alt == '' ) { $alt = 'YouTube Video ' . $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; }
|
includes/generate-transcript-code.php
CHANGED
@@ -28,7 +28,13 @@ function ye_generate_transcript( $id ) {
|
|
28 |
|
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 |
|
33 |
// Get general options
|
34 |
$general = ye_set_general_defaults();
|
28 |
|
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.' );
|
36 |
+
}
|
37 |
+
}
|
38 |
|
39 |
// Get general options
|
40 |
$general = ye_set_general_defaults();
|
includes/options-general.php
CHANGED
@@ -43,6 +43,7 @@ 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 |
|
47 |
// Update the options
|
48 |
update_option( 'youtube_embed_general', $options );
|
@@ -206,6 +207,15 @@ $url = ye_set_url_option();
|
|
206 |
</tr>
|
207 |
</table>
|
208 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
209 |
<?php wp_nonce_field( 'youtube-embed-general','youtube_embed_general_nonce', true, true ); ?>
|
210 |
|
211 |
<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_errors' ] = $_POST[ 'youtube_embed_api_errors' ];
|
47 |
|
48 |
// Update the options
|
49 |
update_option( 'youtube_embed_general', $options );
|
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"'; } ?>/> <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>
|
includes/options-lists.php
CHANGED
@@ -58,10 +58,16 @@ if ( ( !empty( $_POST[ 'Submit' ] ) ) && ( check_admin_referer( 'youtube-embed-g
|
|
58 |
if ( $type == '' ) {
|
59 |
$video_out[ $loop ][ 3 ] = 'Invalid video ID';
|
60 |
$video_out[ $loop ][ 4 ] = '-2';
|
61 |
-
$valid = false;
|
62 |
} else {
|
63 |
-
|
64 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
65 |
}
|
66 |
}
|
67 |
|
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 |
|
includes/set-option-defaults.php
CHANGED
@@ -74,7 +74,7 @@ function ye_set_general_defaults() {
|
|
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' );
|
78 |
$changed = true;
|
79 |
}
|
80 |
}
|
@@ -94,6 +94,7 @@ function ye_set_general_defaults() {
|
|
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 |
|
98 |
// Update the options, if changed, and return the result
|
99 |
if ( $changed ) { update_option( 'youtube_embed_general', $options ); }
|
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 |
}
|
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 ); }
|
includes/shared.php
CHANGED
@@ -65,8 +65,8 @@ function ye_extract_id( $id ) {
|
|
65 |
|
66 |
// Now check to see if it's a full URL, as used in the embed code
|
67 |
// Need to check both video and playlist formats
|
68 |
-
$video_pos = strpos( $id,
|
69 |
-
if ($video_pos === false) { $video_pos = strpos( $id,
|
70 |
|
71 |
if ( $video_pos !== false ) {
|
72 |
$video_pos = $video_pos + 14;
|
@@ -119,10 +119,14 @@ function ye_validate_id( $id, $title_needed = false ) {
|
|
119 |
$type = false;
|
120 |
$title = false;
|
121 |
$options = false;
|
|
|
|
|
122 |
|
123 |
// Attempt to get the video type and title from cache
|
124 |
-
|
125 |
-
|
|
|
|
|
126 |
|
127 |
// Check if items are cached
|
128 |
$cache = true;
|
@@ -131,23 +135,46 @@ function ye_validate_id( $id, $title_needed = false ) {
|
|
131 |
// Get video information if not cached
|
132 |
if ( !$cache ) {
|
133 |
|
134 |
-
$
|
135 |
|
136 |
// Check with YouTube API as to whether the ID is a video
|
137 |
-
$id_check = ye_get_file( '
|
138 |
-
if ( $id_check[ '
|
139 |
-
|
140 |
-
// Check with YouTube API as to whether the ID is a playlist
|
141 |
-
$id_check = ye_get_file( 'http://gdata.youtube.com/feeds/api/playlists/' . $id, false );
|
142 |
if ( $id_check[ 'response' ] != 200 ) {
|
143 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
144 |
} else {
|
145 |
-
$type = '
|
146 |
}
|
147 |
-
} else {
|
148 |
-
$type = 'v';
|
149 |
}
|
150 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
151 |
// Update the cache
|
152 |
set_transient( 'ye_type_' . $id, $type, $options[ 'info_cache' ] * 3600 );
|
153 |
|
@@ -263,9 +290,10 @@ function ye_yes_or_no( $input = '' ) {
|
|
263 |
}
|
264 |
|
265 |
/**
|
266 |
-
* Fetch a file (1.
|
267 |
*
|
268 |
* Use WordPress API to fetch a file and check results
|
|
|
269 |
*
|
270 |
* @since 2.0
|
271 |
*
|
@@ -276,25 +304,32 @@ function ye_yes_or_no( $input = '' ) {
|
|
276 |
|
277 |
function ye_get_file( $filein, $header = false ) {
|
278 |
|
|
|
|
|
279 |
if ( $header ) {
|
280 |
$fileout = wp_remote_head( $filein );
|
281 |
-
if (
|
282 |
-
$
|
283 |
-
|
284 |
-
$file_return[ 'rc' ] = 0;
|
285 |
}
|
286 |
} else {
|
287 |
$fileout = wp_remote_get( $filein );
|
288 |
-
if (
|
289 |
-
$
|
|
|
290 |
} else {
|
291 |
-
|
292 |
-
|
|
|
293 |
}
|
294 |
}
|
295 |
|
296 |
-
|
297 |
-
|
|
|
|
|
|
|
|
|
298 |
}
|
299 |
|
300 |
return $file_return;
|
65 |
|
66 |
// Now check to see if it's a full URL, as used in the embed code
|
67 |
// Need to check both video and playlist formats
|
68 |
+
$video_pos = strpos( $id, 'youtube.com/v/' );
|
69 |
+
if ($video_pos === false) { $video_pos = strpos( $id, 'youtube.com/p/' ); }
|
70 |
|
71 |
if ( $video_pos !== false ) {
|
72 |
$video_pos = $video_pos + 14;
|
119 |
$type = false;
|
120 |
$title = false;
|
121 |
$options = false;
|
122 |
+
|
123 |
+
$options = ye_set_general_defaults();
|
124 |
|
125 |
// Attempt to get the video type and title from cache
|
126 |
+
if ( $general[ 'info_cache' ] != 0 ) {
|
127 |
+
$type = get_transient( 'ye_type_' . $id );
|
128 |
+
$title = get_transient( 'ye_title_' . $id );
|
129 |
+
}
|
130 |
|
131 |
// Check if items are cached
|
132 |
$cache = true;
|
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( 'https://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( 'https://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';
|
170 |
+
} else {
|
171 |
+
if ( strlen( $id ) == 16 ) {
|
172 |
+
$type = 'p';
|
173 |
+
}
|
174 |
+
}
|
175 |
+
}
|
176 |
+
}
|
177 |
+
|
178 |
// Update the cache
|
179 |
set_transient( 'ye_type_' . $id, $type, $options[ 'info_cache' ] * 3600 );
|
180 |
|
290 |
}
|
291 |
|
292 |
/**
|
293 |
+
* Fetch a file (1.6)
|
294 |
*
|
295 |
* Use WordPress API to fetch a file and check results
|
296 |
+
* RC is 0 to indicate success, -1 a failure
|
297 |
*
|
298 |
* @since 2.0
|
299 |
*
|
304 |
|
305 |
function ye_get_file( $filein, $header = false ) {
|
306 |
|
307 |
+
$rc = 0;
|
308 |
+
$error = '';
|
309 |
if ( $header ) {
|
310 |
$fileout = wp_remote_head( $filein );
|
311 |
+
if ( is_wp_error( $fileout ) ) {
|
312 |
+
$error = 'Header: '.$fileout->get_error_message();
|
313 |
+
$rc = -1;
|
|
|
314 |
}
|
315 |
} else {
|
316 |
$fileout = wp_remote_get( $filein );
|
317 |
+
if ( is_wp_error( $fileout ) ) {
|
318 |
+
$error = 'Body: '.$fileout->get_error_message();
|
319 |
+
$rc = -1;
|
320 |
} else {
|
321 |
+
if ( isset( $fileout[ 'body' ] ) ) {
|
322 |
+
$file_return[ 'file' ] = $fileout[ 'body' ];
|
323 |
+
}
|
324 |
}
|
325 |
}
|
326 |
|
327 |
+
$file_return[ 'error' ] = $error;
|
328 |
+
$file_return[ 'rc' ] = $rc;
|
329 |
+
if ( !is_wp_error( $fileout ) ) {
|
330 |
+
if ( isset( $fileout[ 'response' ][ 'code' ] ) ) {
|
331 |
+
$file_return[ 'response' ] = $fileout[ 'response' ][ 'code' ];
|
332 |
+
}
|
333 |
}
|
334 |
|
335 |
return $file_return;
|
includes/shortcodes.php
CHANGED
@@ -241,7 +241,8 @@ function ye_video_name_shortcode( $paras = '', $content = '' ) {
|
|
241 |
|
242 |
// Check what type of video it is and whether it's valid
|
243 |
$return = ye_validate_id( $id, true );
|
244 |
-
if ( !$return['type'] ) { return ye_error( 'The YouTube ID of ' . $id . ' is invalid.' ); }
|
|
|
245 |
|
246 |
// Return the video title
|
247 |
return $return['title'];
|
241 |
|
242 |
// Check what type of video it is and whether it's valid
|
243 |
$return = ye_validate_id( $id, true );
|
244 |
+
if ( !$return[ 'type' ] ) { return ye_error( 'The YouTube ID of ' . $id . ' is invalid.' ); }
|
245 |
+
if ( strlen( $return[ 'type' ] ) != 1 ) { return ye_error( $return[ 'type' ] ); }
|
246 |
|
247 |
// Return the video title
|
248 |
return $return['title'];
|
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.
|
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 |
|
@@ -122,6 +122,8 @@ The template consists simply of any HTML that you wish but with `%video%` where
|
|
122 |
|
123 |
e.g. `<div align="center">%video%</div>`
|
124 |
|
|
|
|
|
125 |
== Profiles ==
|
126 |
|
127 |
You've probably already had a look at the default profile, accessible by selecting `Profiles` from the `YouTube` administration menu option. Here you can specify the default option which will apply to any embedded video.
|
@@ -294,6 +296,7 @@ For problems, suggestions or enhancements for this plugin, there is [a dedicated
|
|
294 |
|
295 |
1. Upload the entire `youtube-embed` folder to your wp-content/plugins/ directory.
|
296 |
2. Activate the plugin through the 'Plugins' menu in WordPress.
|
|
|
297 |
3. That's it, you're done - you just need to add the shortcode wherever you need.
|
298 |
|
299 |
== Frequently Asked Questions ==
|
@@ -316,10 +319,28 @@ Equally, some options are not supported depending on whether you use the IFRAME
|
|
316 |
|
317 |
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`.
|
318 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
319 |
= I've upgraded from an earlier version of Artiss YouTube Embed and one of the functions / shortcodes / parameters that I used is no longer documented =
|
320 |
|
321 |
Code created for previous versions of the plugin should still work - however, the functions will not be documented to deter people from using them in the future.
|
322 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
323 |
= Is the generated code standards compliant? =
|
324 |
|
325 |
In all cases, yes. However, it depends on which options you choose as to which DOCTYPE it will validate to.
|
@@ -436,6 +457,13 @@ That's correct - all Artiss plugins will now add this feature to keep you up-to-
|
|
436 |
* Bug: Fixed problem with list where one video was being ignored and another repeated
|
437 |
* Bug: Modified widget code to allow for all states to be allowable. Defaults updated
|
438 |
* 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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
439 |
|
440 |
== Upgrade Notice ==
|
441 |
|
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.3
|
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 |
|
122 |
|
123 |
e.g. `<div align="center">%video%</div>`
|
124 |
|
125 |
+
Be wary that when adding template via a parameter that any HTML included may cause your video to have <pre> tags wrapped around it. The easiest way to check and fix this is to view any post in the HTML editor and remove any <pre> tags that have been added.
|
126 |
+
|
127 |
== Profiles ==
|
128 |
|
129 |
You've probably already had a look at the default profile, accessible by selecting `Profiles` from the `YouTube` administration menu option. Here you can specify the default option which will apply to any embedded video.
|
296 |
|
297 |
1. Upload the entire `youtube-embed` folder to your wp-content/plugins/ directory.
|
298 |
2. Activate the plugin through the 'Plugins' menu in WordPress.
|
299 |
+
3. If you're updating from version 2.0.1 or before, please read the FAQ on backwards compatibility.
|
300 |
3. That's it, you're done - you just need to add the shortcode wherever you need.
|
301 |
|
302 |
== Frequently Asked Questions ==
|
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`.
|
321 |
|
322 |
+
= When trying to display a video it says "An error occured accessing the YouTube API" =
|
323 |
+
|
324 |
+
This has been reported by a number of users - for some reason some people are unable to access the YouTube API, which is used by this plugin to determine the video type and whether it's valid or not. If you are one of them then simply go to the `Options` screen within the `YouTube Embed` administration menu and, near the bottom, there is an option to stop reporting API errors.
|
325 |
+
|
326 |
+
If you switch off API errors then the plugin will simply assume all IDs are valid and work out the type from the ID length (which is not set, so if this changes in future it may cause problems!).
|
327 |
+
|
328 |
+
I have requested further information on why these errors may be occuring from the YouTube forum but, as yet, I've had no response. [Click here](http://groups.google.com/group/youtube-api-gdata/browse_thread/thread/764f2f2a3b5863f8?hl=en "YouTube APIs Developer Forum") if you wish to track the request.
|
329 |
+
|
330 |
= I've upgraded from an earlier version of Artiss YouTube Embed and one of the functions / shortcodes / parameters that I used is no longer documented =
|
331 |
|
332 |
Code created for previous versions of the plugin should still work - however, the functions will not be documented to deter people from using them in the future.
|
333 |
|
334 |
+
= So if I upgrade to this from an earlier version is it compatible? =
|
335 |
+
|
336 |
+
It should be, yes, but with one exception.
|
337 |
+
|
338 |
+
If you have upgraded from version 2.0.1 or before and used the `style` parameter then it may cause some problems. This is because the `style` parameter now affects the CSS of the video. Before, it added a DIV "wrapper" around the video and applied the styles to this.
|
339 |
+
|
340 |
+
Therefore, if you used the `style` parameter to centre a video this probably doesn't now work. However, you can do this now by using the `template` parameter instead - please read the section on that for further help.
|
341 |
+
|
342 |
+
However, with the change to the way the `style` works you can now apply more direct styling to the video - e.g. adding a border.
|
343 |
+
|
344 |
= Is the generated code standards compliant? =
|
345 |
|
346 |
In all cases, yes. However, it depends on which options you choose as to which DOCTYPE it will validate 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 |
== Upgrade Notice ==
|
469 |
|
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.
|
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.
|
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.0.3
|
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.0.3' );
|
21 |
|
22 |
$functions_dir = WP_PLUGIN_DIR . '/youtube-embed/includes/';
|
23 |
|