| 1 | --- trunk/wp-admin/admin-db.php
|
|---|
| 2 | +++ trunk/wp-admin/admin-db.php
|
|---|
| 3 | @@ -92,16 +92,14 @@
|
|---|
| 4 | $update = true;
|
|---|
| 5 | } else {
|
|---|
| 6 | $update = false;
|
|---|
| 7 | - $id_result = $wpdb->get_row("SHOW TABLE STATUS LIKE '$wpdb->categories'");
|
|---|
| 8 | - $cat_ID = $id_result->Auto_increment;
|
|---|
| 9 | }
|
|---|
| 10 |
|
|---|
| 11 | $cat_name = wp_specialchars($cat_name);
|
|---|
| 12 |
|
|---|
| 13 | if (empty ($category_nicename))
|
|---|
| 14 | - $category_nicename = sanitize_title($cat_name, $cat_ID);
|
|---|
| 15 | + $category_nicename = sanitize_title($cat_name);
|
|---|
| 16 | else
|
|---|
| 17 | - $category_nicename = sanitize_title($category_nicename, $cat_ID);
|
|---|
| 18 | + $category_nicename = sanitize_title($category_nicename);
|
|---|
| 19 |
|
|---|
| 20 | if (empty ($category_description))
|
|---|
| 21 | $category_description = '';
|
|---|
| 22 | @@ -109,18 +107,22 @@
|
|---|
| 23 | if (empty ($category_parent))
|
|---|
| 24 | $category_parent = 0;
|
|---|
| 25 |
|
|---|
| 26 | - if (!$update)
|
|---|
| 27 | - $query = "INSERT INTO $wpdb->categories (cat_ID, cat_name, category_nicename, category_description, category_parent) VALUES ('0', '$cat_name', '$category_nicename', '$category_description', '$cat')";
|
|---|
| 28 | - else
|
|---|
| 29 | - $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'";
|
|---|
| 30 | + if (!$update) {
|
|---|
| 31 | + $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')" );
|
|---|
| 32 | + $cat_ID = $wpdb->insert_id;
|
|---|
| 33 | + } else {
|
|---|
| 34 | + $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'" );
|
|---|
| 35 | + }
|
|---|
| 36 | + if ( $category_nicename == '' ) {
|
|---|
| 37 | + $category_nicename = sanitize_title($cat_name, $cat_ID );
|
|---|
| 38 | + $wpdb->query( "UPDATE $wpdb->categories SET category_nicename = '$category_nicename' WHERE cat_ID = '$cat_ID'" );
|
|---|
| 39 | + }
|
|---|
| 40 |
|
|---|
| 41 | - $result = $wpdb->query($query);
|
|---|
| 42 | -
|
|---|
| 43 | if ($update) {
|
|---|
| 44 | do_action('edit_category', $cat_ID);
|
|---|
| 45 | } else {
|
|---|
| 46 | - do_action('create_category', $rval);
|
|---|
| 47 | - do_action('add_category', $rval);
|
|---|
| 48 | + do_action('create_category', $cat_ID);
|
|---|
| 49 | + do_action('add_category', $cat_ID);
|
|---|
| 50 | }
|
|---|
| 51 |
|
|---|
| 52 | return $cat_ID;
|
|---|