Fix post deletion. Update wp_delete_post() and call from post.php. Bug 472.

git-svn-id: http://svn.automattic.com/wordpress/trunk@1891 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
rboren 2004-11-27 04:46:54 +00:00
parent 65afc9f7b6
commit e9cd4f12cc

View File

@ -18,6 +18,10 @@ for ($i=0; $i<count($wpvarstoreset); $i += 1) {
} }
} }
if (isset($_POST['deletepost'])) {
$action = "delete";
}
switch($action) { switch($action) {
case 'post': case 'post':
@ -388,21 +392,15 @@ case 'editpost':
case 'delete': case 'delete':
check_admin_referer(); check_admin_referer();
$post_id = intval($_GET['post']); $post_id = (isset($_GET['post'])) ? intval($_GET['post']) : intval($_POST['post_ID']);
if (!user_can_delete_post($user_ID, $post_id)) { if (!user_can_delete_post($user_ID, $post_id)) {
die('You are not allowed to delete this post.'); die('You are not allowed to delete this post.');
} }
$result = $wpdb->query("DELETE FROM $wpdb->posts WHERE ID=$post_id"); if (! wp_delete_post($post_id))
if (!$result)
die(__('Error in deleting...')); die(__('Error in deleting...'));
$result = $wpdb->query("DELETE FROM $wpdb->comments WHERE comment_post_ID=$post_id");
$categories = $wpdb->query("DELETE FROM $wpdb->post2cat WHERE post_id = $post_id");
$meta = $wpdb->query("DELETE FROM $wpdb->postmeta WHERE post_id = $post_id");
$sendback = $_SERVER['HTTP_REFERER']; $sendback = $_SERVER['HTTP_REFERER'];
if (strstr($sendback, 'post.php')) $sendback = get_settings('siteurl') .'/wp-admin/post.php'; if (strstr($sendback, 'post.php')) $sendback = get_settings('siteurl') .'/wp-admin/post.php';
$sendback = preg_replace('|[^a-z0-9-~+_.?#=&;,/:]|i', '', $sendback); $sendback = preg_replace('|[^a-z0-9-~+_.?#=&;,/:]|i', '', $sendback);