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

git-svn-id: http://svn.automattic.com/wordpress/trunk@7336 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
ryan
2008-03-16 20:37:02 +00:00
parent c41402325f
commit 4f60026851
3 changed files with 13 additions and 2 deletions

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) ) {