Display
Display Class.
Namespace: WebberZone\Better_Search\Frontend
Since: 3.3.0
Source: includes/frontend/class-display.php line 22
Methods
__construct()
Constructor class.
Since: 3.3.0
Line: 29
public function __construct( );
enqueue_highlight_script() static
Enqueue the client-side highlight script on singular pages.
PHP-based highlighting relies on HTTP_REFERER being available during PHP execution. When a full-page cache (e.g. LiteSpeed Cache) serves a cached response, PHP never runs and the server-side highlighting is skipped. This script reads document.referrer in the browser and applies the same highlighting logic client-side, covering cached-page scenarios.
Only enqueued on singular views where highlight_followed_links is enabled. Search results are handled server-side by content() via the_title / the_content filters; archives and the homepage have no followed-link scenario to highlight.
Since: 4.3.2
Line: 55
static public function enqueue_highlight_script( ): void;
Returns: void
content()
Highlight search queries in the_content.
Since: 3.3.0
Line: 130
public function content( $content ): string;
| Type | Name | Description |
|---|---|---|
string | $content | Post content. |
Returns: string — Post Content
extract_highlight_terms() static
Extract the terms to highlight from a search query, keeping quoted phrases intact.
Double-quoted phrases are returned as single terms so the whole phrase is highlighted rather than its individual words. Terms prefixed with the exclusion operator (-) are skipped as they do not appear in the results.
Since: 4.3.2
Line: 163
static public function extract_highlight_terms( $search_query ): string[];
| Type | Name | Description |
|---|---|---|
string | $search_query | Search query. |
Returns: string[] — Terms and phrases to highlight.