diff --git a/wp-admin/admin-ajax.php b/wp-admin/admin-ajax.php
index 063e369151..5f236c98f2 100644
--- a/wp-admin/admin-ajax.php
+++ b/wp-admin/admin-ajax.php
@@ -181,18 +181,27 @@ function _wp_ajax_delete_comment_response( $comment_id ) {
$id = isset($_POST['id'])? (int) $_POST['id'] : 0;
switch ( $action = $_POST['action'] ) :
case 'delete-comment' : // On success, die with time() instead of 1
- check_ajax_referer( "delete-comment_$id" );
if ( !$comment = get_comment( $id ) )
die( (string) time() );
if ( !current_user_can( 'edit_post', $comment->comment_post_ID ) )
die('-1');
- if ( isset($_POST['spam']) && 1 == $_POST['spam'] ) {
+ if ( isset($_POST['trash']) && 1 == $_POST['trash'] ) {
+ check_ajax_referer( "trash-comment_$id" );
+ if ( 'trash' == wp_get_comment_status( $comment->comment_ID ) )
+ die( (string) time() );
+ $r = wp_trash_comment( $comment->comment_ID );
+ } elseif ( isset($_POST['untrash']) && 1 == $_POST['untrash'] ) {
+ check_ajax_referer( "untrash-comment_$id" );
+ $r = wp_untrash_comment( $comment->comment_ID );
+ } elseif ( isset($_POST['spam']) && 1 == $_POST['spam'] ) {
+ check_ajax_referer( "delete-comment_$id" );
if ( 'spam' == wp_get_comment_status( $comment->comment_ID ) )
die( (string) time() );
$r = wp_set_comment_status( $comment->comment_ID, 'spam' );
} else {
- $r = wp_set_comment_status( $comment->comment_ID, 'delete' );
+ check_ajax_referer( "delete-comment_$id" );
+ $r = wp_delete_comment( $comment->comment_ID );
}
if ( $r ) // Decide if we need to send back '1' or a more complicated response including page links and comment counts
_wp_ajax_delete_comment_response( $comment->comment_ID );
diff --git a/wp-admin/comment.php b/wp-admin/comment.php
index 56c948aca6..0edafda203 100644
--- a/wp-admin/comment.php
+++ b/wp-admin/comment.php
@@ -44,8 +44,8 @@ case 'editcomment' :
if ( !current_user_can('edit_post', $comment->comment_post_ID) )
comment_footer_die( __('You are not allowed to edit comments on this post.') );
- if ( 'deleted' == $comment->comment_status )
- comment_footer_die( __('This comment has been deleted. Please move it out of the Trash if you want to edit it.') );
+ if ( 'trash' == $comment->comment_status )
+ comment_footer_die( __('This comment is in the Trash. Please move it out of the Trash if you want to edit it.') );
$comment = get_comment_to_edit( $comment_id );
@@ -166,6 +166,35 @@ case 'deletecomment' :
die;
break;
+case 'trashcomment' :
+case 'untrashcomment' :
+ $comment_id = absint( $_REQUEST['c'] );
+ $noredir = isset($_REQUEST['noredir']);
+
+ if (!$comment = get_comment($comment_id))
+ comment_footer_die( __('Oops, no comment with this ID.') . sprintf(' '.__('Go back').' !', 'edit-comments.php') );
+ if (!current_user_can('edit_post', $comment->comment_post_ID ))
+ comment_footer_die( __('You are not allowed to edit comments on this post.') );
+
+ if ($action == 'trashcomment') {
+ check_admin_referer( 'trash-comment_' . $comment_id );
+ wp_trash_comment($comment_id);
+ }
+ else {
+ check_admin_referer( 'untrash-comment_' . $comment_id );
+ wp_untrash_comment($comment_id);
+ }
+
+ if ('' != wp_get_referer() && false == $noredir && false === strpos(wp_get_referer(), 'comment.php' ))
+ wp_redirect( wp_get_referer() );
+ else if ('' != wp_get_original_referer() && false == $noredir)
+ wp_redirect(wp_get_original_referer());
+ else
+ wp_redirect(admin_url('edit-comments.php'));
+
+ die;
+ break;
+
case 'unapprovecomment' :
$comment_id = absint( $_GET['c'] );
check_admin_referer( 'unapprove-comment_' . $comment_id );
diff --git a/wp-admin/edit-attachment-rows.php b/wp-admin/edit-attachment-rows.php
index af62b1cb8f..ae8aaf26a8 100644
--- a/wp-admin/edit-attachment-rows.php
+++ b/wp-admin/edit-attachment-rows.php
@@ -28,12 +28,18 @@ add_filter('the_title','esc_html');
$alt = '';
$posts_columns = get_column_headers('upload');
$hidden = get_hidden_columns('upload');
-while (have_posts()) : the_post();
+
+while ( have_posts() ) : the_post();
+
+if ( $is_trash && $post->post_status != 'trash' )
+ continue;
+elseif ( !$is_trash && $post->post_status == 'trash' )
+ continue;
+
$alt = ( 'alternate' == $alt ) ? '' : 'alternate';
global $current_user;
$post_owner = ( $current_user->ID == $post->post_author ? 'self' : 'other' );
$att_title = _draft_or_post_title();
-
?>
post_status ); ?>' valign="top">
@@ -60,13 +66,15 @@ foreach ($posts_columns as $column_name => $column_display_name ) {
?>
>ID, array(80, 60), true ) ) {
+ if ( $is_trash ) echo $thumb;
+ else {
?>
-
$column_display_name ) {
case 'media':
?>
- >
+ >
ID))); ?>
ID) )
- $actions['edit'] = '' . __('Edit') . ' ';
- if ( current_user_can('delete_post', $post->ID) )
- $actions['delete'] = "ID) . "' onclick=\"if ( confirm('" . esc_js(sprintf( ('draft' == $post->post_status) ? __("You are about to delete this attachment '%s'\n 'Cancel' to stop, 'OK' to delete.") : __("You are about to delete this attachment '%s'\n 'Cancel' to stop, 'OK' to delete."), $post->post_title )) . "') ) { return true;}return false;\">" . __('Delete') . " ";
- $actions['view'] = '' . __('View') . ' ';
+ if ( $is_trash && current_user_can('delete_post', $post->ID) ) {
+ $actions['untrash'] = "ID) . "'>" . __('Restore') . " ";
+ $actions['delete'] = "ID) . "'>" . __('Delete Permanently') . " ";
+ } else {
+ if ( current_user_can('edit_post', $post->ID) )
+ $actions['edit'] = '' . __('Edit') . ' ';
+ if ( current_user_can('delete_post', $post->ID) )
+ $actions['trash'] = "ID) . "'>" . __('Trash') . " ";
+ $actions['view'] = '' . __('View') . ' ';
+ }
$action_count = count($actions);
$i = 0;
echo '
';
diff --git a/wp-admin/edit-comments.php b/wp-admin/edit-comments.php
index c9bd78d142..de907cf067 100644
--- a/wp-admin/edit-comments.php
+++ b/wp-admin/edit-comments.php
@@ -14,20 +14,20 @@ enqueue_comment_hotkeys_js();
$post_id = isset($_REQUEST['p']) ? (int) $_REQUEST['p'] : 0;
-if ( isset($_REQUEST['doaction']) || isset($_REQUEST['doaction2']) || isset($_REQUEST['destroy_all']) || isset($_REQUEST['destroy_all2']) ) {
+if ( isset($_REQUEST['doaction']) || isset($_REQUEST['doaction2']) || isset($_REQUEST['delete_all']) || isset($_REQUEST['delete_all2']) ) {
check_admin_referer('bulk-comments');
- if ((isset($_REQUEST['destroy_all']) || isset($_REQUEST['destroy_all2'])) && !empty($_REQUEST['pagegen_timestamp'])) {
+ if ((isset($_REQUEST['delete_all']) || isset($_REQUEST['delete_all2'])) && !empty($_REQUEST['pagegen_timestamp'])) {
$comment_status = $wpdb->escape($_REQUEST['comment_status']);
$delete_time = $wpdb->escape($_REQUEST['pagegen_timestamp']);
$comment_ids = $wpdb->get_col( "SELECT comment_ID FROM $wpdb->comments WHERE comment_approved = '$comment_status' AND '$delete_time' > comment_date_gmt" );
- $doaction = 'destroy';
+ $doaction = 'delete';
} elseif (($_REQUEST['action'] != -1 || $_REQUEST['action2'] != -1) && isset($_REQUEST['delete_comments'])) {
$comment_ids = $_REQUEST['delete_comments'];
$doaction = ($_REQUEST['action'] != -1) ? $_REQUEST['action'] : $_REQUEST['action2'];
} else wp_redirect($_SERVER['HTTP_REFERER']);
- $approved = $unapproved = $spammed = $deleted = $destroyed = 0;
+ $approved = $unapproved = $spammed = $trashed = $untrashed = $deleted = 0;
foreach ($comment_ids as $comment_id) { // Check the permissions on each
$_post_id = (int) $wpdb->get_var( $wpdb->prepare( "SELECT comment_post_ID FROM $wpdb->comments WHERE comment_ID = %d", $comment_id) );
@@ -48,18 +48,22 @@ if ( isset($_REQUEST['doaction']) || isset($_REQUEST['doaction2']) || isset($_R
wp_set_comment_status($comment_id, 'spam');
$spammed++;
break;
- case 'delete' :
- wp_set_comment_status($comment_id, 'delete');
- $deleted++;
+ case 'trash' :
+ wp_trash_comment($comment_id);
+ $trashed++;
break;
- case 'destroy' :
- wp_set_comment_status($comment_id, 'delete');
- $destroyed++;
+ case 'untrash' :
+ wp_untrash_comment($comment_id);
+ $untrashed++;
+ break;
+ case 'delete' :
+ wp_delete_comment($comment_id);
+ $deleted++;
break;
}
}
- $redirect_to = 'edit-comments.php?approved=' . $approved . '&unapproved=' . $unapproved . '&spam=' . $spammed . '&deleted=' . $deleted . '&destroyed=' . $destroyed;
+ $redirect_to = 'edit-comments.php?approved=' . $approved . '&unapproved=' . $unapproved . '&spam=' . $spammed . '&trashed=' . $trashed . '&untrashed=' . $untrashed . '&deleted=' . $deleted;
if ( $post_id )
$redirect_to = add_query_arg( 'p', absint( $post_id ), $redirect_to );
if ( isset($_REQUEST['apage']) )
@@ -86,7 +90,7 @@ require_once('admin-header.php');
$mode = ( ! isset($_GET['mode']) || empty($_GET['mode']) ) ? 'detail' : esc_attr($_GET['mode']);
$comment_status = isset($_REQUEST['comment_status']) ? $_REQUEST['comment_status'] : 'all';
-if ( !in_array($comment_status, array('all', 'moderated', 'approved', 'spam', 'deleted')) )
+if ( !in_array($comment_status, array('all', 'moderated', 'approved', 'spam', 'trash')) )
$comment_status = 'all';
$comment_type = !empty($_GET['comment_type']) ? esc_attr($_GET['comment_type']) : '';
@@ -102,13 +106,14 @@ if ( isset($_GET['s']) && $_GET['s'] )
0 || $deleted > 0 || $destroyed > 0 || $spam > 0 ) {
+ if ( $approved > 0 || $deleted > 0 || $trashed > 0 || $untrashed > 0 || $spam > 0 ) {
echo '
';
if ( $approved > 0 ) {
@@ -119,12 +124,16 @@ if ( isset( $_GET['approved'] ) || isset( $_GET['deleted'] ) || isset( $_GET['de
printf( _n( '%s comment marked as spam', '%s comments marked as spam', $spam ), $spam );
echo ' ';
}
- if ( $deleted > 0 ) {
- printf( _n( '%s comment deleted', '%s comments deleted', $deleted ), $deleted );
+ if ( $trashed > 0 ) {
+ printf( _n( '%s comment moved to the trash', '%s comments moved to the trash', $trashed ), $trashed );
echo ' ';
}
- if ( $destroyed > 0 ) {
- printf( _n( '%s comment permanently deleted', '%s comments permanently deleted', $destroyed ), $destroyed );
+ if ( $untrashed > 0 ) {
+ printf( _n( '%s comment removed from the trash', '%s comments removed from the trash', $untrashed ), $untrashed );
+ echo ' ';
+ }
+ if ( $deleted > 0 ) {
+ printf( _n( '%s comment permanently deleted', '%s comments permanently deleted', $deleted ), $deleted );
echo ' ';
}
@@ -145,7 +154,7 @@ $stati = array(
'moderated' => _n_noop('Pending (%s ) ', 'Pending (%s ) '),
'approved' => _n_noop('Approved', 'Approved'), // singular not used
'spam' => _n_noop('Spam (%s ) ', 'Spam (%s ) '),
- 'deleted' => _n_noop('Trash (%s ) ', 'Trash (%s ) ')
+ 'trash' => _n_noop('Trash (%s ) ', 'Trash (%s ) ')
);
$link = 'edit-comments.php';
if ( !empty($comment_type) && 'all' != $comment_type )
@@ -256,13 +265,13 @@ $page_links = paginate_links( array(
-
-
+
+
-
-
+
+
-
+
@@ -289,12 +298,12 @@ $page_links = paginate_links( array(
-
-
-
+
+
+
@@ -352,21 +361,21 @@ if ( $page_links )
-
-
+
+
-
-
+
+
-
+
-
-
-
+
+
+
diff --git a/wp-admin/edit-form-advanced.php b/wp-admin/edit-form-advanced.php
index a246ea543b..82535bbe4c 100644
--- a/wp-admin/edit-form-advanced.php
+++ b/wp-admin/edit-form-advanced.php
@@ -229,7 +229,7 @@ if ( $can_publish ) : // Contributors don't get to choose the date of publish ?>
diff --git a/wp-admin/edit-form-comment.php b/wp-admin/edit-form-comment.php
index a1d9a584e9..93c64037fa 100644
--- a/wp-admin/edit-form-comment.php
+++ b/wp-admin/edit-form-comment.php
@@ -64,7 +64,7 @@ $date = date_i18n( $datef, strtotime( $comment->comment_date ) );
-comment_ID&_wp_original_http_referer=" . urlencode(wp_get_referer()), 'delete-comment_' . $comment->comment_ID) . "' onclick=\"if ( confirm('" . esc_js(__("You are about to delete this comment. \n 'Cancel' to stop, 'OK' to delete.")) . "') ){return true;}return false;\">" . __('Delete') . "\n"; ?>
+comment_ID&_wp_original_http_referer=" . urlencode(wp_get_referer()), 'delete-comment_' . $comment->comment_ID) . "'>" . __('Move to Trash') . "\n"; ?>
diff --git a/wp-admin/edit-page-form.php b/wp-admin/edit-page-form.php
index 2d436be76b..f9c0d6b8c4 100644
--- a/wp-admin/edit-page-form.php
+++ b/wp-admin/edit-page-form.php
@@ -216,7 +216,7 @@ endif; ?>
diff --git a/wp-admin/edit-pages.php b/wp-admin/edit-pages.php
index 1ffdecf639..8c47cfb2dc 100644
--- a/wp-admin/edit-pages.php
+++ b/wp-admin/edit-pages.php
@@ -10,44 +10,70 @@
require_once('admin.php');
// Handle bulk actions
-if ( isset($_GET['action']) && ( -1 != $_GET['action'] || -1 != $_GET['action2'] ) ) {
- $doaction = ( -1 != $_GET['action'] ) ? $_GET['action'] : $_GET['action2'];
+if ( isset($_GET['doaction']) || isset($_GET['doaction2']) || isset($_GET['delete_all']) || isset($_GET['delete_all2']) ) {
+ check_admin_referer('bulk-pages');
+
+ if (isset($_GET['delete_all']) || isset($_GET['delete_all2'])) {
+ $post_status = $wpdb->escape($_GET['post_status']);
+ $post_ids = $wpdb->get_col( "SELECT ID FROM $wpdb->posts WHERE post_type='page' AND post_status = '$post_status'" );
+ $doaction = 'delete';
+ } elseif (($_GET['action'] != -1 || $_GET['action2'] != -1) && isset($_GET['post'])) {
+ $post_ids = $_GET['post'];
+ $doaction = ($_GET['action'] != -1) ? $_GET['action'] : $_GET['action2'];
+ } else wp_redirect($_SERVER['HTTP_REFERER']);
switch ( $doaction ) {
+ case 'trash':
+ $trashed = 0;
+ foreach( (array) $post_ids as $post_id ) {
+ if ( !current_user_can('delete_page', $post_id) )
+ wp_die( __('You are not allowed to move this page to the trash.') );
+
+ if ( !wp_trash_post($post_id) )
+ wp_die( __('Error in moving to trash...') );
+
+ $trashed++;
+ }
+ break;
+ case 'untrash':
+ $untrashed = 0;
+ foreach( (array) $post_ids as $post_id ) {
+ if ( !current_user_can('delete_page', $post_id) )
+ wp_die( __('You are not allowed to remove this page from the trash.') );
+
+ if ( !wp_untrash_post($post_id) )
+ wp_die( __('Error in removing from trash...') );
+
+ $untrashed++;
+ }
+ break;
case 'delete':
- if ( isset($_GET['post']) && ! isset($_GET['bulk_edit']) && (isset($_GET['doaction']) || isset($_GET['doaction2'])) ) {
- check_admin_referer('bulk-pages');
- $deleted = 0;
- foreach( (array) $_GET['post'] as $post_id_del ) {
- $post_del = & get_post($post_id_del);
+ $deleted = 0;
+ foreach( (array) $post_ids as $post_id_del ) {
+ $post_del = & get_post($post_id_del);
- if ( !current_user_can('delete_page', $post_id_del) )
- wp_die( __('You are not allowed to delete this page.') );
+ if ( !current_user_can('delete_page', $post_id_del) )
+ wp_die( __('You are not allowed to delete this page.') );
- if ( $post_del->post_type == 'attachment' ) {
- if ( ! wp_delete_attachment($post_id_del) )
- wp_die( __('Error in deleting...') );
- } else {
- if ( !wp_delete_post($post_id_del) )
- wp_die( __('Error in deleting...') );
- }
- $deleted++;
+ if ( $post_del->post_type == 'attachment' ) {
+ if ( ! wp_delete_attachment($post_id_del) )
+ wp_die( __('Error in deleting...') );
+ } else {
+ if ( !wp_delete_post($post_id_del) )
+ wp_die( __('Error in deleting...') );
}
+ $deleted++;
}
break;
case 'edit':
- if ( isset($_GET['post']) && isset($_GET['bulk_edit']) ) {
- check_admin_referer('bulk-pages');
-
- if ( -1 == $_GET['_status'] ) {
- $_GET['post_status'] = null;
- unset($_GET['_status'], $_GET['post_status']);
- } else {
- $_GET['post_status'] = $_GET['_status'];
- }
-
- $done = bulk_edit_posts($_GET);
+ if ( -1 == $_GET['_status'] ) {
+ $_GET['post_status'] = null;
+ unset($_GET['_status'], $_GET['post_status']);
+ } else {
+ $_GET['post_status'] = $_GET['_status'];
}
+
+ $done = bulk_edit_posts($_GET);
break;
}
@@ -62,6 +88,10 @@ if ( isset($_GET['action']) && ( -1 != $_GET['action'] || -1 != $_GET['action2']
}
if ( isset($deleted) )
$sendback = add_query_arg('deleted', $deleted, $sendback);
+ elseif ( isset($trashed) )
+ $sendback = add_query_arg('trashed', $trashed, $sendback);
+ elseif ( isset($untrashed) )
+ $sendback = add_query_arg('untrashed', $untrashed, $sendback);
wp_redirect($sendback);
exit();
} elseif ( isset($_GET['_wp_http_referer']) && ! empty($_GET['_wp_http_referer']) ) {
@@ -79,7 +109,8 @@ $post_stati = array( // array( adj, noun )
'future' => array(_x('Scheduled', 'page'), __('Scheduled pages'), _nx_noop('Scheduled
(%s) ', 'Scheduled
(%s) ', 'page')),
'pending' => array(_x('Pending Review', 'page'), __('Pending pages'), _nx_noop('Pending Review
(%s) ', 'Pending Review
(%s) ', 'page')),
'draft' => array(_x('Draft', 'page'), _x('Drafts', 'manage posts header'), _nx_noop('Draft
(%s) ', 'Drafts
(%s) ', 'page')),
- 'private' => array(_x('Private', 'page'), __('Private pages'), _nx_noop('Private
(%s) ', 'Private
(%s) ', 'page'))
+ 'private' => array(_x('Private', 'page'), __('Private pages'), _nx_noop('Private
(%s) ', 'Private
(%s) ', 'page')),
+ 'trash' => array(_x('Trash', 'page'), __('Trash pages'), _nx_noop('Trash
(%s) ', 'Trash
(%s) ', 'page'))
);
$post_stati = apply_filters('page_stati', $post_stati);
@@ -111,28 +142,33 @@ if ( isset($_GET['s']) && $_GET['s'] )
printf( '
' . __('Search results for “%s”') . ' ', esc_html( get_search_query() ) ); ?>
-
+
@@ -150,7 +186,7 @@ $avail_post_stati = get_available_post_statuses('page');
if ( empty($locked_post_status) ) :
$status_links = array();
$num_posts = wp_count_posts('page', 'readable');
-$total_posts = array_sum( (array) $num_posts );
+$total_posts = array_sum( (array) $num_posts ) - $num_posts->trash;
$class = empty($_GET['post_status']) ? ' class="current"' : '';
$status_links[] = "
" . sprintf( _nx( 'All (%s) ', 'All (%s) ', $total_posts, 'pages' ), number_format_i18n( $total_posts ) ) . ' ';
foreach ( $post_stati as $status => $label ) {
@@ -212,11 +248,19 @@ if ( $page_links ) : ?>
+
+
+
+
-
+
+
+
+
+
@@ -251,10 +295,18 @@ if ( $page_links )
+
+
+
+
-
+
+
+
+
+
diff --git a/wp-admin/edit.php b/wp-admin/edit.php
index 281fde1804..12cd94e0d5 100644
--- a/wp-admin/edit.php
+++ b/wp-admin/edit.php
@@ -18,44 +18,74 @@ if ( $_redirect = intval( max( @$_GET['p'], @$_GET['attachment_id'], @$_GET['pag
}
// Handle bulk actions
-if ( isset($_GET['action']) && ( -1 != $_GET['action'] || -1 != $_GET['action2'] ) ) {
- $doaction = ( -1 != $_GET['action'] ) ? $_GET['action'] : $_GET['action2'];
-
+if ( isset($_GET['doaction']) || isset($_GET['doaction2']) || isset($_GET['delete_all']) || isset($_GET['delete_all2']) ) {
+ check_admin_referer('bulk-posts');
+
+ if (isset($_GET['delete_all']) || isset($_GET['delete_all2'])) {
+ $post_status = $wpdb->escape($_GET['post_status']);
+ $post_ids = $wpdb->get_col( "SELECT ID FROM $wpdb->posts WHERE post_type='post' AND post_status = '$post_status'" );
+ $doaction = 'delete';
+ } elseif (($_GET['action'] != -1 || $_GET['action2'] != -1) && isset($_GET['post'])) {
+ $post_ids = $_GET['post'];
+ $doaction = ($_GET['action'] != -1) ? $_GET['action'] : $_GET['action2'];
+ } else wp_redirect($_SERVER['HTTP_REFERER']);
+
switch ( $doaction ) {
+ case 'trash':
+ $trashed = 0;
+ foreach( (array) $post_ids as $post_id ) {
+ $post_del = & get_post($post_id);
+
+ if ( !current_user_can('delete_post', $post_id_del) )
+ wp_die( __('You are not allowed to move this post to the trash.') );
+
+ if ( !wp_trash_post($post_id) )
+ wp_die( __('Error in moving to trash...') );
+
+ $trashed++;
+ }
+ break;
+ case 'untrash':
+ $untrashed = 0;
+ foreach( (array) $post_ids as $post_id ) {
+ $post_del = & get_post($post_id);
+
+ if ( !current_user_can('delete_post', $post_id_del) )
+ wp_die( __('You are not allowed to remove this post from the trash.') );
+
+ if ( !wp_untrash_post($post_id) )
+ wp_die( __('Error in removing from trash...') );
+
+ $untrashed++;
+ }
+ break;
case 'delete':
- if ( isset($_GET['post']) && ! isset($_GET['bulk_edit']) && (isset($_GET['doaction']) || isset($_GET['doaction2'])) ) {
- check_admin_referer('bulk-posts');
- $deleted = 0;
- foreach( (array) $_GET['post'] as $post_id_del ) {
- $post_del = & get_post($post_id_del);
+ $deleted = 0;
+ foreach( (array) $post_ids as $post_id_del ) {
+ $post_del = & get_post($post_id_del);
- if ( !current_user_can('delete_post', $post_id_del) )
- wp_die( __('You are not allowed to delete this post.') );
+ if ( !current_user_can('delete_post', $post_id_del) )
+ wp_die( __('You are not allowed to delete this post.') );
- if ( $post_del->post_type == 'attachment' ) {
- if ( ! wp_delete_attachment($post_id_del) )
- wp_die( __('Error in deleting...') );
- } else {
- if ( !wp_delete_post($post_id_del) )
- wp_die( __('Error in deleting...') );
- }
- $deleted++;
+ if ( $post_del->post_type == 'attachment' ) {
+ if ( ! wp_delete_attachment($post_id_del) )
+ wp_die( __('Error in deleting...') );
+ } else {
+ if ( !wp_delete_post($post_id_del) )
+ wp_die( __('Error in deleting...') );
}
+ $deleted++;
}
break;
case 'edit':
- if ( isset($_GET['post']) && isset($_GET['bulk_edit']) ) {
- check_admin_referer('bulk-posts');
-
- if ( -1 == $_GET['_status'] ) {
- $_GET['post_status'] = null;
- unset($_GET['_status'], $_GET['post_status']);
- } else {
- $_GET['post_status'] = $_GET['_status'];
- }
-
- $done = bulk_edit_posts($_GET);
+ if ( -1 == $_GET['_status'] ) {
+ $_GET['post_status'] = null;
+ unset($_GET['_status'], $_GET['post_status']);
+ } else {
+ $_GET['post_status'] = $_GET['_status'];
}
+
+ $done = bulk_edit_posts($_GET);
break;
}
@@ -70,6 +100,10 @@ if ( isset($_GET['action']) && ( -1 != $_GET['action'] || -1 != $_GET['action2']
}
if ( isset($deleted) )
$sendback = add_query_arg('deleted', $deleted, $sendback);
+ elseif ( isset($trashed) )
+ $sendback = add_query_arg('trashed', $trashed, $sendback);
+ elseif ( isset($untrashed) )
+ $sendback = add_query_arg('untrashed', $untrashed, $sendback);
wp_redirect($sendback);
exit();
} elseif ( isset($_GET['_wp_http_referer']) && ! empty($_GET['_wp_http_referer']) ) {
@@ -107,7 +141,7 @@ if ( isset($_GET['posted']) && $_GET['posted'] ) : $_GET['posted'] = (int) $_GET
-
+
@@ -139,7 +183,7 @@ $_SERVER['REQUEST_URI'] = remove_query_arg( array('locked', 'skipped', 'updated'
if ( empty($locked_post_status) ) :
$status_links = array();
$num_posts = wp_count_posts( 'post', 'readable' );
-$total_posts = array_sum( (array) $num_posts );
+$total_posts = array_sum( (array) $num_posts ) - $num_posts->trash;
$class = empty( $_GET['post_status'] ) ? ' class="current"' : '';
$status_links[] = "" . sprintf( _nx( 'All (%s) ', 'All (%s) ', $total_posts, 'posts' ), number_format_i18n( $total_posts ) ) . ' ';
@@ -190,8 +234,13 @@ $page_links = paginate_links( array(
+
+
+
+
-
+
+
@@ -235,7 +284,8 @@ wp_dropdown_categories($dropdown_options);
do_action('restrict_manage_posts');
?>
-
+
+
@@ -270,10 +320,18 @@ if ( $page_links )
+
+
+
+
-
+
+
+
+
+
diff --git a/wp-admin/includes/dashboard.php b/wp-admin/includes/dashboard.php
index b03730072e..64eb376be6 100644
--- a/wp-admin/includes/dashboard.php
+++ b/wp-admin/includes/dashboard.php
@@ -480,7 +480,7 @@ function wp_dashboard_recent_comments() {
$comments = array();
$start = 0;
- while ( count( $comments ) < 5 && $possible = $wpdb->get_results( "SELECT * FROM $wpdb->comments ORDER BY comment_date_gmt DESC LIMIT $start, 50" ) ) {
+ while ( count( $comments ) < 5 && $possible = $wpdb->get_results( "SELECT * FROM $wpdb->comments c LEFT JOIN $wpdb->posts p ON c.comment_post_ID = p.ID WHERE p.post_status != 'trash' ORDER BY c.comment_date_gmt DESC LIMIT $start, 50" ) ) {
foreach ( $possible as $comment ) {
if ( count( $comments ) >= 5 )
diff --git a/wp-admin/includes/media.php b/wp-admin/includes/media.php
index df3f1b3d8a..66b245ec2b 100644
--- a/wp-admin/includes/media.php
+++ b/wp-admin/includes/media.php
@@ -1166,15 +1166,13 @@ function get_media_item( $attachment_id, $args = null ) {
'extra_rows' => array(),
);
- $delete_href = wp_nonce_url("post.php?action=delete-post&post=$attachment_id", 'delete-post_' . $attachment_id);
+ $delete_href = wp_nonce_url("post.php?action=trash&post=$attachment_id", 'delete-post_' . $attachment_id);
if ( $send )
$send = " ";
if ( $delete )
- $delete = "" . __('Delete') . " ";
+ $delete = "" . __('Move to Trash') . " ";
if ( ( $send || $delete ) && !isset($form_fields['buttons']) )
- $form_fields['buttons'] = array('tr' => "\t\t$send $delete
- \n");
+ $form_fields['buttons'] = array('tr' => "\t\t$send $delete \n");
$hidden_fields = array();
diff --git a/wp-admin/includes/post.php b/wp-admin/includes/post.php
index c7acf91563..a20abf62cb 100644
--- a/wp-admin/includes/post.php
+++ b/wp-admin/includes/post.php
@@ -795,6 +795,7 @@ function wp_edit_posts_query( $q = false ) {
'pending' => array(_x('Pending Review', 'post'), __('Pending posts'), _n_noop('Pending Review (%s) ', 'Pending Review (%s) ')),
'draft' => array(_x('Draft', 'post'), _x('Drafts', 'manage posts header'), _n_noop('Draft (%s) ', 'Drafts (%s) ')),
'private' => array(_x('Private', 'post'), __('Private posts'), _n_noop('Private (%s) ', 'Private (%s) ')),
+ 'trash' => array(_x('Trash', 'post'), __('Trash posts'), _n_noop('Trash (%s) ', 'Trash (%s) ')),
);
$post_stati = apply_filters('post_stati', $post_stati);
@@ -858,7 +859,7 @@ function wp_edit_attachments_query( $q = false ) {
$q['m'] = isset( $q['m'] ) ? (int) $q['m'] : 0;
$q['cat'] = isset( $q['cat'] ) ? (int) $q['cat'] : 0;
$q['post_type'] = 'attachment';
- $q['post_status'] = 'any';
+ $q['post_status'] = isset( $q['status'] ) && 'trash' == $q['status'] ? 'trash' : 'any';
$media_per_page = get_user_option('upload_per_page');
if ( empty($media_per_page) )
$media_per_page = 20;
diff --git a/wp-admin/includes/template.php b/wp-admin/includes/template.php
index 2b0fc0a0be..f3e067ca92 100644
--- a/wp-admin/includes/template.php
+++ b/wp-admin/includes/template.php
@@ -1433,24 +1433,29 @@ function _post_row($a_post, $pending_comments, $mode) {
case 'title':
$attributes = 'class="post-title column-title"' . $style;
?>
- >ID ) ) { ?>
+ >ID) && $post->post_status != 'trash' ) { ?>
ID) ) {
- $actions['edit'] = '' . __('Edit') . ' ';
- $actions['inline hide-if-no-js'] = '' . __('Quick Edit') . ' ';
- }
- if ( current_user_can('delete_post', $post->ID) ) {
- $actions['delete'] = "ID) . "' onclick=\"if ( confirm('" . esc_js(sprintf( ('draft' == $post->post_status) ? __("You are about to delete this draft '%s'\n 'Cancel' to stop, 'OK' to delete.") : __("You are about to delete this post '%s'\n 'Cancel' to stop, 'OK' to delete."), $post->post_title )) . "') ) { return true;}return false;\">" . __('Delete') . " ";
- }
- if ( in_array($post->post_status, array('pending', 'draft')) ) {
- if ( current_user_can('edit_post', $post->ID) )
- $actions['view'] = '' . __('Preview') . ' ';
+ if ( 'trash' == $post->post_status && current_user_can('delete_post', $post->ID) ) {
+ $actions['untrash'] = "ID) . "'>" . __('Restore') . " ";
+ $actions['delete'] = "ID) . "'>" . __('Delete Permanently') . " ";
} else {
- $actions['view'] = '' . __('View') . ' ';
+ if ( current_user_can('edit_post', $post->ID) ) {
+ $actions['edit'] = '' . __('Edit') . ' ';
+ $actions['inline hide-if-no-js'] = '' . __('Quick Edit') . ' ';
+ }
+ if ( current_user_can('delete_post', $post->ID) ) {
+ $actions['trash'] = "ID) . "'>" . __('Trash') . " ";
+ }
+ if ( in_array($post->post_status, array('pending', 'draft')) ) {
+ if ( current_user_can('edit_post', $post->ID) )
+ $actions['view'] = '' . __('Preview') . ' ';
+ } else {
+ $actions['view'] = '' . __('View') . ' ';
+ }
}
$actions = apply_filters('post_row_actions', $actions, $post);
$action_count = count($actions);
@@ -1651,21 +1656,26 @@ foreach ($posts_columns as $column_name=>$column_display_name) {
$attributes = 'class="post-title page-title column-title"' . $style;
$edit_link = get_edit_post_link( $page->ID );
?>
- >ID ) ) { ?>
+ >ID) && $post->post_status != 'trash' ) { ?>
ID) ) {
- $actions['edit'] = '' . __('Edit') . ' ';
- $actions['inline'] = '' . __('Quick Edit') . ' ';
- }
- if ( current_user_can('delete_page', $page->ID) ) {
- $actions['delete'] = "ID) . "' onclick=\"if ( confirm('" . esc_js(sprintf( ('draft' == $page->post_status) ? __("You are about to delete this draft '%s'\n 'Cancel' to stop, 'OK' to delete.") : __("You are about to delete this page '%s'\n 'Cancel' to stop, 'OK' to delete."), $page->post_title )) . "') ) { return true;}return false;\">" . __('Delete') . " ";
- }
- if ( in_array($post->post_status, array('pending', 'draft')) ) {
- if ( current_user_can('edit_page', $page->ID) )
- $actions['view'] = '' . __('Preview') . ' ';
+ if ($post->post_status == 'trash' && current_user_can('delete_page', $page->ID)) {
+ $actions['untrash'] = "ID) . "'>" . __('Restore') . " ";
+ $actions['delete'] = "ID) . "'>" . __('Delete Permanently') . " ";
} else {
- $actions['view'] = '' . __('View') . ' ';
+ if ( current_user_can('edit_page', $page->ID) ) {
+ $actions['edit'] = '' . __('Edit') . ' ';
+ $actions['inline'] = '' . __('Quick Edit') . ' ';
+ }
+ if ( current_user_can('delete_page', $page->ID) ) {
+ $actions['trash'] = "ID) . "'>" . __('Trash') . " ";
+ }
+ if ( in_array($post->post_status, array('pending', 'draft')) ) {
+ if ( current_user_can('edit_page', $page->ID) )
+ $actions['view'] = '' . __('Preview') . ' ';
+ } else {
+ $actions['view'] = '' . __('View') . ' ';
+ }
}
$actions = apply_filters('page_row_actions', $actions, $page);
$action_count = count($actions);
@@ -1981,7 +1991,7 @@ function user_row( $user_object, $style = '', $role = '' ) {
*
* @since unknown
*
- * @param string $status Comment status (approved, spam, deleted, etc)
+ * @param string $status Comment status (approved, spam, trash, etc)
* @param string $s Term to search for
* @param int $start Offset to start at for pagination
* @param int $num Maximum number of comments to return
@@ -1999,62 +2009,63 @@ function _wp_get_comment_list( $status = '', $s = false, $start, $num, $post = 0
$index = '';
if ( 'moderated' == $status ) {
- $approved = "comment_approved = '0'";
+ $approved = "c.comment_approved = '0'";
$total = $count->moderated;
} elseif ( 'approved' == $status ) {
- $approved = "comment_approved = '1'";
+ $approved = "c.comment_approved = '1'";
$total = $count->approved;
} elseif ( 'spam' == $status ) {
- $approved = "comment_approved = 'spam'";
+ $approved = "c.comment_approved = 'spam'";
$total = $count->spam;
- } elseif ( 'deleted' == $status ) {
- $approved = "comment_approved = 'deleted'";
- $total = $count->deleted;
+ } elseif ( 'trash' == $status ) {
+ $approved = "c.comment_approved = 'trash'";
+ $total = $count->trash;
} else {
- $approved = "( comment_approved = '0' OR comment_approved = '1' )";
+ $approved = "( c.comment_approved = '0' OR c.comment_approved = '1' )";
$total = $count->moderated + $count->approved;
- $index = 'USE INDEX (comment_date_gmt)';
+ $index = 'USE INDEX (c.comment_date_gmt)';
}
if ( $post ) {
$total = '';
- $post = " AND comment_post_ID = '$post'";
- $orderby = "ORDER BY comment_date_gmt ASC LIMIT $start, $num";
+ $post = " AND c.comment_post_ID = '$post'";
+ $orderby = "ORDER BY c.comment_date_gmt ASC LIMIT $start, $num";
} else {
$post = '';
- $orderby = "ORDER BY comment_date_gmt DESC LIMIT $start, $num";
+ $orderby = "ORDER BY c.comment_date_gmt DESC LIMIT $start, $num";
}
if ( 'comment' == $type )
- $typesql = "AND comment_type = ''";
+ $typesql = "AND c.comment_type = ''";
elseif ( 'pings' == $type )
- $typesql = "AND ( comment_type = 'pingback' OR comment_type = 'trackback' )";
+ $typesql = "AND ( c.comment_type = 'pingback' OR c.comment_type = 'trackback' )";
elseif ( !empty($type) )
- $typesql = $wpdb->prepare("AND comment_type = %s", $type);
+ $typesql = $wpdb->prepare("AND c.comment_type = %s", $type);
else
$typesql = '';
if ( !empty($type) )
$total = '';
+ $query = "FROM $wpdb->comments c LEFT JOIN $wpdb->posts p ON c.comment_post_ID = p.ID WHERE p.post_status != 'trash' ";
if ( $s ) {
$total = '';
$s = $wpdb->escape($s);
- $query = "FROM $wpdb->comments WHERE
- (comment_author LIKE '%$s%' OR
- comment_author_email LIKE '%$s%' OR
- comment_author_url LIKE ('%$s%') OR
- comment_author_IP LIKE ('%$s%') OR
- comment_content LIKE ('%$s%') ) AND
+ $query .= "AND
+ (c.comment_author LIKE '%$s%' OR
+ c.comment_author_email LIKE '%$s%' OR
+ c.comment_author_url LIKE ('%$s%') OR
+ c.comment_author_IP LIKE ('%$s%') OR
+ c.comment_content LIKE ('%$s%') ) AND
$approved
$typesql";
} else {
- $query = "FROM $wpdb->comments $index WHERE $approved $post $typesql";
+ $query .= "AND $approved $post $typesql";
}
-
+
$comments = $wpdb->get_results("SELECT * $query $orderby");
if ( '' === $total )
- $total = $wpdb->get_var("SELECT COUNT(comment_ID) $query");
+ $total = $wpdb->get_var("SELECT COUNT(c.comment_ID) $query");
update_comment_cache($comments);
@@ -2095,6 +2106,8 @@ function _wp_comment_row( $comment_id, $mode, $comment_status, $checkbox = true,
$approve_url = esc_url( wp_nonce_url( "comment.php?action=approvecomment&p=$post->ID&c=$comment->comment_ID", "approve-comment_$comment->comment_ID" ) );
$unapprove_url = esc_url( wp_nonce_url( "comment.php?action=unapprovecomment&p=$post->ID&c=$comment->comment_ID", "unapprove-comment_$comment->comment_ID" ) );
$spam_url = esc_url( wp_nonce_url( "comment.php?action=deletecomment&dt=spam&p=$post->ID&c=$comment->comment_ID", "delete-comment_$comment->comment_ID" ) );
+ $trash_url = esc_url( wp_nonce_url( "comment.php?action=trashcomment&p=$post->ID&c=$comment->comment_ID", "trash-comment_$comment->comment_ID" ) );
+ $untrash_url = esc_url( wp_nonce_url( "comment.php?action=untrashcomment&p=$post->ID&c=$comment->comment_ID", "untrash-comment_$comment->comment_ID" ) );
echo "