Make WordPress Core

Changeset 32930


Ignore:
Timestamp:
06/24/2015 09:05:59 PM (7 years ago)
Author:
wonderboymusic
Message:

YouTube oEmbed parsing: support the m subdomain.
Adds unit tests.

Props Toru, johnbillion.
Fixes #32714.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/class-oembed.php

    r32650 r32930  
    3535    public function __construct() {
    3636        $providers = array(
    37             '#http://(www\.)?youtube\.com/watch.*#i'              => array( 'http://www.youtube.com/oembed',                      true  ),
    38             '#https://(www\.)?youtube\.com/watch.*#i'             => array( 'http://www.youtube.com/oembed?scheme=https',         true  ),
    39             '#http://(www\.)?youtube\.com/playlist.*#i'           => array( 'http://www.youtube.com/oembed',                      true  ),
    40             '#https://(www\.)?youtube\.com/playlist.*#i'          => array( 'http://www.youtube.com/oembed?scheme=https',         true  ),
     37            '#http://((m|www)\.)?youtube\.com/watch.*#i'          => array( 'http://www.youtube.com/oembed',                      true  ),
     38            '#https://((m|www)\.)?youtube\.com/watch.*#i'         => array( 'http://www.youtube.com/oembed?scheme=https',         true  ),
     39            '#http://((m|www)\.)?youtube\.com/playlist.*#i'       => array( 'http://www.youtube.com/oembed',                      true  ),
     40            '#https://((m|www)\.)?youtube\.com/playlist.*#i'      => array( 'http://www.youtube.com/oembed?scheme=https',         true  ),
    4141            '#http://youtu\.be/.*#i'                              => array( 'http://www.youtube.com/oembed',                      true  ),
    4242            '#https://youtu\.be/.*#i'                             => array( 'http://www.youtube.com/oembed?scheme=https',         true  ),
  • trunk/tests/phpunit/tests/media.php

    r32794 r32930  
    129129        $out = wp_oembed_get( 'https://youtu.be/zHjMoNQN7s0' );
    130130        $this->assertContains( 'https://www.youtube.com/embed/zHjMoNQN7s0?feature=oembed', $out );
     131    }
     132
     133    /**
     134     * Test m.youtube.com embeds
     135     *
     136     * @ticket 32714
     137     */
     138    function test_youtube_com_mobile_embed() {
     139        $out = wp_oembed_get( 'http://m.youtube.com/watch?v=oHg5SJYRHA0' );
     140        $this->assertContains( 'https://www.youtube.com/embed/oHg5SJYRHA0?feature=oembed', $out );
     141
     142        $out = wp_oembed_get( 'https://m.youtube.com/watch?v=oHg5SJYRHA0' );
     143        $this->assertContains( 'https://www.youtube.com/embed/oHg5SJYRHA0?feature=oembed', $out );
    131144    }
    132145
Note: See TracChangeset for help on using the changeset viewer.