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