Default cat deletion fix from westi. fixes #2789
git-svn-id: http://svn.automattic.com/wordpress/branches/2.0@4032 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
0ee416e9b8
commit
9d7419b504
|
@ -156,7 +156,7 @@ function wp_delete_category($cat_ID) {
|
||||||
$cat_ID = (int) $cat_ID;
|
$cat_ID = (int) $cat_ID;
|
||||||
|
|
||||||
// Don't delete the default cat.
|
// Don't delete the default cat.
|
||||||
if (1 == $cat_ID)
|
if ($cat_ID == get_option('default_category'))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
$category = get_category($cat_ID);
|
$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'");
|
$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
|
// 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($cat_ID, 'category');
|
||||||
wp_cache_delete('all_category_ids', 'category');
|
wp_cache_delete('all_category_ids', 'category');
|
||||||
|
|
|
@ -44,7 +44,8 @@ case 'delete':
|
||||||
|
|
||||||
$cat_name = get_catname($cat_ID);
|
$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 <strong>%s</strong> category: this is the default one"), $cat_name));
|
die(sprintf(__("Can't delete the <strong>%s</strong> category: this is the default one"), $cat_name));
|
||||||
|
|
||||||
wp_delete_category($cat_ID);
|
wp_delete_category($cat_ID);
|
||||||
|
|
Loading…
Reference in New Issue