Taxonomy: Restore the ability to use string-based $args
in wp_get_object_terms()
.
Props tyxla. Fixes #39215 git-svn-id: https://develop.svn.wordpress.org/trunk@39578 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
1c84857edf
commit
caa1f1f88d
@ -1877,6 +1877,8 @@ function wp_get_object_terms($object_ids, $taxonomies, $args = array()) {
|
|||||||
$object_ids = array($object_ids);
|
$object_ids = array($object_ids);
|
||||||
$object_ids = array_map('intval', $object_ids);
|
$object_ids = array_map('intval', $object_ids);
|
||||||
|
|
||||||
|
$args = wp_parse_args( $args );
|
||||||
|
|
||||||
$args['taxonomy'] = $taxonomies;
|
$args['taxonomy'] = $taxonomies;
|
||||||
$args['object_ids'] = $object_ids;
|
$args['object_ids'] = $object_ids;
|
||||||
|
|
||||||
|
@ -690,4 +690,27 @@ class Tests_Term_WpGetObjectTerms extends WP_UnitTestCase {
|
|||||||
// all terms should still be objects
|
// all terms should still be objects
|
||||||
return $terms;
|
return $terms;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function test_verify_args_parameter_can_be_string() {
|
||||||
|
$p = self::factory()->post->create();
|
||||||
|
|
||||||
|
$t1 = self::factory()->term->create( array(
|
||||||
|
'taxonomy' => $this->taxonomy,
|
||||||
|
'name' => 'AAA',
|
||||||
|
) );
|
||||||
|
$t2 = self::factory()->term->create( array(
|
||||||
|
'taxonomy' => $this->taxonomy,
|
||||||
|
'name' => 'ZZZ',
|
||||||
|
) );
|
||||||
|
$t3 = self::factory()->term->create( array(
|
||||||
|
'taxonomy' => $this->taxonomy,
|
||||||
|
'name' => 'JJJ',
|
||||||
|
) );
|
||||||
|
|
||||||
|
wp_set_object_terms( $p, array( $t1, $t2, $t3 ), $this->taxonomy );
|
||||||
|
|
||||||
|
$found = wp_get_object_terms( $p, $this->taxonomy, 'orderby=name&fields=ids' );
|
||||||
|
|
||||||
|
$this->assertEquals( array( $t1, $t3, $t2 ), $found );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user