mirror of
https://github.com/WordPress/WordPress.git
synced 2024-12-23 09:37:42 +01:00
If slug and name match an existing term in the same taxonomy at the same hieararchy level return error. fixes #13481
git-svn-id: http://svn.automattic.com/wordpress/trunk@14784 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
7d01ad3a49
commit
a05a51829a
@ -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
Block a user