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/post/wpUniquePostSlug.php

    r35243 r36307  
    303303        $this->assertEquals( '32', $found );
    304304    }
     305
     306    /**
     307     * @ticket 34971
     308     */
     309    public function test_embed_slug_should_be_suffixed_for_posts() {
     310        $this->set_permalink_structure( '/%postname%/' );
     311
     312        $p = self::factory()->post->create( array(
     313            'post_type' => 'post',
     314            'post_name' => 'embed',
     315        ) );
     316
     317        $found = wp_unique_post_slug( 'embed', $p, 'publish', 'post', 0 );
     318        $this->assertSame( 'embed-2', $found );
     319    }
     320
     321    /**
     322     * @ticket 34971
     323     */
     324    public function test_embed_slug_should_be_suffixed_for_pages() {
     325        $this->set_permalink_structure( '/%postname%/' );
     326
     327        $p = self::factory()->post->create( array(
     328            'post_type' => 'page',
     329            'post_name' => 'embed',
     330        ) );
     331
     332        $found = wp_unique_post_slug( 'embed', $p, 'publish', 'paage', 0 );
     333        $this->assertSame( 'embed-2', $found );
     334    }
     335
     336    /**
     337     * @ticket 34971
     338     */
     339    public function test_embed_slug_should_be_suffixed_for_attachments() {
     340        $this->set_permalink_structure( '/%postname%/' );
     341
     342        $p = self::factory()->post->create( array(
     343            'post_type' => 'attachment',
     344            'post_name' => 'embed',
     345        ) );
     346
     347        $found = wp_unique_post_slug( 'embed', $p, 'publish', 'attachment', 0 );
     348        $this->assertSame( 'embed-2', $found );
     349    }
    305350}
Note: See TracChangeset for help on using the changeset viewer.