Restore support for taxonomy 'args' override when querying object terms.
[7520] introduced an undocumented feature whereby developers could register a custom taxonomy with an 'args' parameter, consisting of an array of config params that, when present, override corresponding params in the `$args` array passed to `wp_get_object_terms()` when using that function to query for terms in the specified taxonomy. The `wp_get_object_terms()` refactor in [38667] failed to respect this secret covenant, and the current changeset atones for the transgression. Ports [40513] to the 4.7 branch. Props danielbachhuber. Fixes #40496. Built from https://develop.svn.wordpress.org/branches/4.7@40514 git-svn-id: http://core.svn.wordpress.org/branches/4.7@40390 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
0516c67beb
commit
820070e588
|
@ -1873,10 +1873,30 @@ function wp_get_object_terms($object_ids, $taxonomies, $args = array()) {
|
|||
|
||||
$args = wp_parse_args( $args );
|
||||
|
||||
/*
|
||||
* When one or more queried taxonomies is registered with an 'args' array,
|
||||
* those params override the `$args` passed to this function.
|
||||
*/
|
||||
$terms = array();
|
||||
if ( count( $taxonomies ) > 1 ) {
|
||||
foreach ( $taxonomies as $index => $taxonomy ) {
|
||||
$t = get_taxonomy( $taxonomy );
|
||||
if ( isset( $t->args ) && is_array( $t->args ) && $args != array_merge( $args, $t->args ) ) {
|
||||
unset( $taxonomies[ $index ] );
|
||||
$terms = array_merge( $terms, wp_get_object_terms( $object_ids, $taxonomy, array_merge( $args, $t->args ) ) );
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$t = get_taxonomy( $taxonomies[0] );
|
||||
if ( isset( $t->args ) && is_array( $t->args ) ) {
|
||||
$args = array_merge( $args, $t->args );
|
||||
}
|
||||
}
|
||||
|
||||
$args['taxonomy'] = $taxonomies;
|
||||
$args['object_ids'] = $object_ids;
|
||||
|
||||
$terms = get_terms( $args );
|
||||
$terms = array_merge( $terms, get_terms( $args ) );
|
||||
|
||||
/**
|
||||
* Filters the terms for a given object or objects.
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
*
|
||||
* @global string $wp_version
|
||||
*/
|
||||
$wp_version = '4.7.5-alpha-40512';
|
||||
$wp_version = '4.7.5-alpha-40514';
|
||||
|
||||
/**
|
||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||
|
|
Loading…
Reference in New Issue