Widgets: Normalize YouTube and Vimeo URLs in video shortcode (primarily for Video widget) to work around ME.js 2.22 bug.

Props timmydcrawford, jnylen0, westonruter.
See #32417, #39994.
Fixes #40866.

Built from https://develop.svn.wordpress.org/trunk@40847


git-svn-id: http://core.svn.wordpress.org/trunk@40698 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Weston Ruter 2017-05-26 23:10:44 +00:00
parent 91090572fe
commit 91f544da29
2 changed files with 15 additions and 1 deletions

View File

@ -2546,6 +2546,20 @@ function wp_video_shortcode( $attr, $content = '' ) {
wp_enqueue_script( 'wp-mediaelement' );
}
// Mediaelement has issues with some URL formats for Vimeo and YouTube, so
// update the URL to prevent the ME.js player from breaking.
if ( 'mediaelement' === $library ) {
if ( $is_youtube ) {
// Remove `feature` query arg and force SSL - see #40866.
$atts['src'] = remove_query_arg( 'feature', $atts['src'] );
$atts['src'] = set_url_scheme( $atts['src'], 'https' );
} elseif ( $is_vimeo ) {
// Remove all query arguments and force SSL - see #40866.
$parsed_vimeo_url = wp_parse_url( $atts['src'] );
$atts['src'] = 'https://' . $parsed_vimeo_url['host'] . $parsed_vimeo_url['path'];
}
}
/**
* Filters the class attribute for the video shortcode output container.
*

View File

@ -4,7 +4,7 @@
*
* @global string $wp_version
*/
$wp_version = '4.8-RC1-40846';
$wp_version = '4.8-RC1-40847';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.