WordPress.org

Make WordPress Core


Ignore:
Timestamp:
01/15/2016 07:55:19 AM (4 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/rewrite.php

    r36254 r36307  
    305305
    306306    /**
     307     * @ticket 34971
     308     */
     309    function test_url_to_postid_static_front_page() {
     310        $post_id = self::factory()->post->create( array( 'post_type' => 'page' ) );
     311
     312        $this->assertSame( 0, url_to_postid( home_url() ) );
     313
     314        update_option( 'show_on_front', 'page' );
     315        update_option( 'page_on_front', $post_id );
     316
     317        $this->assertSame( $post_id, url_to_postid( set_url_scheme( home_url(), 'http' ) ) );
     318        $this->assertSame( $post_id, url_to_postid( set_url_scheme( home_url(), 'https' ) ) );
     319        $this->assertSame( $post_id, url_to_postid( str_replace( array( 'http://', 'https://' ), 'http://www.', home_url() ) ) );
     320        $this->assertSame( $post_id, url_to_postid( home_url() . '#random' ) );
     321        $this->assertSame( $post_id, url_to_postid( home_url() . '?random' ) );
     322
     323        update_option( 'show_on_front', 'posts' );
     324    }
     325
     326    /**
    307327     * @ticket 21970
    308328     */
Note: See TracChangeset for help on using the changeset viewer.