Only show "saved at" when the post was actually saved. Props mdawaffe. fixes #6053

git-svn-id: http://svn.automattic.com/wordpress/trunk@7138 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
ryan 2008-03-03 20:58:06 +00:00
parent 0ab4077b3c
commit 5504c11b58
2 changed files with 11 additions and 4 deletions

View File

@ -483,15 +483,18 @@ case 'autosave' : // The name of this action is hardcoded in edit_post()
$do_autosave = (bool) $_POST['autosave'];
$do_lock = true;
$data = '<div class="updated"><p>' . sprintf( __('Saved at %s.'), date( __('g:i:s a'), current_time( 'timestamp', true ) ) ) . '</p></div>';
$data = '';
$message = '<div class="updated"><p>' . sprintf( __('Saved at %s.'), date( __('g:i:s a'), current_time( 'timestamp', true ) ) ) . '</p></div>';
$supplemental = array();
$id = 0;
if($_POST['post_ID'] < 0) {
$_POST['temp_ID'] = $_POST['post_ID'];
if ( $do_autosave )
if ( $do_autosave ) {
$id = wp_write_post();
$data = $message;
}
} else {
$post_ID = (int) $_POST['post_ID'];
$_POST['ID'] = $post_ID;
@ -517,10 +520,12 @@ case 'autosave' : // The name of this action is hardcoded in edit_post()
if ( !current_user_can('edit_post', $post_ID) )
die(__('You are not allowed to edit this post.'));
}
if ( $do_autosave )
if ( $do_autosave ) {
$id = wp_update_post($_POST);
else
$data = $message;
} else {
$id = $post->ID;
}
}
if ( $do_lock && $id && is_numeric($id) )

View File

@ -17,6 +17,7 @@ jQuery(function($) {
// called when autosaving pre-existing post
function autosave_saved(response) {
var oldMessage = jQuery('#autosave').html();
var res = wpAjax.parseAjaxResponse(response, 'autosave'); // parse the ajax response
var message = '';
@ -38,6 +39,7 @@ function autosave_saved(response) {
}
}
if ( message ) { jQuery('#autosave').html(message); } // update autosave message
else if ( oldMessage && res ) { jQuery('#autosave').html( oldMessage ); }
autosave_enable_buttons(); // re-enable disabled form buttons
return res;
}