mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-07-04 09:10:06 +00:00
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:
@@ -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 );
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user