Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Turn certain filters into WP_Query arguments #3352

Open
1 task done
JakePT opened this issue Mar 1, 2023 · 0 comments
Open
1 task done

Turn certain filters into WP_Query arguments #3352

JakePT opened this issue Mar 1, 2023 · 0 comments
Milestone

Comments

@JakePT
Copy link
Contributor

JakePT commented Mar 1, 2023

Is your enhancement related to a problem? Please describe.

In certain parts of the plugin, custom filters are used to apply changes or functionality to WP_Query queries. The downside of this approach is that it's hard to target queries specifically as any query that occurs after adding to the filter will receive the changes.

I ran into this issue developing the facet block, which uses the ep_is_facetable filter to enable faceting for the queries used to create the block previews. This filter applies aggregations to the query and populates a global variable with the results of those aggregations. I was experiencing an issue where another query was somehow being fired down the chain, which meant that aggregations were also applied to that query and the global variable was populated with aggregations for the wrong query.

A better approach would be to support an ep_is_facetable argument in WP_Query which applies the aggregations to just that query. Then, instead of populating a global variable, the aggregation results could be applied to the query object itself. This keeps everything contained to the specific query that needs to be facetable.

With a quick look I've identified these filters that could use this approach:

  • ep_is_facetable
  • ep_intercept_remote_request
  • ep_bypass_exclusion_from_search

There may be others.

Designs

No response

Describe alternatives you've considered

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct
@felipeelia felipeelia added this to the 5.0.0 milestone Mar 1, 2023
@felipeelia felipeelia modified the milestones: 5.0.0, 4.7.0 Jun 16, 2023
@felipeelia felipeelia modified the milestones: 4.7.0, 5.0.0 Jul 18, 2023
@felipeelia felipeelia modified the milestones: 5.0.0, 5.1.0 Nov 1, 2023
@gosixl gosixl mentioned this issue Jan 29, 2024
1 task
@felipeelia felipeelia modified the milestones: 5.1.0, 5.2.0 Feb 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants