]> scripts.mit.edu Git - autoinstalls/wordpress.git/blobdiff - wp-admin/link-category.php
Wordpress 3.0.6
[autoinstalls/wordpress.git] / wp-admin / link-category.php
index 42058928c326e423b1a1f59e7d12f75295e20a05..caf73923e803d10a3b9667a4d83ffae838fe2e2a 100644 (file)
@@ -1,5 +1,16 @@
 <?php
 <?php
-require_once('admin.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'));
 
 
 wp_reset_vars(array('action', 'cat'));
 
@@ -28,27 +39,36 @@ case 'delete':
                wp_die(__('Cheatin&#8217; uh?'));
 
        $cat_name = get_term_field('name', $cat_ID, 'link_category');
                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.
 
        // 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_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));
 
 
-       wp_redirect('edit-link-categories.php?message=2');
+       $location = 'edit-link-categories.php';
+       if ( $referer = wp_get_original_referer() ) {
+               if ( false !== strpos($referer, 'edit-link-categories.php') )
+                       $location = $referer;
+       }
+
+       $location = add_query_arg('message', 2, $location);
+
+       wp_redirect($location);
        exit;
 
 break;
 
 case 'edit':
        exit;
 
 break;
 
 case 'edit':
-       $title = __('Categories');
+       $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'];
        $category = get_term_to_edit($cat_ID, 'link_category');
        $parent_file = 'link-manager.php';
        $submenu_file = 'edit-link-categories.php';
        require_once ('admin-header.php');
        $cat_ID = (int) $_GET['cat_ID'];
        $category = get_term_to_edit($cat_ID, 'link_category');
-       include('edit-link-category-form.php');
-       include('admin-footer.php');
+       include('./edit-link-category-form.php');
+       include('./admin-footer.php');
        exit;
 break;
 
        exit;
 break;
 
@@ -59,11 +79,20 @@ case 'editedcat':
        if ( !current_user_can('manage_categories') )
                wp_die(__('Cheatin&#8217; uh?'));
 
        if ( !current_user_can('manage_categories') )
                wp_die(__('Cheatin&#8217; uh?'));
 
-       if ( wp_update_term($cat_ID, 'link_category', $_POST) )
-               wp_redirect('edit-link-categories.php?message=3');
+       $location = 'edit-link-categories.php';
+       if ( $referer = wp_get_original_referer() ) {
+               if ( false !== strpos($referer, 'edit-link-categories.php') )
+                       $location = $referer;
+       }
+
+       $update =  wp_update_term($cat_ID, 'link_category', $_POST);
+
+       if ( $update && !is_wp_error($update) )
+               $location = add_query_arg('message', 3, $location);
        else
        else
-               wp_redirect('edit-link-categories.php?message=5');
+               $location = add_query_arg('message', 5, $location);
 
 
+       wp_redirect($location);
        exit;
 break;
 }
        exit;
 break;
 }