In `wp_update_term()`, limit duplicate slug checks to the same taxonomy as the updated term.

In 4.1 [30240], `wp_insert_term()` was modified to allow the creation of terms
with duplicate slugs, as long as the terms are in different taxonomies.
`wp_update_term()` didn't get the corresponding modification, with the result
that term updates fail when the term being updated shares a slug with an older
term, regardless of that older term's taxonomy.

Props ipm-frommen.
Fixes #30780 for trunk.
Built from https://develop.svn.wordpress.org/trunk@30985


git-svn-id: http://core.svn.wordpress.org/trunk@30971 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Boone Gorges 2014-12-22 15:33:25 +00:00
parent bc1341628f
commit b806668e71
1 changed files with 2 additions and 2 deletions

View File

@ -3353,8 +3353,8 @@ function wp_update_term( $term_id, $taxonomy, $args = array() ) {
$parent = apply_filters( 'wp_update_term_parent', $args['parent'], $term_id, $taxonomy, $parsed_args, $args );
// Check for duplicate slug
$id = $wpdb->get_var( $wpdb->prepare( "SELECT term_id FROM $wpdb->terms WHERE slug = %s", $slug ) );
if ( $id && ($id != $term_id) ) {
$duplicate = get_term_by( 'slug', $slug, $taxonomy );
if ( $duplicate && $duplicate->term_id != $term_id ) {
// If an empty slug was passed or the parent changed, reset the slug to something unique.
// Otherwise, bail.
if ( $empty_slug || ( $parent != $term['parent']) )