Custom_Field extends Type implements Indexable_Filter, Injectable_Filter, Queriable_Filter, Formattable_Filter

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".
Injectable_Filter
Injectable_Filter interface
Queriable_Filter
Queriable_Filter provides a single method "attach_statement".
Formattable_Filter
Formattable_Filter interface provides a single method "get_active_formatted_values".

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_checkboxes_search_query()  : array<string|int, mixed>
Get the search query for checkboxes.
get_custom_field_key()  : string
Retrieve the meta key assigned to the filter.
get_custom_field_type()  : string
Retrieve the custom field type assigned to the filter.
get_filter()  : Filter
Get the filter object.
get_formatted_search_query()  : array<string|int, mixed>
Get the formatted search query.
get_ids_from_results()  : array<string|int, mixed>
Get the post IDs from the results.
inject_properties()  : array<string|int, mixed>
Inject properties into the possible choices.

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>

For custom fields, we only want to display the name of the filter right now.

Return values
array<string|int, mixed>

get_checkboxes_search_query()

Get the search query for checkboxes.

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

get_custom_field_key()

Retrieve the meta key assigned to the filter.

public get_custom_field_key() : string
Return values
string

get_custom_field_type()

Retrieve the custom field type assigned to the filter.

public get_custom_field_type() : string
Return values
string

get_filter()

Get the filter object.

public get_filter() : Filter
Return values
Filter

get_formatted_search_query()

Get the formatted search query.

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

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>

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.

Search results