Prefiller implements Registerable, JsonSerializable Uses Query_Aware, Params_Provider

Handles prefilling of the query.

Interfaces, Classes and Traits

Registerable
JsonSerializable

Table of Contents

$filters  : Collection
List of filters loaded based on the prefilling parameters.
$orderby  : string
Orderby parameter for the query.
$paged  : string|int
Paged parameter for the query.
$parameters  : Collection
URL parameters request.
$post_ids  : array<string|int, mixed>
Collection of post ids that has been found.
$is_404  : bool
Whether or not the query is a 404.
$run  : bool
Whether or not the prefiller should run.
assets()  : void
Attach the json on the frontend.
get_orderby()  : string|bool
Get the orderby parameter for prefilling.
init()  : void
Initialize the service.
is_404()  : bool
Check whether or not the query is a 404.
jsonSerialize()  : array<string|int, mixed>
Load the prefilling parameters for the counters request.
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.
parse_request()  : Collection
Parses string as if it were the query string passed via a URL and sets variables in the current scope.
prepare_url_params()  : array<string|int, mixed>
Prepare the collection of parameters that will then be injected into the url.
register()  : void
Hook the service.
set_is_404()  : self
Set whether or not the query is a 404.
set_should_run()  : self
Set whether or not the automated counters update ajax request should run.
should_run()  : bool
Determine whether or not the prefiller ajax request should run.
update_query_vars()  : void
Update the query parameters with the prefelling results.
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.

Properties

$filters

List of filters loaded based on the prefilling parameters.

public Collection $filters

$orderby

Orderby parameter for the query.

public string $orderby

$paged

Paged parameter for the query.

public string|int $paged

$parameters

URL parameters request.

public Collection $parameters

$post_ids

Collection of post ids that has been found.

public array<string|int, mixed> $post_ids = []

$is_404

Whether or not the query is a 404.

protected bool $is_404 = false

$run

Whether or not the prefiller should run.

protected bool $run = true

Methods

assets()

Attach the json on the frontend.

public assets() : void
Return values
void

get_orderby()

Get the orderby parameter for prefilling.

public get_orderby() : string|bool
Return values
string|bool

init()

Initialize the service.

public init() : void
Return values
void

is_404()

Check whether or not the query is a 404.

public is_404() : bool
Return values
bool

jsonSerialize()

Load the prefilling parameters for the counters request.

public jsonSerialize() : array<string|int, mixed>
Return values
array<string|int, mixed>

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

parse_request()

Parses string as if it were the query string passed via a URL and sets variables in the current scope.

public parse_request(string $string) : Collection
Parameters
$string : string
Return values
Collection

prepare_url_params()

Prepare the collection of parameters that will then be injected into the url.

public prepare_url_params() : array<string|int, mixed>
Return values
array<string|int, mixed>

register()

Hook the service.

public register() : void
Return values
void

set_is_404()

Set whether or not the query is a 404.

public set_is_404(bool $is_404) : self
Parameters
$is_404 : bool

whether or not the query is a 404.

Return values
self

set_should_run()

Set whether or not the automated counters update ajax request should run.

public set_should_run(bool $run) : self
Parameters
$run : bool
Return values
self

should_run()

Determine whether or not the prefiller ajax request should run.

public should_run() : bool

This request updates the counters automatically on page load.

Return values
bool

update_query_vars()

Update the query parameters with the prefelling results.

public update_query_vars(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
Return values
void

Search results