- if ( !current_user_can('delete_post', $post_id) )
- wp_die( __('You are not allowed to delete this post.') );
+ if ( !current_user_can($post_type_object->cap->delete_post, $post_id) )
+ wp_die( __('You are not allowed to move this item to the Trash.') );
+
+ 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_type . '_' . $post_id);
+
+ if ( !current_user_can($post_type_object->cap->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;
+
+case 'delete':
+ check_admin_referer('delete-' . $post_type . '_' . $post_id);
+
+ if ( !current_user_can($post_type_object->cap->delete_post, $post_id) )
+ wp_die( __('You are not allowed to delete this item.') );