WordPress.org

Make WordPress Core

Changeset 39611


Ignore:
Timestamp:
12/16/16 05:49:02 (11 months ago)
Author:
dd32
Message:

Taxonomy: Restore the ability to use string-based $args in wp_get_object_terms().

Props tyxla.
Merges [39578] to the 4.7 branch.
Fixes #39215.

Location:
branches/4.7
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/4.7

  • branches/4.7/src/wp-includes/taxonomy.php

    r39476 r39611  
    18721872    $object_ids = array_map('intval', $object_ids); 
    18731873 
     1874    $args = wp_parse_args( $args ); 
     1875 
    18741876    $args['taxonomy'] = $taxonomies; 
    18751877    $args['object_ids'] = $object_ids; 
  • branches/4.7/tests/phpunit/tests/term/wpGetObjectTerms.php

    r38667 r39611  
    691691        return $terms; 
    692692    } 
     693 
     694    public function test_verify_args_parameter_can_be_string() { 
     695        $p = self::factory()->post->create(); 
     696 
     697        $t1 = self::factory()->term->create( array( 
     698            'taxonomy' => $this->taxonomy, 
     699            'name' => 'AAA', 
     700        ) ); 
     701        $t2 = self::factory()->term->create( array( 
     702            'taxonomy' => $this->taxonomy, 
     703            'name' => 'ZZZ', 
     704        ) ); 
     705        $t3 = self::factory()->term->create( array( 
     706            'taxonomy' => $this->taxonomy, 
     707            'name' => 'JJJ', 
     708        ) ); 
     709 
     710        wp_set_object_terms( $p, array( $t1, $t2, $t3 ), $this->taxonomy ); 
     711 
     712        $found = wp_get_object_terms( $p, $this->taxonomy, 'orderby=name&fields=ids' ); 
     713 
     714        $this->assertEquals( array( $t1, $t3, $t2 ), $found ); 
     715    } 
    693716} 
Note: See TracChangeset for help on using the changeset viewer.