From ae974b849518da4154f35990b8a2dc87abc08d18 Mon Sep 17 00:00:00 2001 From: Peter Westwood Date: Thu, 14 Feb 2013 16:45:43 +0000 Subject: [PATCH] Revisions: Allow a plugin to force us to skip the don't save this revision because it hasn't changed code if it knows better. See #7392 and #9843. Also cleans up the whitespace. git-svn-id: http://core.svn.wordpress.org/trunk@23415 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/post.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/wp-includes/post.php b/wp-includes/post.php index b76a1b4446..dbedab7bf1 100644 --- a/wp-includes/post.php +++ b/wp-includes/post.php @@ -4947,11 +4947,11 @@ function wp_save_post_revision( $post_id, $new_data = null ) { if ( !post_type_supports($post['post_type'], 'revisions') ) return; - // if new data is supplied, check that it is different from last saved revision - if( is_array( $new_data ) ) { + // if new data is supplied, check that it is different from last saved revision, unless a plugin tells us to always save regardless + if ( apply_filters( 'wp_save_post_revision_check_for_changes', true, $post, $new_data ) && is_array( $new_data ) ) { $post_has_changed = false; - foreach( array_keys( _wp_post_revision_fields() ) as $field ) { - if( normalize_whitespace( $new_data[ $field ] ) != normalize_whitespace( $post[ $field ] ) ) { + foreach ( array_keys( _wp_post_revision_fields() ) as $field ) { + if ( normalize_whitespace( $new_data[ $field ] ) != normalize_whitespace( $post[ $field ] ) ) { $post_has_changed = true; break; }