Index: wp-includes/post.php
===================================================================
--- wp-includes/post.php (revision 11743)
+++ wp-includes/post.php (working copy)
@@ -998,7 +998,7 @@
$count = $wpdb->get_results( $wpdb->prepare( $query, $type ), ARRAY_A );
- $stats = array( 'publish' => 0, 'private' => 0, 'draft' => 0, 'pending' => 0, 'future' => 0 );
+ $stats = array( 'publish' => 0, 'private' => 0, 'draft' => 0, 'pending' => 0, 'future' => 0, 'deleted' => 0 );
foreach( (array) $count as $row_num => $row ) {
$stats[$row['post_status']] = $row['num_posts'];
}
@@ -1027,12 +1027,13 @@
global $wpdb;
$and = wp_post_mime_type_where( $mime_type );
- $count = $wpdb->get_results( "SELECT post_mime_type, COUNT( * ) AS num_posts FROM $wpdb->posts WHERE post_type = 'attachment' $and GROUP BY post_mime_type", ARRAY_A );
+ $count = $wpdb->get_results( "SELECT post_mime_type, COUNT( * ) AS num_posts FROM $wpdb->posts WHERE post_type = 'attachment' AND post_status != 'deleted' $and GROUP BY post_mime_type", ARRAY_A );
$stats = array( );
foreach( (array) $count as $row ) {
$stats[$row['post_mime_type']] = $row['num_posts'];
}
+ $stats['trash'] = $wpdb->get_var( "SELECT COUNT( * ) FROM $wpdb->posts WHERE post_type = 'attachment' AND post_status = 'deleted' $and");
return (object) $stats;
}
@@ -1140,10 +1141,17 @@
if ( !$post = $wpdb->get_row($wpdb->prepare("SELECT * FROM $wpdb->posts WHERE ID = %d", $postid)) )
return $post;
- if ( 'attachment' == $post->post_type )
+ if (($post->post_type == 'post' || $post->post_type == 'page') && get_post_status($postid) != 'deleted') {
+ wp_update_post(array('ID'=>$postid, 'post_status'=>'deleted'));
+ wp_schedule_post_delete($postid);
+ return true;
+ }
+ else if ($post->post_type == 'attachment')
return wp_delete_attachment($postid);
do_action('delete_post', $postid);
+
+ wp_unschedule_post_delete($postid);
/** @todo delete for pluggable post taxonomies too */
wp_delete_object_term_relationships($postid, array('category', 'post_tag'));
@@ -1205,6 +1213,69 @@
}
/**
+ * Removes a post or page from the Trash
+ *
+ * @since 2.9.0
+ * @uses do_action() on 'undelete_post' before deletion
+ * @uses do_action() on 'undeleted_post' after deletion
+ *
+ * @param int $postid Post ID.
+ * @return mixed False on failure
+ */
+function wp_undelete_post($postid = 0) {
+ global $wpdb, $wp_rewrite;
+
+ if ( !$post = $wpdb->get_row($wpdb->prepare("SELECT * FROM $wpdb->posts WHERE ID = %d", $postid)) )
+ return $post;
+
+ do_action('undelete_post', $postid);
+
+ wp_update_post(array('ID'=>$postid, 'post_status'=>'draft'));
+
+ wp_unschedule_post_delete($postid);
+
+ do_action('undeleted_post', $postid);
+
+ return $post;
+}
+
+/**
+ * Schedules a post for permanent deletion.
+ *
+ * @since 2.9.0
+ *
+ * @param int $post_id Post ID.
+ * @return void
+ */
+function wp_schedule_post_delete($post_id) {
+ $to_delete = get_option('wp_scheduled_delete');
+ if (!is_array($to_delete))
+ $to_delete = array();
+
+ $to_delete['posts'][$post_id] = time();
+
+ update_option('wp_scheduled_delete', $to_delete);
+}
+
+/**
+ * Unschedules a post for permanent deletion.
+ *
+ * @since 2.9.0
+ *
+ * @param int $post_id Post ID.
+ * @return void
+ */
+function wp_unschedule_post_delete($post_id) {
+ $to_delete = get_option('wp_scheduled_delete');
+ if (!is_array($to_delete))
+ return;
+
+ unset($to_delete['posts'][$post_id]);
+
+ update_option('wp_scheduled_delete', $to_delete);
+}
+
+/**
* Retrieve the list of categories for a post.
*
* Compatibility layer for themes and plugins. Also an easy layer of abstraction
@@ -2586,6 +2657,13 @@
if ( 'attachment' != $post->post_type )
return false;
+ elseif (get_post_status($postid) != 'deleted') {
+ $post = wp_get_single_post($postid, ARRAY_A);
+ $post['post_status'] = 'deleted';
+ wp_insert_post($post);
+ wp_schedule_post_delete($postid);
+ return true;
+ }
$meta = wp_get_attachment_metadata( $postid );
$file = get_attached_file( $postid );
@@ -2632,6 +2710,35 @@
}
/**
+ * Removes an attachment from the Trash
+ *
+ * @since 2.9.0
+ * @uses do_action() on 'undelete_attachment' before deletion
+ * @uses do_action() on 'undeleted_attachment' after deletion
+ *
+ * @param int $postid Post ID.
+ * @return mixed False on failure
+ */
+function wp_undelete_attachment($postid = 0) {
+ global $wpdb, $wp_rewrite;
+
+ if ( !$post = $wpdb->get_row($wpdb->prepare("SELECT * FROM $wpdb->posts WHERE ID = %d", $postid)) )
+ return $post;
+
+ do_action('undelete_attachment', $postid);
+
+ $post = wp_get_single_post($postid, ARRAY_A);
+ $post['post_status'] = 'inherit';
+ wp_insert_post($post);
+
+ wp_unschedule_post_delete($postid);
+
+ do_action('undeleted_attachment', $postid);
+
+ return $post;
+}
+
+/**
* Retrieve attachment meta field for attachment ID.
*
* @since 2.1.0
Index: wp-includes/comment.php
===================================================================
--- wp-includes/comment.php (revision 11743)
+++ wp-includes/comment.php (working copy)
@@ -694,11 +694,12 @@
if ( false !== $count )
return $count;
- $where = '';
+ $where = 'WHERE ';
if( $post_id > 0 )
- $where = $wpdb->prepare( "WHERE comment_post_ID = %d", $post_id );
+ $where .= $wpdb->prepare( "c.comment_post_ID = %d AND ", $post_id );
+ $where .= "p.post_status <> 'deleted'";
- $count = $wpdb->get_results( "SELECT comment_approved, COUNT( * ) AS num_comments FROM {$wpdb->comments} {$where} GROUP BY comment_approved", ARRAY_A );
+ $count = $wpdb->get_results( "SELECT comment_approved, COUNT( * ) AS num_comments FROM {$wpdb->comments} c LEFT JOIN {$wpdb->posts} p ON c.comment_post_ID = p.ID {$where} GROUP BY comment_approved", ARRAY_A );
$total = 0;
$approved = array('0' => 'moderated', '1' => 'approved', 'spam' => 'spam', 'deleted' => 'deleted');
@@ -1084,7 +1085,7 @@
}
/**
- * Schedules a comment for destruction in 30 days.
+ * Schedules a comment for permanent deletion.
*
* @since 2.9.0
*
@@ -1102,7 +1103,7 @@
}
/**
- * Unschedules a comment for destruction.
+ * Unschedules a comment for permanent deletion.
*
* @since 2.9.0
*
Index: wp-includes/functions.php
===================================================================
--- wp-includes/functions.php (revision 11743)
+++ wp-includes/functions.php (working copy)
@@ -3339,10 +3339,8 @@
}
/**
- * Permanently deletes comments that have been scheduled for deleting.
- * Will do the same for posts, pages, etc in the future.
+ * Permanently deletes posts, pages, and comments that have been scheduled for deleting.
*
- * @access private
* @since 2.9.0
*
* @return void
@@ -3355,14 +3353,20 @@
if ( !isset($to_delete['comments']) || !is_array($to_delete['comments']) )
$to_delete['comments'] = array();
- $delete_delay = defined('EMPTY_TRASH_TIMEOUT') ? (int) EMPTY_TRASH_TIMEOUT : (60*60*24*30);
- $deletetimestamp = time() - $delete_delay;
+ $delete_days = defined('EMPTY_TRASH_DAYS') ? (int) EMPTY_TRASH_DAYS : 30;
+ $deletetimestamp = time() - (60*60*24*$delete_days);
foreach ($to_delete['comments'] as $comment_id => $timestamp) {
if ($timestamp < $deletetimestamp) {
wp_delete_comment($comment_id);
unset($to_delete['comments'][$comment_id]);
}
}
+ foreach ($to_delete['posts'] as $post_id => $timestamp) {
+ if ($timestamp < $deletetimestamp) {
+ wp_delete_post($post_id);
+ unset($to_delete['posts'][$post_id]);
+ }
+ }
update_option('wp_scheduled_delete', $to_delete);
}
Index: wp-includes/query.php
===================================================================
--- wp-includes/query.php (revision 11743)
+++ wp-includes/query.php (working copy)
@@ -2099,6 +2099,8 @@
$p_status[] = "$wpdb->posts.post_status = 'private'";
if ( in_array( 'publish', $q_status ) )
$r_status[] = "$wpdb->posts.post_status = 'publish'";
+ if ( in_array( 'deleted', $q_status ) )
+ $r_status[] = "$wpdb->posts.post_status = 'deleted'";
if ( empty($q['perm'] ) || 'readable' != $q['perm'] ) {
$r_status = array_merge($r_status, $p_status);
Index: wp-admin/edit-comments.php
===================================================================
--- wp-admin/edit-comments.php (revision 11743)
+++ wp-admin/edit-comments.php (working copy)
@@ -292,9 +292,9 @@
if ( ( 'spam' == $comment_status || 'deleted' == $comment_status) && current_user_can ('moderate_comments') ) {
wp_nonce_field('bulk-destroy', '_destroy_nonce');
if ( 'spam' == $comment_status ) { ?>
-
+
-
+
@@ -364,7 +364,7 @@
-
+
Index: wp-admin/wp-admin.css
===================================================================
--- wp-admin/wp-admin.css (revision 11743)
+++ wp-admin/wp-admin.css (working copy)
@@ -409,7 +409,8 @@
}
#doaction,
-#doaction2 {
+#doaction2,
+#post-query-submit {
margin-right: 8px;
}
Index: wp-admin/includes/post.php
===================================================================
--- wp-admin/includes/post.php (revision 11743)
+++ wp-admin/includes/post.php (working copy)
@@ -795,6 +795,7 @@
'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)')),
+ 'deleted' => array(_x('Trash', 'post'), __('Trash posts'), _n_noop('Trash (%s)', 'Trash (%s)')),
);
$post_stati = apply_filters('post_stati', $post_stati);
Index: wp-admin/includes/dashboard.php
===================================================================
--- wp-admin/includes/dashboard.php (revision 11743)
+++ wp-admin/includes/dashboard.php (working copy)
@@ -480,7 +480,7 @@
$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 != 'deleted' ORDER BY c.comment_date_gmt DESC LIMIT $start, 50" ) ) {
foreach ( $possible as $comment ) {
if ( count( $comments ) >= 5 )
Index: wp-admin/includes/template.php
===================================================================
--- wp-admin/includes/template.php (revision 11743)
+++ wp-admin/includes/template.php (working copy)
@@ -1433,24 +1433,29 @@
case 'title':
$attributes = 'class="post-title column-title"' . $style;
?>
-
>ID ) ) { ?>
+ | >ID) && $post->post_status != 'deleted' ) { ?>
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 ( 'deleted' == $post->post_status ) {
+ $actions['undelete'] = "ID) . "'>" . __('Return to Drafts') . "";
+ $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['delete'] = "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,28 @@
$attributes = 'class="post-title page-title column-title"' . $style;
$edit_link = get_edit_post_link( $page->ID );
?>
- | >ID ) ) { ?>
+ | >ID) && $post->post_status != 'deleted' ) { ?>
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 == 'deleted') {
+ if ( current_user_can('delete_page', $page->ID) ) {
+ $actions['undelete'] = "ID) . "'>" . __('Return to Drafts') . "";
+ $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['delete'] = "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);
@@ -1999,64 +2011,65 @@
$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'";
+ $approved = "c.comment_approved = 'deleted'";
$total = $count->deleted;
} 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 ( 'pingback' == $type )
- $typesql = "AND comment_type = 'pingback'";
+ $typesql = "AND c.comment_type = 'pingback'";
elseif ( 'trackback' == $type )
- $typesql = "AND comment_type = 'trackback'";
+ $typesql = "AND c.comment_type = 'trackback'";
elseif ( 'pings' == $type )
- $typesql = "AND ( comment_type = 'pingback' OR comment_type = 'trackback' )";
+ $typesql = "AND ( c.comment_type = 'pingback' OR c.comment_type = 'trackback' )";
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 != 'deleted' ";
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);
@@ -2157,7 +2170,7 @@
$actions['delete'] = "';
} else {
$actions['spam'] = "';
- $actions['delete'] = "';
+ $actions['delete'] = "';
}
$actions['edit'] = "". __('Edit') . '';
Index: wp-admin/includes/media.php
===================================================================
--- wp-admin/includes/media.php (revision 11743)
+++ wp-admin/includes/media.php (working copy)
@@ -1170,11 +1170,9 @@
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();
Index: wp-admin/post.php
===================================================================
--- wp-admin/post.php (revision 11743)
+++ wp-admin/post.php (working copy)
@@ -116,6 +116,7 @@
$post = get_post($post_ID);
if ( empty($post->ID) ) wp_die( __('You attempted to edit a post that doesn’t exist. Perhaps it was deleted?') );
+ if ( $post->post_status == 'deleted' ) wp_die( __('You can’t edit this post because it is in the Trash. Please move it out of the Trash and try again.') );
if ( 'post' != $post->post_type ) {
wp_redirect( get_edit_post_link( $post->ID, 'url' ) );
@@ -206,6 +207,28 @@
exit();
break;
+case 'undelete':
+ $post_id = (isset($_GET['post'])) ? intval($_GET['post']) : intval($_POST['post_ID']);
+ check_admin_referer('undelete-post_' . $post_id);
+
+ $post = & get_post($post_id);
+
+ if ( $post->post_type == 'attachment' ) {
+ if ( ! wp_undelete_attachment($post_id) )
+ wp_die( __('Error in undeleting...') );
+ } else {
+ if ( !wp_undelete_post($post_id) )
+ wp_die( __('Error in undeleting...') );
+ }
+
+ $sendback = wp_get_referer();
+ if (strpos($sendback, 'post.php') !== false) $sendback = admin_url('edit.php?undeleted=1');
+ elseif (strpos($sendback, 'attachments.php') !== false) $sendback = admin_url('attachments.php');
+ else $sendback = add_query_arg('undeleted', 1, $sendback);
+ wp_redirect($sendback);
+ exit();
+ break;
+
case 'preview':
check_admin_referer( 'autosave', 'autosavenonce' );
Index: wp-admin/js/common.dev.js
===================================================================
--- wp-admin/js/common.dev.js (revision 11743)
+++ wp-admin/js/common.dev.js (working copy)
@@ -154,16 +154,6 @@
$('div.wrap h2 ~ div.updated, div.wrap h2 ~ div.error').addClass('below-h2');
$('div.updated, div.error').not('.below-h2').insertAfter('div.wrap h2:first');
- // show warnings
- $('#doaction, #doaction2').click(function(){
- if ( $('select[name="action"]').val() == 'destroy' || $('select[name="action2"]').val() == 'destroy' ) {
- return showNotice.warn();
- }
- });
- $('#destroy_all, #destroy_all2').click(function(){
- return showNotice.warn();
- });
-
// screen settings tab
$('#show-settings-link').click(function () {
if ( ! $('#screen-options-wrap').hasClass('screen-options-open') ) {
Index: wp-admin/js/edit-comments.dev.js
===================================================================
--- wp-admin/js/edit-comments.dev.js (revision 11743)
+++ wp-admin/js/edit-comments.dev.js (working copy)
@@ -39,7 +39,7 @@
settings.data._url = document.location.href;
if ( 'undefined' != showNotice && settings.data.action && settings.data.action == 'delete-comment' && settings.data.deleted)
- return showNotice.warn() ? settings : false;
+ return settings;
return settings;
};
Index: wp-admin/edit-page-form.php
===================================================================
--- wp-admin/edit-page-form.php (revision 11743)
+++ wp-admin/edit-page-form.php (working copy)
@@ -216,7 +216,7 @@
Index: wp-admin/edit-attachment-rows.php
===================================================================
--- wp-admin/edit-attachment-rows.php (revision 11743)
+++ wp-admin/edit-attachment-rows.php (working copy)
@@ -29,6 +29,8 @@
$posts_columns = get_column_headers('upload');
$hidden = get_hidden_columns('upload');
while (have_posts()) : the_post();
+if ($is_trash && $post->post_status != 'deleted') continue;
+elseif (!$is_trash && $post->post_status == 'deleted') continue;
$alt = ( 'alternate' == $alt ) ? '' : 'alternate';
global $current_user;
$post_owner = ( $current_user->ID == $post->post_author ? 'self' : 'other' );
@@ -60,13 +62,15 @@
?>
>ID, array(80, 60), true ) ) {
+ if ($is_trash) echo $thumb;
+ else {
?>
-
|
- >
+ | >
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['undelete'] = "ID) . "'>" . __('Remove from Trash') . "";
+ $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['delete'] = "ID) . "'>" . __('Trash') . "";
+ $actions['view'] = '' . __('View') . '';
+ }
$action_count = count($actions);
$i = 0;
echo ' ';
Index: wp-admin/media.php
===================================================================
--- wp-admin/media.php (revision 11743)
+++ wp-admin/media.php (working copy)
@@ -58,6 +58,9 @@
$att = get_post($att_id);
+ if ( empty($att->ID) ) wp_die( __('You attempted to edit an attachment that doesn’t exist. Perhaps it was deleted?') );
+ if ( $att->post_status == 'deleted' ) wp_die( __('You can’t edit this attachment because it is in the Trash. Please move it out of the Trash and try again.') );
+
add_filter('attachment_fields_to_edit', 'media_single_attachment_fields_to_edit', 10, 2);
wp_enqueue_script( 'wp-ajax-response' );
Index: wp-admin/upload.php
===================================================================
--- wp-admin/upload.php (revision 11743)
+++ wp-admin/upload.php (working copy)
@@ -67,33 +67,52 @@
exit;
}
-} elseif ( isset($_GET['action']) && isset($_GET['media']) && ( -1 != $_GET['action'] || -1 != $_GET['action2'] ) ) {
+} elseif ( isset($_GET['doaction']) || isset($_GET['doaction2']) || isset($_GET['delete_all']) || isset($_GET['delete_all2']) ) {
check_admin_referer('bulk-media');
- $doaction = ( -1 != $_GET['action'] ) ? $_GET['action'] : $_GET['action2'];
+
+ if (isset($_GET['delete_all']) || isset($_GET['delete_all2'])) {
+ $post_ids = $wpdb->get_col( "SELECT ID FROM $wpdb->posts WHERE post_type='attachment' AND post_status = 'deleted'" );
+ $doaction = 'delete';
+ } elseif (($_GET['action'] != -1 || $_GET['action2'] != -1) && isset($_GET['media'])) {
+ $post_ids = $_GET['media'];
+ $doaction = ($_GET['action'] != -1) ? $_GET['action'] : $_GET['action2'];
+ } else wp_redirect($_SERVER['HTTP_REFERER']);
+
+ $location = 'upload.php';
+ if ( $referer = wp_get_referer() ) {
+ if ( false !== strpos($referer, 'upload.php') )
+ $location = $referer;
+ }
- if ( 'delete' == $doaction ) {
- foreach( (array) $_GET['media'] as $post_id_del ) {
- $post_del = & get_post($post_id_del);
+ switch ( $doaction ) {
+ case 'delete':
+ 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 ( $post_del->post_type == 'attachment' )
+ if ( !wp_delete_attachment($post_id_del) )
+ wp_die( __('Error in deleting...') );
+ }
+ $location = add_query_arg('message', 2, $location);
+ break;
+ case 'undelete':
+ 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 delete this post.') );
+ if ( $post_del->post_type == 'attachment' )
+ if ( !wp_undelete_attachment($post_id) )
+ wp_die( __('Error in undeleting...') );
+ }
+ $location = add_query_arg('message', 4, $location);
+ break;
+ }
- if ( $post_del->post_type == 'attachment' )
- if ( ! wp_delete_attachment($post_id_del) )
- wp_die( __('Error in deleting...') );
- }
-
- $location = 'upload.php';
- if ( $referer = wp_get_referer() ) {
- if ( false !== strpos($referer, 'upload.php') )
- $location = $referer;
- }
-
- $location = add_query_arg('message', 2, $location);
- $location = remove_query_arg('posted', $location);
- wp_redirect($location);
- exit;
- }
+ $location = remove_query_arg('posted', $location);
+ wp_redirect($location);
+ exit;
} elseif ( isset($_GET['_wp_http_referer']) && ! empty($_GET['_wp_http_referer']) ) {
wp_redirect( remove_query_arg( array('_wp_http_referer', '_wpnonce'), stripslashes($_SERVER['REQUEST_URI']) ) );
exit;
@@ -135,6 +154,8 @@
list($post_mime_types, $avail_post_mime_types) = wp_edit_attachments_query();
}
+$is_trash = (isset($_GET['status']) && $_GET['status'] == 'deleted');
+
wp_enqueue_script('media');
require_once('admin-header.php'); ?>
@@ -153,6 +174,7 @@
$messages[1] = __('Media attachment updated.');
$messages[2] = __('Media deleted.');
$messages[3] = __('Error saving media attachment.');
+$messages[4] = __('Media removed from Trash.');
if ( isset($_GET['message']) && (int) $_GET['message'] ) {
$message = $messages[$_GET['message']];
@@ -180,13 +202,13 @@
$reals )
foreach ( $reals as $real )
$num_posts[$type] = ( isset( $num_posts[$type] ) ) ? $num_posts[$type] + $_num_posts[$real] : $_num_posts[$real];
-$class = empty($_GET['post_mime_type']) && ! isset($_GET['detached']) ? ' class="current"' : '';
+$class = (empty($_GET['post_mime_type']) && !isset($_GET['detached']) && !isset($_GET['status'])) ? ' class="current"' : '';
$type_links[] = " " . sprintf( _nx( 'All (%s)', 'All (%s)', $_total_posts, 'uploaded files' ), number_format_i18n( $_total_posts ) ) . '';
foreach ( $post_mime_types as $mime_type => $label ) {
$class = '';
@@ -199,8 +221,8 @@
$type_links[] = "" . sprintf( _n( $label[2][0], $label[2][1], $num_posts[$mime_type] ), number_format_i18n( $num_posts[$mime_type] )) . '';
}
-$class = isset($_GET['detached']) ? ' class="current"' : '';
-$type_links[] = '' . __('Unattached') . '';
+$type_links[] = '' . __('Unattached') . '';
+$type_links[] = '' . sprintf( _nx( 'Trash (%s)', 'Trash (%s)', $_num_posts['trash'], 'uploaded files' ), number_format_i18n( $_num_posts['trash'] ) ) . '';
echo implode( " |\n", $type_links) . '';
unset($type_links);
@@ -242,8 +264,12 @@
@@ -251,7 +277,7 @@
posts WHERE post_type = 'attachment' ORDER BY post_date DESC";
$arc_result = $wpdb->get_results( $arc_query );
@@ -286,6 +312,8 @@
+
+
@@ -341,7 +369,7 @@
if ( current_user_can('edit_post', $post->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['delete'] = " ID) . "'>" . __('Trash') . "";
$actions['view'] = ' ' . __('View') . '';
if ( current_user_can('edit_post', $post->ID) )
$actions['attach'] = ' '.__('Attach').'';
@@ -398,12 +426,20 @@
+
+
+
+
Index: wp-admin/edit-form-comment.php
===================================================================
--- wp-admin/edit-form-comment.php (revision 11743)
+++ wp-admin/edit-form-comment.php (working copy)
@@ -64,7 +64,7 @@
-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"; ?>
Index: wp-admin/edit-form-advanced.php
===================================================================
--- wp-admin/edit-form-advanced.php (revision 11743)
+++ wp-admin/edit-form-advanced.php (working copy)
@@ -229,7 +229,7 @@
Index: wp-admin/edit.php
===================================================================
--- wp-admin/edit.php (revision 11743)
+++ wp-admin/edit.php (working copy)
@@ -18,45 +18,58 @@
}
// 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 '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');
+ case 'undelete':
+ $undeleted = 0;
+ foreach( (array) $post_ids as $post_id ) {
+ $post_del = & get_post($post_id);
- 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 ( !wp_undelete_post($post_id) )
+ wp_die( __('Error in undeleting...') );
+
+ $undeleted++;
}
break;
+ case 'edit':
+ 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;
}
$sendback = wp_get_referer();
@@ -70,6 +83,8 @@
}
if ( isset($deleted) )
$sendback = add_query_arg('deleted', $deleted, $sendback);
+ elseif ( isset($undeleted) )
+ $sendback = add_query_arg('undeleted', $undeleted, $sendback);
wp_redirect($sendback);
exit();
} elseif ( isset($_GET['_wp_http_referer']) && ! empty($_GET['_wp_http_referer']) ) {
@@ -127,6 +142,11 @@
unset($_GET['deleted']);
}
+if ( isset($_GET['undeleted']) && (int) $_GET['undeleted'] ) {
+ printf( _n( 'Post returned to Pending.', '%s posts returned to Pending.', $_GET['undeleted'] ), number_format_i18n( $_GET['undeleted'] ) );
+ unset($_GET['undeleted']);
+}
+
$_SERVER['REQUEST_URI'] = remove_query_arg( array('locked', 'skipped', 'updated', 'deleted'), $_SERVER['REQUEST_URI'] );
?>
@@ -139,7 +159,7 @@
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->deleted;
$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 +210,13 @@
@@ -235,7 +260,8 @@
do_action('restrict_manage_posts');
?>
-
+
+
@@ -270,10 +296,18 @@
+
+
+
Index: wp-admin/page.php
===================================================================
--- wp-admin/page.php (revision 11743)
+++ wp-admin/page.php (working copy)
@@ -83,6 +83,7 @@
$post = get_post_to_edit($page_ID);
if ( empty($post->ID) ) wp_die( __('You attempted to edit a page that doesn’t exist. Perhaps it was deleted?') );
+ if ( $post->post_status == 'deleted' ) wp_die( __('You can’t edit this page because it is in the Trash. Please move it out of the Trash and try again.') );
if ( 'page' != $post->post_type ) {
wp_redirect( get_edit_post_link( $post_ID, 'url' ) );
@@ -165,6 +166,28 @@
exit();
break;
+case 'undelete':
+ $post_id = (isset($_GET['post'])) ? intval($_GET['post']) : intval($_POST['post_ID']);
+ check_admin_referer('undelete-page_' . $post_id);
+
+ $post = & get_post($post_id);
+
+ if ( $post->post_type == 'attachment' ) {
+ if ( ! wp_undelete_attachment($post_id) )
+ wp_die( __('Error in undeleting...') );
+ } else {
+ if ( !wp_undelete_post($post_id) )
+ wp_die( __('Error in undeleting...') );
+ }
+
+ $sendback = wp_get_referer();
+ if (strpos($sendback, 'page.php') !== false) $sendback = admin_url('edit.php?undeleted=1');
+ elseif (strpos($sendback, 'attachments.php') !== false) $sendback = admin_url('attachments.php');
+ else $sendback = add_query_arg('undeleted', 1, $sendback);
+ wp_redirect($sendback);
+ exit();
+ break;
+
case 'preview':
check_admin_referer( 'autosave', 'autosavenonce' );
Index: wp-admin/edit-pages.php
===================================================================
--- wp-admin/edit-pages.php (revision 11743)
+++ wp-admin/edit-pages.php (working copy)
@@ -10,45 +10,58 @@
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 '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');
+ case 'undelete':
+ $undeleted = 0;
+ foreach( (array) $post_ids as $post_id ) {
+ $post_del = & get_post($post_id);
- 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 ( !wp_undelete_post($post_id) )
+ wp_die( __('Error in undeleting...') );
+
+ $undeleted++;
}
break;
+ case 'edit':
+ 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;
}
$sendback = wp_get_referer();
@@ -62,6 +75,8 @@
}
if ( isset($deleted) )
$sendback = add_query_arg('deleted', $deleted, $sendback);
+ elseif ( isset($undeleted) )
+ $sendback = add_query_arg('undeleted', $undeleted, $sendback);
wp_redirect($sendback);
exit();
} elseif ( isset($_GET['_wp_http_referer']) && ! empty($_GET['_wp_http_referer']) ) {
@@ -79,7 +94,8 @@
'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')),
+ 'deleted' => array(_x('Trash', 'page'), __('Trash pages'), _nx_noop('Trash (%s)', 'Trash (%s)', 'page'))
);
$post_stati = apply_filters('page_stati', $post_stati);
@@ -150,7 +166,7 @@
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->deleted;
$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 +228,19 @@
+
+
+
@@ -251,10 +275,18 @@
+
+
+
|