Make WordPress Core


Ignore:
Timestamp:
01/15/2016 07:55:19 AM (9 years ago)
Author:
swissspidy
Message:

Embeds: Allow embedding static front pages and pages having a child page with an embed slug.

This makes embed a special slug that can't be used for new pages/posts. When https://example.com/foo/embed/ is an existing page, embeds fall back to https://example.com/foo/?embed=true.
Adds unit tests.

Fixes #34971.

File:
1 edited

Legend:

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

    r36059 r36307  
    1010
    1111    function test_add_oembed_discovery_links_front_page() {
    12         $this->go_to( home_url('/') );
     12        $this->go_to( home_url() );
    1313        $this->assertSame( '', get_echo( 'wp_oembed_add_discovery_links' ) );
     14        $this->assertSame( 0, url_to_postid( home_url() ) );
    1415    }
    1516
     17    /**
     18     * @ticket 34971
     19     */
    1620    function test_add_oembed_discovery_links_static_front_page() {
    1721        update_option( 'show_on_front', 'page' );
    18         update_option( 'page_for_posts', self::factory()->post->create( array( 'post_title' => 'blog-page', 'post_type' => 'page' ) ) );
    1922        update_option( 'page_on_front', self::factory()->post->create( array( 'post_title' => 'front-page', 'post_type' => 'page' ) ) );
    2023
    21         $this->go_to( home_url('/') );
    22         $this->assertSame( '', get_echo( 'wp_oembed_add_discovery_links' ) );
     24        $this->go_to( home_url() );
     25        $this->assertQueryTrue( 'is_front_page', 'is_singular', 'is_page' );
     26
     27        $expected = '<link rel="alternate" type="application/json+oembed" href="' . esc_url( get_oembed_endpoint_url( get_permalink() ) ) . '" />' . "\n";
     28        $expected .= '<link rel="alternate" type="text/xml+oembed" href="' . esc_url( get_oembed_endpoint_url( get_permalink(), 'xml' ) ) . '" />' . "\n";
     29
     30        $this->assertSame( $expected, get_echo( 'wp_oembed_add_discovery_links' ) );
    2331
    2432        update_option( 'show_on_front', 'posts' );
Note: See TracChangeset for help on using the changeset viewer.