+case 'trash':
+ check_admin_referer('trash-post_' . $post_id);
+
+ if ( ! $post )
+ wp_die( __( 'The item you are trying to move to the Trash no longer exists.' ) );
+
+ if ( ! $post_type_object )
+ wp_die( __( 'Unknown post type.' ) );
+
+ if ( ! current_user_can( 'delete_post', $post_id ) )
+ wp_die( __( 'You are not allowed to move this item to the Trash.' ) );
+
+ if ( $user_id = wp_check_post_lock( $post_id ) ) {
+ $user = get_userdata( $user_id );
+ wp_die( sprintf( __( 'You cannot move this item to the Trash. %s is currently editing.' ), $user->display_name ) );
+ }
+
+ if ( ! wp_trash_post( $post_id ) )
+ wp_die( __( 'Error in moving to Trash.' ) );
+
+ wp_redirect( add_query_arg( array('trashed' => 1, 'ids' => $post_id), $sendback ) );
+ exit();
+ break;
+
+case 'untrash':
+ check_admin_referer('untrash-post_' . $post_id);
+
+ if ( ! $post )
+ wp_die( __( 'The item you are trying to restore from the Trash no longer exists.' ) );
+
+ if ( ! $post_type_object )
+ wp_die( __( 'Unknown post type.' ) );
+
+ if ( ! current_user_can( 'delete_post', $post_id ) )
+ wp_die( __( 'You are not allowed to move this item out of the Trash.' ) );
+
+ if ( ! wp_untrash_post( $post_id ) )
+ wp_die( __( 'Error in restoring from Trash.' ) );
+
+ wp_redirect( add_query_arg('untrashed', 1, $sendback) );
+ exit();
+ break;
+