]> scripts.mit.edu Git - autoinstalls/wordpress.git/blob - wp-admin/link-category.php
Wordpress 2.5.1
[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
32         // Don't delete the default cats.
33     if ( $cat_ID == get_option('default_link_category') )
34                 wp_die(sprintf(__("Can&#8217;t delete the <strong>%s</strong> category: this is the default one"), $cat_name));
35
36         wp_delete_term($cat_ID, 'link_category');
37
38         $location = 'edit-link-categories.php';
39         if ( $referer = wp_get_original_referer() ) {
40                 if ( false !== strpos($referer, 'edit-link-categories.php') )
41                         $location = $referer;
42         }
43
44         $location = add_query_arg('message', 2, $location);
45
46         wp_redirect($location);
47         exit;
48
49 break;
50
51 case 'edit':
52         $title = __('Categories');
53         $parent_file = 'edit.php';
54         $submenu_file = 'edit-link-categories.php';
55         require_once ('admin-header.php');
56         $cat_ID = (int) $_GET['cat_ID'];
57         $category = get_term_to_edit($cat_ID, 'link_category');
58         include('edit-link-category-form.php');
59         include('admin-footer.php');
60         exit;
61 break;
62
63 case 'editedcat':
64         $cat_ID = (int) $_POST['cat_ID'];
65         check_admin_referer('update-link-category_' . $cat_ID);
66
67         if ( !current_user_can('manage_categories') )
68                 wp_die(__('Cheatin&#8217; uh?'));
69
70         $location = 'edit-link-categories.php';
71         if ( $referer = wp_get_original_referer() ) {
72                 if ( false !== strpos($referer, 'edit-link-categories.php') )
73                         $location = $referer;
74         }
75
76         if ( wp_update_term($cat_ID, 'link_category', $_POST) )
77                 $location = add_query_arg('message', 3, $location);
78         else
79                 $location = add_query_arg('message', 5, $location);
80
81         wp_redirect($location);
82         exit;
83 break;
84 }
85
86 ?>