If slug and name match an existing term in the same taxonomy at the same hieararchy level return error. fixes #13481
git-svn-id: https://develop.svn.wordpress.org/trunk@14784 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
b7f90a2046
commit
90ae6fa7f8
|
@ -1626,6 +1626,9 @@ function wp_insert_term( $term, $taxonomy, $args = array() ) {
|
|||
if ( false === $wpdb->insert( $wpdb->terms, compact( 'name', 'slug', 'term_group' ) ) )
|
||||
return new WP_Error('db_insert_error', __('Could not insert term into the database'), $wpdb->last_error);
|
||||
$term_id = (int) $wpdb->insert_id;
|
||||
} elseif ( is_term( (int) $term_id, $taxonomy ) ) {
|
||||
// Same name, same slug.
|
||||
return new WP_Error('term_exists', __('A term with the name provided already exists.'));
|
||||
}
|
||||
} else {
|
||||
// This term does not exist at all in the database, Create it.
|
||||
|
|
Loading…
Reference in New Issue