Taxonomy extends Type implements Indexable_Filter, Filterable_Filter, Queriable_Filter, Formattable_Filter, Restrictable_Filter, Injectable_Filter Uses Filter_Can_Index_Taxonomy, Filter_Can_Restrict_Terms, Filter_Has_Injectable_Properties

Represents a filter type.

Tags
author

Barn2 Plugins support@barn2.com

license

GPL-3.0

copyright

Barn2 Media Ltd

Interfaces, Classes and Traits

Indexable_Filter
Indexable_Filter provides a single method "generate_index_data".
Filterable_Filter
Filterable_Filter provides a single method "get_indexed_values".
Queriable_Filter
Queriable_Filter provides a single method "attach_statement".
Formattable_Filter
Formattable_Filter interface provides a single method "get_active_formatted_values".
Restrictable_Filter
Restrictable_Filter interface
Injectable_Filter
Injectable_Filter interface

Table of Contents

$filter  : Filter
The filter object.
__construct()  : mixed
Initialize the type.
attach_statement()  : void
Attach a statement to the filtering query.
generate_index_data()  : array<string|int, mixed>
Generate data for the indexer.
get_active_formatted_values()  : array<string|int, mixed>
Get the formatted values of the filter that are currently active.
get_filter()  : Filter
Get the filter object.
get_formatted_search_query()  : array<string|int, mixed>
Format the search query to ensure it's an array of integers.
get_ids_from_results()  : array<string|int, mixed>
Get the post IDs from the results.
get_indexable_taxonomy_data()  : array<string|int, mixed>
Generate taxonomy index data.
get_indexed_terms()  : array<string|int, mixed>
Get indexed terms for this filter type.
get_indexed_values()  : array<string|int, mixed>
Get indexed values for this filter type.
get_matching_posts()  : array<string|int, mixed>
Get the posts that match the filter.
get_specific_terms()  : array<string|int, mixed>
Get the specific terms for the filter.
get_taxonomy_slug()  : string|false
Get the proper taxonomy slug based on the type of source selected.
get_terms_from_attribute()  : array<string|int, mixed>|false
Get the terms from the product's attributes.
inject_properties()  : array<string|int, mixed>
Inject properties into the possible choices.
is_restricted_to_specific_terms()  : bool
Determine if the filter is restricted to specific terms.
restrict_possible_choices()  : array<string|int, mixed>
Restrict the possible choices based on specific terms selection.

Properties

Methods

__construct()

Initialize the type.

public __construct(Filter $filter) : mixed
Parameters
$filter : Filter

The filter object.

Return values
mixed

attach_statement()

Attach a statement to the filtering query.

public attach_statement(Query &$statement[, bool $is_first = false ]) : void

This method is responsible for attaching a statement to the filtering query, making it possible to query the database for the filtered products.

Parameters
$statement : Query

The query object to modify.

$is_first : bool = false

Whether this is the first filter in the query.

Return values
void

generate_index_data()

Generate data for the indexer.

public generate_index_data(array<string|int, mixed> $defaults, string $post_id) : array<string|int, mixed>
Parameters
$defaults : array<string|int, mixed>

default index values

$post_id : string

the ID of the post to index

Tags
inheritdoc
Return values
array<string|int, mixed>

get_active_formatted_values()

Get the formatted values of the filter that are currently active.

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

get_filter()

Get the filter object.

public get_filter() : Filter
Return values
Filter

get_formatted_search_query()

Format the search query to ensure it's an array of integers.

public get_formatted_search_query(string|array<string|int, mixed> $search_query) : array<string|int, mixed>
Parameters
$search_query : string|array<string|int, mixed>

The input search query.

Return values
array<string|int, mixed>

An array of integers.

get_ids_from_results()

Get the post IDs from the results.

public get_ids_from_results(array<string|int, mixed> $results) : array<string|int, mixed>
Parameters
$results : array<string|int, mixed>

The results from the database.

Return values
array<string|int, mixed>

get_indexable_taxonomy_data()

Generate taxonomy index data.

public get_indexable_taxonomy_data(array<string|int, mixed> $defaults, string $post_id, string $taxonomy) : array<string|int, mixed>
Parameters
$defaults : array<string|int, mixed>

the default index data.

$post_id : string

the post ID.

$taxonomy : string

the taxonomy slug.

Return values
array<string|int, mixed>

get_indexed_terms()

Get indexed terms for this filter type.

public get_indexed_terms([array<string|int, mixed> $posts = [] ]) : array<string|int, mixed>
Parameters
$posts : array<string|int, mixed> = []

The posts to look up. When empty, all values will be returned.

Return values
array<string|int, mixed>

get_indexed_values()

Get indexed values for this filter type.

public get_indexed_values([array<string|int, mixed> $posts = [] ]) : array<string|int, mixed>
Parameters
$posts : array<string|int, mixed> = []

The posts to look up. When empty, all values will be returned.

Return values
array<string|int, mixed>

get_matching_posts()

Get the posts that match the filter.

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

get_specific_terms()

Get the specific terms for the filter.

public get_specific_terms() : array<string|int, mixed>

This method returns an array of term IDs.

Return values
array<string|int, mixed>

get_taxonomy_slug()

Get the proper taxonomy slug based on the type of source selected.

public get_taxonomy_slug() : string|false
Return values
string|false

get_terms_from_attribute()

Get the terms from the product's attributes.

public get_terms_from_attribute(int $variation_id, string $taxonomy) : array<string|int, mixed>|false
Parameters
$variation_id : int

the variation ID.

$taxonomy : string

the taxonomy slug.

Return values
array<string|int, mixed>|false

inject_properties()

Inject properties into the possible choices.

public inject_properties(array<string|int, mixed> $possible_choices) : array<string|int, mixed>
Parameters
$possible_choices : array<string|int, mixed>

The possible choices.

Return values
array<string|int, mixed>

The possible choices with injected properties.

is_restricted_to_specific_terms()

Determine if the filter is restricted to specific terms.

public is_restricted_to_specific_terms() : bool
Return values
bool

restrict_possible_choices()

Restrict the possible choices based on specific terms selection.

public restrict_possible_choices(array<string|int, mixed> $possible_choices) : array<string|int, mixed>

Purposefully ignore phpcs warnings for now.

Parameters
$possible_choices : array<string|int, mixed>

All the possible choices for all filters.

Return values
array<string|int, mixed>

The restricted possible choices.

Search results