Ticket #16165: 16165.diff
File 16165.diff, 3.0 KB (added by , 13 years ago) |
---|
-
wp-admin/upload.php
36 36 $location = remove_query_arg( array( 'trashed', 'untrashed', 'deleted', 'message', 'ids', 'posted' ), $referer ); 37 37 } 38 38 39 $errors = array(); 39 40 switch ( $doaction ) { 40 41 case 'find_detached': 41 42 if ( !current_user_can('edit_posts') ) … … 92 93 case 'trash': 93 94 foreach ( (array) $post_ids as $post_id ) { 94 95 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 ) ); 96 97 97 98 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 ) ); 99 100 } 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 100 109 $location = add_query_arg( array( 'trashed' => count( $post_ids ), 'ids' => join( ',', $post_ids ) ), $location ); 101 110 break; 102 111 case 'untrash': 103 112 foreach ( (array) $post_ids as $post_id ) { 104 113 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 ) ); 106 115 107 116 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 ) ); 109 118 } 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 110 127 $location = add_query_arg( 'untrashed', count( $post_ids ), $location ); 111 128 break; 112 129 case 'delete': 113 130 foreach ( (array) $post_ids as $post_id_del ) { 131 if( get_post( $post_id_del ) ) 132 continue; 133 114 134 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 ) ); 116 136 117 137 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 ) ); 119 139 } 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 120 148 $location = add_query_arg( 'deleted', count( $post_ids ), $location ); 121 149 break; 122 150 }