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
This commit is contained in:
parent
7104f60653
commit
d53401fbd5
|
@ -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 = "<a href='categories.php?action=edit&cat_ID=$category->cat_ID' class='edit'>" . __('Edit') . "</a></td><td><a href='categories.php?action=Delete&cat_ID=$category->cat_ID' onclick=\"return confirm('". sprintf(__("You are about to delete the category \'%s\'. All of its posts will go to the default category.\\n \'OK\' to delete, \'Cancel\' to stop."), addslashes($category->cat_name)) . "')\" class='delete'>" . __('Delete') . "</a>";
|
||||
$edit = "<a href='categories.php?action=edit&cat_ID=$category->cat_ID' class='edit'>" . __('Edit') . "</a></td><td><a href='categories.php?action=delete&cat_ID=$category->cat_ID' onclick=\"return confirm('". sprintf(__("You are about to delete the category \'%s\'. All of its posts will go to the default category.\\n \'OK\' to delete, \'Cancel\' to stop."), addslashes($category->cat_name)) . "')\" class='delete'>" . __('Delete') . "</a>";
|
||||
else
|
||||
$edit = '';
|
||||
|
||||
|
|
|
@ -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 <strong>%s</strong> category: this is the default one"), $cat_name));
|
||||
if ( 1 == $cat_ID )
|
||||
die(sprintf(__("Can't delete the <strong>%s</strong> 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;
|
||||
|
||||
|
|
Loading…
Reference in New Issue