PluginProbe
Jetpack – WP Security, Backup, Speed, & Growth / 16.2
Jetpack – WP Security, Backup, Speed, & Growth v16.2
16.3-a.1 16.2 16.2-beta 12.0.3 12.1.3 12.2.3 12.3.2 12.4.2 12.5.2 12.6.4 12.7.3 12.8.3 12.9.5 13.0.2 13.1.5 13.2.4 13.3.3 13.4.5 13.5.2 13.6.2 13.7.2 13.8.3 13.9.2 14.0.1 14.1.1 All 503 releases
← All changes | functions.compat.php +16 -9 12.9.516.2 View file →
@@ -9,9 +9,9 @@
9 9
10 10 /**
11 11 * Required for class.media-extractor.php to match expected function naming convention.
12 12 *
13 - * @param $url Can be just the $url or the whole $atts array.
13 + * @param string|array $url Can be just the $url or the whole $atts array.
14 14 * @return bool|mixed The Youtube video ID via jetpack_get_youtube_id
15 15 */
16 16 function jetpack_shortcode_get_youtube_id( $url ) {
17 17 return jetpack_get_youtube_id( $url );
@@ -19,9 +19,9 @@
19 19
20 20 /**
21 21 * Extract video ID from a YouTube url.
22 22 *
23 - * @param string $url YouTube URL.
23 + * @param string|array $url YouTube URL.
24 24 * @return bool|mixed The Youtube video ID
25 25 */
26 26 function jetpack_get_youtube_id( $url ) {
27 27 // Do we have an $atts array? Get first att
@@ -28,9 +28,9 @@
28 28 if ( is_array( $url ) ) {
29 29 $url = reset( $url );
30 30 }
31 31
32 - $url = youtube_sanitize_url( $url );
32 + $url = jetpack_youtube_sanitize_url( $url );
33 33 $url = wp_parse_url( $url );
34 34 $id = false;
35 35
36 36 if ( ! isset( $url['query'] ) ) {
@@ -53,21 +53,28 @@
53 53
54 54 return $id;
55 55 }
56 56
57 -if ( ! function_exists( 'youtube_sanitize_url' ) ) :
57 +if ( ! function_exists( 'jetpack_youtube_sanitize_url' ) ) :
58 58 /**
59 59 * Normalizes a YouTube URL to include a v= parameter and a query string free of encoded ampersands.
60 60 *
61 - * @param string $url YouTube URL.
62 - * @return string The normalized URL
61 + * @param string|array $url YouTube URL.
62 + * @return string|false The normalized URL or false if input is invalid.
63 63 */
64 - function youtube_sanitize_url( $url ) {
64 + function jetpack_youtube_sanitize_url( $url ) {
65 + if ( is_array( $url ) && isset( $url['url'] ) ) {
66 + $url = $url['url'];
67 + }
68 + if ( ! is_string( $url ) ) {
69 + return false;
70 + }
71 +
65 72 $url = trim( $url, ' "' );
66 73 $url = trim( $url );
67 - $url = str_replace( array( 'youtu.be/', '/v/', '#!v=', '&', '&', 'playlist' ), array( 'youtu.be/?v=', '/?v=', '?v=', '&', '&', 'videoseries' ), $url );
74 + $url = str_replace( array( 'youtu.be/', '/v/', '/shorts/', '#!v=', '&', '&', 'playlist' ), array( 'youtu.be/?v=', '/?v=', '/watch?v=', '?v=', '&', '&', 'videoseries' ), $url );
68 75
69 - // Replace any extra question marks with ampersands - the result of a URL like "https://www.youtube.com/v/9FhMMmqzbD8?fs=1&hl=en_US" being passed in.
76 + // Replace any extra question marks with ampersands - the result of a URL like "https://www.youtube.com/v/dQw4w9WgXcQ?fs=1&hl=en_US" being passed in.
70 77 $query_string_start = strpos( $url, '?' );
71 78
72 79 if ( false !== $query_string_start ) {
73 80 $url = substr( $url, 0, $query_string_start + 1 ) . str_replace( '?', '&', substr( $url, $query_string_start + 1 ) );