diff --git a/wp-admin/admin-db.php b/wp-admin/admin-db.php index 89732b8700..d81b6b845a 100644 --- a/wp-admin/admin-db.php +++ b/wp-admin/admin-db.php @@ -156,7 +156,7 @@ function wp_delete_category($cat_ID) { $cat_ID = (int) $cat_ID; // Don't delete the default cat. - if (1 == $cat_ID) + if ($cat_ID == get_option('default_category')) return 0; $category = get_category($cat_ID); @@ -170,7 +170,8 @@ function wp_delete_category($cat_ID) { $wpdb->query("UPDATE $wpdb->categories SET category_parent = '$parent' WHERE category_parent = '$cat_ID'"); // TODO: Only set categories to general if they're not in another category already - $wpdb->query("UPDATE $wpdb->post2cat SET category_id='1' WHERE category_id='$cat_ID'"); + $default_cat = get_option('default_category'); + $wpdb->query("UPDATE $wpdb->post2cat SET category_id='$default_cat' WHERE category_id='$cat_ID'"); wp_cache_delete($cat_ID, 'category'); wp_cache_delete('all_category_ids', 'category'); diff --git a/wp-admin/categories.php b/wp-admin/categories.php index f70e774d19..30d37c8b4b 100644 --- a/wp-admin/categories.php +++ b/wp-admin/categories.php @@ -44,7 +44,8 @@ case 'delete': $cat_name = get_catname($cat_ID); - if ( 1 == $cat_ID ) + // Don't delete the default cats. + if ( $cat_ID == get_option('default_category') ) die(sprintf(__("Can't delete the %s category: this is the default one"), $cat_name)); wp_delete_category($cat_ID);