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

View File

@@ -302,4 +302,49 @@ class Tests_Post_WpUniquePostSlug extends WP_UnitTestCase {
$found = wp_unique_post_slug( '32', $p, 'publish', 'post', 0 );
$this->assertEquals( '32', $found );
}
/**
* @ticket 34971
*/
public function test_embed_slug_should_be_suffixed_for_posts() {
$this->set_permalink_structure( '/%postname%/' );
$p = self::factory()->post->create( array(
'post_type' => 'post',
'post_name' => 'embed',
) );
$found = wp_unique_post_slug( 'embed', $p, 'publish', 'post', 0 );
$this->assertSame( 'embed-2', $found );
}
/**
* @ticket 34971
*/
public function test_embed_slug_should_be_suffixed_for_pages() {
$this->set_permalink_structure( '/%postname%/' );
$p = self::factory()->post->create( array(
'post_type' => 'page',
'post_name' => 'embed',
) );
$found = wp_unique_post_slug( 'embed', $p, 'publish', 'paage', 0 );
$this->assertSame( 'embed-2', $found );
}
/**
* @ticket 34971
*/
public function test_embed_slug_should_be_suffixed_for_attachments() {
$this->set_permalink_structure( '/%postname%/' );
$p = self::factory()->post->create( array(
'post_type' => 'attachment',
'post_name' => 'embed',
) );
$found = wp_unique_post_slug( 'embed', $p, 'publish', 'attachment', 0 );
$this->assertSame( 'embed-2', $found );
}
}