Revisions: Clean up _wp_post_revision_fields():
* Move the array processing to a new function, `_wp_post_revision_data()`. * Make both functions accept a post array or a `WP_Post` object. * Always apply the `_wp_post_revision_fields` filter and pass the post data to it. Fixes #13382. Built from https://develop.svn.wordpress.org/trunk@36659 git-svn-id: http://core.svn.wordpress.org/trunk@36626 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
@@ -1662,14 +1662,14 @@ function wp_create_post_autosave( $post_data ) {
|
||||
|
||||
// Store one autosave per author. If there is already an autosave, overwrite it.
|
||||
if ( $old_autosave = wp_get_post_autosave( $post_id, $post_author ) ) {
|
||||
$new_autosave = _wp_post_revision_fields( $post_data, true );
|
||||
$new_autosave = _wp_post_revision_data( $post_data, true );
|
||||
$new_autosave['ID'] = $old_autosave->ID;
|
||||
$new_autosave['post_author'] = $post_author;
|
||||
|
||||
// If the new autosave has the same content as the post, delete the autosave.
|
||||
$post = get_post( $post_id );
|
||||
$autosave_is_different = false;
|
||||
foreach ( array_intersect( array_keys( $new_autosave ), array_keys( _wp_post_revision_fields() ) ) as $field ) {
|
||||
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;
|
||||
|
||||
Reference in New Issue
Block a user