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
This commit is contained in:
azaozz
2009-07-30 13:39:34 +00:00
parent 190a148e6b
commit 39e4f05a15
29 changed files with 758 additions and 329 deletions

View File

@@ -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);