CRP_Core_Query
Contextual Related Posts: Main CRP Class.
Namespace: WebberZone\Contextual_Related_Posts
Since: 3.0.0
Source: includes/class-crp-core-query.php line 25
Methods
__construct()
Main constructor.
Since: 3.0.0
Line: 177
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.5.0
Line: 197
public function hooks( );
prepare_query_args()
Prepare the query variables.
Since: 3.0.0
Line: 225
public function prepare_query_args( $args = ... );
| Type | Name | Description |
|---|---|---|
string|array |
$args |
{ |
get_match_sql()
Get the MATCH sql.
Since: 3.0.0
Line: 564
public function get_match_sql( ): string;
Returns: string — Updated Fields
is_backlogged()
Check if MySQL is currently under heavy load.
Since: 4.2.0
Line: 693
public function is_backlogged( ): bool;
Returns: bool — True if the database is considered backlogged.
pre_get_posts()
Modify the pre_get_posts clause.
Since: 3.5.0
Line: 756
public function pre_get_posts( $query );
| Type | Name | Description |
|---|---|---|
\WP_Query |
$query |
The WP_Query instance. |
posts_fields()
Modify the SELECT clause - posts_fields.
Since: 3.0.0
Line: 804
public function posts_fields( $fields, $query ): string;
| Type | Name | Description |
|---|---|---|
string |
$fields |
The SELECT clause of the query. |
\WP_Query|\CRP_Query |
$query |
The WP_Query or CRP_Query instance. |
Returns: string — Updated Fields
posts_join()
Modify the posts_join clause.
Since: 3.0.0
Line: 848
public function posts_join( $join, $query ): string;
| Type | Name | Description |
|---|---|---|
string |
$join |
The JOIN clause of the query. |
\WP_Query|\CRP_Query |
$query |
The WP_Query or CRP_Query instance. |
Returns: string — Updated JOIN
posts_where()
Modify the posts_where clause.
Since: 3.0.0
Line: 897
public function posts_where( $where, $query ): string;
| Type | Name | Description |
|---|---|---|
string |
$where |
The WHERE clause of the query. |
\WP_Query|\CRP_Query |
$query |
The WP_Query or CRP_Query instance. |
Returns: string — Updated WHERE
posts_orderby()
Modify the posts_orderby clause.
Since: 3.0.0
Line: 1021
public function posts_orderby( $orderby, $query ): string;
| Type | Name | Description |
|---|---|---|
string |
$orderby |
The ORDER BY clause of the query. |
\WP_Query|\CRP_Query |
$query |
The WP_Query or CRP_Query instance. |
Returns: string — Updated ORDER BY
posts_groupby()
Modify the posts_groupby clause.
Since: 3.0.0
Line: 1114
public function posts_groupby( $groupby, $query ): string;
| Type | Name | Description |
|---|---|---|
string |
$groupby |
The GROUP BY clause of the query. |
\WP_Query|\CRP_Query |
$query |
The WP_Query or CRP_Query instance. |
Returns: string — Updated GROUP BY
get_relevance_threshold()
The minimum share of the strongest candidate’s score that a post must reach.
Since: 4.5.0
Line: 1152
public function get_relevance_threshold( ): float;
Returns: float — Percentage from 0 to 100. 0 disables the filter.
posts_request()
Modify the completed SQL query before sending.
Since: 3.0.0
Line: 1337
public function posts_request( $sql, $query ): string;
| Type | Name | Description |
|---|---|---|
string |
$sql |
The complete SQL query. |
\WP_Query|\CRP_Query |
$query |
The WP_Query or CRP_Query instance. |
Returns: string — Updated SQL query.
posts_pre_query()
Filter posts_pre_query to allow caching to work.
Since: 3.0.0
Line: 1406
public function posts_pre_query( $posts, $query ): \WP_Post[];
| Type | Name | Description |
|---|---|---|
\WP_Post[] |
$posts |
Array of post data. |
\WP_Query|\CRP_Query |
$query |
The WP_Query or CRP_Query instance. |
Returns: \WP_Post[] — Updated Array of post objects.
the_posts()
Modify the array of retrieved posts.
Since: 3.0.0
Line: 1473
public function the_posts( $posts, $query ): \WP_Post[];
| Type | Name | Description |
|---|---|---|
\WP_Post[] |
$posts |
Array of post objects. |
\WP_Query|\CRP_Query |
$query |
The WP_Query or CRP_Query instance (passed by reference). |
Returns: \WP_Post[] — Updated Array of post objects.
exclude_post_ids()
Exclude Post IDs. Allows other plugins/functions to hook onto this and extend the list.
Line: 1633
public function exclude_post_ids( $args ): array;
| Type | Name | Description |
|---|---|---|
array |
$args |
Array of arguments for CRP_Query. |
Returns: array — Array of post IDs to exclude.
should_cache()
Check if the output should be cached.
Since: 4.2.0
Line: 1821
public function should_cache( ): bool;
Returns: bool — True if the output should be cached.
should_cache_posts_list()
Whether the list of related post IDs should be saved.
Wider than should_cache(), which gates reading it back: the list is also saved when only the
HTML output is cached, because it is the record that lets a save clear the cache of posts the
saved post is no longer related to. It is never read back unless cache_posts is enabled.
Since: 4.5.0
Line: 1866
public function should_cache_posts_list( ): bool;
Returns: bool