Make WordPress Core


Ignore:
Timestamp:
08/12/2009 10:57:15 AM (17 years ago)
Author:
azaozz
Message:

Fix bulk edit, some cleanup and message fixes for moving in/out of the trash, see #4529

File:
1 edited

Legend:

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

    r11749 r11807  
    5656        $location = explode('#', $location);
    5757        $location = $location[0] . '#postcustom';
    58     } elseif ($action == 'editattachment') {
    59         $location = 'attachments.php';
    6058    } elseif ( 'post-quickpress-save-cont' == $_POST['action'] ) {
    6159        $location = "post.php?action=edit&post=$post_ID&message=7";
     
    116114    $post = get_post($post_ID);
    117115
    118     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.') );
     116    if ( empty($post->ID) )
     117        wp_die( __('You attempted to edit a post that doesn’t exist. Perhaps it was deleted?') );
     118
     119    if ( !current_user_can('edit_post', $post_ID) )
     120        wp_die( __('You are not allowed to edit this post.') );
     121
     122    if ( 'trash' == $post->post_status )
     123        wp_die( __('You can’t edit this post because it is in the Trash. Please restore it and try again.') );
    120124
    121125    if ( 'post' != $post->post_type ) {
     
    133137    enqueue_comment_hotkeys_js();
    134138
    135     if ( current_user_can('edit_post', $post_ID) ) {
    136         if ( $last = wp_check_post_lock( $post->ID ) ) {
    137             $last_user = get_userdata( $last );
    138             $last_user_name = $last_user ? $last_user->display_name : __('Somebody');
    139             $message = sprintf( __( 'Warning: %s is currently editing this post' ), esc_html( $last_user_name ) );
    140             $message = str_replace( "'", "\'", "<div class='error'><p>$message</p></div>" );
    141             add_action('admin_notices', create_function( '', "echo '$message';" ) );
    142         } else {
    143             wp_set_post_lock( $post->ID );
    144             wp_enqueue_script('autosave');
    145         }
     139    if ( $last = wp_check_post_lock( $post->ID ) ) {
     140        $last_user = get_userdata( $last );
     141        $last_user_name = $last_user ? $last_user->display_name : __('Somebody');
     142        $message = sprintf( __( 'Warning: %s is currently editing this post' ), esc_html( $last_user_name ) );
     143        $message = str_replace( "'", "\'", "<div class='error'><p>$message</p></div>" );
     144        add_action('admin_notices', create_function( '', "echo '$message';" ) );
     145    } else {
     146        wp_set_post_lock( $post->ID );
     147        wp_enqueue_script('autosave');
    146148    }
    147149
    148150    $title = __('Edit Post');
    149 
    150     if ( !current_user_can('edit_post', $post_ID) )
    151         die ( __('You are not allowed to edit this post.') );
    152 
    153151    $post = get_post_to_edit($post_ID);
    154152
     
    184182
    185183case 'trash':
    186     $post_id = (isset($_GET['post'])) ? intval($_GET['post']) : intval($_POST['post_ID']);
     184    $post_id = isset($_GET['post']) ? intval($_GET['post']) : intval($_POST['post_ID']);
    187185    check_admin_referer('trash-post_' . $post_id);
    188186
     
    196194
    197195    $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);
     196    if ( strpos($sendback, 'post.php') !== false )
     197        $sendback = admin_url('edit.php?trashed=1');
     198    else
     199        $sendback = add_query_arg('trashed', 1, $sendback);
     200
    201201    wp_redirect($sendback);
    202202    exit();
     
    204204
    205205case 'untrash':
    206     $post_id = (isset($_GET['post'])) ? intval($_GET['post']) : intval($_POST['post_ID']);
     206    $post_id = isset($_GET['post']) ? intval($_GET['post']) : intval($_POST['post_ID']);
    207207    check_admin_referer('untrash-post_' . $post_id);
    208208
     
    210210
    211211    if ( !current_user_can('delete_post', $post_id) )
    212         wp_die( __('You are not allowed to remove this post from the trash.') );
     212        wp_die( __('You are not allowed to move this post out of the trash.') );
    213213
    214214    if ( ! wp_untrash_post($post_id) )
    215         wp_die( __('Error in removing from trash...') );
     215        wp_die( __('Error in restoring from trash...') );
    216216
    217217    $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);
     218    if ( strpos($sendback, 'post.php') !== false )
     219        $sendback = admin_url('edit.php?untrashed=1');
     220    else
     221        $sendback = add_query_arg('untrashed', 1, $sendback);
     222
    221223    wp_redirect($sendback);
    222224    exit();
     
    241243
    242244    $sendback = wp_get_referer();
    243     if (strpos($sendback, 'post.php') !== false) $sendback = admin_url('edit.php?deleted=1');
    244     elseif (strpos($sendback, 'attachments.php') !== false) $sendback = admin_url('attachments.php');
    245     else $sendback = add_query_arg('deleted', 1, $sendback);
     245    if ( strpos($sendback, 'post.php') !== false )
     246        $sendback = admin_url('edit.php?deleted=1');
     247    else
     248        $sendback = add_query_arg('deleted', 1, $sendback);
     249
    246250    wp_redirect($sendback);
    247251    exit();
Note: See TracChangeset for help on using the changeset viewer.