Search_Redirects
Redirects searches for configured keywords to a specific post, page or URL.
Namespace: WebberZone\Better_Search\Pro
Since: 4.4.0
Source: includes/pro/class-search-redirects.php line 23
Methods
__construct()
Constructor.
Since: 4.4.0
Line: 48
public function __construct( );
maybe_redirect()
Redirect the current search request if a rule matches.
Since: 4.4.0
Line: 59
public function maybe_redirect( ): void;
Returns: void
get_rules()
Get the configured redirect rules, normalised.
Since: 4.4.0
Line: 152
public function get_rules( ): array[];
Returns: array[] — Array of rules, each with keywords, match_type, destination and redirect_type.
find_match()
Find the first rule matching a search query.
All exact rules are tried before any “contains” rule so a precise rule is never shadowed by a broader one above it.
Since: 4.4.0
Line: 280
public function find_match( $search_query ): array|null;
| Type | Name | Description |
|---|---|---|
string |
$search_query |
The raw search query. |
Returns: array|null — The matched rule, or null when nothing matches.
resolve_destination()
Resolve a configured destination to an absolute URL.
Numeric = post ID, resolved only when published and not password protected.
Since: 4.4.0
Line: 320
public function resolve_destination( $destination ): string;
| Type | Name | Description |
|---|---|---|
string |
$destination |
Configured destination: a post ID or a URL. |
Returns: string — Absolute URL, or an empty string when it cannot be resolved.
allow_destination_host()
Add the current destination’s host to the safe redirect allow list.
Since: 4.4.0
Line: 508
public function allow_destination_host( $hosts ): string[];
| Type | Name | Description |
|---|---|---|
string[] |
$hosts |
Allowed hosts. |
Returns: string[] — Allowed hosts, with the current destination’s host added.