Skip to content

Commit

Permalink
Always create or update autosave
Browse files Browse the repository at this point in the history
  • Loading branch information
adamsilverstein committed Dec 29, 2021
1 parent 8492387 commit ae3aab1
Showing 1 changed file with 0 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -362,25 +362,6 @@ public function create_post_autosave( $post_data ) {
$new_autosave['ID'] = $old_autosave->ID;
$new_autosave['post_author'] = $user_id;

// If the new autosave has the same content as the post, delete the autosave.
$autosave_is_different = false;

foreach ( array_intersect( array_keys( $new_autosave ), array_keys( _wp_post_revision_fields( $post ) ) ) as $field ) {
if ( normalize_whitespace( $new_autosave[ $field ] ) !== normalize_whitespace( $post->$field ) ) {
$autosave_is_different = true;
break;
}
}

if ( ! $autosave_is_different ) {
wp_delete_post_revision( $old_autosave->ID );
return new WP_Error(
'rest_autosave_no_changes',
__( 'There is nothing to save. The autosave and the post content are the same.' ),
array( 'status' => 400 )
);
}

/** This filter is documented in wp-admin/post.php */
do_action( 'wp_creating_autosave', $new_autosave );

Expand Down

0 comments on commit ae3aab1

Please sign in to comment.