Make WordPress Core


Ignore:
Timestamp:
07/30/2009 01:39:34 PM (15 years ago)
Author:
azaozz
Message:

Trash status updates for posts, pages, comments and attachments, props caesarsgrunt, see #4529

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/post.php

    r11380 r11749  
    117117
    118118    if ( empty($post->ID) ) wp_die( __('You attempted to edit a post that doesn’t exist. Perhaps it was deleted?') );
     119    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.') );
    119120
    120121    if ( 'post' != $post->post_type ) {
     
    182183    break;
    183184
     185case 'trash':
     186    $post_id = (isset($_GET['post']))  ? intval($_GET['post']) : intval($_POST['post_ID']);
     187    check_admin_referer('trash-post_' . $post_id);
     188
     189    $post = & get_post($post_id);
     190
     191    if ( !current_user_can('delete_post', $post_id) )
     192        wp_die( __('You are not allowed to move this post to the trash.') );
     193
     194    if ( ! wp_trash_post($post_id) )
     195        wp_die( __('Error in moving to trash...') );
     196
     197    $sendback = wp_get_referer();
     198    if (strpos($sendback, 'post.php') !== false) $sendback = admin_url('edit.php?trashed=1');
     199    elseif (strpos($sendback, 'attachments.php') !== false) $sendback = admin_url('attachments.php');
     200    else $sendback = add_query_arg('trashed', 1, $sendback);
     201    wp_redirect($sendback);
     202    exit();
     203    break;
     204
     205case 'untrash':
     206    $post_id = (isset($_GET['post']))  ? intval($_GET['post']) : intval($_POST['post_ID']);
     207    check_admin_referer('untrash-post_' . $post_id);
     208
     209    $post = & get_post($post_id);
     210
     211    if ( !current_user_can('delete_post', $post_id) )
     212        wp_die( __('You are not allowed to remove this post from the trash.') );
     213
     214    if ( ! wp_untrash_post($post_id) )
     215        wp_die( __('Error in removing from trash...') );
     216
     217    $sendback = wp_get_referer();
     218    if (strpos($sendback, 'post.php') !== false) $sendback = admin_url('edit.php?untrashed=1');
     219    elseif (strpos($sendback, 'attachments.php') !== false) $sendback = admin_url('attachments.php');
     220    else $sendback = add_query_arg('untrashed', 1, $sendback);
     221    wp_redirect($sendback);
     222    exit();
     223    break;
     224
    184225case 'delete':
    185226    $post_id = (isset($_GET['post']))  ? intval($_GET['post']) : intval($_POST['post_ID']);
Note: See TracChangeset for help on using the changeset viewer.