From 0bff7272e8d626eaaf2c4c1cba6f3f1d99aad657 Mon Sep 17 00:00:00 2001 From: Konstantin Obenland Date: Thu, 5 Oct 2017 01:28:11 +0000 Subject: [PATCH] Widgets: Continue to use shortcode for some embeds Renders YouTube and Vimeo embeds through WordPress' video shortcode. See #42039. git-svn-id: https://develop.svn.wordpress.org/trunk@41765 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-includes/widgets/class-wp-widget-media-video.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/wp-includes/widgets/class-wp-widget-media-video.php b/src/wp-includes/widgets/class-wp-widget-media-video.php index a171ca8c4f..e4ab697a13 100644 --- a/src/wp-includes/widgets/class-wp-widget-media-video.php +++ b/src/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(