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
This commit is contained in:
Peter Westwood 2013-02-14 16:45:43 +00:00
parent 716d48e0cd
commit ae974b8495
1 changed files with 4 additions and 4 deletions

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