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. Merges [30985] to the 4.1 branch. Fixes #30780. Built from https://develop.svn.wordpress.org/branches/4.1@31378 git-svn-id: http://core.svn.wordpress.org/branches/4.1@31359 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
93cf0191c3
commit
7ba6f5dfd4
|
@ -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']) )
|
||||
|
|
Loading…
Reference in New Issue