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 <strong>%s</strong> 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() ) {
$location = $referer;
}
- if ( wp_update_term($cat_ID, 'link_category', $_POST) )
+ $update = wp_update_term($cat_ID, 'link_category', $_POST);
+
+ if ( $update && !is_wp_error($update) )
$location = add_query_arg('message', 3, $location);
else
$location = add_query_arg('message', 5, $location);