Spell_Dictionary
Builds and queries a word-level dictionary drawn from published post titles and public taxonomy term names — the site’s authoritative vocabulary. Used as the second-tier “Did you mean” corpus (after the search-log corpus in Fuzzy_Search), so correctly spelled terms that haven’t been searched yet can still be suggested.
Namespace: WebberZone\Better_Search\Pro
Since: 4.4.0
Source: includes/pro/class-spell-dictionary.php line 26
Methods
__construct()
Constructor.
Line: 45
public function __construct( );
activation_hook()
Activation hook — create the table and do an initial build.
Since: 4.4.0
Line: 68
public function activation_hook( );
get_table_name() static
Get the fully-prefixed table name.
Since: 4.4.0
Line: 80
static public function get_table_name( ): string;
Returns: string — Prefixed table name.
is_table_installed() static
Check whether the dictionary table exists.
Since: 4.4.0
Line: 92
static public function is_table_installed( ): bool;
Returns: bool — True if the table exists.
create_table() static
Create the dictionary table if it doesn’t already exist.
Since: 4.4.0
Line: 106
static public function create_table( );
delete_table() static
Drop the dictionary table and clear the rebuild cron.
Since: 4.4.0
Line: 134
static public function delete_table( );
schedule_rebuild_cron()
Schedule the periodic rebuild cron if “Did you mean” is enabled, else clear it.
Since: 4.4.0
Line: 148
public function schedule_rebuild_cron( ): void;
Returns: void
tokenize() static
Extract meaningful, distinct lowercase words from a string.
Since: 4.4.0
Line: 170
static public function tokenize( string $text ): array;
| Type | Name | Description |
|---|---|---|
string |
$text |
Text to tokenize. |
Returns: array — Distinct words, at least min_char long, stopwords removed.
rebuild() static
Rebuild the dictionary from published post titles and public taxonomy term names.
Truncates and repopulates the table. Hooked to twicedaily cron and plugin activation.
Since: 4.4.0
Line: 197
static public function rebuild( ): void;
Returns: void
sync_post()
Add a single published post’s title words to the dictionary.
Additive only; periodic rebuild() reconciles stale words.
Since: 4.4.0
Line: 322
public function sync_post( $post_id, $post );
| Type | Name | Description |
|---|---|---|
int |
$post_id |
Post ID. |
\WP_Post |
$post |
Post object. |
get_suggestion()
Look up the closest dictionary word for a token that returned zero results.
Since: 4.4.0
Line: 363
public function get_suggestion( string $token ): ?string;
| Type | Name | Description |
|---|---|---|
string |
$token |
Search token. |
Returns: ?string — Suggested word, or null if nothing close enough was found.
add_tools_page_section()
Render the dictionary section on the Tools page.
Since: 4.4.0
Line: 376
public function add_tools_page_section( );
handle_rebuild()
Handle the Tools page “Rebuild dictionary” request.
Creates the table if missing, then rebuilds it from the current content.
Since: 4.4.0
Line: 418
public function handle_rebuild( );