Surface "Move to Trash" link for posts/pages immediately after first autosave fires. Props cross country flight. fixes #10344
git-svn-id: http://svn.automattic.com/wordpress/trunk@11986 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
4e20ae5719
commit
9109450809
|
@ -968,13 +968,9 @@ case 'autosave' : // The name of this action is hardcoded in edit_post()
|
|||
case 'autosave-generate-nonces' :
|
||||
check_ajax_referer( 'autosave', 'autosavenonce' );
|
||||
$ID = (int) $_POST['post_ID'];
|
||||
if ( $_POST['post_type'] == 'post' ) {
|
||||
if ( current_user_can('edit_post', $ID) )
|
||||
die(wp_create_nonce('update-post_' . $ID));
|
||||
} elseif ( $_POST['post_type'] == 'page' ) {
|
||||
if ( current_user_can('edit_page', $ID) )
|
||||
die(wp_create_nonce('update-page_' . $ID));
|
||||
}
|
||||
$post_type = ( 'page' == $_POST['post_type'] ) ? 'page' : 'post';
|
||||
if ( current_user_can( "edit_{$post_type}", $ID ) )
|
||||
die( json_encode( array( 'updateNonce' => wp_create_nonce( "update-{$post_type}_{$ID}" ), 'deleteURL' => str_replace( '&', '&', wp_nonce_url( admin_url( $post_type . '.php?action=trash&post=' . $ID ), "trash-{$post_type}_{$ID}" ) ) ) ) );
|
||||
do_action('autosave_generate_nonces');
|
||||
die('0');
|
||||
break;
|
||||
|
|
|
@ -183,9 +183,9 @@ if ( $can_publish ) : // Contributors don't get to choose the date of publish ?>
|
|||
<?php do_action('post_submitbox_start'); ?>
|
||||
<div id="delete-action">
|
||||
<?php
|
||||
if ( ( 'edit' == $action ) && current_user_can("delete_${post_type}", $post->ID) ) { ?>
|
||||
if ( current_user_can("delete_${post_type}", $post->ID) ) { ?>
|
||||
<?php $delete_url = add_query_arg( array('action'=>'trash', 'post'=>$post->ID) ); ?>
|
||||
<a class="submitdelete deletion" href="<?php echo wp_nonce_url($delete_url, "trash-${post_type}_" . $post->ID); ?>"><?php _e('Move to Trash'); ?></a>
|
||||
<a class="submitdelete deletion<?php if ( 'edit' != $action ) { echo " hidden"; } ?>" href="<?php echo wp_nonce_url($delete_url, "trash-${post_type}_" . $post->ID); ?>"><?php _e('Move to Trash'); ?></a>
|
||||
<?php } ?>
|
||||
</div>
|
||||
|
||||
|
|
|
@ -155,7 +155,7 @@ case 'trash':
|
|||
wp_die( __('Error in moving to trash...') );
|
||||
|
||||
$sendback = wp_get_referer();
|
||||
if ( strpos($sendback, 'page.php') !== false )
|
||||
if ( strpos($sendback, 'page.php') !== false || strpos($sendback, 'page-new.php') !== false )
|
||||
$sendback = admin_url('edit-pages.php?trashed=1');
|
||||
else
|
||||
$sendback = add_query_arg('trashed', 1, $sendback);
|
||||
|
|
|
@ -195,7 +195,7 @@ case 'trash':
|
|||
wp_die( __('Error in moving to trash...') );
|
||||
|
||||
$sendback = wp_get_referer();
|
||||
if ( strpos($sendback, 'post.php') !== false )
|
||||
if ( strpos($sendback, 'post.php') !== false || strpos($sendback, 'post-new.php') !== false )
|
||||
$sendback = admin_url('edit.php?trashed=1');
|
||||
else
|
||||
$sendback = add_query_arg('trashed', 1, $sendback);
|
||||
|
|
|
@ -152,9 +152,12 @@ function autosave_update_post_ID( postID ) {
|
|||
autosavenonce: jQuery('#autosavenonce').val(),
|
||||
post_type: jQuery('#post_type').val()
|
||||
}, function(html) {
|
||||
jQuery('#_wpnonce').val(html);
|
||||
jQuery('#_wpnonce').val(html.updateNonce);
|
||||
jQuery('#delete-action a.submitdelete').attr('href', html.deleteURL);
|
||||
autosave_enable_buttons(); // re-enable disabled form buttons
|
||||
});
|
||||
jQuery('#delete-action a.submitdelete').fadeIn();
|
||||
},
|
||||
'json');
|
||||
jQuery('#hiddenaction').val('editpost');
|
||||
}
|
||||
}
|
||||
|
|
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue