+ $location = add_query_arg( array( 'attached' => $attached ) , $location );
+ wp_redirect( $location );
+ exit;
+ }
+ break;
+ case 'trash':
+ foreach ( (array) $post_ids as $post_id ) {
+ if ( !current_user_can( 'delete_post', $post_id ) )
+ wp_die( __( 'You are not allowed to move this post to the trash.' ) );
+
+ if ( !wp_trash_post( $post_id ) )
+ wp_die( __( 'Error in moving to trash...' ) );
+ }
+ $location = add_query_arg( array( 'trashed' => count( $post_ids ), 'ids' => join( ',', $post_ids ) ), $location );
+ break;
+ case 'untrash':
+ foreach ( (array) $post_ids as $post_id ) {
+ if ( !current_user_can( 'delete_post', $post_id ) )
+ wp_die( __( 'You are not allowed to move this post out of the trash.' ) );
+
+ if ( !wp_untrash_post( $post_id ) )
+ wp_die( __( 'Error in restoring from trash...' ) );
+ }
+ $location = add_query_arg( 'untrashed', count( $post_ids ), $location );
+ break;
+ case 'delete':
+ foreach ( (array) $post_ids as $post_id_del ) {
+ if ( !current_user_can( 'delete_post', $post_id_del ) )
+ wp_die( __( 'You are not allowed to delete this post.' ) );
+
+ if ( !wp_delete_attachment( $post_id_del ) )
+ wp_die( __( 'Error in deleting...' ) );
+ }
+ $location = add_query_arg( 'deleted', count( $post_ids ), $location );
+ break;
+ }