From bca08d2d24d11160dbdef9673d37df771f2c1515 Mon Sep 17 00:00:00 2001 From: jverber Date: Tue, 10 Feb 2004 23:39:08 +0000 Subject: [PATCH] Deleting a category moves any subcats up the hierarchy. git-svn-id: http://svn.automattic.com/wordpress/trunk@862 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/categories.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/wp-admin/categories.php b/wp-admin/categories.php index 49ae994f56..bb28878895 100644 --- a/wp-admin/categories.php +++ b/wp-admin/categories.php @@ -63,6 +63,8 @@ case 'Delete': $cat_ID = intval($HTTP_GET_VARS["cat_ID"]); $cat_name = get_catname($cat_ID); $cat_name = addslashes($cat_name); + $category = $wpdb->get_row("SELECT * FROM $tablecategories WHERE cat_ID = " . $cat_ID); + $cat_parent = $category->category_parent; if (1 == $cat_ID) die("Can't delete the $cat_name category: this is the default one"); @@ -71,6 +73,7 @@ case 'Delete': die ('Cheatin’ uh?'); $wpdb->query("DELETE FROM $tablecategories WHERE cat_ID = $cat_ID"); + $wpdb->query("UPDATE $tablecategories SET category_parent=$cat_parent WHERE category_parent=$cat_ID"); $wpdb->query("UPDATE $tablepost2cat SET category_id='1' WHERE category_id='$cat_ID'"); header('Location: categories.php');