Ticket #7392: 7392.4.patch
File 7392.4.patch, 1.5 KB (added by , 11 years ago) |
---|
-
wp-admin/includes/post.php
1296 1296 * @subpackage Post_Revisions 1297 1297 * @since 2.6.0 1298 1298 * 1299 * @uses get_post() 1299 1300 * @uses _wp_translate_postdata() 1301 * @uses is_wp_error() 1302 * @uses get_current_user_id() 1303 * @uses wp_get_post_autosave() 1300 1304 * @uses _wp_post_revision_fields() 1305 * @uses apply_filters() 1306 * @uses normalize_whitespace() 1307 * @uses wp_update_post() 1308 * @uses wp_unslash() 1309 * @uses _wp_put_post_revision() 1301 1310 * 1302 * @return unknown1311 * @return mixed 1303 1312 */ 1304 1313 function wp_create_post_autosave( $post_id ) { 1314 if ( ! $post = get_post( $post_id ) ) 1315 return; 1316 1305 1317 $translated = _wp_translate_postdata( true ); 1306 1318 if ( is_wp_error( $translated ) ) 1307 1319 return $translated; … … 1314 1326 $new_autosave['ID'] = $old_autosave->ID; 1315 1327 $new_autosave['post_author'] = $post_author; 1316 1328 1329 // Check if post content has changed before autosaving 1330 if ( is_array( $new_autosave ) && apply_filters( 'wp_save_post_revision_check_for_changes', true, $post, $new_autosave ) ) { 1331 $post_has_changed = false; 1332 1333 foreach ( array_keys( _wp_post_revision_fields() ) as $field ) { 1334 if ( normalize_whitespace( $new_autosave[ $field ] ) != normalize_whitespace( $post->{$field} ) ) { 1335 $post_has_changed = true; 1336 break; 1337 } 1338 } 1339 1340 // Don't save anything new if post is unchanged 1341 if ( ! $post_has_changed ) 1342 return; 1343 } 1344 1317 1345 return wp_update_post( $new_autosave ); 1318 1346 } 1319 1347