[wp-trac] [WordPress Trac] #40661: WP_Term_Query->parse_query() needs filter like 'get_terms'
WordPress Trac
noreply at wordpress.org
Fri Jun 23 02:56:24 UTC 2017
#40661: WP_Term_Query->parse_query() needs filter like 'get_terms'
------------------------------------------+------------------------------
Reporter: mpol | Owner:
Type: enhancement | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Taxonomy | Version:
Severity: normal | Resolution:
Keywords: needs-unit-tests needs-patch | Focuses:
------------------------------------------+------------------------------
Changes (by boonebgorges):
* keywords: has-patch needs-refresh needs-unit-tests => needs-unit-tests
needs-patch
Comment:
Hi all - @mpol Thanks for the report, and @jarocks thanks for the follow-
up patch.
For clarification, this appears to have nothing to do with
`parse_query()`. `parse_query()`, in `WP_Term_Query` and in other query
classes, is where the arguments passed to the `query()` method are parsed
together with the default arguments and validated.
`WP_Term_Query::parse_query()` does, in fact, have an action available for
plugins to intervene: `parse_term_query`.
What's being requested here is a filter on the results of the query. The
`get_terms` filter still exists, but when `WP_Term_Query` was introduced,
it was decided to leave that filter in the `get_terms()` wrapper function,
for naming consistency.
@jarocks The pre-query filter you've suggested here is interesting, but I
don't think it serves the purpose of this ticket. custom-taxonomy-order-ne
and similar plugins work by modifying the results of the core query;
`posts_pre_query` is a way of preventing core queries from taking place.
Here's the pattern elsewhere in our query classes:
* `WP_Query` runs a filter `posts_results` on query results
* `WP_Comment_Query` runs a filter `the_comments` on query results
* `WP_User_Query` has no results filter, either in the query class or in
the `get_users()` wrapper function
So there's not a great pattern to follow here. `term_query_results` seems
like a reasonable naming convention. What do others think?
--
Ticket URL: <https://core.trac.wordpress.org/ticket/40661#comment:4>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list