source: trunk/www.guidonia.net/wp/wp-admin/link-category.php@ 44

Last change on this file since 44 was 44, checked in by luciano, 14 years ago
File size: 2.5 KB
Line 
1<?php
2/**
3 * Manage link category administration actions.
4 *
5 * This page is accessed by the link management pages and handles the forms and
6 * AJAX processes for category actions.
7 *
8 * @package WordPress
9 * @subpackage Administration
10 */
11
12/** Load WordPress Administration Bootstrap */
13require_once('admin.php');
14
15wp_reset_vars(array('action', 'cat'));
16
17switch($action) {
18
19case 'addcat':
20
21 check_admin_referer('add-link-category');
22
23 if ( !current_user_can('manage_categories') )
24 wp_die(__('Cheatin&#8217; uh?'));
25
26 if ( wp_insert_term($_POST['name'], 'link_category', $_POST ) ) {
27 wp_redirect('edit-link-categories.php?message=1#addcat');
28 } else {
29 wp_redirect('edit-link-categories.php?message=4#addcat');
30 }
31 exit;
32break;
33
34case 'delete':
35 $cat_ID = (int) $_GET['cat_ID'];
36 check_admin_referer('delete-link-category_' . $cat_ID);
37
38 if ( !current_user_can('manage_categories') )
39 wp_die(__('Cheatin&#8217; uh?'));
40
41 $cat_name = get_term_field('name', $cat_ID, 'link_category');
42 $default_cat_id = get_option('default_link_category');
43
44 // Don't delete the default cats.
45 if ( $cat_ID == $default_cat_id )
46 wp_die(sprintf(__("Can&#8217;t delete the <strong>%s</strong> category: this is the default one"), $cat_name));
47
48 wp_delete_term($cat_ID, 'link_category', array('default' => $default_cat_id));
49
50 $location = 'edit-link-categories.php';
51 if ( $referer = wp_get_original_referer() ) {
52 if ( false !== strpos($referer, 'edit-link-categories.php') )
53 $location = $referer;
54 }
55
56 $location = add_query_arg('message', 2, $location);
57
58 wp_redirect($location);
59 exit;
60
61break;
62
63case 'edit':
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');
72 exit;
73break;
74
75case 'editedcat':
76 $cat_ID = (int) $_POST['cat_ID'];
77 check_admin_referer('update-link-category_' . $cat_ID);
78
79 if ( !current_user_can('manage_categories') )
80 wp_die(__('Cheatin&#8217; uh?'));
81
82 $location = 'edit-link-categories.php';
83 if ( $referer = wp_get_original_referer() ) {
84 if ( false !== strpos($referer, 'edit-link-categories.php') )
85 $location = $referer;
86 }
87
88 $update = wp_update_term($cat_ID, 'link_category', $_POST);
89
90 if ( $update && !is_wp_error($update) )
91 $location = add_query_arg('message', 3, $location);
92 else
93 $location = add_query_arg('message', 5, $location);
94
95 wp_redirect($location);
96 exit;
97break;
98}
99
100?>
Note: See TracBrowser for help on using the repository browser.