Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/wp-admin/includes/post.php
Original file line number Diff line number Diff line change
Expand Up @@ -762,9 +762,10 @@ function get_default_post_to_edit( $post_type = 'post', $create_in_db = false )
}

if ( $create_in_db ) {
$default_title = post_type_supports( $post_type, 'title' ) ? __( 'Auto Draft' ) : __( '(no title supported)' );
$post_id = wp_insert_post(
array(
'post_title' => __( 'Auto Draft' ),
'post_title' => $default_title,
'post_type' => $post_type,
'post_status' => 'auto-draft',
),
Expand Down
18 changes: 18 additions & 0 deletions tests/phpunit/tests/admin/includesPost.php
Original file line number Diff line number Diff line change
Expand Up @@ -1325,4 +1325,22 @@ public function test_user_get_refreshed_metabox_nonce() {
$this->assertNotEmpty( $response['wp-refresh-metabox-loader-nonces']['replace']['_wpnonce'] );
$this->assertNotEmpty( $response['wp-refresh-metabox-loader-nonces']['replace']['metabox_loader_nonce'] );
}

/**
* Ensure default title is set to "(no title supported)" when CPT lacks title support.
*
* @ticket 45516
*/
public function test_no_title_supported_when_title_not_supported() {
register_post_type(
'no_title',
array(
'supports' => array( 'editor' ),
)
);

$default_post = get_default_post_to_edit( 'no_title', true );
$post = get_post( $default_post->ID );
$this->assertSame( '(no title supported)', $post->post_title );
}
}
Loading