]> scripts.mit.edu Git - autoinstalls/wordpress.git/blob - wp-admin/link-category.php
Wordpress 2.6.2
[autoinstalls/wordpress.git] / wp-admin / link-category.php
1 <?php
2 require_once('admin.php');
3
4 wp_reset_vars(array('action', 'cat'));
5
6 switch($action) {
7
8 case 'addcat':
9
10         check_admin_referer('add-link-category');
11
12         if ( !current_user_can('manage_categories') )
13                 wp_die(__('Cheatin&#8217; uh?'));
14
15         if ( wp_insert_term($_POST['name'], 'link_category', $_POST ) ) {
16                 wp_redirect('edit-link-categories.php?message=1#addcat');
17         } else {
18                 wp_redirect('edit-link-categories.php?message=4#addcat');
19         }
20         exit;
21 break;
22
23 case 'delete':
24         $cat_ID = (int) $_GET['cat_ID'];
25         check_admin_referer('delete-link-category_' .  $cat_ID);
26
27         if ( !current_user_can('manage_categories') )
28                 wp_die(__('Cheatin&#8217; uh?'));
29
30         $cat_name = get_term_field('name', $cat_ID, 'link_category');
31         $default_cat_id = get_option('default_link_category');
32
33         // Don't delete the default cats.
34     if ( $cat_ID == $default_cat_id )
35                 wp_die(sprintf(__("Can&#8217;t delete the <strong>%s</strong> category: this is the default one"), $cat_name));
36
37         wp_delete_term($cat_ID, 'link_category', array('default' => $default_cat_id));
38
39         $location = 'edit-link-categories.php';
40         if ( $referer = wp_get_original_referer() ) {
41                 if ( false !== strpos($referer, 'edit-link-categories.php') )
42                         $location = $referer;
43         }
44
45         $location = add_query_arg('message', 2, $location);
46
47         wp_redirect($location);
48         exit;
49
50 break;
51
52 case 'edit':
53         $title = __('Categories');
54         $parent_file = 'edit.php';
55         $submenu_file = 'edit-link-categories.php';
56         require_once ('admin-header.php');
57         $cat_ID = (int) $_GET['cat_ID'];
58         $category = get_term_to_edit($cat_ID, 'link_category');
59         include('edit-link-category-form.php');
60         include('admin-footer.php');
61         exit;
62 break;
63
64 case 'editedcat':
65         $cat_ID = (int) $_POST['cat_ID'];
66         check_admin_referer('update-link-category_' . $cat_ID);
67
68         if ( !current_user_can('manage_categories') )
69                 wp_die(__('Cheatin&#8217; uh?'));
70
71         $location = 'edit-link-categories.php';
72         if ( $referer = wp_get_original_referer() ) {
73                 if ( false !== strpos($referer, 'edit-link-categories.php') )
74                         $location = $referer;
75         }
76
77         $update =  wp_update_term($cat_ID, 'link_category', $_POST);
78
79         if ( $update && !is_wp_error($update) )
80                 $location = add_query_arg('message', 3, $location);
81         else
82                 $location = add_query_arg('message', 5, $location);
83
84         wp_redirect($location);
85         exit;
86 break;
87 }
88
89 ?>