| [ Index ] |
PHP Cross Reference of zeList |
[Summary view] [Print] [Text view]
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 */ 13 require_once('admin.php'); 14 15 wp_reset_vars(array('action', 'cat')); 16 17 //if($_POST) { echo '<pre>'.print_r($_POST,1).'</pre>';die();} 18 19 20 switch($action) { 21 22 case 'addcat': 23 24 check_admin_referer('add-link-category'); 25 26 if ( !current_user_can('manage_categories') ) 27 wp_die(__('Cheatin’ uh?')); 28 29 if ( wp_insert_term($_POST['name'], 'link_category', $_POST ) ) { 30 wp_redirect(ZELIST_ADMIN_URL_CATEGORIES.'&message=1#addcat'); 31 } else { 32 wp_redirect(ZELIST_ADMIN_URL_CATEGORIES.'&message=4#addcat'); 33 } 34 exit; 35 break; 36 37 case 'delete': 38 $cat_ID = (int) $_GET['cat_ID']; 39 check_admin_referer('delete-link-category_' . $cat_ID); 40 41 if ( !current_user_can('manage_categories') ) 42 wp_die(__('Cheatin’ uh?')); 43 44 $cat_name = get_term_field('name', $cat_ID, 'link_category'); 45 $default_cat_id = get_option('default_link_category'); 46 47 // Don't delete the default cats. 48 if ( $cat_ID == $default_cat_id ) 49 wp_die(sprintf(__("Can’t delete the <strong>%s</strong> category: this is the default one"), $cat_name)); 50 51 wp_delete_term($cat_ID, 'link_category', array('default' => $default_cat_id)); 52 53 zelist_update_link_counts(); 54 $location = ZELIST_ADMIN_URL_CATEGORIES; 55 if ( $referer = wp_get_original_referer() ) { 56 if ( false !== strpos($referer, ZELIST_ADMIN_URL_CATEGORIES) ) 57 $location = $referer; 58 } 59 60 $location = add_query_arg('message', 2, $location); 61 62 wp_redirect($location); 63 exit; 64 65 break; 66 67 case 'edit': 68 $title = __('Edit Category'); 69 $parent_file = ZELIST_ADMIN_URL_MANAGER; 70 $submenu_file = ZELIST_ADMIN_URL_CATEGORIES; 71 require_once ('admin-header.php'); 72 $cat_ID = (int) $_GET['cat_ID']; 73 $category = get_term_to_edit($cat_ID, 'link_category'); 74 include(ZELIST_ADMIN_PATH_EDIT_CATEGORY_FORM); 75 include('admin-footer.php'); 76 exit; 77 break; 78 79 case 'editedcat': 80 $cat_ID = (int) $_POST['cat_ID']; 81 check_admin_referer('update-link-category_' . $cat_ID); 82 83 if ( !current_user_can('manage_categories') ) 84 wp_die(__('Cheatin’ uh?')); 85 86 $location = ZELIST_ADMIN_URL_CATEGORIES; 87 if ( $referer = wp_get_original_referer() ) { 88 if ( false !== strpos($referer, 'edit-link-categories.php') ) 89 $location = $referer; 90 } 91 92 $update = wp_update_term($cat_ID, 'link_category', $_POST); 93 zelist_update_link_counts(); 94 if ( $update && !is_wp_error($update) ) 95 $location = add_query_arg('message', 3, $location); 96 else 97 $location = add_query_arg('message', 5, $location); 98 99 wp_redirect($location); 100 exit; 101 break; 102 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Sat May 30 23:51:06 2009 | Cross-referenced by PHPXref 0.7 |