Make WordPress Core

Ticket #176: 0000176-categories.diff

File 0000176-categories.diff, 1.2 KB (added by Tomcat, 20 years ago)
  • categories.php

    RCS file: /cvsroot/cafelog/wordpress/wp-admin/categories.php,v
    retrieving revision 1.36
    diff -u -3 -r1.36 categories.php
     
    6969    $cat_name = get_catname($cat_ID);
    7070    $category = $wpdb->get_row("SELECT * FROM $wpdb->categories WHERE cat_ID = '$cat_ID'");
    7171    $cat_parent = $category->category_parent;
     72    $cat_default = get_settings('default_category');
     73    if ($cat_default == $cat_ID) $cat_default = 1; // Make sure default isn't being deleted
    7274
    7375    if (1 == $cat_ID)
    7476        die(sprintf(__("Can't delete the <strong>%s</strong> category: this is the default one"), $cat_name));
     
    7880
    7981    $wpdb->query("DELETE FROM $wpdb->categories WHERE cat_ID = '$cat_ID'");
    8082    $wpdb->query("UPDATE $wpdb->categories SET category_parent = '$cat_parent' WHERE category_parent = '$cat_ID'");
    81     $wpdb->query("UPDATE $wpdb->post2cat SET category_id='1' WHERE category_id='$cat_ID'");
     83    $wpdb->query("UPDATE $wpdb->post2cat SET category_id='$cat_default' WHERE category_id='$cat_ID'");
    8284
    8385    header('Location: categories.php?message=2');
    8486