mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-10-06 07:36:58 +00:00
Customize: Allow custom post types to be used in starter content.
Changes `WP_Customize_Nav_Menus::insert_auto_draft_post()` so it can be invoked for a `post_type` that is not registered (yet). See #38615, #38114. Fixes #39610. git-svn-id: https://develop.svn.wordpress.org/trunk@39924 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -373,6 +373,10 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase {
|
||||
'post_title' => 'Custom',
|
||||
'thumbnail' => '{{waffles}}',
|
||||
),
|
||||
'unknown_cpt' => array(
|
||||
'post_type' => 'unknown_cpt',
|
||||
'post_title' => 'Unknown CPT',
|
||||
),
|
||||
),
|
||||
'attachments' => array(
|
||||
'waffles' => array(
|
||||
@@ -441,7 +445,7 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase {
|
||||
$this->assertEquals( array( 'text-2', 'meta-3' ), $changeset_values['sidebars_widgets[sidebar-1]'] );
|
||||
|
||||
$posts_by_name = array();
|
||||
$this->assertCount( 6, $changeset_values['nav_menus_created_posts'] );
|
||||
$this->assertCount( 7, $changeset_values['nav_menus_created_posts'] );
|
||||
$this->assertContains( $existing_published_home_page_id, $changeset_values['nav_menus_created_posts'], 'Expected reuse of non-auto-draft posts.' );
|
||||
$this->assertContains( $existing_canola_attachment_id, $changeset_values['nav_menus_created_posts'], 'Expected reuse of non-auto-draft attachment.' );
|
||||
$this->assertNotContains( $existing_auto_draft_about_page_id, $changeset_values['nav_menus_created_posts'], 'Expected non-reuse of auto-draft posts.' );
|
||||
@@ -461,7 +465,7 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase {
|
||||
}
|
||||
$posts_by_name[ $post_name ] = $post->ID;
|
||||
}
|
||||
$this->assertEquals( array( 'waffles', 'canola', 'home', 'about', 'blog', 'custom' ), array_keys( $posts_by_name ) );
|
||||
$this->assertEquals( array( 'waffles', 'canola', 'home', 'about', 'blog', 'custom', 'unknown-cpt' ), array_keys( $posts_by_name ) );
|
||||
$this->assertEquals( 'Custom', get_post( $posts_by_name['custom'] )->post_title );
|
||||
$this->assertEquals( 'sample-page-template.php', get_page_template_slug( $posts_by_name['about'] ) );
|
||||
$this->assertEquals( '', get_page_template_slug( $posts_by_name['blog'] ) );
|
||||
|
||||
@@ -538,9 +538,13 @@ class Test_WP_Customize_Nav_Menus extends WP_UnitTestCase {
|
||||
$this->assertInstanceOf( 'WP_Error', $r );
|
||||
$this->assertEquals( 'unknown_post_type', $r->get_error_code() );
|
||||
|
||||
$r = $menus->insert_auto_draft_post( array( 'post_type' => 'fake' ) );
|
||||
// Non-existent post types allowed as of #39610.
|
||||
$r = $menus->insert_auto_draft_post( array( 'post_title' => 'Non-existent', 'post_type' => 'nonexistent' ) );
|
||||
$this->assertInstanceOf( 'WP_Post', $r );
|
||||
|
||||
$r = $menus->insert_auto_draft_post( array( 'post_type' => 'post' ) );
|
||||
$this->assertInstanceOf( 'WP_Error', $r );
|
||||
$this->assertEquals( 'unknown_post_type', $r->get_error_code() );
|
||||
$this->assertEquals( 'empty_title', $r->get_error_code() );
|
||||
|
||||
$r = $menus->insert_auto_draft_post( array( 'post_status' => 'publish', 'post_title' => 'Bad', 'post_type' => 'post' ) );
|
||||
$this->assertInstanceOf( 'WP_Error', $r );
|
||||
|
||||
Reference in New Issue
Block a user