diff --git a/src/wp-includes/taxonomy.php b/src/wp-includes/taxonomy.php index bed3894334..7fa4076acf 100644 --- a/src/wp-includes/taxonomy.php +++ b/src/wp-includes/taxonomy.php @@ -1877,6 +1877,8 @@ function wp_get_object_terms($object_ids, $taxonomies, $args = array()) { $object_ids = array($object_ids); $object_ids = array_map('intval', $object_ids); + $args = wp_parse_args( $args ); + $args['taxonomy'] = $taxonomies; $args['object_ids'] = $object_ids; diff --git a/tests/phpunit/tests/term/wpGetObjectTerms.php b/tests/phpunit/tests/term/wpGetObjectTerms.php index a03550157c..95c8abcb62 100644 --- a/tests/phpunit/tests/term/wpGetObjectTerms.php +++ b/tests/phpunit/tests/term/wpGetObjectTerms.php @@ -690,4 +690,27 @@ class Tests_Term_WpGetObjectTerms extends WP_UnitTestCase { // all terms should still be objects 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 ); + } }