Deleting a category moves any subcats up the hierarchy.

git-svn-id: http://svn.automattic.com/wordpress/trunk@862 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
jverber 2004-02-10 23:39:08 +00:00
parent 4ce864c6bc
commit bca08d2d24
1 changed files with 3 additions and 0 deletions

View File

@ -63,6 +63,8 @@ case 'Delete':
$cat_ID = intval($HTTP_GET_VARS["cat_ID"]); $cat_ID = intval($HTTP_GET_VARS["cat_ID"]);
$cat_name = get_catname($cat_ID); $cat_name = get_catname($cat_ID);
$cat_name = addslashes($cat_name); $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) if (1 == $cat_ID)
die("Can't delete the <strong>$cat_name</strong> category: this is the default one"); die("Can't delete the <strong>$cat_name</strong> category: this is the default one");
@ -71,6 +73,7 @@ case 'Delete':
die ('Cheatin&#8217; uh?'); die ('Cheatin&#8217; uh?');
$wpdb->query("DELETE FROM $tablecategories WHERE cat_ID = $cat_ID"); $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'"); $wpdb->query("UPDATE $tablepost2cat SET category_id='1' WHERE category_id='$cat_ID'");
header('Location: categories.php'); header('Location: categories.php');