WordPress.org

Make WordPress Core


Ignore:
Timestamp:
10/29/2015 10:50:13 PM (4 years ago)
Author:
pento
Message:

Embeds: Who put this REST API infrastructure in my WordPress?

Well, while it's here, we probably should make use of it. The oEmbed endpoint now uses the REST API infrastructure, instead of providing its own.

Props swissspidy.

Fixes #34207.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/oembed/discovery.php

    r35242 r35436  
    66class Tests_oEmbed_Discovery extends WP_UnitTestCase {
    77    function test_add_oembed_discovery_links_non_singular() {
    8         ob_start();
    9         wp_oembed_add_discovery_links();
    10         $actual = ob_get_clean();
    11         $this->assertSame( '', $actual );
     8        $this->assertSame( '', get_echo( 'wp_oembed_add_discovery_links' ) );
    129    }
    1310
     
    1512        $post_id = self::factory()->post->create();
    1613        $this->go_to( get_permalink( $post_id ) );
    17 
    1814        $this->assertQueryTrue( 'is_single', 'is_singular' );
    19 
    20         ob_start();
    21         wp_oembed_add_discovery_links();
    22         $actual = ob_get_clean();
    2315
    2416        $expected = '<link rel="alternate" type="application/json+oembed" href="' . esc_url( get_oembed_endpoint_url( get_permalink() ) ) . '" />' . "\n";
    2517        $expected .= '<link rel="alternate" type="text/xml+oembed" href="' . esc_url( get_oembed_endpoint_url( get_permalink(), 'xml' ) ) . '" />' . "\n";
    2618
    27         $this->assertEquals( $expected, $actual );
     19        $this->assertEquals( $expected, get_echo( 'wp_oembed_add_discovery_links' ) );
    2820    }
    2921
     
    3325        ));
    3426        $this->go_to( get_permalink( $post_id ) );
    35 
    3627        $this->assertQueryTrue( 'is_page', 'is_singular' );
    37 
    38         ob_start();
    39         wp_oembed_add_discovery_links();
    40         $actual = ob_get_clean();
    4128
    4229        $expected = '<link rel="alternate" type="application/json+oembed" href="' . esc_url( get_oembed_endpoint_url( get_permalink() ) ) . '" />' . "\n";
    4330        $expected .= '<link rel="alternate" type="text/xml+oembed" href="' . esc_url( get_oembed_endpoint_url( get_permalink(), 'xml' ) ) . '" />' . "\n";
    4431
    45         $this->assertEquals( $expected, $actual );
     32        $this->assertEquals( $expected, get_echo( 'wp_oembed_add_discovery_links' ) );
    4633    }
    4734
     
    5441
    5542        $this->go_to( get_permalink( $attachment_id ) );
    56 
    5743        $this->assertQueryTrue( 'is_attachment', 'is_singular', 'is_single' );
    58 
    59         ob_start();
    60         wp_oembed_add_discovery_links();
    61         $actual = ob_get_clean();
    6244
    6345        $expected = '<link rel="alternate" type="application/json+oembed" href="' . esc_url( get_oembed_endpoint_url( get_permalink() ) ) . '" />' . "\n";
    6446        $expected .= '<link rel="alternate" type="text/xml+oembed" href="' . esc_url( get_oembed_endpoint_url( get_permalink(), 'xml' ) ) . '" />' . "\n";
    6547
    66         $this->assertEquals( $expected, $actual );
     48        $this->assertEquals( $expected, get_echo( 'wp_oembed_add_discovery_links' ) );
    6749    }
    6850}
Note: See TracChangeset for help on using the changeset viewer.