From 2bd80ac24f3d33b5cbc9d1e6c6ef20136485872b Mon Sep 17 00:00:00 2001 From: Konstantin Obenland Date: Thu, 5 Oct 2017 01:29:46 +0000 Subject: [PATCH] Widgets: Continue to use shortcode for some embeds Renders YouTube and Vimeo embeds through WordPress' video shortcode. See #42039. Built from https://develop.svn.wordpress.org/trunk@41765 git-svn-id: http://core.svn.wordpress.org/trunk@41599 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/version.php | 2 +- wp-includes/widgets/class-wp-widget-media-video.php | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/wp-includes/version.php b/wp-includes/version.php index 508862bff6..b7018cd4c6 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -4,7 +4,7 @@ * * @global string $wp_version */ -$wp_version = '4.9-alpha-41764'; +$wp_version = '4.9-alpha-41765'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema. diff --git a/wp-includes/widgets/class-wp-widget-media-video.php b/wp-includes/widgets/class-wp-widget-media-video.php index a171ca8c4f..e4ab697a13 100644 --- a/wp-includes/widgets/class-wp-widget-media-video.php +++ b/wp-includes/widgets/class-wp-widget-media-video.php @@ -121,7 +121,10 @@ class WP_Widget_Media_Video extends WP_Widget_Media { return; } - if ( $attachment ) { + $youtube_pattern = '#^https?://(?:www\.)?(?:youtube\.com/watch|youtu\.be/)#'; + $vimeo_pattern = '#^https?://(.+\.)?vimeo\.com/.*#'; + + if ( $attachment || preg_match( $youtube_pattern, $src ) || preg_match( $vimeo_pattern, $src ) ) { add_filter( 'wp_video_shortcode', array( $this, 'inject_video_max_width_style' ) ); echo wp_video_shortcode(