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:
parent
716d48e0cd
commit
ae974b8495
|
@ -4947,11 +4947,11 @@ function wp_save_post_revision( $post_id, $new_data = null ) {
|
||||||
if ( !post_type_supports($post['post_type'], 'revisions') )
|
if ( !post_type_supports($post['post_type'], 'revisions') )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// if new data is supplied, check that it is different from last saved revision
|
// if new data is supplied, check that it is different from last saved revision, unless a plugin tells us to always save regardless
|
||||||
if( is_array( $new_data ) ) {
|
if ( apply_filters( 'wp_save_post_revision_check_for_changes', true, $post, $new_data ) && is_array( $new_data ) ) {
|
||||||
$post_has_changed = false;
|
$post_has_changed = false;
|
||||||
foreach( array_keys( _wp_post_revision_fields() ) as $field ) {
|
foreach ( array_keys( _wp_post_revision_fields() ) as $field ) {
|
||||||
if( normalize_whitespace( $new_data[ $field ] ) != normalize_whitespace( $post[ $field ] ) ) {
|
if ( normalize_whitespace( $new_data[ $field ] ) != normalize_whitespace( $post[ $field ] ) ) {
|
||||||
$post_has_changed = true;
|
$post_has_changed = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue