Multisite_Search
Class to handle multisite search.
Namespace: WebberZone\Better_Search\Pro
Source: includes/class-multisite-search.php line 24
Methods
__construct()
Constructor.
Line: 54
public function __construct( Custom_Tables\Custom_Tables $custom_tables );
| Type | Name | Description |
|---|---|---|
Custom_Tables\Custom_Tables | $custom_tables | Custom Tables instance. |
pre_query_flat_table()
Short-circuit the database query for flat-table Better Search queries.
Fired via posts_pre_query at highest priority so we act after all other callbacks have had a chance to run but before WP_Query hits the DB. Returning a non-null value tells WP_Query to use that as the posts array and skip running the SQL statement.
Since: 4.2.0
Line: 113
public function pre_query_flat_table( $posts, $query ): null|array;
| Type | Name | Description |
|---|---|---|
null|array | $posts | Null (default) or an array of WP_Post objects supplied by an earlier filter. |
WP_Query | $query | Current query object. |
Returns: null|array — Null to continue normally, empty array to cancel DB hit.
filter_posts_request()
Filter the posts request to include posts from all sites.
Since: 4.0.0
Line: 164
public function filter_posts_request( $request, $query, $instance ): string;
| Type | Name | Description |
|---|---|---|
string | $request | The 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 — Updated SQL query.
prevent_recursive_query()
Prevent recursive queries by returning an empty array for nested better_search_query.
Since: 4.0.6
Line: 347
public function prevent_recursive_query( $posts, $query ): array;
| Type | Name | Description |
|---|---|---|
array | $posts | Array of post objects. |
WP_Query | $query | The WP_Query instance (passed by reference). |
Returns: array — Modified array of post objects.
handle_polylang_compatibility()
Handle Polylang compatibility.
Since: 4.0.6
Line: 361
public function handle_polylang_compatibility( $remove = ... );
| Type | Name | Description |
|---|---|---|
bool | $remove | Whether to remove the filter or not. Default is true. |
validate_sites() static
Validate the sites.
Line: 382
static public function validate_sites( $sites ): int[];
| Type | Name | Description |
|---|---|---|
mixed[] | $sites | Array of site IDs, possibly containing invalid entries from stored options. |
Returns: int[] — Array of validated site IDs.
switch_to_blog_in_loop()
Update the_post while WP_Query loops through this.
Since: 4.0.0
Line: 401
public function switch_to_blog_in_loop( $post );
| Type | Name | Description |
|---|---|---|
WP_Post | $post | The Post object (passed by reference). |
filter_the_permalink_for_multisite()
Filter permalinks for multisite search results.
Since: 4.0.6
Line: 429
public function filter_the_permalink_for_multisite( $permalink, $current_post ): string;
| Type | Name | Description |
|---|---|---|
string | $permalink | The post’s permalink. |
WP_Post|int | $current_post | Post object or post ID. |
Returns: string — Modified permalink for cross-site posts.
filter_the_title_for_multisite()
Filters the post title for multisite installations.
Retrieves the correct title when displaying cross-site posts in search results.
Since: 4.0.6
Line: 479
public function filter_the_title_for_multisite( $title, $id ): string;
| Type | Name | Description |
|---|---|---|
string | $title | The post title. |
int | $id | The post ID. |
Returns: string — Filtered post title.
loop_end()
Restore current blog on loop end.
Since: 4.0.0
Line: 507
public function loop_end( );
filter_the_posts()
Hydrate results manually from the custom table and return WP_Post objects.
Since: 4.2.0
Line: 528
public function filter_the_posts( $posts, $query, $instance ): WP_Post[]|array;
| Type | Name | Description |
|---|---|---|
WP_Post[] | $posts | Posts. |
WP_Query | $query | WP_Query object. |
Better_Search_Core_Query | $instance | Better_Search_Core_Query instance. |
Returns: WP_Post[]|array — Array of posts.
render_page()
Render the network admin page.
Since: 4.0.0
Line: 754
public function render_page( );
ajax_run_collation_fix()
AJAX handler to run collation fix for a given site.
Line: 1007
public function ajax_run_collation_fix( );