Ticket #7392: dont-save-autosave.2.diff
File dont-save-autosave.2.diff, 1.3 KB (added by , 12 years ago) |
---|
-
wp-admin/includes/post.php
1267 1267 * @return unknown 1268 1268 */ 1269 1269 function wp_create_post_autosave( $post_id ) { 1270 if ( ! $post = get_post( $post_id ) ) 1271 return; 1272 1270 1273 $translated = _wp_translate_postdata( true ); 1271 1274 if ( is_wp_error( $translated ) ) 1272 1275 return $translated; 1273 1276 1274 1277 $post_author = get_current_user_id(); 1275 1278 1279 1276 1280 // Store one autosave per author. If there is already an autosave, overwrite it. 1277 1281 if ( $old_autosave = wp_get_post_autosave( $post_id, $post_author ) ) { 1278 1282 $new_autosave = _wp_post_revision_fields( $_POST, true ); 1279 1283 $new_autosave['ID'] = $old_autosave->ID; 1280 1284 $new_autosave['post_author'] = $post_author; 1285 if ( apply_filters( 'wp_save_post_revision_check_for_changes', true, $post, $new_data ) && is_array( $new_data ) ) { 1286 $post_has_changed = false; 1287 foreach ( array_keys( _wp_post_revision_fields() ) as $field ) { 1288 if ( normalize_whitespace( $new_autosave[ $field ] ) != normalize_whitespace( $post[ $field ] ) ) { 1289 $post_has_changed = true; 1290 break; 1291 } 1292 } 1293 //don't save revision if post unchanged 1294 if( ! $post_has_changed ) 1295 return; 1296 } 1297 1298 1281 1299 return wp_update_post( $new_autosave ); 1282 1300 } 1283 1301