| 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’ 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’ uh?')); |
|---|
| 29 |
|
|---|
| 30 |
$cat_name = get_term_field('name', $cat_ID, 'link_category'); |
|---|
| 31 |
|
|---|
| 32 |
|
|---|
| 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)); |
|---|
| 35 |
|
|---|
| 36 |
wp_delete_term($cat_ID, 'link_category'); |
|---|
| 37 |
|
|---|
| 38 |
wp_redirect('edit-link-categories.php?message=2'); |
|---|
| 39 |
exit; |
|---|
| 40 |
|
|---|
| 41 |
break; |
|---|
| 42 |
|
|---|
| 43 |
case 'edit': |
|---|
| 44 |
$title = __('Categories'); |
|---|
| 45 |
$parent_file = 'link-manager.php'; |
|---|
| 46 |
$submenu_file = 'edit-link-categories.php'; |
|---|
| 47 |
require_once ('admin-header.php'); |
|---|
| 48 |
$cat_ID = (int) $_GET['cat_ID']; |
|---|
| 49 |
$category = get_term_to_edit($cat_ID, 'link_category'); |
|---|
| 50 |
include('edit-link-category-form.php'); |
|---|
| 51 |
include('admin-footer.php'); |
|---|
| 52 |
exit; |
|---|
| 53 |
break; |
|---|
| 54 |
|
|---|
| 55 |
case 'editedcat': |
|---|
| 56 |
$cat_ID = (int) $_POST['cat_ID']; |
|---|
| 57 |
check_admin_referer('update-link-category_' . $cat_ID); |
|---|
| 58 |
|
|---|
| 59 |
if ( !current_user_can('manage_categories') ) |
|---|
| 60 |
wp_die(__('Cheatin’ uh?')); |
|---|
| 61 |
|
|---|
| 62 |
if ( wp_update_term($cat_ID, 'link_category', $_POST) ) |
|---|
| 63 |
wp_redirect('edit-link-categories.php?message=3'); |
|---|
| 64 |
else |
|---|
| 65 |
wp_redirect('edit-link-categories.php?message=5'); |
|---|
| 66 |
|
|---|
| 67 |
exit; |
|---|
| 68 |
break; |
|---|
| 69 |
} |
|---|
| 70 |
|
|---|
| 71 |
?> |
|---|
| 72 |
|
|---|