Ticket #7392: 7392.2.diff
File 7392.2.diff, 1.6 KB (added by , 12 years ago) |
---|
-
wp-admin/includes/post.php
1278 1278 * @return unknown 1279 1279 */ 1280 1280 function wp_create_post_autosave( $post_id ) { 1281 if ( ! $post = get_post( $post_id ) ) 1282 return; 1283 1281 1284 $translated = _wp_translate_postdata( true ); 1282 1285 if ( is_wp_error( $translated ) ) 1283 1286 return $translated; 1284 1287 1285 1288 $post_author = get_current_user_id(); 1289 $new_data = $_POST; 1286 1290 1287 1291 // Store one autosave per author. If there is already an autosave, overwrite it. 1288 1292 if ( $old_autosave = wp_get_post_autosave( $post_id, $post_author ) ) { … … 1290 1294 $new_autosave['ID'] = $old_autosave->ID; 1291 1295 $new_autosave['post_author'] = $post_author; 1292 1296 1297 // check to see if post content has changed before autosaving (filterable with wp_save_post_revision_check_for_changes) 1298 if ( apply_filters( 'wp_save_post_revision_check_for_changes', true, $post, $new_data ) && is_array( $new_data ) ) { 1299 $post_has_changed = false; 1300 foreach ( array_keys( _wp_post_revision_fields() ) as $field ) { 1301 if ( normalize_whitespace( $new_data[ $field ] ) != normalize_whitespace( $post[ $field ] ) ) { 1302 $post_has_changed = true; 1303 break; 1304 } 1305 } 1306 // don't save revision if post unchanged 1307 if ( ! $post_has_changed ) 1308 return; 1309 } 1310 1293 1311 // Auto-save revisioned meta fields. 1294 1312 foreach ( _wp_post_revision_meta_keys() as $meta_key ) { 1295 1313 if ( isset( $_POST[ $meta_key ] ) && get_post_meta( $new_autosave['ID'], $meta_key, true ) != $_POST[ $meta_key ] ) {