Query_Aware
Table of Contents
- get_orderby() : string|bool
- Get the orderby parameter for prefilling.
- maybe_insert_search_query() : void
- If a filter was found within the request, update the query instance by injecting the appropriate search query.
- maybe_order_results() : void
- If an orderby parameter was found within the request, update the query instance by injecting the appropriate sorting functions/parameters.
- maybe_unset_tax_queries() : void
- Unset the tax queries from the query instance.
- array_remove_empty() : array<string|int, mixed>
- Recursively remove empty values from a collection.
- attach_search_query_to_filters() : Collection
- Attach the value of the filter from the frontend request, to the `Filter` instance `search_query` attribute.
- get_filtered_post_ids() : array<string|int, mixed>
- Query the database and find all post ids belonging to the selected filters.
- is_main_query() : bool
- Determine if it's a query we should be filtering or not.
- prepare_requested_filters_collection() : Collection
- Apply specific modifications to the collection keys and/or values.
- process_filters() : void
- Load the filters and attach values to them.
Methods
get_orderby()
Get the orderby parameter for prefilling.
public
get_orderby() : string|bool
Return values
string|bool —maybe_insert_search_query()
If a filter was found within the request, update the query instance by injecting the appropriate search query.
public
maybe_insert_search_query(WP_Query &$wp_query) : void
Parameters
- $wp_query : WP_Query
Return values
void —maybe_order_results()
If an orderby parameter was found within the request, update the query instance by injecting the appropriate sorting functions/parameters.
public
maybe_order_results(WP_Query &$query) : void
Parameters
- $query : WP_Query
Return values
void —maybe_unset_tax_queries()
Unset the tax queries from the query instance.
public
maybe_unset_tax_queries(WP_Query &$query) : void
Parameters
- $query : WP_Query
Return values
void —array_remove_empty()
Recursively remove empty values from a collection.
private
array_remove_empty(array<string|int, mixed> $haystack) : array<string|int, mixed>
Parameters
- $haystack : array<string|int, mixed>
Return values
array<string|int, mixed> —attach_search_query_to_filters()
Attach the value of the filter from the frontend request, to the `Filter` instance `search_query` attribute.
private
attach_search_query_to_filters(Collection $collection) : Collection
This is then later used via the get_search_query
method of the Filter.
Parameters
- $collection : Collection
Return values
Collection —get_filtered_post_ids()
Query the database and find all post ids belonging to the selected filters.
private
get_filtered_post_ids([mixed $custom_query = false ]) : array<string|int, mixed>
Parameters
- $custom_query : mixed = false
Return values
array<string|int, mixed> —is_main_query()
Determine if it's a query we should be filtering or not.
private
is_main_query(WP_Query $query) : bool
Parameters
- $query : WP_Query
Return values
bool —prepare_requested_filters_collection()
Apply specific modifications to the collection keys and/or values.
private
prepare_requested_filters_collection(Collection $collection) : Collection
- Modify strings such as "true" or "false" to bools.
- Remove any false (bool) value from the collection.
Parameters
- $collection : Collection
Return values
Collection —process_filters()
Load the filters and attach values to them.
private
process_filters(Collection $requested_filters) : void
Parameters
- $requested_filters : Collection