From a05a51829a23a79bbf6df8f7db5468ed2eb0080b Mon Sep 17 00:00:00 2001 From: ryan Date: Fri, 21 May 2010 18:03:53 +0000 Subject: [PATCH] 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 --- wp-includes/taxonomy.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/wp-includes/taxonomy.php b/wp-includes/taxonomy.php index 8117a2aac..2f8e9ba80 100644 --- a/wp-includes/taxonomy.php +++ b/wp-includes/taxonomy.php @@ -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.