Recent

Search_RetrieverclassPro only

Search_Retriever

Retrieves public content through Better Search with bounded keyword fallback.

Namespace: WebberZone\Better_Search\Pro\AI
Since: 4.5.0
Source: includes/pro/ai/class-search-retriever.php line 19 Implements: Retriever_Interface

Methods

__construct()

Constructor.

Line: 54

public function __construct( int $max_chars = ... );
Type Name Description
int $max_chars Maximum characters of plain text per article. 0 uses the setting.

retrieve()

Retrieve articles relevant to a question.

Since: 4.5.0
Line: 67

public function retrieve( string $question, int $limit ): array;
Type Name Description
string $question Visitor question.
int $limit Maximum number of articles.

Returns: array — Articles, most relevant first.

get_prepared()

Articles returned by the last retrieve() call.

Since: 4.5.0
Line: 146

public function get_prepared(  ): array;

Returns: array — Articles keyed by ID.

prepare_article()

Build the article data sent as context.

Since: 4.5.0
Line: 158

public function prepare_article( WP_Post $post ): array;
Type Name Description
\WP_Post $post Article.

Returns: array — Article data.

get_plain_text()

Convert an article to plain text trimmed to the character limit.

Saved block content is read without executing dynamic blocks or shortcodes. Block-level elements become line breaks so the text keeps its structure.

Since: 4.5.0
Line: 208

public function get_plain_text( WP_Post $post ): string;
Type Name Description
\WP_Post $post Article.

Returns: string — Plain text.

get_skipped_blocks() static

Blocks left out of the article text.

Since: 4.5.0
Line: 219

static public function get_skipped_blocks(  ): array;

Returns: array — Block names.

html_to_text() static

Convert HTML to plain text.

Since: 4.5.0
Line: 245

static public function html_to_text( string $html ): string;
Type Name Description
string $html HTML.

Returns: string — Plain text with collapsed whitespace.

trim_text() static

Trim text to a maximum length, preferring a word boundary.

Since: 4.5.0
Line: 265

static public function trim_text( string $text, int $max_chars ): string;
Type Name Description
string $text Text.
int $max_chars Maximum characters, including the ellipsis.

Returns: string — Trimmed text.

extract_keywords() static

Extract search keywords from a question.

Since: 4.5.0
Line: 290

static public function extract_keywords( string $question, int $max = ... ): array;
Type Name Description
string $question Question.
int $max Maximum number of keywords, in question order.

Returns: array — Keywords.

get_stop_words() static

Words dropped from questions before searching.

Since: 4.5.0
Line: 319

static public function get_stop_words(  ): array;

Returns: array — Stop words.

post_types() static

Public post types enabled for search.

Since: 4.5.0
Line: 369

static public function post_types(  ): array;

Returns: array — Post types.

is_public() static

Recheck the public boundary before sending content.

Since: 4.5.0
Line: 393

static public function is_public( WP_Post $post ): bool;
Type Name Description
\WP_Post $post Post.

Returns: bool — Whether the post can be used.