Make WordPress Core

Ticket #24246: 24246.2.patch

File 24246.2.patch, 4.3 KB (added by SergeyBiryukov, 11 years ago)
  • wp-admin/post.php

     
    133133                exit();
    134134        }
    135135
    136         if ( empty($post->ID) )
    137                 wp_die( __('You attempted to edit an item that doesn’t exist. Perhaps it was deleted?') );
     136        if ( ! $post )
     137                wp_die( __( 'You attempted to edit an item that doesn’t exist. Perhaps it was deleted?' ) );
    138138
    139         if ( null == $post_type_object )
    140                 wp_die( __('Unknown post type.') );
     139        if ( ! $post_type_object )
     140                wp_die( __( 'Unknown post type.' ) );
    141141
    142         if ( !current_user_can($post_type_object->cap->edit_post, $post_id) )
    143                 wp_die( __('You are not allowed to edit this item.') );
     142        if ( ! current_user_can( $post_type_object->cap->edit_post, $post_id ) )
     143                wp_die( __( 'You are not allowed to edit this item.' ) );
    144144
    145145        if ( 'trash' == $post->post_status )
    146                 wp_die( __('You can’t edit this item because it is in the Trash. Please restore it and try again.') );
     146                wp_die( __( 'You can’t edit this item because it is in the Trash. Please restore it and try again.' ) );
    147147
    148         if ( !empty( $_GET['get-post-lock'] ) ) {
     148        if ( ! empty( $_GET['get-post-lock'] ) ) {
    149149                wp_set_post_lock( $post_id );
    150150                wp_redirect( get_edit_post_link( $post_id, 'url' ) );
    151151                exit();
     
    220220case 'trash':
    221221        check_admin_referer('trash-post_' . $post_id);
    222222
    223         if ( !current_user_can($post_type_object->cap->delete_post, $post_id) )
    224                 wp_die( __('You are not allowed to move this item to the Trash.') );
     223        if ( ! $post )
     224                wp_die( __( 'The item you are trying to move to the Trash no longer exists.' ) );
    225225
     226        if ( ! $post_type_object )
     227                wp_die( __( 'Unknown post type.' ) );
     228
     229        if ( ! current_user_can( $post_type_object->cap->delete_post, $post_id ) )
     230                wp_die( __( 'You are not allowed to move this item to the Trash.' ) );
     231
    226232        if ( $user_id = wp_check_post_lock( $post_id ) ) {
    227233                $user = get_userdata( $user_id );
    228234                wp_die( sprintf( __( 'You cannot move this item to the Trash. %s is currently editing.' ), $user->display_name ) );
    229235        }
    230236
    231         if ( ! wp_trash_post($post_id) )
    232                 wp_die( __('Error in moving to Trash.') );
     237        if ( ! wp_trash_post( $post_id ) )
     238                wp_die( __( 'Error in moving to Trash.' ) );
    233239
    234240        wp_redirect( add_query_arg( array('trashed' => 1, 'ids' => $post_id), $sendback ) );
    235241        exit();
     
    238244case 'untrash':
    239245        check_admin_referer('untrash-post_' . $post_id);
    240246
    241         if ( !current_user_can($post_type_object->cap->delete_post, $post_id) )
    242                 wp_die( __('You are not allowed to move this item out of the Trash.') );
     247        if ( ! $post )
     248                wp_die( __( 'The item you are trying to restore from the Trash no longer exists.' ) );
    243249
    244         if ( ! wp_untrash_post($post_id) )
    245                 wp_die( __('Error in restoring from Trash.') );
     250        if ( ! $post_type_object )
     251                wp_die( __( 'Unknown post type.' ) );
    246252
     253        if ( ! current_user_can( $post_type_object->cap->delete_post, $post_id ) )
     254                wp_die( __( 'You are not allowed to move this item out of the Trash.' ) );
     255
     256        if ( ! wp_untrash_post( $post_id ) )
     257                wp_die( __( 'Error in restoring from Trash.' ) );
     258
    247259        wp_redirect( add_query_arg('untrashed', 1, $sendback) );
    248260        exit();
    249261        break;
     
    251263case 'delete':
    252264        check_admin_referer('delete-post_' . $post_id);
    253265
    254         if ( !current_user_can($post_type_object->cap->delete_post, $post_id) )
    255                 wp_die( __('You are not allowed to delete this item.') );
     266        if ( ! $post )
     267                wp_die( __( 'This item has already been deleted.' ) );
    256268
    257         $force = !EMPTY_TRASH_DAYS;
     269        if ( ! $post_type_object )
     270                wp_die( __( 'Unknown post type.' ) );
     271
     272        if ( ! current_user_can( $post_type_object->cap->delete_post, $post_id ) )
     273                wp_die( __( 'You are not allowed to delete this item.' ) );
     274
     275        $force = ! EMPTY_TRASH_DAYS;
    258276        if ( $post->post_type == 'attachment' ) {
    259                 $force = ( $force || !MEDIA_TRASH );
    260                 if ( ! wp_delete_attachment($post_id, $force) )
    261                         wp_die( __('Error in deleting.') );
     277                $force = ( $force || ! MEDIA_TRASH );
     278                if ( ! wp_delete_attachment( $post_id, $force ) )
     279                        wp_die( __( 'Error in deleting.' ) );
    262280        } else {
    263                 if ( !wp_delete_post($post_id, $force) )
    264                         wp_die( __('Error in deleting.') );
     281                if ( ! wp_delete_post( $post_id, $force ) )
     282                        wp_die( __( 'Error in deleting.' ) );
    265283        }
    266284
    267285        wp_redirect( add_query_arg('deleted', 1, $sendback) );