Recent

Better_Search_Core_Query class

Better_Search_Core_Query

Better_Search: Main search class.

Since: 4.0.0
Source: includes/class-better-search-core-query.php line 24 Extends: WP_Query

Methods

__construct()

Main constructor.

Since: 3.0.0
Line: 164

public function __construct( $args = ... );
TypeNameDescription
array|string$argsThe Query variables. Accepts an array or a query string.

hooks()

Initialise search hooks.

Since: 3.0.0
Line: 180

public function hooks(  );

prepare_query_args()

Prepare the query variables.

Since: 3.0.0
Line: 220

public function prepare_query_args( $args = ... );
TypeNameDescription
string|array$args{

unset_unnecessary_args() static

Unset unnecessary arguments that are not needed for the WP_Query.

Since: 4.0.0
Line: 468

static public function unset_unnecessary_args( $args ): array;
TypeNameDescription
array$argsArray of arguments.

Returns: array — Modified array of arguments.

should_use_custom_table()

Check if we should use the custom tables for search.

Since: 4.2.0
Line: 506

public function should_use_custom_table(  ): bool;

Returns: bool — Whether to use custom tables.

set_class_variables()

Sets some of the variables used by the CLASS.

Since: 3.0.0
Line: 528

public function set_class_variables( $search_query = ... );
TypeNameDescription
string$search_querySearch query.

pre_get_posts()

Modify the pre_get_posts clause.

Since: 3.0.0
Line: 591

public function pre_get_posts( $query );
TypeNameDescription
WP_Query$queryThe WP_Query instance.

get_match_sql()

Get the MATCH field of the query

Since: 3.0.0
Line: 629

public function get_match_sql( $search_query, $args = ... ): string;
TypeNameDescription
string$search_querySearch query.
array$argsArray of arguments.

Returns: string — MATCH field

posts_fields()

Modify the SELECT clause - posts_fields.

Since: 3.0.0
Line: 702

public function posts_fields( $fields, $query ): string;
TypeNameDescription
string$fieldsThe SELECT clause of the query.
WP_Query$queryThe WP_Query instance.

Returns: string — Updated Fields

posts_join()

Modify the posts_join clause.

Since: 3.0.0
Line: 746

public function posts_join( $join, $query ): string;
TypeNameDescription
string$joinThe JOIN clause of the query.
WP_Query$queryThe WP_Query instance.

Returns: string — Updated JOIN

posts_where()

Modify the posts_where clause.

Since: 3.0.0
Line: 801

public function posts_where( $where, $query ): string;
TypeNameDescription
string$whereThe WHERE clause of the query.
WP_Query$queryThe WP_Query instance.

Returns: string — Updated WHERE

Modify the posts_search clause.

Since: 3.0.0
Line: 838

public function posts_search( $where, $query ): string;
TypeNameDescription
string$whereThe search part of the WHERE clause of the query.
WP_Query$queryThe WP_Query instance.

Returns: string — Updated WHERE

posts_distinct()

Modify the posts_distinct clause.

Since: 3.0.0
Line: 1081

public function posts_distinct( $distinct, $query ): string;
TypeNameDescription
string$distinctThe DISTINCT clause of the query.
WP_Query$queryThe WP_Query instance.

Returns: string — Updated DISTNCT

posts_orderby()

Modify the posts_orderby clause.

Since: 3.0.0
Line: 1115

public function posts_orderby( $orderby, $query ): string;
TypeNameDescription
string$orderbyThe ORDER BY clause of the query.
WP_Query$queryThe WP_Query instance.

Returns: string — Updated ORDER BY

posts_groupby()

Modify the posts_groupby clause.

Since: 3.0.0
Line: 1224

public function posts_groupby( $groupby, $query ): string;
TypeNameDescription
string$groupbyThe GROUP BY clause of the query.
WP_Query$queryThe WP_Query instance.

Returns: string — Updated GROUP BY

posts_clauses()

Filter posts_clauses in WP_Query.

Since: 4.0.0
Line: 1257

public function posts_clauses( $clauses, $query ): array;
TypeNameDescription
string[]$clausesArray of clauses.
\WP_Query$queryThe WP_Query instance.

Returns: array — Updated array of clauses.

posts_request()

Filter posts_request in WP_Query.

Since: 4.0.0
Line: 1290

public function posts_request( $request, $query ): string;
TypeNameDescription
string$requestThe request.
\WP_Query$queryThe WP_Query instance.

Returns: string — Updated request.

posts_pre_query()

Filter posts_pre_query to allow caching to work.

Since: 3.0.0
Line: 1322

public function posts_pre_query( $posts, $query ): WP_Post[];
TypeNameDescription
WP_Post[]$postsArray of post data.
WP_Query$queryThe WP_Query instance.

Returns: WP_Post[] — Updated Array of post objects.

the_posts()

Modify the array of retrieved posts.

Since: 3.0.0
Line: 1400

public function the_posts( $posts, $query ): WP_Post[];
TypeNameDescription
WP_Post[]$postsArray of post objects.
WP_Query$queryThe WP_Query instance (passed by reference).

Returns: WP_Post[] — Updated Array of post objects.

set_topscore()

Set up the top score for the query. This runs an extra query.

Since: 4.0.6
Line: 1507

public function set_topscore( $request, $query, $instance ): string;
TypeNameDescription
string$requestThe complete SQL query.
\WP_Query$queryThe WP_Query instance (passed by reference).
Better_Search_Core_Query$instanceThe Better_Search instance (passed by reference).

Returns: string — The SQL query.

get_cache_key()

Get the cache key.

Line: 1613

public function get_cache_key( $query, $context = ... ): string;
TypeNameDescription
WP_Query$queryThe WP_Query instance.
string$contextContext of the cache key to be set.

Returns: string — Cache meta key.

Check if a query is for a search.

Since: 4.0.0
Line: 1640

public function is_better_search( $query ): bool;
TypeNameDescription
WP_Query$queryThe WP_Query instance.

Returns: bool — Whether a query is for a search.