Ticket #16215: 16215.3.diff
File 16215.3.diff, 4.2 KB (added by , 12 years ago) |
---|
-
wp-includes/default-filters.php
250 250 add_action( 'plugins_loaded', 'wp_maybe_load_widgets', 0 ); 251 251 add_action( 'plugins_loaded', 'wp_maybe_load_embeds', 0 ); 252 252 add_action( 'shutdown', 'wp_ob_end_flush_all', 1 ); 253 add_action( 'p re_post_update','wp_save_post_revision', 10, 2 );253 add_action( 'post_post_update', 'wp_save_post_revision', 10, 2 ); 254 254 add_action( 'publish_post', '_publish_post_hook', 5, 1 ); 255 255 add_action( 'transition_post_status', '_transition_post_status', 5, 3 ); 256 256 add_action( 'transition_post_status', '_update_term_count_on_transition_post_status', 10, 3 ); -
wp-includes/post.php
2878 2878 2879 2879 if ( $update ) { 2880 2880 do_action('edit_post', $post_ID, $post); 2881 do_action( 'post_post_update', $post_ID, $data ); 2882 2881 2883 $post_after = get_post($post_ID); 2882 2884 do_action( 'post_updated', $post_ID, $post_after, $post_before); 2883 2885 } -
wp-includes/revision.php
82 82 if ( ! WP_POST_REVISIONS ) 83 83 return; 84 84 85 if ( ! $post = get_post( $post_id, ARRAY_A ) )85 if ( ! $post = get_post( $post_id, ARRAY_A ) ) 86 86 return; 87 87 88 88 if ( 'auto-draft' == $post['post_status'] ) 89 89 return; 90 90 91 if ( ! post_type_supports($post['post_type'], 'revisions') )91 if ( ! post_type_supports( $post['post_type'], 'revisions' ) ) 92 92 return; 93 93 94 94 // if new data is supplied, check that it is different from last saved revision, unless a plugin tells us to always save regardless 95 if ( apply_filters( 'wp_save_post_revision_check_for_changes', true, $post, $new_data ) && is_array( $new_data ) ) { 96 $post_has_changed = false; 97 foreach ( array_keys( _wp_post_revision_fields() ) as $field ) { 98 if ( normalize_whitespace( $new_data[ $field ] ) != normalize_whitespace( $post[ $field ] ) ) { 99 $post_has_changed = true; 100 break; 95 if ( $revisions = wp_get_post_revisions( $post_id ) ) { // grab the last revision 96 $last_revision = array_shift( $revisions ); 97 if ( ! $last_revision_array = get_post( $last_revision->ID, ARRAY_A ) ) //if no previous revisions, save one for sure 98 return; 99 100 if ( apply_filters( 'wp_save_post_revision_check_for_changes', true, $last_revision_array, $new_data ) && is_array( $new_data ) ) { 101 $post_has_changed = false; 102 foreach ( array_keys( _wp_post_revision_fields() ) as $field ) { 103 if ( normalize_whitespace( $new_data[ $field ] ) != normalize_whitespace( $last_revision_array[ $field ] ) ) { 104 $post_has_changed = true; 105 break; 106 } 101 107 } 108 //don't save revision if post unchanged 109 if( ! $post_has_changed ) 110 return; 102 111 } 103 //don't save revision if post unchanged104 if( ! $post_has_changed )105 return;106 112 } 107 113 108 114 $return = _wp_put_post_revision( $post ); 109 115 110 116 // WP_POST_REVISIONS = true (default), -1 111 if ( ! is_numeric( WP_POST_REVISIONS ) || WP_POST_REVISIONS < 0 )117 if ( ! is_numeric( WP_POST_REVISIONS ) || WP_POST_REVISIONS < 0 ) 112 118 return $return; 113 119 114 120 // all revisions and (possibly) one autosave 115 121 $revisions = wp_get_post_revisions( $post_id, array( 'order' => 'ASC' ) ); 116 122 117 123 // WP_POST_REVISIONS = (int) (# of autosaves to save) 118 $delete = count( $revisions) - WP_POST_REVISIONS;124 $delete = count( $revisions ) - WP_POST_REVISIONS; 119 125 120 126 if ( $delete < 1 ) 121 127 return $return; … … 123 129 $revisions = array_slice( $revisions, 0, $delete ); 124 130 125 131 for ( $i = 0; isset($revisions[$i]); $i++ ) { 126 if ( false !== strpos( $revisions[ $i]->post_name, 'autosave' ) )132 if ( false !== strpos( $revisions[ $i ]->post_name, 'autosave' ) ) 127 133 continue; 128 wp_delete_post_revision( $revisions[ $i]->ID );134 wp_delete_post_revision( $revisions[ $i ]->ID ); 129 135 } 130 136 131 137 return $return;