Make WordPress Core

Ticket #2789: 2789b.diff

File 2789b.diff, 2.9 KB (added by westi, 18 years ago)

Also remove delete link for default link category

  • wp-admin/link-categories.php

     
    356356                <td nowrap="nowrap"><?php echo htmlentities($row->text_after_all)?></td>
    357357                <td><?php echo $row->list_limit ?></td>
    358358                <td><a href="link-categories.php?cat_id=<?php echo $row->cat_id?>&amp;action=Edit" class="edit"><?php _e('Edit') ?></a></td>
    359                 <td><a href="<?php echo wp_nonce_url("link-categories.php?cat_id=$row->cat_id?>&amp;action=Delete", 'delete-link-category_' . $row->cat_id) ?>" "onclick="return deleteSomething( 'link category', <?php echo $row->cat_id . ", '" . sprintf(__("You are about to delete the &quot;%s&quot; link category.\\n&quot;Cancel&quot; to stop, &quot;OK&quot; to delete."), wp_specialchars($row->cat_name,1)); ?>' );" class="delete"><?php _e('Delete') ?></a></td>
     359                <td><?php if (1 == $row->cat_id) {
     360                                        _e('Default');
     361                                } else { ?>
     362                                <a href="<?php echo wp_nonce_url("link-categories.php?cat_id=$row->cat_id&amp;action=Delete", 'delete-link-category_' . $row->cat_id) ?>" "onclick="return deleteSomething( 'link category', <?php echo $row->cat_id . ", '" . sprintf(__("You are about to delete the &quot;%s&quot; link category.\\n&quot;Cancel&quot; to stop, &quot;OK&quot; to delete."), wp_specialchars($row->cat_name,1)); ?>' );" class="delete"><?php _e('Delete') ?></a>
     363                                <?php } ?>
     364                                </td>
    360365              </tr>
    361366<?php
    362367        ++$i;
  • wp-admin/admin-db.php

     
    156156        $cat_ID = (int) $cat_ID;
    157157
    158158        // Don't delete the default cat.
    159         if (1 == $cat_ID)
     159        if ($cat_ID == get_option('default_category'))
    160160                return 0;
    161161
    162162        $category = get_category($cat_ID);
     
    170170        $wpdb->query("UPDATE $wpdb->categories SET category_parent = '$parent' WHERE category_parent = '$cat_ID'");
    171171
    172172        // TODO: Only set categories to general if they're not in another category already
    173         $wpdb->query("UPDATE $wpdb->post2cat SET category_id='1' WHERE category_id='$cat_ID'");
     173        $default_cat = get_option('default_category');
     174        $wpdb->query("UPDATE $wpdb->post2cat SET category_id='$default_cat' WHERE category_id='$cat_ID'");
    174175
    175176        wp_cache_delete($cat_ID, 'category');
    176177        wp_cache_delete('all_category_ids', 'category');
  • wp-admin/categories.php

     
    4444
    4545        $cat_name = get_catname($cat_ID);
    4646
    47         if ( 1 == $cat_ID )
     47        // Don't delete the default cats.
     48        if ( $cat_ID == get_option('default_category') )
    4849                die(sprintf(__("Can't delete the <strong>%s</strong> category: this is the default one"), $cat_name));
    4950
    5051        wp_delete_category($cat_ID);