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:
ryan 2010-05-21 18:03:53 +00:00
parent 7d01ad3a49
commit a05a51829a

View File

@ -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.