From 39e4f05a15bd3de70b48783161ff978c0c779c80 Mon Sep 17 00:00:00 2001 From: azaozz Date: Thu, 30 Jul 2009 13:39:34 +0000 Subject: [PATCH] Trash status updates for posts, pages, comments and attachments, props caesarsgrunt, see #4529 git-svn-id: http://svn.automattic.com/wordpress/trunk@11749 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/admin-ajax.php | 15 +++- wp-admin/comment.php | 33 ++++++- wp-admin/edit-attachment-rows.php | 31 +++++-- wp-admin/edit-comments.php | 89 +++++++++--------- wp-admin/edit-form-advanced.php | 2 +- wp-admin/edit-form-comment.php | 2 +- wp-admin/edit-page-form.php | 2 +- wp-admin/edit-pages.php | 128 ++++++++++++++++++-------- wp-admin/edit.php | 128 ++++++++++++++++++-------- wp-admin/includes/dashboard.php | 2 +- wp-admin/includes/media.php | 8 +- wp-admin/includes/post.php | 3 +- wp-admin/includes/template.php | 128 +++++++++++++++----------- wp-admin/js/common.dev.js | 10 --- wp-admin/js/common.js | 2 +- wp-admin/js/edit-comments.dev.js | 15 ++-- wp-admin/js/edit-comments.js | 2 +- wp-admin/media.php | 3 + wp-admin/page.php | 41 +++++++++ wp-admin/post.php | 41 +++++++++ wp-admin/upload.php | 117 ++++++++++++++++-------- wp-admin/wp-admin.css | 7 +- wp-app.php | 2 +- wp-includes/comment.php | 144 ++++++++++++++++++------------ wp-includes/functions.php | 27 +++--- wp-includes/post.php | 91 ++++++++++++++++++- wp-includes/query.php | 2 + wp-includes/script-loader.php | 6 +- wp-settings.php | 6 ++ 29 files changed, 758 insertions(+), 329 deletions(-) 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 -
    " . sprintf(__("You are about to delete %s."), $filename) . " " . __('Continue') . " - " . __('Cancel') . "
    \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 ""; $columns = get_column_headers('edit-comments'); @@ -2134,9 +2147,9 @@ function _wp_comment_row( $comment_id, $mode, $comment_status, $checkbox = true, $actions = array(); if ( $user_can ) { - if ( 'deleted' == $the_comment_status ) { - $actions['unapprove'] = "" . __( 'Return to Pending' ) . ''; - $actions['delete'] = "" . __('Delete Permanently') . ''; + if ( 'trash' == $the_comment_status ) { + $actions['untrash'] = "" . __( 'Restore' ) . ''; + $actions['delete'] = "" . __('Delete Permanently') . ''; } else { $actions['approve'] = "" . __( 'Approve' ) . ''; $actions['unapprove'] = "" . __( 'Unapprove' ) . ''; @@ -2152,10 +2165,10 @@ function _wp_comment_row( $comment_id, $mode, $comment_status, $checkbox = true, } if ( 'spam' == $the_comment_status ) { - $actions['delete'] = "" . __('Delete Permanently') . ''; + $actions['delete'] = "" . __('Delete Permanently') . ''; } else { $actions['spam'] = "" . /* translators: mark as spam link */ _x( 'Spam', 'verb' ) . ''; - $actions['delete'] = "" . __('Move to Trash') . ''; + $actions['trash'] = "" . __('Trash') . ''; } $actions['edit'] = "". __('Edit') . ''; @@ -2176,6 +2189,15 @@ function _wp_comment_row( $comment_id, $mode, $comment_status, $checkbox = true, // Reply and quickedit need a hide-if-no-js span when not added with ajax if ( ('reply' == $action || 'quickedit' == $action) && ! $from_ajax ) $action .= ' hide-if-no-js'; + elseif ($action == 'untrash' && $the_comment_status == 'trash') { + $trash_meta = get_option('wp_trash_meta'); + if (is_array($trash_meta) && isset($trash_meta['comments'][$comment_id]['status'])) { + if ($trash_meta['comments'][$comment_id]['status'] == '1') + $action .= ' approve'; + else + $action .= ' unapprove'; + } + } echo "$sep$link"; } diff --git a/wp-admin/js/common.dev.js b/wp-admin/js/common.dev.js index 0d269fe3c6..e2ff4bd24b 100644 --- a/wp-admin/js/common.dev.js +++ b/wp-admin/js/common.dev.js @@ -154,16 +154,6 @@ jQuery(document).ready( function($) { $('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') ) { diff --git a/wp-admin/js/common.js b/wp-admin/js/common.js index f7a44db971..d9073ce29d 100644 --- a/wp-admin/js/common.js +++ b/wp-admin/js/common.js @@ -1 +1 @@ -var showNotice,adminMenu,columns,validateForm;(function(a){adminMenu={init:function(){a("#adminmenu div.wp-menu-toggle").each(function(){if(a(this).siblings(".wp-submenu").length){a(this).click(function(){adminMenu.toggle(a(this).siblings(".wp-submenu"))})}else{a(this).hide()}});this.favorites();a("a.separator").click(function(){if(a("body").hasClass("folded")){adminMenu.fold(1);deleteUserSetting("mfold")}else{adminMenu.fold();setUserSetting("mfold","f")}return false});if(a("body").hasClass("folded")){this.fold()}this.restoreMenuState()},restoreMenuState:function(){a("#adminmenu li.wp-has-submenu").each(function(c,d){var b=getUserSetting("m"+c);if(a(d).hasClass("wp-has-current-submenu")){return true}if("o"==b){a(d).addClass("wp-menu-open")}else{if("c"==b){a(d).removeClass("wp-menu-open")}}})},toggle:function(b){b.slideToggle(150,function(){b.css("display","")}).parent().toggleClass("wp-menu-open");a("#adminmenu li.wp-has-submenu").each(function(d,f){var c=a(f).hasClass("wp-menu-open")?"o":"c";setUserSetting("m"+d,c)});return false},fold:function(b){if(b){a("body").removeClass("folded");a("#adminmenu li.wp-has-submenu").unbind()}else{a("body").addClass("folded");a("#adminmenu li.wp-has-submenu").hoverIntent({over:function(j){var d,c,g,k,i;d=a(this).find(".wp-submenu");c=d.parent().offset().top+d.height()+1;g=a("#wpwrap").height();k=60+c-g;i=a(window).height()+a("body").scrollTop()-15;if(i<(c-k)){k=c-i}if(k>1){d.css({marginTop:"-"+k+"px"})}else{if(d.css("marginTop")){d.css({marginTop:""})}}d.addClass("sub-open")},out:function(){a(this).find(".wp-submenu").removeClass("sub-open").css({marginTop:""})},timeout:220,sensitivity:8,interval:100})}},favorites:function(){a("#favorite-inside").width(a("#favorite-actions").width()-4);a("#favorite-toggle, #favorite-inside").bind("mouseenter",function(){a("#favorite-inside").removeClass("slideUp").addClass("slideDown");setTimeout(function(){if(a("#favorite-inside").hasClass("slideDown")){a("#favorite-inside").slideDown(100);a("#favorite-first").addClass("slide-down")}},200)});a("#favorite-toggle, #favorite-inside").bind("mouseleave",function(){a("#favorite-inside").removeClass("slideDown").addClass("slideUp");setTimeout(function(){if(a("#favorite-inside").hasClass("slideUp")){a("#favorite-inside").slideUp(100,function(){a("#favorite-first").removeClass("slide-down")})}},300)})}};a(document).ready(function(){adminMenu.init()});columns={init:function(){a(".hide-column-tog").click(function(){var c=a(this).val(),b=a(this).attr("checked");if(b){a(".column-"+c).show()}else{a(".column-"+c).hide()}columns.save_manage_columns_state()})},save_manage_columns_state:function(){var b=a(".manage-column").filter(":hidden").map(function(){return this.id}).get().join(",");a.post(ajaxurl,{action:"hidden-columns",hidden:b,screenoptionnonce:a("#screenoptionnonce").val(),page:pagenow})}};a(document).ready(function(){columns.init()});validateForm=function(b){return !a(b).find(".form-required").filter(function(){return a("input:visible",this).val()==""}).addClass("form-invalid").change(function(){a(this).removeClass("form-invalid")}).size()}})(jQuery);showNotice={warn:function(){var a=commonL10n.warnDelete||"";if(confirm(a)){return true}return false},note:function(a){alert(a)}};jQuery(document).ready(function(d){var f=false,a,e,c,b;d(".fade").animate({backgroundColor:"#ffffe0"},300).animate({backgroundColor:"#fffbcc"},300).animate({backgroundColor:"#ffffe0"},300).animate({backgroundColor:"#fffbcc"},300);d("div.wrap h2 ~ div.updated, div.wrap h2 ~ div.error").addClass("below-h2");d("div.updated, div.error").not(".below-h2").insertAfter("div.wrap h2:first");d("#doaction, #doaction2").click(function(){if(d('select[name="action"]').val()=="destroy"||d('select[name="action2"]').val()=="destroy"){return showNotice.warn()}});d("#destroy_all, #destroy_all2").click(function(){return showNotice.warn()});d("#show-settings-link").click(function(){if(!d("#screen-options-wrap").hasClass("screen-options-open")){d("#contextual-help-link-wrap").css("visibility","hidden")}d("#screen-options-wrap").slideToggle("fast",function(){if(d(this).hasClass("screen-options-open")){d("#show-settings-link").css({backgroundImage:'url("images/screen-options-right.gif")'});d("#contextual-help-link-wrap").css("visibility","");d(this).removeClass("screen-options-open")}else{d("#show-settings-link").css({backgroundImage:'url("images/screen-options-right-up.gif")'});d(this).addClass("screen-options-open")}});return false});d("#contextual-help-link").click(function(){if(!d("#contextual-help-wrap").hasClass("contextual-help-open")){d("#screen-options-link-wrap").css("visibility","hidden")}d("#contextual-help-wrap").slideToggle("fast",function(){if(d(this).hasClass("contextual-help-open")){d("#contextual-help-link").css({backgroundImage:'url("images/screen-options-right.gif")'});d("#screen-options-link-wrap").css("visibility","");d(this).removeClass("contextual-help-open")}else{d("#contextual-help-link").css({backgroundImage:'url("images/screen-options-right-up.gif")'});d(this).addClass("contextual-help-open")}});return false});d("#contextual-help-link-wrap, #screen-options-link-wrap").show();d("table:visible tbody .check-column :checkbox").click(function(g){if("undefined"==g.shiftKey){return true}if(g.shiftKey){if(!f){return true}a=d(f).parents("form:first").find(":checkbox");e=a.index(f);c=a.index(this);b=d(this).attr("checked");if(01){d.css({marginTop:"-"+k+"px"})}else{if(d.css("marginTop")){d.css({marginTop:""})}}d.addClass("sub-open")},out:function(){a(this).find(".wp-submenu").removeClass("sub-open").css({marginTop:""})},timeout:220,sensitivity:8,interval:100})}},favorites:function(){a("#favorite-inside").width(a("#favorite-actions").width()-4);a("#favorite-toggle, #favorite-inside").bind("mouseenter",function(){a("#favorite-inside").removeClass("slideUp").addClass("slideDown");setTimeout(function(){if(a("#favorite-inside").hasClass("slideDown")){a("#favorite-inside").slideDown(100);a("#favorite-first").addClass("slide-down")}},200)});a("#favorite-toggle, #favorite-inside").bind("mouseleave",function(){a("#favorite-inside").removeClass("slideDown").addClass("slideUp");setTimeout(function(){if(a("#favorite-inside").hasClass("slideUp")){a("#favorite-inside").slideUp(100,function(){a("#favorite-first").removeClass("slide-down")})}},300)})}};a(document).ready(function(){adminMenu.init()});columns={init:function(){a(".hide-column-tog").click(function(){var c=a(this).val(),b=a(this).attr("checked");if(b){a(".column-"+c).show()}else{a(".column-"+c).hide()}columns.save_manage_columns_state()})},save_manage_columns_state:function(){var b=a(".manage-column").filter(":hidden").map(function(){return this.id}).get().join(",");a.post(ajaxurl,{action:"hidden-columns",hidden:b,screenoptionnonce:a("#screenoptionnonce").val(),page:pagenow})}};a(document).ready(function(){columns.init()});validateForm=function(b){return !a(b).find(".form-required").filter(function(){return a("input:visible",this).val()==""}).addClass("form-invalid").change(function(){a(this).removeClass("form-invalid")}).size()}})(jQuery);showNotice={warn:function(){var a=commonL10n.warnDelete||"";if(confirm(a)){return true}return false},note:function(a){alert(a)}};jQuery(document).ready(function(d){var f=false,a,e,c,b;d(".fade").animate({backgroundColor:"#ffffe0"},300).animate({backgroundColor:"#fffbcc"},300).animate({backgroundColor:"#ffffe0"},300).animate({backgroundColor:"#fffbcc"},300);d("div.wrap h2 ~ div.updated, div.wrap h2 ~ div.error").addClass("below-h2");d("div.updated, div.error").not(".below-h2").insertAfter("div.wrap h2:first");d("#show-settings-link").click(function(){if(!d("#screen-options-wrap").hasClass("screen-options-open")){d("#contextual-help-link-wrap").css("visibility","hidden")}d("#screen-options-wrap").slideToggle("fast",function(){if(d(this).hasClass("screen-options-open")){d("#show-settings-link").css({backgroundImage:'url("images/screen-options-right.gif")'});d("#contextual-help-link-wrap").css("visibility","");d(this).removeClass("screen-options-open")}else{d("#show-settings-link").css({backgroundImage:'url("images/screen-options-right-up.gif")'});d(this).addClass("screen-options-open")}});return false});d("#contextual-help-link").click(function(){if(!d("#contextual-help-wrap").hasClass("contextual-help-open")){d("#screen-options-link-wrap").css("visibility","hidden")}d("#contextual-help-wrap").slideToggle("fast",function(){if(d(this).hasClass("contextual-help-open")){d("#contextual-help-link").css({backgroundImage:'url("images/screen-options-right.gif")'});d("#screen-options-link-wrap").css("visibility","");d(this).removeClass("contextual-help-open")}else{d("#contextual-help-link").css({backgroundImage:'url("images/screen-options-right-up.gif")'});d(this).addClass("contextual-help-open")}});return false});d("#contextual-help-link-wrap, #screen-options-link-wrap").show();d("table:visible tbody .check-column :checkbox").click(function(g){if("undefined"==g.shiftKey){return true}if(g.shiftKey){if(!f){return true}a=d(f).parents("form:first").find(":checkbox");e=a.index(f);c=a.index(this);b=d(this).attr("checked");if(03){o=o.substr(0,o.length-3)+" "+o.substr(-3)}m.html(o)})};e=function(j){j.data._total=g.val();j.data._per_page=i.val();j.data._page=h.val();j.data._url=document.location.href;if("undefined"!=showNotice&&j.data.action&&j.data.action=="delete-comment"&&j.data.deleted){return showNotice.warn()?j:false}return j};d=function(j,k,l){if(k3){o=o.substr(0,o.length-3)+" "+o.substr(-3)}m.html(o)})};b=function(l,j){a("span.pending-count").each(function(){var m=a(this),o;o=m.html().replace(/[ ,.]+/g,"");o=parseInt(o,10);if(isNaN(o)){return}if(a("#"+j.element).is(".unapproved")){o=o-1}else{if(a(j.target).parents("span.unapprove").size()){o=o+1}}if(o<0){o=0}m.parents("#awaiting-mod")[0==o?"addClass":"removeClass"]("count-0");o=o.toString();if(o.length>3){o=o.substr(0,o.length-3)+" "+o.substr(-3)}m.html(o)});a("span.spam-count").each(function(){var m=a(this),o;o=m.html().replace(/[ ,.]+/g,"");o=parseInt(o,10);if(isNaN(o)){return}if(a(j.target).parents("span.spam").size()){o=o+1}else{if(a("#"+j.element).is(".spam")){o=o-1}}if(o<0){o=0}o=o.toString();if(o.length>3){o=o.substr(0,o.length-3)+" "+o.substr(-3)}m.html(o)});a("span.deleted-count").each(function(){var m=a(this),o;o=m.html().replace(/[ ,.]+/g,"");o=parseInt(o,10);if(isNaN(o)){return}if(a(j.target).parents("span.delete").size()&&a("#"+j.element).is(".deleted,.spam")){o--}else{if(a(j.target).parents("span.delete").size()){o++}else{if(a("#"+j.element).is(".deleted")){o--}}}if(o<0){o=0}o=o.toString();if(o.length>3){o=o.substr(0,o.length-3)+" "+o.substr(-3)}m.html(o)});if(("object"==typeof l)&&f p").dblclick(function(){commentReply.toggle(a(this).parent())});a("#doaction, #doaction2, #post-query-submit").click(function(c){if(a("#the-comment-list #replyrow").length>0){commentReply.close()}});this.comments_listing=a('#comments-form > input[name="comment_status"]').val()||""},addEvents:function(b){b.each(function(){a(this).find(".column-comment > p").dblclick(function(){commentReply.toggle(a(this).parent())})})},toggle:function(b){if(a(b).css("display")!="none"){a(b).find("a.vim-q").click()}},revert:function(){if(a("#the-comment-list #replyrow").length<1){return false}a("#replyrow").fadeOut("fast",function(){commentReply.close()});return false},close:function(){a(this.o).fadeIn("fast").css("backgroundColor","");a("#com-reply").append(a("#replyrow"));a("#replycontent").val("");a("#edithead input").val("");a("#replysubmit .error").html("").hide();a("#replysubmit .waiting").hide();if(a.browser.msie){a("#replycontainer, #replycontent").css("height","120px")}else{a("#replycontainer").resizable("destroy").css("height","120px")}},open:function(i,g,c){var e=this,d,b,f;e.close();e.o="#comment-"+i;a("#replyrow td").attr("colspan",a(".widefat thead th:visible").length);d=a("#replyrow"),rowData=a("#inline-"+i);b=e.act=(c=="edit")?"edit-comment":"replyto-comment";a("#action",d).val(b);a("#comment_post_ID",d).val(g);a("#comment_ID",d).val(i);if(c=="edit"){a("#author",d).val(a("div.author",rowData).text());a("#author-email",d).val(a("div.author-email",rowData).text());a("#author-url",d).val(a("div.author-url",rowData).text());a("#status",d).val(a("div.comment_status",rowData).text());a("#replycontent",d).val(a("textarea.comment",rowData).val());a("#edithead, #savebtn",d).show();a("#replyhead, #replybtn",d).hide();f=a(e.o).height();if(f>220){if(a.browser.msie){a("#replycontainer, #replycontent",d).height(f-105)}else{a("#replycontainer",d).height(f-105)}}a(e.o).after(d.hide()).fadeOut("fast",function(){a("#replyrow").fadeIn("fast")})}else{a("#edithead, #savebtn",d).hide();a("#replyhead, #replybtn",d).show();a(e.o).after(d);a("#replyrow").hide().fadeIn("fast")}if(!a.browser.msie){a("#replycontainer").resizable({handles:"s",axis:"y",minHeight:80,stop:function(){a("#replycontainer").width("auto")}})}setTimeout(function(){var l,j,m,h,k;l=a("#replyrow").offset().top;j=l+a("#replyrow").height();m=window.pageYOffset||document.documentElement.scrollTop;h=document.documentElement.clientHeight||self.innerHeight||0;k=m+h;if(k-20]*?>/g,"")}if(c){a("#replysubmit .error").html(c).show()}}};a(document).ready(function(){var e,b,c,d;setCommentsList();commentReply.init();a("span.delete a.delete").click(function(){return false});if(typeof QTags!="undefined"){ed_reply=new QTags("ed_reply","replycontent","replycontainer","more")}if(typeof a.table_hotkeys!="undefined"){e=function(f){return function(){var h,g;h="next"==f?"first":"last";g=a("."+f+".page-numbers");if(g.length){window.location=g[0].href.replace(/\&hotkeys_highlight_(first|last)=1/g,"")+"&hotkeys_highlight_"+h+"=1"}}};b=function(g,f){window.location=a("span.edit a",f).attr("href")};c=function(){toggleWithKeyboard=true;a("#comments-form thead #cb input:checkbox").click().attr("checked","");toggleWithKeyboard=false};d=function(f){return function(h,g){a("option[value="+f+"]").attr("selected","selected");a("form#comments-form")[0].submit()}};a.table_hotkeys(a("table.widefat"),["a","u","s","d","r","q",["e",b],["shift+a",d("approve")],["shift+s",d("markspam")],["shift+d",d("delete")],["shift+x",c],["shift+u",d("unapprove")]],{highlight_first:adminCommentsL10n.hotkeys_highlight_first,highlight_last:adminCommentsL10n.hotkeys_highlight_last,prev_page_link_cb:e("prev"),next_page_link_cb:e("next")})}})})(jQuery); \ No newline at end of file +var theList,theExtraList,toggleWithKeyboard=false;(function(a){setCommentsList=function(){var g,i,h,f=0,c,e,d,b;g=a('#comments-form .tablenav :input[name="_total"]');i=a('#comments-form .tablenav :input[name="_per_page"]');h=a('#comments-form .tablenav :input[name="_page"]');c=function(k,j){var l=a("#"+j.element);if(l.is(".unapproved")){l.find("div.comment_status").html("0")}else{l.find("div.comment_status").html("1")}a("span.pending-count").each(function(){var m=a(this),o;o=m.html().replace(/[ ,.]+/g,"");o=parseInt(o,10);if(isNaN(o)){return}o=o+(a("#"+j.element).is("."+j.dimClass)?1:-1);if(o<0){o=0}m.parents("#awaiting-mod")[0==o?"addClass":"removeClass"]("count-0");o=o.toString();if(o.length>3){o=o.substr(0,o.length-3)+" "+o.substr(-3)}m.html(o)})};e=function(j){j.data._total=g.val();j.data._per_page=i.val();j.data._page=h.val();j.data._url=document.location.href;return j};d=function(j,k,l){if(k3){o=o.substr(0,o.length-3)+" "+o.substr(-3)}m.html(o)})};b=function(l,j){a("span.pending-count").each(function(){var m=a(this),o;o=m.html().replace(/[ ,.]+/g,"");o=parseInt(o,10);if(isNaN(o)){return}if(a("#"+j.element).is(".unapproved")){o=o-1}else{if(a(j.target).parents("span.unapprove").size()){o=o+1}}if(o<0){o=0}m.parents("#awaiting-mod")[0==o?"addClass":"removeClass"]("count-0");o=o.toString();if(o.length>3){o=o.substr(0,o.length-3)+" "+o.substr(-3)}m.html(o)});a("span.spam-count").each(function(){var m=a(this),o;o=m.html().replace(/[ ,.]+/g,"");o=parseInt(o,10);if(isNaN(o)){return}if(a(j.target).parents("span.spam").size()){o=o+1}else{if(a("#"+j.element).is(".spam")){o=o-1}}if(o<0){o=0}o=o.toString();if(o.length>3){o=o.substr(0,o.length-3)+" "+o.substr(-3)}m.html(o)});a("span.trash-count").each(function(){var m=a(this),o;o=m.html().replace(/[ ,.]+/g,"");o=parseInt(o,10);if(isNaN(o)){return}if(a(j.target).parents("span.trash").size()){o=o+1}else{if(a("#"+j.element).is(".trash")){o=o-1}}if(o<0){o=0}o=o.toString();if(o.length>3){o=o.substr(0,o.length-3)+" "+o.substr(-3)}m.html(o)});if(("object"==typeof l)&&f p").dblclick(function(){commentReply.toggle(a(this).parent())});a("#doaction, #doaction2, #post-query-submit").click(function(c){if(a("#the-comment-list #replyrow").length>0){commentReply.close()}});this.comments_listing=a('#comments-form > input[name="comment_status"]').val()||""},addEvents:function(b){b.each(function(){a(this).find(".column-comment > p").dblclick(function(){commentReply.toggle(a(this).parent())})})},toggle:function(b){if(a(b).css("display")!="none"){a(b).find("a.vim-q").click()}},revert:function(){if(a("#the-comment-list #replyrow").length<1){return false}a("#replyrow").fadeOut("fast",function(){commentReply.close()});return false},close:function(){a(this.o).fadeIn("fast").css("backgroundColor","");a("#com-reply").append(a("#replyrow"));a("#replycontent").val("");a("#edithead input").val("");a("#replysubmit .error").html("").hide();a("#replysubmit .waiting").hide();if(a.browser.msie){a("#replycontainer, #replycontent").css("height","120px")}else{a("#replycontainer").resizable("destroy").css("height","120px")}},open:function(i,g,c){var e=this,d,b,f;e.close();e.o="#comment-"+i;a("#replyrow td").attr("colspan",a(".widefat thead th:visible").length);d=a("#replyrow"),rowData=a("#inline-"+i);b=e.act=(c=="edit")?"edit-comment":"replyto-comment";a("#action",d).val(b);a("#comment_post_ID",d).val(g);a("#comment_ID",d).val(i);if(c=="edit"){a("#author",d).val(a("div.author",rowData).text());a("#author-email",d).val(a("div.author-email",rowData).text());a("#author-url",d).val(a("div.author-url",rowData).text());a("#status",d).val(a("div.comment_status",rowData).text());a("#replycontent",d).val(a("textarea.comment",rowData).val());a("#edithead, #savebtn",d).show();a("#replyhead, #replybtn",d).hide();f=a(e.o).height();if(f>220){if(a.browser.msie){a("#replycontainer, #replycontent",d).height(f-105)}else{a("#replycontainer",d).height(f-105)}}a(e.o).after(d.hide()).fadeOut("fast",function(){a("#replyrow").fadeIn("fast")})}else{a("#edithead, #savebtn",d).hide();a("#replyhead, #replybtn",d).show();a(e.o).after(d);a("#replyrow").hide().fadeIn("fast")}if(!a.browser.msie){a("#replycontainer").resizable({handles:"s",axis:"y",minHeight:80,stop:function(){a("#replycontainer").width("auto")}})}setTimeout(function(){var l,j,m,h,k;l=a("#replyrow").offset().top;j=l+a("#replyrow").height();m=window.pageYOffset||document.documentElement.scrollTop;h=document.documentElement.clientHeight||self.innerHeight||0;k=m+h;if(k-20]*?>/g,"")}if(c){a("#replysubmit .error").html(c).show()}}};a(document).ready(function(){var e,b,c,d;setCommentsList();commentReply.init();a("span.delete a.delete").click(function(){return false});if(typeof QTags!="undefined"){ed_reply=new QTags("ed_reply","replycontent","replycontainer","more")}if(typeof a.table_hotkeys!="undefined"){e=function(f){return function(){var h,g;h="next"==f?"first":"last";g=a("."+f+".page-numbers");if(g.length){window.location=g[0].href.replace(/\&hotkeys_highlight_(first|last)=1/g,"")+"&hotkeys_highlight_"+h+"=1"}}};b=function(g,f){window.location=a("span.edit a",f).attr("href")};c=function(){toggleWithKeyboard=true;a("#comments-form thead #cb input:checkbox").click().attr("checked","");toggleWithKeyboard=false};d=function(f){return function(h,g){a("option[value="+f+"]").attr("selected","selected");a("form#comments-form")[0].submit()}};a.table_hotkeys(a("table.widefat"),["a","u","s","d","r","q",["e",b],["shift+a",d("approve")],["shift+s",d("markspam")],["shift+d",d("delete")],["shift+x",c],["shift+u",d("unapprove")]],{highlight_first:adminCommentsL10n.hotkeys_highlight_first,highlight_last:adminCommentsL10n.hotkeys_highlight_last,prev_page_link_cb:e("prev"),next_page_link_cb:e("next")})}})})(jQuery); \ No newline at end of file diff --git a/wp-admin/media.php b/wp-admin/media.php index e31baf2d5e..1795d3f8e3 100644 --- a/wp-admin/media.php +++ b/wp-admin/media.php @@ -58,6 +58,9 @@ case 'edit' : $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 == 'trash' ) 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' ); diff --git a/wp-admin/page.php b/wp-admin/page.php index 68a6690201..497ef206da 100644 --- a/wp-admin/page.php +++ b/wp-admin/page.php @@ -83,6 +83,7 @@ case 'edit': $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 == 'trash' ) 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' ) ); @@ -140,6 +141,46 @@ case 'editpost': exit(); break; +case 'trash': + $post_id = (isset($_GET['post'])) ? intval($_GET['post']) : intval($_POST['post_ID']); + check_admin_referer('trash-page_' . $post_id); + + $post = & get_post($post_id); + + if ( !current_user_can('delete_page', $page_id) ) + wp_die( __('You are not allowed to move this page to the trash.') ); + + if ( !wp_trash_post($post_id) ) + wp_die( __('Error in removing from trash...') ); + + $sendback = wp_get_referer(); + if (strpos($sendback, 'page.php') !== false) $sendback = admin_url('edit-pages.php?trashed=1'); + elseif (strpos($sendback, 'attachments.php') !== false) $sendback = admin_url('attachments.php'); + else $sendback = add_query_arg('trashed', 1, $sendback); + wp_redirect($sendback); + exit(); + break; + +case 'untrash': + $post_id = (isset($_GET['post'])) ? intval($_GET['post']) : intval($_POST['post_ID']); + check_admin_referer('untrash-page_' . $post_id); + + $post = & get_post($post_id); + + if ( !current_user_can('delete_page', $page_id) ) + wp_die( __('You are not allowed to remove this page form the trash.') ); + + if ( !wp_untrash_post($post_id) ) + wp_die( __('Error in removing from trash...') ); + + $sendback = wp_get_referer(); + if (strpos($sendback, 'page.php') !== false) $sendback = admin_url('edit-pages.php?untrashed=1'); + elseif (strpos($sendback, 'attachments.php') !== false) $sendback = admin_url('attachments.php'); + else $sendback = add_query_arg('untrashed', 1, $sendback); + wp_redirect($sendback); + exit(); + break; + case 'delete': $page_id = (isset($_GET['post'])) ? intval($_GET['post']) : intval($_POST['post_ID']); check_admin_referer('delete-page_' . $page_id); diff --git a/wp-admin/post.php b/wp-admin/post.php index 008778faeb..81c85b45f5 100644 --- a/wp-admin/post.php +++ b/wp-admin/post.php @@ -116,6 +116,7 @@ case 'edit': $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 == 'trash' ) 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' ) ); @@ -181,6 +182,46 @@ case 'editpost': exit(); break; +case 'trash': + $post_id = (isset($_GET['post'])) ? intval($_GET['post']) : intval($_POST['post_ID']); + check_admin_referer('trash-post_' . $post_id); + + $post = & get_post($post_id); + + if ( !current_user_can('delete_post', $post_id) ) + 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...') ); + + $sendback = wp_get_referer(); + if (strpos($sendback, 'post.php') !== false) $sendback = admin_url('edit.php?trashed=1'); + elseif (strpos($sendback, 'attachments.php') !== false) $sendback = admin_url('attachments.php'); + else $sendback = add_query_arg('trashed', 1, $sendback); + wp_redirect($sendback); + exit(); + break; + +case 'untrash': + $post_id = (isset($_GET['post'])) ? intval($_GET['post']) : intval($_POST['post_ID']); + check_admin_referer('untrash-post_' . $post_id); + + $post = & get_post($post_id); + + if ( !current_user_can('delete_post', $post_id) ) + 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...') ); + + $sendback = wp_get_referer(); + if (strpos($sendback, 'post.php') !== false) $sendback = admin_url('edit.php?untrashed=1'); + elseif (strpos($sendback, 'attachments.php') !== false) $sendback = admin_url('attachments.php'); + else $sendback = add_query_arg('untrashed', 1, $sendback); + wp_redirect($sendback); + exit(); + break; + case 'delete': $post_id = (isset($_GET['post'])) ? intval($_GET['post']) : intval($_POST['post_ID']); check_admin_referer('delete-post_' . $post_id); diff --git a/wp-admin/upload.php b/wp-admin/upload.php index 0f01e36fe8..df44e989c3 100644 --- a/wp-admin/upload.php +++ b/wp-admin/upload.php @@ -67,33 +67,60 @@ if ( isset($_GET['find_detached'] ) ) { 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 ( 'delete' == $doaction ) { - foreach( (array) $_GET['media'] 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 = '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; + + 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 = 'trash'" ); + $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; } + + switch ( $doaction ) { + case 'trash': + foreach( (array) $post_ids as $post_id ) { + if ( !current_user_can('delete_post', $post_id) ) + 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...') ); + } + $location = add_query_arg('message', 4, $location); + break; + case 'untrash': + foreach( (array) $post_ids as $post_id ) { + if ( !current_user_can('delete_post', $post_id) ) + wp_die( __('You are not allowed to remove this post from the trash.') ); + + if ( !wp_untrash_post($post_id) ) + wp_die( __('Error in restoring from trash...') ); + } + $location = add_query_arg('message', 5, $location); + break; + case 'delete': + foreach( (array) $post_ids as $post_id_del ) { + if ( !current_user_can('delete_post', $post_id_del) ) + wp_die( __('You are not allowed to delete this post.') ); + + if ( !wp_delete_attachment($post_id_del) ) + wp_die( __('Error in deleting...') ); + } + $location = add_query_arg('message', 2, $location); + break; + } + + $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; @@ -115,7 +142,7 @@ if ( isset($_GET['detached']) ) { $orphans = $wpdb->get_results( "SELECT * FROM $wpdb->posts WHERE post_type = 'attachment' AND ID IN ($lost) LIMIT $start, 50" ); } else { $start = ( $_GET['paged'] - 1 ) * 25; - $orphans = $wpdb->get_results( "SELECT SQL_CALC_FOUND_ROWS * FROM $wpdb->posts WHERE post_type = 'attachment' AND post_parent < 1 LIMIT $start, 25" ); + $orphans = $wpdb->get_results( "SELECT SQL_CALC_FOUND_ROWS * FROM $wpdb->posts WHERE post_type = 'attachment' AND post_status != 'trash' AND post_parent < 1 LIMIT $start, 25" ); $page_links_total = ceil($wpdb->get_var( "SELECT FOUND_ROWS()" ) / 25); } @@ -135,6 +162,8 @@ if ( isset($_GET['detached']) ) { list($post_mime_types, $avail_post_mime_types) = wp_edit_attachments_query(); } +$is_trash = ( isset($_GET['status']) && $_GET['status'] == 'trash' ); + wp_enqueue_script('media'); require_once('admin-header.php'); ?> @@ -153,6 +182,8 @@ if ( isset($_GET['attached']) && (int) $_GET['attached'] ) { $messages[1] = __('Media attachment updated.'); $messages[2] = __('Media deleted.'); $messages[3] = __('Error saving media attachment.'); +$messages[4] = __('Media moved to Trash.'); +$messages[5] = __('Media removed from Trash.'); if ( isset($_GET['message']) && (int) $_GET['message'] ) { $message = $messages[$_GET['message']]; @@ -180,13 +211,13 @@ if ( isset($message) ) { ?> $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 +230,8 @@ foreach ( $post_mime_types as $mime_type => $label ) { $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 +273,12 @@ if ( $page_links ) : ?>
    @@ -251,7 +286,7 @@ if ( $page_links ) : ?> posts WHERE post_type = 'attachment' ORDER BY post_date DESC"; $arc_result = $wpdb->get_results( $arc_query ); @@ -286,6 +321,8 @@ foreach ($arc_result as $arc_row) { + +
    @@ -341,7 +378,7 @@ foreach ($arc_result as $arc_row) { 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['trash'] = "ID) . "'>" . __('Trash') . ""; $actions['view'] = '' . __('View') . ''; if ( current_user_can('edit_post', $post->ID) ) $actions['attach'] = ''.__('Attach').''; @@ -398,12 +435,20 @@ if ( $page_links )
    + + + +

    diff --git a/wp-admin/wp-admin.css b/wp-admin/wp-admin.css index 18263c7bb0..53e65e32be 100644 --- a/wp-admin/wp-admin.css +++ b/wp-admin/wp-admin.css @@ -409,7 +409,8 @@ a.button-secondary { } #doaction, -#doaction2 { +#doaction2, +#post-query-submit { margin-right: 8px; } @@ -444,7 +445,9 @@ a.button-secondary { display: none; } -.unapproved .approve, .spam .approve, .deleted .approve { +.unapproved .approve, +.spam .approve, +.trash .approve { display: inline; } diff --git a/wp-app.php b/wp-app.php index 0ada250e3a..8bd742e95c 100644 --- a/wp-app.php +++ b/wp-app.php @@ -1231,7 +1231,7 @@ list($content_type, $content) = prep_atom_text_construct(get_the_content()); ?> log_app('Status','204: No Content'); header('Content-Type: text/plain'); status_header('204'); - echo "Deleted."; + echo "Moved to Trash."; exit; } diff --git a/wp-includes/comment.php b/wp-includes/comment.php index de700c4292..41999ad147 100644 --- a/wp-includes/comment.php +++ b/wp-includes/comment.php @@ -208,8 +208,8 @@ function get_comments( $args = '' ) { $approved = "comment_approved = '1'"; elseif ( 'spam' == $status ) $approved = "comment_approved = 'spam'"; - elseif ( 'deleted' == $status ) - $approved = "comment_approved = 'deleted'"; + elseif ( 'trash' == $status ) + $approved = "comment_approved = 'trash'"; else $approved = "( comment_approved = '0' OR comment_approved = '1' )"; @@ -694,14 +694,15 @@ function wp_count_comments( $post_id = 0 ) { 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 <> 'trash'"; - $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'); + $approved = array('0' => 'moderated', '1' => 'approved', 'spam' => 'spam', 'trash' => 'trash'); $known_types = array_keys( $approved ); foreach( (array) $count as $row_num => $row ) { $total += $row['num_comments']; @@ -737,15 +738,20 @@ function wp_count_comments( $post_id = 0 ) { * @return bool False if delete comment query failure, true on success. */ function wp_delete_comment($comment_id) { - if (wp_get_comment_status($comment_id) != 'deleted' && wp_get_comment_status($comment_id) != 'spam') - return wp_set_comment_status($comment_id, 'delete'); - global $wpdb; + if (!$comment = get_comment($comment_id)) + return false; + + if (wp_get_comment_status($comment_id) != 'trash' && wp_get_comment_status($comment_id) != 'spam' && EMPTY_TRASH_DAYS > 0) + return wp_trash_comment($comment_id); + do_action('delete_comment', $comment_id); - wp_unschedule_comment_delete($comment_id); - - $comment = get_comment($comment_id); + $trash_meta = get_option('wp_trash_meta'); + if (is_array($trash_meta) && isset($trash_meta['comments'][$comment_id])) { + unset($trash_meta['comments'][$comment_id]); + update_option('wp_trash_meta', $trash_meta); + } if ( ! $wpdb->query( $wpdb->prepare("DELETE FROM $wpdb->comments WHERE comment_ID = %d LIMIT 1", $comment_id) ) ) return false; @@ -768,13 +774,73 @@ function wp_delete_comment($comment_id) { return true; } +/** + * Moves a comment to the Trash + * + * @since 2.9.0 + * @uses do_action() on 'trash_comment' before trashing + * @uses do_action() on 'trashed_comment' after trashing + * + * @param int $comment_id Comment ID. + * @return mixed False on failure + */ +function wp_trash_comment($comment_id = 0) { + if (EMPTY_TRASH_DAYS == 0) + return wp_delete_comment($comment_id); + + if (!$comment = get_comment($comment_id)) + return false; + + do_action('trash_comment', $comment_id); + + $trash_meta = get_option('wp_trash_meta', array()); + $trash_meta['comments'][$comment_id]['status'] = $comment->comment_approved; + $trash_meta['comments'][$comment_id]['time'] = time(); + update_option('wp_trash_meta', $trash_meta); + + wp_set_comment_status($comment_id, 'trash'); + + do_action('trashed_comment', $comment_id); + + return true; +} + +/** + * Removes a comment from the Trash + * + * @since 2.9.0 + * @uses do_action() on 'untrash_comment' before undeletion + * @uses do_action() on 'untrashed_comment' after undeletion + * + * @param int $comment_id Comment ID. + * @return mixed False on failure + */ +function wp_untrash_comment($comment_id = 0) { + do_action('untrash_comment', $comment_id); + + $comment = array('comment_ID'=>$comment_id, 'comment_approved'=>'0'); + + $trash_meta = get_option('wp_trash_meta'); + if (is_array($trash_meta) && isset($trash_meta['comments'][$comment_id])) { + $comment['comment_approved'] = $trash_meta['comments'][$comment_id]['status']; + unset($trash_meta['comments'][$comment_id]); + update_option('wp_trash_meta', $trash_meta); + } + + wp_update_comment($comment); + + do_action('untrashed_comment', $comment_id); + + return true; +} + /** * The status of a comment by ID. * * @since 1.0.0 * * @param int $comment_id Comment ID - * @return string|bool Status might be 'deleted', 'approved', 'unapproved', 'spam'. False on failure. + * @return string|bool Status might be 'trash', 'approved', 'unapproved', 'spam'. False on failure. */ function wp_get_comment_status($comment_id) { $comment = get_comment($comment_id); @@ -784,15 +850,15 @@ function wp_get_comment_status($comment_id) { $approved = $comment->comment_approved; if ( $approved == NULL ) - return 'deleted'; + return false; elseif ( $approved == '1' ) return 'approved'; elseif ( $approved == '0' ) return 'unapproved'; elseif ( $approved == 'spam' ) return 'spam'; - elseif ( $approved == 'deleted' ) - return 'deleted'; + elseif ( $approved == 'trash' ) + return 'trash'; else return false; } @@ -1037,8 +1103,7 @@ function wp_new_comment( $commentdata ) { */ function wp_set_comment_status($comment_id, $comment_status, $wp_error = false) { global $wpdb; - wp_unschedule_comment_delete($comment_id); - + $status = '0'; switch ( $comment_status ) { case 'hold': @@ -1054,11 +1119,8 @@ function wp_set_comment_status($comment_id, $comment_status, $wp_error = false) case 'spam': $status = 'spam'; break; - case 'delete': - if (wp_get_comment_status($comment_id) == 'deleted' || wp_get_comment_status($comment_id) == 'spam') - return wp_delete_comment($comment_id); - $status = 'deleted'; - wp_schedule_comment_delete($comment_id); + case 'trash': + $status = 'trash'; break; default: return false; @@ -1083,42 +1145,6 @@ function wp_set_comment_status($comment_id, $comment_status, $wp_error = false) return true; } -/** - * Schedules a comment for destruction in 30 days. - * - * @since 2.9.0 - * - * @param int $comment_id Comment ID. - * @return void - */ -function wp_schedule_comment_delete($comment_id) { - $to_delete = get_option('wp_scheduled_delete'); - if ( !is_array($to_delete) ) - $to_delete = array(); - - $to_delete['comments'][$comment_id] = time(); - - update_option('wp_scheduled_delete', $to_delete); -} - -/** - * Unschedules a comment for destruction. - * - * @since 2.9.0 - * - * @param int $comment_id Comment ID. - * @return void - */ -function wp_unschedule_comment_delete($comment_id) { - $to_delete = get_option('wp_scheduled_delete'); - if ( !is_array($to_delete) ) - return; - - unset($to_delete['comments'][$comment_id]); - - update_option('wp_scheduled_delete', $to_delete); -} - /** * Updates an existing comment in the database. * diff --git a/wp-includes/functions.php b/wp-includes/functions.php index 9f7f25fd1f..96c211f6fe 100644 --- a/wp-includes/functions.php +++ b/wp-includes/functions.php @@ -3339,28 +3339,29 @@ function _cleanup_header_comment($str) { } /** - * Permanently deletes comments that have been scheduled for deleting. - * Will do the same for posts, pages, etc in the future. + * Permanently deletes posts, pages, attachments, and comments which have been in the trash for EMPTY_TRASH_DAYS. * - * @access private * @since 2.9.0 * * @return void */ function wp_scheduled_delete() { - $to_delete = get_option('wp_scheduled_delete'); - if (!is_array($to_delete)) + $trash_meta = get_option('wp_trash_meta'); + if ( !is_array($trash_meta) ) return; - if ( !isset($to_delete['comments']) || !is_array($to_delete['comments']) ) - $to_delete['comments'] = array(); + $delete_timestamp = time() - (60*60*24*EMPTY_TRASH_DAYS); - $delete_delay = defined('EMPTY_TRASH_TIMEOUT') ? (int) EMPTY_TRASH_TIMEOUT : (60*60*24*30); - $deletetimestamp = time() - $delete_delay; - foreach ($to_delete['comments'] as $comment_id => $timestamp) { - if ($timestamp < $deletetimestamp) { - wp_delete_comment($comment_id); - unset($to_delete['comments'][$comment_id]); + foreach ( $trash_meta['comments'] as $id => $meta ) { + if ( $meta['time'] < $delete_timestamp ) { + wp_delete_comment($id); + unset($trash_meta['comments'][$id]); + } + } + foreach ( $trash_meta['posts'] as $id => $meta ) { + if ( $meta['time'] < $delete_timestamp ) { + wp_delete_post($id); + unset($to_delete['posts'][$id]); } } diff --git a/wp-includes/post.php b/wp-includes/post.php index 7ae5431b0a..b677115590 100644 --- a/wp-includes/post.php +++ b/wp-includes/post.php @@ -998,7 +998,7 @@ function wp_count_posts( $type = 'post', $perm = '' ) { $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, 'trash' => 0 ); foreach( (array) $count as $row_num => $row ) { $stats[$row['post_status']] = $row['num_posts']; } @@ -1027,12 +1027,13 @@ function wp_count_attachments( $mime_type = '' ) { 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 != 'trash' $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 = 'trash' $and"); return (object) $stats; } @@ -1140,10 +1141,19 @@ function wp_delete_post($postid = 0) { 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) != 'trash' && EMPTY_TRASH_DAYS > 0 ) + return wp_trash_post($postid); + + if ( $post->post_type == 'attachment' ) return wp_delete_attachment($postid); do_action('delete_post', $postid); + + $trash_meta = get_option('wp_trash_meta'); + if ( is_array($trash_meta) && isset($trash_meta['posts'][$postid]) ) { + unset($trash_meta['posts'][$postid]); + update_option('wp_trash_meta', $trash_meta); + } /** @todo delete for pluggable post taxonomies too */ wp_delete_object_term_relationships($postid, array('category', 'post_tag')); @@ -1204,6 +1214,72 @@ function wp_delete_post($postid = 0) { return $post; } +/** + * Moves a post or page to the Trash + * + * @since 2.9.0 + * @uses do_action() on 'trash_post' before trashing + * @uses do_action() on 'trashed_post' after trashing + * + * @param int $postid Post ID. + * @return mixed False on failure + */ +function wp_trash_post($postid = 0) { + if ( EMPTY_TRASH_DAYS == 0 ) + return wp_delete_post($postid); + + if ( !$post = wp_get_single_post($postid, ARRAY_A) ) + return $post; + + do_action('trash_post', $postid); + + $trash_meta = get_option('wp_trash_meta'); + if ( !is_array($trash_meta) ) + $trash_meta = array(); + $trash_meta['posts'][$postid]['status'] = $post['post_status']; + $trash_meta['posts'][$postid]['time'] = time(); + update_option('wp_trash_meta', $trash_meta); + + $post['post_status'] = 'trash'; + wp_insert_post($post); + + do_action('trashed_post', $postid); + + return $post; +} + +/** + * Removes a post or page from the Trash + * + * @since 2.9.0 + * @uses do_action() on 'untrash_post' before undeletion + * @uses do_action() on 'untrashed_post' after undeletion + * + * @param int $postid Post ID. + * @return mixed False on failure + */ +function wp_untrash_post($postid = 0) { + if (!$post = wp_get_single_post($postid, ARRAY_A)) + return $post; + + do_action('untrash_post', $postid); + + $post['post_status'] = 'draft'; + + $trash_meta = get_option('wp_trash_meta'); + if (is_array($trash_meta) && isset($trash_meta['posts'][$postid])) { + $post['post_status'] = $trash_meta['posts'][$postid]['status']; + unset($trash_meta['posts'][$postid]); + update_option('wp_trash_meta', $trash_meta); + } + + wp_insert_post($post); + + do_action('untrashed_post', $postid); + + return $post; +} + /** * Retrieve the list of categories for a post. * @@ -2586,6 +2662,15 @@ function wp_delete_attachment($postid) { if ( 'attachment' != $post->post_type ) return false; + + if ( 'trash' != $post->post_status ) + return wp_trash_post($postid); + + $trash_meta = get_option('wp_trash_meta'); + if ( is_array($trash_meta) && isset($trash_meta['posts'][$postid]) ) { + unset($trash_meta['posts'][$postid]); + update_option('wp_trash_meta', $trash_meta); + } $meta = wp_get_attachment_metadata( $postid ); $file = get_attached_file( $postid ); diff --git a/wp-includes/query.php b/wp-includes/query.php index c9f9655876..0747a0a8b0 100644 --- a/wp-includes/query.php +++ b/wp-includes/query.php @@ -2099,6 +2099,8 @@ class WP_Query { $p_status[] = "$wpdb->posts.post_status = 'private'"; if ( in_array( 'publish', $q_status ) ) $r_status[] = "$wpdb->posts.post_status = 'publish'"; + if ( in_array( 'trash', $q_status ) ) + $r_status[] = "$wpdb->posts.post_status = 'trash'"; if ( empty($q['perm'] ) || 'readable' != $q['perm'] ) { $r_status = array_merge($r_status, $p_status); diff --git a/wp-includes/script-loader.php b/wp-includes/script-loader.php index b7baa05892..f7fe9b79fb 100644 --- a/wp-includes/script-loader.php +++ b/wp-includes/script-loader.php @@ -60,7 +60,7 @@ function wp_default_scripts( &$scripts ) { $scripts->add( 'utils', "/wp-admin/js/utils$suffix.js", false, '20090102' ); - $scripts->add( 'common', "/wp-admin/js/common$suffix.js", array('jquery', 'hoverIntent', 'utils'), '20090720' ); + $scripts->add( 'common', "/wp-admin/js/common$suffix.js", array('jquery', 'hoverIntent', 'utils'), '20090730' ); $scripts->add_data( 'common', 'group', 1 ); $scripts->localize( 'common', 'commonL10n', array( 'warnDelete' => __("You are about to permanently delete the selected items.\n 'Cancel' to stop, 'OK' to delete."), @@ -204,7 +204,7 @@ function wp_default_scripts( &$scripts ) { 'upload_stopped' => __('Upload stopped.'), 'dismiss' => __('Dismiss'), 'crunching' => __('Crunching…'), - 'deleted' => __('Deleted'), + 'deleted' => __('Moved to Trash'), 'l10n_print_after' => 'try{convertEntities(swfuploadL10n);}catch(e){};' ) ); @@ -248,7 +248,7 @@ function wp_default_scripts( &$scripts ) { $scripts->add( 'user-profile', "/wp-admin/js/user-profile$suffix.js", array('jquery'), '20090514' ); $scripts->add_data( 'user-profile', 'group', 1 ); - $scripts->add( 'admin-comments', "/wp-admin/js/edit-comments$suffix.js", array('wp-lists', 'jquery-ui-resizable', 'quicktags'), '20090720' ); + $scripts->add( 'admin-comments', "/wp-admin/js/edit-comments$suffix.js", array('wp-lists', 'jquery-ui-resizable', 'quicktags'), '20090730' ); $scripts->add_data( 'admin-comments', 'group', 1 ); $scripts->localize( 'admin-comments', 'adminCommentsL10n', array( 'hotkeys_highlight_first' => isset($_GET['hotkeys_highlight_first']), diff --git a/wp-settings.php b/wp-settings.php index 1c49f8d095..ba7b9ec524 100644 --- a/wp-settings.php +++ b/wp-settings.php @@ -534,6 +534,12 @@ force_ssl_login(FORCE_SSL_LOGIN); if ( !defined( 'AUTOSAVE_INTERVAL' ) ) define( 'AUTOSAVE_INTERVAL', 60 ); +/** + * It is possible to define this in wp-config.php + * @since 2.9.0 + */ +if ( !defined( 'EMPTY_TRASH_DAYS' ) ) + define( 'EMPTY_TRASH_DAYS', 30 ); require (ABSPATH . WPINC . '/vars.php');