| 1 | Index: wp-admin/upload.php |
|---|
| 2 | =================================================================== |
|---|
| 3 | --- wp-admin/upload.php (revision 17378) |
|---|
| 4 | +++ wp-admin/upload.php (working copy) |
|---|
| 5 | @@ -36,6 +36,7 @@ |
|---|
| 6 | $location = remove_query_arg( array( 'trashed', 'untrashed', 'deleted', 'message', 'ids', 'posted' ), $referer ); |
|---|
| 7 | } |
|---|
| 8 | |
|---|
| 9 | + $errors = array(); |
|---|
| 10 | switch ( $doaction ) { |
|---|
| 11 | case 'find_detached': |
|---|
| 12 | if ( !current_user_can('edit_posts') ) |
|---|
| 13 | @@ -92,31 +93,58 @@ |
|---|
| 14 | case 'trash': |
|---|
| 15 | foreach ( (array) $post_ids as $post_id ) { |
|---|
| 16 | if ( !current_user_can( 'delete_post', $post_id ) ) |
|---|
| 17 | - wp_die( __( 'You are not allowed to move this post to the trash.' ) ); |
|---|
| 18 | + $errors[] = sprintf( __( 'You are not allowed to move the item %s to the trash.' ), get_the_title( $post_id ) ); |
|---|
| 19 | |
|---|
| 20 | if ( !wp_trash_post( $post_id ) ) |
|---|
| 21 | - wp_die( __( 'Error in moving to trash...' ) ); |
|---|
| 22 | + $errors[] = sprintf( __( 'Error in moving the item %s to the trash.' ), get_the_title( $post_id ) ); |
|---|
| 23 | } |
|---|
| 24 | + |
|---|
| 25 | + if( ! empty( $errors ) ) { |
|---|
| 26 | + $wp_err = new WP_Error( 'bulk_media_trash_error' ); |
|---|
| 27 | + foreach( $errors as $err ) |
|---|
| 28 | + $wp_err->add( 'bulk_media_trash_error', $err ); |
|---|
| 29 | + wp_die( $wp_err ); |
|---|
| 30 | + } |
|---|
| 31 | + |
|---|
| 32 | $location = add_query_arg( array( 'trashed' => count( $post_ids ), 'ids' => join( ',', $post_ids ) ), $location ); |
|---|
| 33 | break; |
|---|
| 34 | case 'untrash': |
|---|
| 35 | foreach ( (array) $post_ids as $post_id ) { |
|---|
| 36 | if ( !current_user_can( 'delete_post', $post_id ) ) |
|---|
| 37 | - wp_die( __( 'You are not allowed to move this post out of the trash.' ) ); |
|---|
| 38 | + $errors[] = sprintf( __( 'You are not allowed to move the item %s out of the trash.' ), get_the_title( $post_id ) ); |
|---|
| 39 | |
|---|
| 40 | if ( !wp_untrash_post( $post_id ) ) |
|---|
| 41 | - wp_die( __( 'Error in restoring from trash...' ) ); |
|---|
| 42 | + $errors[] = sprintf( __( 'Error in restoring the item %s from the trash.' ), get_the_title( $post_id ) ); |
|---|
| 43 | } |
|---|
| 44 | + |
|---|
| 45 | + if( ! empty( $errors ) ) { |
|---|
| 46 | + $wp_err = new WP_Error( 'bulk_media_untrash_error' ); |
|---|
| 47 | + foreach( $errors as $err ) |
|---|
| 48 | + $wp_err->add( 'bulk_media_untrash_error', $err ); |
|---|
| 49 | + wp_die( $wp_err ); |
|---|
| 50 | + } |
|---|
| 51 | + |
|---|
| 52 | $location = add_query_arg( 'untrashed', count( $post_ids ), $location ); |
|---|
| 53 | break; |
|---|
| 54 | case 'delete': |
|---|
| 55 | foreach ( (array) $post_ids as $post_id_del ) { |
|---|
| 56 | + if( get_post( $post_id_del ) ) |
|---|
| 57 | + continue; |
|---|
| 58 | + |
|---|
| 59 | if ( !current_user_can( 'delete_post', $post_id_del ) ) |
|---|
| 60 | - wp_die( __( 'You are not allowed to delete this post.' ) ); |
|---|
| 61 | + $errors[] = sprintf( __( 'You are not allowed to delete the item %s.' ), get_the_title( $post_id_del ) ); |
|---|
| 62 | |
|---|
| 63 | if ( !wp_delete_attachment( $post_id_del ) ) |
|---|
| 64 | - wp_die( __( 'Error in deleting...' ) ); |
|---|
| 65 | + $errors[] = sprintf( __( 'Error in deleting the item %s.' ), get_the_title( $post_id_del ) ); |
|---|
| 66 | } |
|---|
| 67 | + |
|---|
| 68 | + if( ! empty( $errors ) ) { |
|---|
| 69 | + $wp_err = new WP_Error( 'bulk_media_delete_error' ); |
|---|
| 70 | + foreach( $errors as $err ) |
|---|
| 71 | + $wp_err->add( 'bulk_media_delete_error', $err ); |
|---|
| 72 | + wp_die( $wp_err ); |
|---|
| 73 | + } |
|---|
| 74 | + |
|---|
| 75 | $location = add_query_arg( 'deleted', count( $post_ids ), $location ); |
|---|
| 76 | break; |
|---|
| 77 | } |
|---|