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');
31 $default_cat_id = get_option('default_link_category');
33 // Don't delete the default cats.
34 if ( $cat_ID == $default_cat_id )
35 wp_die(sprintf(__("Can’t delete the <strong>%s</strong> category: this is the default one"), $cat_name));
37 wp_delete_term($cat_ID, 'link_category', array('default' => $default_cat_id));
39 $location = 'edit-link-categories.php';
40 if ( $referer = wp_get_original_referer() ) {
41 if ( false !== strpos($referer, 'edit-link-categories.php') )
45 $location = add_query_arg('message', 2, $location);
47 wp_redirect($location);
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');
65 $cat_ID = (int) $_POST['cat_ID'];
66 check_admin_referer('update-link-category_' . $cat_ID);
68 if ( !current_user_can('manage_categories') )
69 wp_die(__('Cheatin’ uh?'));
71 $location = 'edit-link-categories.php';
72 if ( $referer = wp_get_original_referer() ) {
73 if ( false !== strpos($referer, 'edit-link-categories.php') )
77 $update = wp_update_term($cat_ID, 'link_category', $_POST);
79 if ( $update && !is_wp_error($update) )
80 $location = add_query_arg('message', 3, $location);
82 $location = add_query_arg('message', 5, $location);
84 wp_redirect($location);