Opened 17 years ago
Closed 16 years ago
#3799 closed enhancement (fixed)
improvements for submitting new categories via wp-admin/categories.php
Reported by: |
|
Owned by: |
|
---|---|---|---|
Milestone: | 2.5 | Priority: | normal |
Severity: | normal | Version: | |
Component: | Administration | Keywords: | category has-patch |
Focuses: | Cc: |
Description
There are 2 things I would like to improve wile submitting new category into WP.
- If user by accident chose category name which is already exists in the system
- If user by accident hit submit without entering any category name (category name is empty).
In order to fix this problems 3 files need to be updated.
- wp-admin/admin-ajax.php
add after line 132 (case 'add-cat')
following code:
##################
$cat = wp_insert_category($_POST);
if ( !$cat ) #= wp_insert_category( $_POST ) )
die('4');
$rr = $cat;
if (is_string($rr) && preg_match('/same/',$rr))
die('5');
# if ( !$cat = wp_insert_category( $_POST ) )
# die('0');
##################
- wp-admin/admin-db.php
add in the function wp_insert_category($catarr)
after line 85
following code:
#############
$ccat = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->categories WHERE cat_name = '$cat_name'");
if ($ccat)
return 'same';
#############
- /wp-includes/js/wp-ajax-js.php
add after line 61 (in ParseAjaxResponse)
following code or make adjustment to existing error definition:
else if ( 4 == r ) {
Element.update(this.myResponseElement,"<div class='error'><p><?php _e("Something strange happened. Category field is empty."); ?></p></div>");
return false;
} else if ( 5 == r ) {
Element.update(this.myResponseElement,"<div class='error'><p><?php _e("Something strange happened. The same category name already exists."); ?></p></div>");
return false;
}
Attachments (5)
Change History (16)
#3
@
17 years ago
- Keywords patched added; needs-patch removed
- Resolution set to worksforme
- Status changed from new to closed
#4
@
17 years ago
- Keywords has-patch added; patched removed
- Resolution worksforme deleted
- Status changed from closed to reopened
#8
@
16 years ago
On trunk you get visual feedback if the box is empty already.
But you can add an identically named category but you don't end up with two.
#9
@
16 years ago
- Owner changed from anonymous to mdawaffe
- Status changed from reopened to new
Uploading a patch which stops duplicate category creation.
However the current ajax code doesn't seem to display any errors that are returned.
mdawaffe any clues?
Patch it up!
But instead of:
"Something strange happened. The same category name already exists."
Do:
"The same category name already exists."
We know what happened... no need to attribute it to mystical forces. :-)