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

    r11749 r11807  
    5353        $location = explode('#', $location);
    5454        $location = $location[0] . '#postcustom';
    55     } elseif ($action == 'editattachment') {
    56         $location = 'attachments.php';
    5755    } else {
    5856        $location = add_query_arg( 'message', 1, get_edit_post_link( $page_ID, 'url' ) );
     
    8381    $post = get_post_to_edit($page_ID);
    8482
    85     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.') );
     83    if ( empty($post->ID) )
     84        wp_die( __('You attempted to edit a page that doesn’t exist. Perhaps it was deleted?') );
     85
     86    if ( !current_user_can('edit_page', $page_ID) )
     87        wp_die( __('You are not allowed to edit this page.') );
     88
     89    if ( 'trash' == $post->post_status )
     90        wp_die( __('You can’t edit this page because it is in the Trash. Please move it out of the Trash and try again.') );
    8791
    8892    if ( 'page' != $post->post_type ) {
     
    98102    wp_enqueue_script('word-count');
    99103
    100     if ( current_user_can('edit_page', $page_ID) ) {
    101         if ( $last = wp_check_post_lock( $post->ID ) ) {
    102             $last_user = get_userdata( $last );
    103             $last_user_name = $last_user ? $last_user->display_name : __('Somebody');
    104             $message = sprintf( __( 'Warning: %s is currently editing this page' ), esc_html( $last_user_name ) );
    105             $message = str_replace( "'", "\'", "<div class='error'><p>$message</p></div>" );
    106             add_action('admin_notices', create_function( '', "echo '$message';" ) );
    107         } else {
    108             wp_set_post_lock( $post->ID );
    109             wp_enqueue_script('autosave');
    110         }
    111     }
    112 
    113     if ( !current_user_can('edit_page', $page_ID) )
    114         die ( __('You are not allowed to edit this page.') );
     104    if ( $last = wp_check_post_lock( $post->ID ) ) {
     105        $last_user = get_userdata( $last );
     106        $last_user_name = $last_user ? $last_user->display_name : __('Somebody');
     107        $message = sprintf( __( 'Warning: %s is currently editing this page' ), esc_html( $last_user_name ) );
     108        $message = str_replace( "'", "\'", "<div class='error'><p>$message</p></div>" );
     109        add_action('admin_notices', create_function( '', "echo '$message';" ) );
     110    } else {
     111        wp_set_post_lock( $post->ID );
     112        wp_enqueue_script('autosave');
     113    }
    115114
    116115    include('edit-page-form.php');
     
    143142
    144143case 'trash':
    145     $post_id = (isset($_GET['post'])) ? intval($_GET['post']) : intval($_POST['post_ID']);
     144    $post_id = isset($_GET['post']) ? intval($_GET['post']) : intval($_POST['post_ID']);
    146145    check_admin_referer('trash-page_' . $post_id);
    147146
     
    152151
    153152    if ( !wp_trash_post($post_id) )
    154         wp_die( __('Error in removing from trash...') );
     153        wp_die( __('Error in moving to trash...') );
    155154
    156155    $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);
     156    if ( strpos($sendback, 'page.php') !== false )
     157        $sendback = admin_url('edit-pages.php?trashed=1');
     158    else
     159        $sendback = add_query_arg('trashed', 1, $sendback);
     160
    160161    wp_redirect($sendback);
    161162    exit();
     
    163164
    164165case 'untrash':
    165     $post_id = (isset($_GET['post'])) ? intval($_GET['post']) : intval($_POST['post_ID']);
     166    $post_id = isset($_GET['post']) ? intval($_GET['post']) : intval($_POST['post_ID']);
    166167    check_admin_referer('untrash-page_' . $post_id);
    167168
     
    169170
    170171    if ( !current_user_can('delete_page', $page_id) )
    171         wp_die( __('You are not allowed to remove this page form the trash.') );
     172        wp_die( __('You are not allowed to move this page out of the trash.') );
    172173
    173174    if ( !wp_untrash_post($post_id) )
    174         wp_die( __('Error in removing from trash...') );
     175        wp_die( __('Error in restoring from trash...') );
    175176
    176177    $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);
     178    if ( strpos($sendback, 'page.php') !== false )
     179        $sendback = admin_url('edit-pages.php?untrashed=1');
     180    else
     181        $sendback = add_query_arg('untrashed', 1, $sendback);
     182
    180183    wp_redirect($sendback);
    181184    exit();
     
    183186
    184187case 'delete':
    185     $page_id = (isset($_GET['post'])) ? intval($_GET['post']) : intval($_POST['post_ID']);
     188    $page_id = isset($_GET['post']) ? intval($_GET['post']) : intval($_POST['post_ID']);
    186189    check_admin_referer('delete-page_' .  $page_id);
    187190
     
    200203
    201204    $sendback = wp_get_referer();
    202     if (strpos($sendback, 'page.php') !== false) $sendback = admin_url('edit-pages.php?deleted=1');
    203     elseif (strpos($sendback, 'attachments.php') !== false) $sendback = admin_url('attachments.php');
    204     else $sendback = add_query_arg('deleted', 1, $sendback);
     205    if ( strpos($sendback, 'page.php') !== false )
     206        $sendback = admin_url('edit-pages.php?deleted=1');
     207    else
     208        $sendback = add_query_arg('deleted', 1, $sendback);
     209
    205210    wp_redirect($sendback);
    206211    exit();
Note: See TracChangeset for help on using the changeset viewer.