Make WordPress Core

Changeset 11807


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

Location:
trunk/wp-admin
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/edit-pages.php

    r11779 r11807  
    1414
    1515// Handle bulk actions
    16 if ( isset($_GET['doaction']) || isset($_GET['doaction2']) || isset($_GET['delete_all']) || isset($_GET['delete_all2']) ) {
     16if ( isset($_GET['doaction']) || isset($_GET['doaction2']) || isset($_GET['delete_all']) || isset($_GET['delete_all2']) || isset($_GET['bulk_edit']) ) {
    1717        check_admin_referer('bulk-pages');
    18        
    19         if (isset($_GET['delete_all']) || isset($_GET['delete_all2'])) {
    20                 $post_status = $wpdb->escape($_GET['post_status']);
    21                 $post_ids = $wpdb->get_col( "SELECT ID FROM $wpdb->posts WHERE post_type='page' AND post_status = '$post_status'" );
     18        $sendback = wp_get_referer();
     19
     20        if ( strpos($sendback, 'page.php') !== false )
     21                $sendback = admin_url('page-new.php');
     22
     23        if ( isset($_GET['delete_all']) || isset($_GET['delete_all2']) ) {
     24                $post_status = preg_replace('/[^a-z0-9_-]+/i', '', $_GET['post_status']);
     25                $post_ids = $wpdb->get_col( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_type='page' AND post_status = %s", $post_status ) );
    2226                $doaction = 'delete';
    23         } elseif (($_GET['action'] != -1 || $_GET['action2'] != -1) && isset($_GET['post'])) {
    24                 $post_ids = $_GET['post'];
     27        } elseif ( ($_GET['action'] != -1 || $_GET['action2'] != -1) && isset($_GET['post']) ) {
     28                $post_ids = array_map( 'intval', (array) $_GET['post'] );
    2529                $doaction = ($_GET['action'] != -1) ? $_GET['action'] : $_GET['action2'];
    26         } else wp_redirect($_SERVER['HTTP_REFERER']);
     30        } else {
     31                wp_redirect( admin_url('edit-pages.php') );
     32        }
    2733
    2834        switch ( $doaction ) {
     
    3844                                $trashed++;
    3945                        }
     46                        $sendback = add_query_arg('trashed', $trashed, $sendback);
    4047                        break;
    4148                case 'untrash':
     
    4350                        foreach( (array) $post_ids as $post_id ) {
    4451                                if ( !current_user_can('delete_page', $post_id) )
    45                                         wp_die( __('You are not allowed to remove this page from the trash.') );
     52                                        wp_die( __('You are not allowed to restore this page from the trash.') );
    4653
    4754                                if ( !wp_untrash_post($post_id) )
    48                                         wp_die( __('Error in removing from trash...') );
     55                                        wp_die( __('Error in restoring from trash...') );
    4956                               
    5057                                $untrashed++;
    5158                        }
     59                        $sendback = add_query_arg('untrashed', $untrashed, $sendback);
    5260                        break;
    5361                case 'delete':
    5462                        $deleted = 0;
    55                         foreach( (array) $post_ids as $post_id_del ) {
    56                                 $post_del = & get_post($post_id_del);
    57 
    58                                 if ( !current_user_can('delete_page', $post_id_del) )
     63                        foreach( (array) $post_ids as $post_id ) {
     64                                $post_del = & get_post($post_id);
     65
     66                                if ( !current_user_can('delete_page', $post_id) )
    5967                                        wp_die( __('You are not allowed to delete this page.') );
    6068
    6169                                if ( $post_del->post_type == 'attachment' ) {
    62                                         if ( ! wp_delete_attachment($post_id_del) )
     70                                        if ( ! wp_delete_attachment($post_id) )
    6371                                                wp_die( __('Error in deleting...') );
    6472                                } else {
    65                                         if ( !wp_delete_post($post_id_del) )
     73                                        if ( !wp_delete_post($post_id) )
    6674                                                wp_die( __('Error in deleting...') );
    6775                                }
    6876                                $deleted++;
    6977                        }
     78                        $sendback = add_query_arg('deleted', $deleted, $sendback);
    7079                        break;
    7180                case 'edit':
    72                         if ( -1 == $_GET['_status'] ) {
    73                                 $_GET['post_status'] = null;
    74                                 unset($_GET['_status'], $_GET['post_status']);
    75                         } else {
    76                                 $_GET['post_status'] = $_GET['_status'];
     81                        $_GET['post_type'] = 'page';
     82                        $done = bulk_edit_posts($_GET);
     83
     84                        if ( is_array($done) ) {
     85                                $done['updated'] = count( $done['updated'] );
     86                                $done['skipped'] = count( $done['skipped'] );
     87                                $done['locked'] = count( $done['locked'] );
     88                                $sendback = add_query_arg( $done, $sendback );
    7789                        }
    78 
    79                         $done = bulk_edit_posts($_GET);
    8090                        break;
    8191        }
    8292
    83         $sendback = wp_get_referer();
    84         if (strpos($sendback, 'page.php') !== false) $sendback = admin_url('page-new.php');
    85         elseif (strpos($sendback, 'attachments.php') !== false) $sendback = admin_url('attachments.php');
    86         if ( isset($done) ) {
    87                 $done['updated'] = count( $done['updated'] );
    88                 $done['skipped'] = count( $done['skipped'] );
    89                 $done['locked'] = count( $done['locked'] );
    90                 $sendback = add_query_arg( $done, $sendback );
    91         }
    92         if ( isset($deleted) )
    93                 $sendback = add_query_arg('deleted', $deleted, $sendback);
    94         elseif ( isset($trashed) )
    95                 $sendback = add_query_arg('trashed', $trashed, $sendback);
    96         elseif ( isset($untrashed) )
    97                 $sendback = add_query_arg('untrashed', $untrashed, $sendback);
     93        if ( isset($_GET['action']) )
     94                $sendback = remove_query_arg( array('action', 'action2', 'post_parent', 'page_template', 'post_author', 'comment_status', 'ping_status', '_status',  'post', 'bulk_edit', 'post_view', 'post_type'), $sendback );
     95
    9896        wp_redirect($sendback);
    9997        exit();
     
    182180endif; ?>
    183181
    184 <form id="posts-filter" action="" method="get">
     182<form id="posts-filter" action="<?php echo admin_url('edit-pages.php'); ?>" method="get">
    185183<ul class="subsubsub">
    186184<?php
  • trunk/wp-admin/edit.php

    r11779 r11807  
    2222
    2323// Handle bulk actions
    24 if ( isset($_GET['doaction']) || isset($_GET['doaction2']) || isset($_GET['delete_all']) || isset($_GET['delete_all2']) ) {
     24if ( isset($_GET['doaction']) || isset($_GET['doaction2']) || isset($_GET['delete_all']) || isset($_GET['delete_all2']) || isset($_GET['bulk_edit']) ) {
    2525        check_admin_referer('bulk-posts');
    26        
     26        $sendback = wp_get_referer();
     27
     28        if ( strpos($sendback, 'post.php') !== false )
     29                $sendback = admin_url('post-new.php');
     30
    2731        if ( isset($_GET['delete_all']) || isset($_GET['delete_all2']) ) {
    28                 $post_status = $wpdb->escape($_GET['post_status']);
    29                 $post_ids = $wpdb->get_col( "SELECT ID FROM $wpdb->posts WHERE post_type='post' AND post_status = '$post_status'" );
     32                $post_status = preg_replace('/[^a-z0-9_-]+/i', '', $_GET['post_status']);
     33                $post_ids = $wpdb->get_col( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_type='post' AND post_status = %s", $post_status ) );
    3034                $doaction = 'delete';
    31         } elseif (($_GET['action'] != -1 || $_GET['action2'] != -1) && isset($_GET['post'])) {
    32                 $post_ids = $_GET['post'];
     35        } elseif ( ($_GET['action'] != -1 || $_GET['action2'] != -1) && isset($_GET['post']) ) {
     36                $post_ids = array_map( 'intval', (array) $_GET['post'] );
    3337                $doaction = ($_GET['action'] != -1) ? $_GET['action'] : $_GET['action2'];
    34         } else wp_redirect($_SERVER['HTTP_REFERER']);
    35        
     38        } else {
     39                wp_redirect( admin_url('edit.php') );
     40        }
     41
    3642        switch ( $doaction ) {
    3743                case 'trash':
    3844                        $trashed = 0;
    3945                        foreach( (array) $post_ids as $post_id ) {
    40                                 $post_del = & get_post($post_id);
    41 
    42                                 if ( !current_user_can('delete_post', $post_id_del) )
     46                                if ( !current_user_can('delete_post', $post_id) )
    4347                                        wp_die( __('You are not allowed to move this post to the trash.') );
    4448
     
    4852                                $trashed++;
    4953                        }
     54                        $sendback = add_query_arg('trashed', $trashed, $sendback);
    5055                        break;
    5156                case 'untrash':
    5257                        $untrashed = 0;
    5358                        foreach( (array) $post_ids as $post_id ) {
    54                                 $post_del = & get_post($post_id);
    55 
    56                                 if ( !current_user_can('delete_post', $post_id_del) )
    57                                         wp_die( __('You are not allowed to remove this post from the trash.') );
     59                                if ( !current_user_can('delete_post', $post_id) )
     60                                        wp_die( __('You are not allowed to restore this post from the trash.') );
    5861
    5962                                if ( !wp_untrash_post($post_id) )
    60                                         wp_die( __('Error in removing from trash...') );
     63                                        wp_die( __('Error in restoring from trash...') );
    6164                               
    6265                                $untrashed++;
    6366                        }
     67                        $sendback = add_query_arg('untrashed', $untrashed, $sendback);
    6468                        break;
    6569                case 'delete':
    6670                        $deleted = 0;
    67                         foreach( (array) $post_ids as $post_id_del ) {
    68                                 $post_del = & get_post($post_id_del);
    69 
    70                                 if ( !current_user_can('delete_post', $post_id_del) )
     71                        foreach( (array) $post_ids as $post_id ) {
     72                                $post_del = & get_post($post_id);
     73
     74                                if ( !current_user_can('delete_post', $post_id) )
    7175                                        wp_die( __('You are not allowed to delete this post.') );
    7276
    7377                                if ( $post_del->post_type == 'attachment' ) {
    74                                         if ( ! wp_delete_attachment($post_id_del) )
     78                                        if ( ! wp_delete_attachment($post_id) )
    7579                                                wp_die( __('Error in deleting...') );
    7680                                } else {
    77                                         if ( !wp_delete_post($post_id_del) )
     81                                        if ( !wp_delete_post($post_id) )
    7882                                                wp_die( __('Error in deleting...') );
    7983                                }
    8084                                $deleted++;
    8185                        }
     86                        $sendback = add_query_arg('deleted', $deleted, $sendback);
    8287                        break;
    8388                case 'edit':
    84                         if ( -1 == $_GET['_status'] ) {
    85                                 $_GET['post_status'] = null;
    86                                 unset($_GET['_status'], $_GET['post_status']);
    87                         } else {
    88                                 $_GET['post_status'] = $_GET['_status'];
     89                        $done = bulk_edit_posts($_GET);
     90
     91                        if ( is_array($done) ) {
     92                                $done['updated'] = count( $done['updated'] );
     93                                $done['skipped'] = count( $done['skipped'] );
     94                                $done['locked'] = count( $done['locked'] );
     95                                $sendback = add_query_arg( $done, $sendback );
    8996                        }
    90 
    91                         $done = bulk_edit_posts($_GET);
    9297                        break;
    9398        }
    9499
    95         $sendback = wp_get_referer();
    96         if ( strpos($sendback, 'post.php') !== false ) $sendback = admin_url('post-new.php');
    97         elseif ( strpos($sendback, 'attachments.php') !== false ) $sendback = admin_url('attachments.php');
    98         if ( isset($done) ) {
    99                 $done['updated'] = count( $done['updated'] );
    100                 $done['skipped'] = count( $done['skipped'] );
    101                 $done['locked'] = count( $done['locked'] );
    102                 $sendback = add_query_arg( $done, $sendback );
    103         }
    104         if ( isset($deleted) )
    105                 $sendback = add_query_arg('deleted', $deleted, $sendback);
    106         elseif ( isset($trashed) )
    107                 $sendback = add_query_arg('trashed', $trashed, $sendback);
    108         elseif ( isset($untrashed) )
    109                 $sendback = add_query_arg('untrashed', $untrashed, $sendback);
     100        if ( isset($_GET['action']) )
     101                $sendback = remove_query_arg( array('action', 'action2', 'cat', 'tags_input', 'post_author', 'comment_status', 'ping_status', '_status',  'post', 'bulk_edit', 'post_view', 'post_type'), $sendback );
     102
    110103        wp_redirect($sendback);
    111104        exit();
     
    180173<?php } ?>
    181174
    182 <form id="posts-filter" action="" method="get">
     175<form id="posts-filter" action="<?php echo admin_url('edit.php'); ?>" method="get">
    183176
    184177<ul class="subsubsub">
  • trunk/wp-admin/includes/post.php

    r11796 r11807  
    237237        }
    238238
     239        if ( -1 == $post_data['_status'] ) {
     240                $post_data['post_status'] = null;
     241                unset($post_data['post_status']);
     242        } else {
     243                $post_data['post_status'] = $post_data['_status'];
     244        }
     245        unset($post_data['_status']);
     246
    239247        $post_IDs = array_map( 'intval', (array) $post_data['post'] );
    240248
     
    299307                $updated[] = wp_update_post( $post_data );
    300308
    301                 if ( current_user_can( 'edit_others_posts' ) && isset( $post_data['sticky'] ) ) {
     309                if ( isset( $post_data['sticky'] ) && current_user_can( 'edit_others_posts' ) ) {
    302310                        if ( 'sticky' == $post_data['sticky'] )
    303311                                stick_post( $post_ID );
  • 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&#8217;t exist. Perhaps it was deleted?') );
    86         if ( $post->post_status == 'trash' ) wp_die( __('You can&#8217;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&#8217;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&#8217;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();
  • 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&#8217;t exist. Perhaps it was deleted?') );
    119         if ( $post->post_status == 'trash' ) wp_die( __('You can&#8217;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&#8217;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&#8217;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();
  • trunk/wp-admin/upload.php

    r11749 r11807  
    1212wp_enqueue_script( 'jquery-ui-draggable' );
    1313
    14 if (!current_user_can('upload_files'))
     14if ( !current_user_can('upload_files') )
    1515        wp_die(__('You do not have permission to upload files.'));
    1616
    17 if ( isset($_GET['find_detached'] ) ) {
     17if ( isset($_GET['find_detached']) ) {
    1818        check_admin_referer('bulk-media');
    1919
    20         if ( ! current_user_can('edit_posts') )
     20        if ( !current_user_can('edit_posts') )
    2121                wp_die( __('You are not allowed to scan for lost attachments.') );
    2222
     
    100100                        foreach( (array) $post_ids as $post_id ) {
    101101                                if ( !current_user_can('delete_post', $post_id) )
    102                                         wp_die( __('You are not allowed to remove this post from the trash.') );
     102                                        wp_die( __('You are not allowed to move this post out of the trash.') );
    103103                               
    104104                                if ( !wp_untrash_post($post_id) )
Note: See TracChangeset for help on using the changeset viewer.