-
+ 97719BC44CC660B8613B24EA851AF02BA3A5E13D6CBCBAF8616D8480D8A0F19FC75B05813F44F211F44BA5F06567A88E34923C7AD8F4BB6A22B8BA6339C047D9mp-wp/wp-admin/link-category.php(0 . 0)(1 . 100)
51966 <?php
51967 /**
51968 * Manage link category administration actions.
51969 *
51970 * This page is accessed by the link management pages and handles the forms and
51971 * AJAX processes for category actions.
51972 *
51973 * @package WordPress
51974 * @subpackage Administration
51975 */
51976
51977 /** Load WordPress Administration Bootstrap */
51978 require_once('admin.php');
51979
51980 wp_reset_vars(array('action', 'cat'));
51981
51982 switch($action) {
51983
51984 case 'addcat':
51985
51986 check_admin_referer('add-link-category');
51987
51988 if ( !current_user_can('manage_categories') )
51989 wp_die(__('Cheatin’ uh?'));
51990
51991 if ( wp_insert_term($_POST['name'], 'link_category', $_POST ) ) {
51992 wp_redirect('edit-link-categories.php?message=1#addcat');
51993 } else {
51994 wp_redirect('edit-link-categories.php?message=4#addcat');
51995 }
51996 exit;
51997 break;
51998
51999 case 'delete':
52000 $cat_ID = (int) $_GET['cat_ID'];
52001 check_admin_referer('delete-link-category_' . $cat_ID);
52002
52003 if ( !current_user_can('manage_categories') )
52004 wp_die(__('Cheatin’ uh?'));
52005
52006 $cat_name = get_term_field('name', $cat_ID, 'link_category');
52007 $default_cat_id = get_option('default_link_category');
52008
52009 // Don't delete the default cats.
52010 if ( $cat_ID == $default_cat_id )
52011 wp_die(sprintf(__("Can’t delete the <strong>%s</strong> category: this is the default one"), $cat_name));
52012
52013 wp_delete_term($cat_ID, 'link_category', array('default' => $default_cat_id));
52014
52015 $location = 'edit-link-categories.php';
52016 if ( $referer = wp_get_original_referer() ) {
52017 if ( false !== strpos($referer, 'edit-link-categories.php') )
52018 $location = $referer;
52019 }
52020
52021 $location = add_query_arg('message', 2, $location);
52022
52023 wp_redirect($location);
52024 exit;
52025
52026 break;
52027
52028 case 'edit':
52029 $title = __('Edit Category');
52030 $parent_file = 'link-manager.php';
52031 $submenu_file = 'edit-link-categories.php';
52032 require_once ('admin-header.php');
52033 $cat_ID = (int) $_GET['cat_ID'];
52034 $category = get_term_to_edit($cat_ID, 'link_category');
52035 include('edit-link-category-form.php');
52036 include('admin-footer.php');
52037 exit;
52038 break;
52039
52040 case 'editedcat':
52041 $cat_ID = (int) $_POST['cat_ID'];
52042 check_admin_referer('update-link-category_' . $cat_ID);
52043
52044 if ( !current_user_can('manage_categories') )
52045 wp_die(__('Cheatin’ uh?'));
52046
52047 $location = 'edit-link-categories.php';
52048 if ( $referer = wp_get_original_referer() ) {
52049 if ( false !== strpos($referer, 'edit-link-categories.php') )
52050 $location = $referer;
52051 }
52052
52053 $update = wp_update_term($cat_ID, 'link_category', $_POST);
52054
52055 if ( $update && !is_wp_error($update) )
52056 $location = add_query_arg('message', 3, $location);
52057 else
52058 $location = add_query_arg('message', 5, $location);
52059
52060 wp_redirect($location);
52061 exit;
52062 break;
52063 }
52064
52065 ?>