Always convert auto-drafts to drafts in edit_draft() and _wp_translate_postdata().
This regressed due to refactoring in [26995]. This commit fixes Quick Draft. see #25272. git-svn-id: https://develop.svn.wordpress.org/trunk@27405 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
83b61e9400
commit
a14b999605
@ -83,8 +83,9 @@ function _wp_translate_postdata( $update = false, $post_data = null ) {
|
||||
$post_data['post_status'] = sanitize_key( $post_data['post_status'] );
|
||||
|
||||
// No longer an auto-draft
|
||||
if ( 'auto-draft' == $post_data['post_status'] )
|
||||
if ( 'auto-draft' === $post_data['post_status'] ) {
|
||||
$post_data['post_status'] = 'draft';
|
||||
}
|
||||
}
|
||||
|
||||
// What to do based on which button they pressed
|
||||
@ -113,8 +114,9 @@ function _wp_translate_postdata( $update = false, $post_data = null ) {
|
||||
if ( ! in_array( $previous_status, $published_statuses ) || !current_user_can( 'edit_post', $post_id ) )
|
||||
$post_data['post_status'] = 'pending';
|
||||
|
||||
if ( ! isset($post_data['post_status']) )
|
||||
$post_data['post_status'] = $previous_status;
|
||||
if ( ! isset( $post_data['post_status'] ) ) {
|
||||
$post_data['post_status'] = 'auto-draft' === $previous_status ? 'draft' : $previous_status;
|
||||
}
|
||||
|
||||
if (!isset( $post_data['comment_status'] ))
|
||||
$post_data['comment_status'] = 'closed';
|
||||
|
@ -114,4 +114,26 @@ class Tests_Admin_includesPost extends WP_UnitTestCase {
|
||||
|
||||
wp_set_current_user( 0 );
|
||||
}
|
||||
|
||||
/**
|
||||
* edit_post() should convert an existing auto-draft to a draft.
|
||||
*
|
||||
* @ticket 25272
|
||||
*/
|
||||
function test_edit_post_auto_draft() {
|
||||
$user_id = $this->factory->user->create( array( 'role' => 'editor' ) );
|
||||
wp_set_current_user( $user_id );
|
||||
$post = $this->factory->post->create_and_get( array( 'post_status' => 'auto-draft' ) );
|
||||
$this->assertEquals( 'auto-draft', $post->post_status );
|
||||
$post_data = array(
|
||||
'post_title' => 'Post title',
|
||||
'content' => 'Post content',
|
||||
'post_type' => 'post',
|
||||
'post_ID' => $post->ID,
|
||||
);
|
||||
edit_post( $post_data );
|
||||
$this->assertEquals( 'draft', get_post( $post->ID )->post_status );
|
||||
wp_set_current_user( 0 );
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user