Make WordPress Core

Ticket #46986: 46986.2.diff

File 46986.2.diff, 2.1 KB (added by Mista-Flo, 4 years ago)

Fix if state and add unit test

  • src/wp-includes/class-wp-oembed.php

    diff --git a/src/wp-includes/class-wp-oembed.php b/src/wp-includes/class-wp-oembed.php
    index 881de68103..292bc343d1 100644
    a b class WP_oEmbed { 
    520520                $provider = add_query_arg( 'maxwidth', (int) $args['width'], $provider );
    521521                $provider = add_query_arg( 'maxheight', (int) $args['height'], $provider );
    522522                $provider = add_query_arg( 'url', urlencode( $url ), $provider );
    523                 $provider = add_query_arg( 'dnt', 1, $provider );
     523                if ( strpos( $provider, 'vimeo.com' ) === false ) {
     524                        $provider = add_query_arg( 'dnt', 1, $provider );
     525                }
    524526
    525527                /**
    526528                 * Filters the oEmbed URL to be fetched.
    527529                 *
    528530                 * @since 2.9.0
    529531                 * @since 4.9.0 The `dnt` (Do Not Track) query parameter was added to all oEmbed provider URLs.
     532                 * @since 5.6.0 The `dnt` (Do Not Track) query parameter was removed from Vimeo oEmbed URLs. (@ticket: #46986)
     533                 *
     534                 * The `dnt` parameter can be re-enabled on Vimeo oEmbed URLs using the following:
     535                 *
     536                 *     function enable_dnt_vimeo_oembed( $provider, $url, $args ) {
     537                 *         if ( strpos( $provider, 'vimeo.com' ) !== false ) {
     538                 *             $provider = add_query_arg( 'dnt', 1, $provider );
     539                 *         }
     540                 *         return $provider;
     541                 *     }
     542                 *     add_filter( 'oembed_fetch_url', 'enable_dnt_vimeo_oembed', 10, 3 );
    530543                 *
    531544                 * @param string $provider URL of the oEmbed provider.
    532545                 * @param string $url      URL of the content to be embedded.
  • tests/phpunit/tests/oembed/wpOembed.php

    diff --git a/tests/phpunit/tests/oembed/wpOembed.php b/tests/phpunit/tests/oembed/wpOembed.php
    index 1f15abbad8..418f40aed4 100644
    a b class Tests_WP_oEmbed extends WP_UnitTestCase { 
    234234                $this->assertFalse( $actual );
    235235                $this->assertSame( $current_blog_id, get_current_blog_id() );
    236236        }
     237
     238        /**
     239         * @ticket 46986
     240         */
     241        public function test_vimeo_oembed_does_not_have_dnt() {
     242                $vimeo_oembed = $this->oembed->get_data( 'https://vimeo.com/202791609' );
     243
     244                $this->assertNotContains( 'dnt=1', $vimeo_oembed->html );
     245        }
    237246}