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.

git-svn-id: https://develop.svn.wordpress.org/trunk@36307 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Pascal Birchler
2016-01-15 07:55:19 +00:00
parent ee60e36a2c
commit d80a3c7ccd
10 changed files with 241 additions and 27 deletions
+20
View File
@@ -303,6 +303,26 @@ class Tests_Rewrite extends WP_UnitTestCase {
$this->set_permalink_structure();
}
/**
* @ticket 34971
*/
function test_url_to_postid_static_front_page() {
$post_id = self::factory()->post->create( array( 'post_type' => 'page' ) );
$this->assertSame( 0, url_to_postid( home_url() ) );
update_option( 'show_on_front', 'page' );
update_option( 'page_on_front', $post_id );
$this->assertSame( $post_id, url_to_postid( set_url_scheme( home_url(), 'http' ) ) );
$this->assertSame( $post_id, url_to_postid( set_url_scheme( home_url(), 'https' ) ) );
$this->assertSame( $post_id, url_to_postid( str_replace( array( 'http://', 'https://' ), 'http://www.', home_url() ) ) );
$this->assertSame( $post_id, url_to_postid( home_url() . '#random' ) );
$this->assertSame( $post_id, url_to_postid( home_url() . '?random' ) );
update_option( 'show_on_front', 'posts' );
}
/**
* @ticket 21970
*/