diff options
| author | donncha <donncha@7be80a69-a1ef-0310-a953-fb0f7c49ff36> | 2005-10-11 15:34:15 +0000 |
|---|---|---|
| committer | donncha <donncha@7be80a69-a1ef-0310-a953-fb0f7c49ff36> | 2005-10-11 15:34:15 +0000 |
| commit | 306b3f523fabadd1fa756b19fdda6cee578edb9d (patch) | |
| tree | 0fb0982858d4b50e124523d0a2236335acf3b199 /wp-inst/wp-admin/admin-db.php | |
| parent | e46b0a2226845a92067cb936cd8324083bb8f3b8 (diff) | |
Category fixes
git-svn-id: http://svn.automattic.com/wordpress-mu/trunk@397 7be80a69-a1ef-0310-a953-fb0f7c49ff36
Diffstat (limited to 'wp-inst/wp-admin/admin-db.php')
| -rw-r--r-- | wp-inst/wp-admin/admin-db.php | 26 |
1 files changed, 14 insertions, 12 deletions
diff --git a/wp-inst/wp-admin/admin-db.php b/wp-inst/wp-admin/admin-db.php index 6afefcb..43d1f03 100644 --- a/wp-inst/wp-admin/admin-db.php +++ b/wp-inst/wp-admin/admin-db.php @@ -92,16 +92,14 @@ function wp_insert_category($catarr) { $update = true; } else { $update = false; - $id_result = $wpdb->get_row("SHOW TABLE STATUS LIKE '$wpdb->categories'"); - $cat_ID = $id_result->Auto_increment; } $cat_name = wp_specialchars($cat_name); if (empty ($category_nicename)) - $category_nicename = sanitize_title($cat_name, $cat_ID); + $category_nicename = sanitize_title($cat_name); else - $category_nicename = sanitize_title($category_nicename, $cat_ID); + $category_nicename = sanitize_title($category_nicename); if (empty ($category_description)) $category_description = ''; @@ -109,18 +107,22 @@ function wp_insert_category($catarr) { if (empty ($category_parent)) $category_parent = 0; - if (!$update) - $query = "INSERT INTO $wpdb->categories (cat_ID, cat_name, category_nicename, category_description, category_parent) VALUES ('0', '$cat_name', '$category_nicename', '$category_description', '$cat')"; - else - $query = "UPDATE $wpdb->categories SET cat_name = '$cat_name', category_nicename = '$category_nicename', category_description = '$category_description', category_parent = '$category_parent' WHERE cat_ID = '$cat_ID'"; - - $result = $wpdb->query($query); + if (!$update) { + $wpdb->query( "INSERT INTO $wpdb->categories (cat_ID, cat_name, category_nicename, category_description, category_parent) VALUES ('0', '$cat_name', '$category_nicename', '$category_description', '$category_parent')" ); + $cat_ID = $wpdb->insert_id; + } else { + $wpdb->query( "UPDATE $wpdb->categories SET cat_name = '$cat_name', category_nicename = '$category_nicename', category_description = '$category_description', category_parent = '$category_parent' WHERE cat_ID = '$cat_ID'" ); + } + if ( $category_nicename == '' ) { + $category_nicename = sanitize_title($cat_name, $cat_ID ); + $wpdb->query( "UPDATE $wpdb->categories SET category_nicename = '$category_nicename' WHERE cat_ID = '$cat_ID'" ); + } if ($update) { do_action('edit_category', $cat_ID); } else { - do_action('create_category', $rval); - do_action('add_category', $rval); + do_action('create_category', $cat_ID); + do_action('add_category', $cat_ID); } return $cat_ID; |
