Make WordPress Core

Ticket #16165: 16165.diff

File 16165.diff, 3.0 KB (added by solarissmoke, 13 years ago)
  • wp-admin/upload.php

     
    3636                        $location = remove_query_arg( array( 'trashed', 'untrashed', 'deleted', 'message', 'ids', 'posted' ), $referer );
    3737        }
    3838
     39        $errors = array();
    3940        switch ( $doaction ) {
    4041                case 'find_detached':
    4142                        if ( !current_user_can('edit_posts') )
     
    9293                case 'trash':
    9394                        foreach ( (array) $post_ids as $post_id ) {
    9495                                if ( !current_user_can( 'delete_post', $post_id ) )
    95                                         wp_die( __( 'You are not allowed to move this post to the trash.' ) );
     96                                        $errors[] = sprintf( __( 'You are not allowed to move the item %s to the trash.' ), get_the_title( $post_id ) );
    9697
    9798                                if ( !wp_trash_post( $post_id ) )
    98                                         wp_die( __( 'Error in moving to trash...' ) );
     99                                        $errors[] = sprintf( __( 'Error in moving the item %s to the trash.' ), get_the_title( $post_id ) );
    99100                        }
     101                       
     102                        if( ! empty( $errors ) ) {
     103                                $wp_err = new WP_Error( 'bulk_media_trash_error' );
     104                                foreach( $errors as $err )
     105                                        $wp_err->add( 'bulk_media_trash_error', $err );
     106                                wp_die( $wp_err );
     107                        }
     108                               
    100109                        $location = add_query_arg( array( 'trashed' => count( $post_ids ), 'ids' => join( ',', $post_ids ) ), $location );
    101110                        break;
    102111                case 'untrash':
    103112                        foreach ( (array) $post_ids as $post_id ) {
    104113                                if ( !current_user_can( 'delete_post', $post_id ) )
    105                                         wp_die( __( 'You are not allowed to move this post out of the trash.' ) );
     114                                        $errors[] = sprintf( __( 'You are not allowed to move the item %s out of the trash.' ), get_the_title( $post_id ) );
    106115
    107116                                if ( !wp_untrash_post( $post_id ) )
    108                                         wp_die( __( 'Error in restoring from trash...' ) );
     117                                        $errors[] = sprintf( __( 'Error in restoring the item %s from the trash.' ), get_the_title( $post_id ) );
    109118                        }
     119                       
     120                        if( ! empty( $errors ) ) {
     121                                $wp_err = new WP_Error( 'bulk_media_untrash_error' );
     122                                foreach( $errors as $err )
     123                                        $wp_err->add( 'bulk_media_untrash_error', $err );
     124                                wp_die( $wp_err );
     125                        }
     126                               
    110127                        $location = add_query_arg( 'untrashed', count( $post_ids ), $location );
    111128                        break;
    112129                case 'delete':
    113130                        foreach ( (array) $post_ids as $post_id_del ) {
     131                                if( get_post( $post_id_del ) )
     132                                        continue;
     133                               
    114134                                if ( !current_user_can( 'delete_post', $post_id_del ) )
    115                                         wp_die( __( 'You are not allowed to delete this post.' ) );
     135                                        $errors[] = sprintf( __( 'You are not allowed to delete the item %s.' ), get_the_title( $post_id_del ) );
    116136
    117137                                if ( !wp_delete_attachment( $post_id_del ) )
    118                                         wp_die( __( 'Error in deleting...' ) );
     138                                        $errors[] = sprintf( __( 'Error in deleting the item %s.' ), get_the_title( $post_id_del ) );
    119139                        }
     140                       
     141                        if( ! empty( $errors ) ) {
     142                                $wp_err = new WP_Error( 'bulk_media_delete_error' );
     143                                foreach( $errors as $err )
     144                                        $wp_err->add( 'bulk_media_delete_error', $err );
     145                                wp_die( $wp_err );
     146                        }
     147                       
    120148                        $location = add_query_arg( 'deleted', count( $post_ids ), $location );
    121149                        break;
    122150        }