3 * Manage link category administration actions.
5 * This page is accessed by the link management pages and handles the forms and
6 * AJAX processes for category actions.
9 * @subpackage Administration
12 /** Load WordPress Administration Bootstrap */
13 require_once('./admin.php');
15 wp_reset_vars(array('action', 'cat'));
21 check_admin_referer('add-link-category');
23 if ( !current_user_can('manage_categories') )
24 wp_die(__('Cheatin’ uh?'));
26 if ( wp_insert_term($_POST['name'], 'link_category', $_POST ) ) {
27 wp_redirect('edit-link-categories.php?message=1#addcat');
29 wp_redirect('edit-link-categories.php?message=4#addcat');
35 $cat_ID = (int) $_GET['cat_ID'];
36 check_admin_referer('delete-link-category_' . $cat_ID);
38 if ( !current_user_can('manage_categories') )
39 wp_die(__('Cheatin’ uh?'));
41 $cat_name = get_term_field('name', $cat_ID, 'link_category');
42 $default_cat_id = get_option('default_link_category');
44 // Don't delete the default cats.
45 if ( $cat_ID == $default_cat_id )
46 wp_die(sprintf(__("Can’t delete the <strong>%s</strong> category: this is the default one"), $cat_name));
48 wp_delete_term($cat_ID, 'link_category', array('default' => $default_cat_id));
50 $location = 'edit-link-categories.php';
51 if ( $referer = wp_get_original_referer() ) {
52 if ( false !== strpos($referer, 'edit-link-categories.php') )
56 $location = add_query_arg('message', 2, $location);
58 wp_redirect($location);
64 $title = __('Edit Category');
65 $parent_file = 'link-manager.php';
66 $submenu_file = 'edit-link-categories.php';
67 require_once ('admin-header.php');
68 $cat_ID = (int) $_GET['cat_ID'];
69 $category = get_term_to_edit($cat_ID, 'link_category');
70 include('./edit-link-category-form.php');
71 include('./admin-footer.php');
76 $cat_ID = (int) $_POST['cat_ID'];
77 check_admin_referer('update-link-category_' . $cat_ID);
79 if ( !current_user_can('manage_categories') )
80 wp_die(__('Cheatin’ uh?'));
82 $location = 'edit-link-categories.php';
83 if ( $referer = wp_get_original_referer() ) {
84 if ( false !== strpos($referer, 'edit-link-categories.php') )
88 $update = wp_update_term($cat_ID, 'link_category', $_POST);
90 if ( $update && !is_wp_error($update) )
91 $location = add_query_arg('message', 3, $location);
93 $location = add_query_arg('message', 5, $location);
95 wp_redirect($location);