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/page.php

    r11380 r11749  
    8484
    8585    if ( empty($post->ID) ) wp_die( __('You attempted to edit a page that doesn’t exist. Perhaps it was deleted?') );
     86    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.') );
    8687
    8788    if ( 'page' != $post->post_type ) {
     
    141142    break;
    142143
     144case 'trash':
     145    $post_id = (isset($_GET['post']))  ? intval($_GET['post']) : intval($_POST['post_ID']);
     146    check_admin_referer('trash-page_' . $post_id);
     147
     148    $post = & get_post($post_id);
     149
     150    if ( !current_user_can('delete_page', $page_id) )
     151        wp_die( __('You are not allowed to move this page to the trash.') );
     152
     153    if ( !wp_trash_post($post_id) )
     154        wp_die( __('Error in removing from trash...') );
     155
     156    $sendback = wp_get_referer();
     157    if (strpos($sendback, 'page.php') !== false) $sendback = admin_url('edit-pages.php?trashed=1');
     158    elseif (strpos($sendback, 'attachments.php') !== false) $sendback = admin_url('attachments.php');
     159    else $sendback = add_query_arg('trashed', 1, $sendback);
     160    wp_redirect($sendback);
     161    exit();
     162    break;
     163
     164case 'untrash':
     165    $post_id = (isset($_GET['post']))  ? intval($_GET['post']) : intval($_POST['post_ID']);
     166    check_admin_referer('untrash-page_' . $post_id);
     167
     168    $post = & get_post($post_id);
     169
     170    if ( !current_user_can('delete_page', $page_id) )
     171        wp_die( __('You are not allowed to remove this page form the trash.') );
     172
     173    if ( !wp_untrash_post($post_id) )
     174        wp_die( __('Error in removing from trash...') );
     175
     176    $sendback = wp_get_referer();
     177    if (strpos($sendback, 'page.php') !== false) $sendback = admin_url('edit-pages.php?untrashed=1');
     178    elseif (strpos($sendback, 'attachments.php') !== false) $sendback = admin_url('attachments.php');
     179    else $sendback = add_query_arg('untrashed', 1, $sendback);
     180    wp_redirect($sendback);
     181    exit();
     182    break;
     183
    143184case 'delete':
    144185    $page_id = (isset($_GET['post']))  ? intval($_GET['post']) : intval($_POST['post_ID']);
Note: See TracChangeset for help on using the changeset viewer.