REST API: Terms: Respect taxonomy's default query args #7848
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Port of WordPress/gutenberg#67154.
What
It is possible to supply a set of default query
args
toregister_taxonomy()
which will be used when querying a list of terms -- for example,orderby
in order to specify how the resulting list of terms should be sorted. This PR makes it so that the list of terms returned by the Terms REST API controller respects that order if no post ID is included in the REST API request.How
The controller's
get_items()
method has two code branches:get_items()
useswp_get_object_terms()
to get the terms associated with the given post. That function already includes code to respect the default queryargs
specified when the taxonomy was registered.get_terms()
, which does not respect the default query args.This PR adds code to respect the default query args if no post ID is given.
Trac ticket: https://core.trac.wordpress.org/ticket/62500
This Pull Request is for code review only. Please keep all other discussion in the Trac ticket. Do not merge this Pull Request. See GitHub Pull Requests for Code Review in the Core Handbook for more details.