Don't allow duplicate category creation. Props westi and mdawaffe. fixes #3799

git-svn-id: https://develop.svn.wordpress.org/trunk@7336 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Ryan Boren
2008-03-16 20:37:02 +00:00
parent f0b35af5b9
commit 11620cd3b4
3 changed files with 13 additions and 2 deletions
+8
View File
@@ -246,6 +246,14 @@ case 'add-cat' : // From Manage->Categories
$x->send();
}
if ( category_exists( trim( $_POST['cat_name'] ) ) ) {
$x = new WP_Ajax_Response( array(
'what' => 'cat',
'id' => new WP_Error( 'cat_exists', __('The category you are trying to create already exists.'), array( 'form-field' => 'cat_name' ) ),
) );
$x->send();
}
$cat = wp_insert_category( $_POST, true );
if ( is_wp_error($cat) ) {