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 = ... );
| 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: 180
public function hooks( );
prepare_query_args()
Prepare the query variables.
Since: 3.0.0
Line: 220
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: 468
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: 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 = ... );
| Type | Name | Description |
|---|---|---|
string | $search_query | Search query. |
pre_get_posts()
Modify the pre_get_posts clause.
Since: 3.0.0
Line: 591
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: 629
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
posts_fields()
Modify the SELECT clause - posts_fields.
Since: 3.0.0
Line: 702
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: 746
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: 801
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
posts_search()
Modify the posts_search clause.
Since: 3.0.0
Line: 838
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: 1081
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: 1115
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: 1224
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: 1257
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: 1290
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: 1322
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: 1400
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: 4.0.6
Line: 1507
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: 1613
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.
is_better_search()
Check if a query is for a search.
Since: 4.0.0
Line: 1640
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.