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
This commit is contained in:
Konstantin Obenland 2017-10-05 01:28:11 +00:00
parent e4726752ab
commit 0bff7272e8
1 changed files with 4 additions and 1 deletions

View File

@ -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(