Ticket #7392: 7392-autosave.patch
File 7392-autosave.patch, 1.5 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(); 1278 $new_data = $_POST; 1275 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; 1281 return wp_update_post( $new_autosave ); 1285 1286 $new_data = $new_autosave; 1282 1287 } 1283 1288 1289 if ( apply_filters( 'wp_save_post_revision_check_for_changes', true, $post, $new_data ) && is_array( $new_data ) ) { 1290 $post_has_changed = false; 1291 foreach ( array_keys( _wp_post_revision_fields() ) as $field ) { 1292 if ( normalize_whitespace( $new_data[ $field ] ) != normalize_whitespace( $post[ $field ] ) ) { 1293 $post_has_changed = true; 1294 break; 1295 } 1296 } 1297 //don't save revision if post unchanged 1298 if( ! $post_has_changed ) 1299 return; 1300 } 1301 1302 if ( isset( $new_autosave ) ) 1303 return wp_update_post( $new_autosave ); 1304 1284 1305 // _wp_put_post_revision() expects unescaped. 1285 1306 $_POST = wp_unslash($_POST); 1286 1307