From ac63fb4dc35511a04c01b23a98a9b72e3bfddc0f Mon Sep 17 00:00:00 2001 From: Scott Taylor Date: Wed, 24 Jun 2015 21:05:59 +0000 Subject: [PATCH] YouTube oEmbed parsing: support the `m` subdomain. Adds unit tests. Props Toru, johnbillion. Fixes #32714. git-svn-id: https://develop.svn.wordpress.org/trunk@32930 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-includes/class-oembed.php | 8 ++++---- tests/phpunit/tests/media.php | 13 +++++++++++++ 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/src/wp-includes/class-oembed.php b/src/wp-includes/class-oembed.php index 706660c134..401fedcc3b 100644 --- a/src/wp-includes/class-oembed.php +++ b/src/wp-includes/class-oembed.php @@ -34,10 +34,10 @@ class WP_oEmbed { */ public function __construct() { $providers = array( - '#http://(www\.)?youtube\.com/watch.*#i' => array( 'http://www.youtube.com/oembed', true ), - '#https://(www\.)?youtube\.com/watch.*#i' => array( 'http://www.youtube.com/oembed?scheme=https', true ), - '#http://(www\.)?youtube\.com/playlist.*#i' => array( 'http://www.youtube.com/oembed', true ), - '#https://(www\.)?youtube\.com/playlist.*#i' => array( 'http://www.youtube.com/oembed?scheme=https', true ), + '#http://((m|www)\.)?youtube\.com/watch.*#i' => array( 'http://www.youtube.com/oembed', true ), + '#https://((m|www)\.)?youtube\.com/watch.*#i' => array( 'http://www.youtube.com/oembed?scheme=https', true ), + '#http://((m|www)\.)?youtube\.com/playlist.*#i' => array( 'http://www.youtube.com/oembed', true ), + '#https://((m|www)\.)?youtube\.com/playlist.*#i' => array( 'http://www.youtube.com/oembed?scheme=https', true ), '#http://youtu\.be/.*#i' => array( 'http://www.youtube.com/oembed', true ), '#https://youtu\.be/.*#i' => array( 'http://www.youtube.com/oembed?scheme=https', true ), 'http://blip.tv/*' => array( 'http://blip.tv/oembed/', false ), diff --git a/tests/phpunit/tests/media.php b/tests/phpunit/tests/media.php index d14a504acd..b815a1a4c7 100644 --- a/tests/phpunit/tests/media.php +++ b/tests/phpunit/tests/media.php @@ -130,6 +130,19 @@ CAP; $this->assertContains( 'https://www.youtube.com/embed/zHjMoNQN7s0?feature=oembed', $out ); } + /** + * Test m.youtube.com embeds + * + * @ticket 32714 + */ + function test_youtube_com_mobile_embed() { + $out = wp_oembed_get( 'http://m.youtube.com/watch?v=oHg5SJYRHA0' ); + $this->assertContains( 'https://www.youtube.com/embed/oHg5SJYRHA0?feature=oembed', $out ); + + $out = wp_oembed_get( 'https://m.youtube.com/watch?v=oHg5SJYRHA0' ); + $this->assertContains( 'https://www.youtube.com/embed/oHg5SJYRHA0?feature=oembed', $out ); + } + function test_youtube_embed_url() { global $wp_embed; $out = $wp_embed->autoembed( 'https://www.youtube.com/embed/QcIy9NiNbmo' );