Recent

Better_Search_Core_Queryclass

Better_Search_Core_Query

Better_Search: Main search class.

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

Methods

__construct()

Main constructor.

Since: 3.0.0
Line: 165

public function __construct( $args = ... );
Type Name Description
array|string $args The Query variables. Accepts an array or a query string.

hooks()

Initialise search hooks.

Since: 3.0.0
Line: 181

public function hooks(  );

prepare_query_args()

Prepare the query variables.

Since: 3.0.0
Line: 221

public function prepare_query_args( $args = ... );
Type Name Description
string|array $args {

unset_unnecessary_args() static

Unset unnecessary arguments that are not needed for the WP_Query.

Since: 4.0.0
Line: 469

static public function unset_unnecessary_args( $args ): array;
Type Name Description
array $args Array 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: 507

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: 531

public function set_class_variables( $search_query = ... );
Type Name Description
string $search_query Search query.

pre_get_posts()

Modify the pre_get_posts clause.

Since: 3.0.0
Line: 594

public function pre_get_posts( $query );
Type Name Description
WP_Query $query The WP_Query instance.

get_match_sql()

Get the MATCH field of the query

Since: 3.0.0
Line: 632

public function get_match_sql( $search_query, $args = ... ): string;
Type Name Description
string $search_query Search query.
array $args Array of arguments.

Returns: string — MATCH field

get_positive_search_query()

Get the search query without excluded terms.

Negative terms are applied separately to every enabled search field. Keeping them out of MATCH prevents a negative-only search from requiring a positive full-text match and keeps natural-language mode consistent with boolean mode.

Since: 4.4.3
Line: 714

public function get_positive_search_query(  ): string;

Returns: string — Search query containing only positive terms.

posts_fields()

Modify the SELECT clause - posts_fields.

Since: 3.0.0
Line: 739

public function posts_fields( $fields, $query ): string;
Type Name Description
string $fields The SELECT clause of the query.
WP_Query $query The WP_Query instance.

Returns: string — Updated Fields

posts_join()

Modify the posts_join clause.

Since: 3.0.0
Line: 783

public function posts_join( $join, $query ): string;
Type Name Description
string $join The JOIN clause of the query.
WP_Query $query The WP_Query instance.

Returns: string — Updated JOIN

posts_where()

Modify the posts_where clause.

Since: 3.0.0
Line: 840

public function posts_where( $where, $query ): string;
Type Name Description
string $where The WHERE clause of the query.
WP_Query $query The WP_Query instance.

Returns: string — Updated WHERE

Modify the posts_search clause.

Since: 3.0.0
Line: 877

public function posts_search( $where, $query ): string;
Type Name Description
string $where The search part of the WHERE clause of the query.
WP_Query $query The WP_Query instance.

Returns: string — Updated WHERE

posts_distinct()

Modify the posts_distinct clause.

Since: 3.0.0
Line: 1202

public function posts_distinct( $distinct, $query ): string;
Type Name Description
string $distinct The DISTINCT clause of the query.
WP_Query $query The WP_Query instance.

Returns: string — Updated DISTNCT

posts_orderby()

Modify the posts_orderby clause.

Since: 3.0.0
Line: 1236

public function posts_orderby( $orderby, $query ): string;
Type Name Description
string $orderby The ORDER BY clause of the query.
WP_Query $query The WP_Query instance.

Returns: string — Updated ORDER BY

posts_groupby()

Modify the posts_groupby clause.

Since: 3.0.0
Line: 1327

public function posts_groupby( $groupby, $query ): string;
Type Name Description
string $groupby The GROUP BY clause of the query.
WP_Query $query The WP_Query instance.

Returns: string — Updated GROUP BY

posts_clauses()

Filter posts_clauses in WP_Query.

Since: 4.0.0
Line: 1360

public function posts_clauses( $clauses, $query ): array;
Type Name Description
string[] $clauses Array of clauses.
\WP_Query $query The WP_Query instance.

Returns: array — Updated array of clauses.

posts_request()

Filter posts_request in WP_Query.

Since: 4.0.0
Line: 1393

public function posts_request( $request, $query ): string;
Type Name Description
string $request The request.
\WP_Query $query The WP_Query instance.

Returns: string — Updated request.

posts_pre_query()

Filter posts_pre_query to allow caching to work.

Since: 3.0.0
Line: 1425

public function posts_pre_query( $posts, $query ): WP_Post[];
Type Name Description
WP_Post[] $posts Array of post data.
WP_Query $query The WP_Query instance.

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

the_posts()

Modify the array of retrieved posts.

Since: 3.0.0
Line: 1503

public function the_posts( $posts, $query ): WP_Post[];
Type Name Description
WP_Post[] $posts Array of post objects.
WP_Query $query The 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: 3.0.0
Line: 1611

public function set_topscore( $request, $query, $instance ): string;
Type Name Description
string $request The complete SQL query.
\WP_Query $query The WP_Query instance (passed by reference).
Better_Search_Core_Query $instance The Better_Search instance (passed by reference).

Returns: string — The SQL query.

get_cache_key()

Get the cache key.

Line: 1718

public function get_cache_key( $query, $context = ... ): string;
Type Name Description
WP_Query $query The WP_Query instance.
string $context Context 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: 1745

public function is_better_search( $query ): bool;
Type Name Description
WP_Query $query The WP_Query instance.

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