From d53401fbd546d4e4ad1f84c9cb8e19903d82a3d7 Mon Sep 17 00:00:00 2001 From: saxmatt Date: Tue, 14 Dec 2004 09:22:21 +0000 Subject: [PATCH] Just a little code cleanup and case normalization. http://mosquito.wordpress.org/view.php?id=360 git-svn-id: http://svn.automattic.com/wordpress/trunk@1953 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/admin-functions.php | 2 +- wp-admin/categories.php | 29 +++++++++++++++-------------- 2 files changed, 16 insertions(+), 15 deletions(-) diff --git a/wp-admin/admin-functions.php b/wp-admin/admin-functions.php index a0a4d8d99..1769b597c 100644 --- a/wp-admin/admin-functions.php +++ b/wp-admin/admin-functions.php @@ -117,7 +117,7 @@ function cat_rows($parent = 0, $level = 0, $categories = 0) { $count = $wpdb->get_var("SELECT COUNT(post_id) FROM $wpdb->post2cat WHERE category_id = $category->cat_ID"); $pad = str_repeat('— ', $level); if ( $user_level > 3 ) - $edit = "" . __('Edit') . "cat_name)) . "')\" class='delete'>" . __('Delete') . ""; + $edit = "" . __('Edit') . "cat_name)) . "')\" class='delete'>" . __('Delete') . ""; else $edit = ''; diff --git a/wp-admin/categories.php b/wp-admin/categories.php index ac574389a..46e29234b 100644 --- a/wp-admin/categories.php +++ b/wp-admin/categories.php @@ -38,26 +38,27 @@ case 'addcat': header('Location: categories.php?message=1#addcat'); break; -case 'Delete': +case 'delete': - check_admin_referer(); + check_admin_referer(); - $cat_ID = intval($_GET["cat_ID"]); - $cat_name = get_catname($cat_ID); - $category = $wpdb->get_row("SELECT * FROM $wpdb->categories WHERE cat_ID = '$cat_ID'"); - $cat_parent = $category->category_parent; + $cat_ID = (int) $_GET['cat_ID']; + $cat_name = get_catname($cat_ID); + $category = $wpdb->get_row("SELECT * FROM $wpdb->categories WHERE cat_ID = '$cat_ID'"); + $cat_parent = $category->category_parent; - if (1 == $cat_ID) - die(sprintf(__("Can't delete the %s category: this is the default one"), $cat_name)); + if ( 1 == $cat_ID ) + die(sprintf(__("Can't delete the %s category: this is the default one"), $cat_name)); - if ($user_level < 3) - die (__('Cheatin’ uh?')); + if ( $user_level < 3 ) + die (__('Cheatin’ uh?')); - $wpdb->query("DELETE FROM $wpdb->categories WHERE cat_ID = '$cat_ID'"); - $wpdb->query("UPDATE $wpdb->categories SET category_parent = '$cat_parent' WHERE category_parent = '$cat_ID'"); - $wpdb->query("UPDATE $wpdb->post2cat SET category_id='1' WHERE category_id='$cat_ID'"); + $wpdb->query("DELETE FROM $wpdb->categories WHERE cat_ID = '$cat_ID'"); + $wpdb->query("UPDATE $wpdb->categories SET category_parent = '$cat_parent' WHERE category_parent = '$cat_ID'"); + // TODO: Only set categories to general if they're not in another category already + $wpdb->query("UPDATE $wpdb->post2cat SET category_id='1' WHERE category_id='$cat_ID'"); - header('Location: categories.php?message=2'); + header('Location: categories.php?message=2'); break;