Add filter to flat term selector#58941
Conversation
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
…t-term-selector-query-filter
|
Warning: Type of PR label mismatch To merge this PR, it requires exactly 1 label indicating the type of PR. Other labels are optional and not being checked here.
Read more about Type labels in Gutenberg. Don't worry if you don't have the required permissions to add labels; the PR reviewer should be able to help with the task. |
|
Hi, I just wanted to follow up on this PR as I put it in some time ago. Is there any feedback or could this code be approved and merged as is? Thanks! |
|
Considering that the search query can be modified via the HTTP API filter, I am unsure how helpful the new filter would be. Additionally, whole-term selector components can be replaced via the Example filter add_filter( 'rest_post_tag_query', function( $query_args, $request ) {
// Only modify search query.
if ( ! isset( $query_args['search'] ) ) {
return $query_args;
}
// Display most used tags first.
$query_args['order'] = 'desc';
$query_args['orderby'] = 'count';
return $query_args;
}, 10, 2 ); |
|
That makes sense. I'll close this PR. Thx! |
What?
This is a follow up to a PR I submitted that was merged. This PR adds a filter to the query for those that want more control over the query.
Why?
There was a comment left on my PR asking for the older behavior. In some situations when there is a lot of terms, the query is not ideal. Having control over this in a case by case basis can be handy.
How?
This just applies a filter named
editor.FlatTermSelector.queryArgsto the query. It passes theDEFAULT_QUERYconstant as default query, and taxonomy slug as second argument.Testing Instructions
Testing Instructions for Keyboard
N/A
Screenshots or screencast
N/A