Check term_id
against the $term
object, not the non-existent var $args
. Props rboren. Fixes #12729.
git-svn-id: https://develop.svn.wordpress.org/trunk@25106 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
ad94ffb64d
commit
39171d7527
@ -2380,8 +2380,8 @@ function wp_unique_term_slug($slug, $term) {
|
||||
}
|
||||
|
||||
// If we didn't get a unique slug, try appending a number to make it unique.
|
||||
if ( !empty($args['term_id']) )
|
||||
$query = $wpdb->prepare( "SELECT slug FROM $wpdb->terms WHERE slug = %s AND term_id != %d", $slug, $args['term_id'] );
|
||||
if ( ! empty( $term->term_id ) )
|
||||
$query = $wpdb->prepare( "SELECT slug FROM $wpdb->terms WHERE slug = %s AND term_id != %d", $slug, $term->term_id );
|
||||
else
|
||||
$query = $wpdb->prepare( "SELECT slug FROM $wpdb->terms WHERE slug = %s", $slug );
|
||||
|
||||
|
@ -373,8 +373,17 @@ class Tests_Term extends WP_UnitTestCase {
|
||||
$e = wp_insert_term( 'child-neighbor', $this->taxonomy, array( 'parent' => $c['term_id'] ) );
|
||||
$this->assertEquals( 'child-neighbor-2', wp_unique_term_slug( 'child', $d_term ) );
|
||||
|
||||
$f = wp_insert_term( 'foo', $this->taxonomy );
|
||||
$this->assertInternalType( 'array', $f );
|
||||
$f_term = get_term( $f['term_id'], $this->taxonomy );
|
||||
$this->assertEquals( 'foo', $f_term->slug );
|
||||
$this->assertEquals( 'foo', wp_unique_term_slug( 'foo', $f_term ) );
|
||||
|
||||
$g = wp_insert_term( 'foo', $this->taxonomy );
|
||||
$this->assertInstanceOf( 'WP_Error', $g );
|
||||
|
||||
// clean up
|
||||
foreach ( array( $a, $b, $c, $d, $e ) as $t )
|
||||
foreach ( array( $a, $b, $c, $d, $e, $f ) as $t )
|
||||
$this->assertTrue( wp_delete_term( $t['term_id'], $this->taxonomy ) );
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user