2 require_once('admin.php');
4 wp_reset_vars(array('action', 'cat'));
10 check_admin_referer('add-link-category');
12 if ( !current_user_can('manage_categories') )
13 wp_die(__('Cheatin’ uh?'));
15 if ( wp_insert_term($_POST['name'], 'link_category', $_POST ) ) {
16 wp_redirect('edit-link-categories.php?message=1#addcat');
18 wp_redirect('edit-link-categories.php?message=4#addcat');
24 $cat_ID = (int) $_GET['cat_ID'];
25 check_admin_referer('delete-link-category_' . $cat_ID);
27 if ( !current_user_can('manage_categories') )
28 wp_die(__('Cheatin’ uh?'));
30 $cat_name = get_term_field('name', $cat_ID, 'link_category');
32 // Don't delete the default cats.
33 if ( $cat_ID == get_option('default_link_category') )
34 wp_die(sprintf(__("Can’t delete the <strong>%s</strong> category: this is the default one"), $cat_name));
36 wp_delete_term($cat_ID, 'link_category');
38 $location = 'edit-link-categories.php';
39 if ( $referer = wp_get_original_referer() ) {
40 if ( false !== strpos($referer, 'edit-link-categories.php') )
44 $location = add_query_arg('message', 2, $location);
46 wp_redirect($location);
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');
64 $cat_ID = (int) $_POST['cat_ID'];
65 check_admin_referer('update-link-category_' . $cat_ID);
67 if ( !current_user_can('manage_categories') )
68 wp_die(__('Cheatin’ uh?'));
70 $location = 'edit-link-categories.php';
71 if ( $referer = wp_get_original_referer() ) {
72 if ( false !== strpos($referer, 'edit-link-categories.php') )
76 if ( wp_update_term($cat_ID, 'link_category', $_POST) )
77 $location = add_query_arg('message', 3, $location);
79 $location = add_query_arg('message', 5, $location);
81 wp_redirect($location);