From 2749db26de0032706504155c56c2b9f721d8a336 Mon Sep 17 00:00:00 2001 From: ryan Date: Mon, 21 Jul 2008 16:13:23 +0000 Subject: [PATCH] Fix assignment of links to the default category when a category is deleted. Props scohoust. fixes #7316 for trunk git-svn-id: http://svn.automattic.com/wordpress/trunk@8388 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/edit-link-categories.php | 7 ++++--- wp-admin/link-category.php | 5 +++-- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/wp-admin/edit-link-categories.php b/wp-admin/edit-link-categories.php index da5b41561..c7a5e9d99 100644 --- a/wp-admin/edit-link-categories.php +++ b/wp-admin/edit-link-categories.php @@ -10,12 +10,13 @@ if ( isset($_GET['deleteit']) && isset($_GET['delete']) ) { foreach( (array) $_GET['delete'] as $cat_ID ) { $cat_name = get_term_field('name', $cat_ID, 'link_category'); - + $default_cat_id = get_option('default_link_category'); + // Don't delete the default cats. - if ( $cat_ID == get_option('default_link_category') ) + if ( $cat_ID == $default_cat_id ) wp_die(sprintf(__("Can’t delete the %s category: this is the default one"), $cat_name)); - wp_delete_term($cat_ID, 'link_category'); + wp_delete_term($cat_ID, 'link_category', array('default' => $default_cat_id)); } $location = 'edit-link-categories.php'; diff --git a/wp-admin/link-category.php b/wp-admin/link-category.php index a67cf2b6a..bafb73f8e 100644 --- a/wp-admin/link-category.php +++ b/wp-admin/link-category.php @@ -28,12 +28,13 @@ case 'delete': wp_die(__('Cheatin’ uh?')); $cat_name = get_term_field('name', $cat_ID, 'link_category'); + $default_cat_id = get_option('default_link_category'); // Don't delete the default cats. - if ( $cat_ID == get_option('default_link_category') ) + if ( $cat_ID == $default_cat_id ) wp_die(sprintf(__("Can’t delete the %s category: this is the default one"), $cat_name)); - wp_delete_term($cat_ID, 'link_category'); + wp_delete_term($cat_ID, 'link_category', array('default' => $default_cat_id)); $location = 'edit-link-categories.php'; if ( $referer = wp_get_original_referer() ) {