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: https://develop.svn.wordpress.org/trunk@23415 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Peter Westwood
2013-02-14 16:45:43 +00:00
parent 671a9b2017
commit 4ca366a0d1

View File

@@ -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;
}