]> scripts.mit.edu Git - autoinstalls/wordpress.git/blobdiff - wp-admin/link-category.php
Wordpress 2.8.5-scripts
[autoinstalls/wordpress.git] / wp-admin / link-category.php
index a67cf2b6a7a78b72f9f1ae359b432a0cf0232957..bcfbf2e8785dc1ccf0e2d1c05e6b2a835b647c52 100644 (file)
@@ -1,4 +1,15 @@
 <?php
+/**
+ * Manage link category administration actions.
+ *
+ * This page is accessed by the link management pages and handles the forms and
+ * AJAX processes for category actions.
+ *
+ * @package WordPress
+ * @subpackage Administration
+ */
+
+/** Load WordPress Administration Bootstrap */
 require_once('admin.php');
 
 wp_reset_vars(array('action', 'cat'));
@@ -28,12 +39,13 @@ case 'delete':
                wp_die(__('Cheatin&#8217; 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&#8217;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() ) {
@@ -49,8 +61,8 @@ case 'delete':
 break;
 
 case 'edit':
-       $title = __('Categories');
-       $parent_file = 'edit.php';
+       $title = __('Edit Category');
+       $parent_file = 'link-manager.php';
        $submenu_file = 'edit-link-categories.php';
        require_once ('admin-header.php');
        $cat_ID = (int) $_GET['cat_ID'];
@@ -73,7 +85,9 @@ case 'editedcat':
                        $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);