Skip to content

Commit

Permalink
New Pro setting: Fuzzy Search
Browse files Browse the repository at this point in the history
  • Loading branch information
ajaydsouza committed Nov 1, 2024
1 parent d5d03d7 commit a7e51e6
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 1 deletion.
2 changes: 1 addition & 1 deletion better-search.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* Plugin Name: Better Search
* Plugin URI: https://webberzone.com/plugins/better-search/
* Description: Replace the default WordPress search with a contextual search. Search results are sorted by relevancy ensuring a better visitor search experience.
* Version: 4.0.0-beta1
* Version: 4.0.0-beta2
* Author: WebberZone
* Author URI: https://webberzone.com/
* Text Domain: better-search
Expand Down
7 changes: 7 additions & 0 deletions includes/admin/class-activator.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,13 @@ public static function single_activate() {
self::recreate_daily_table();
update_option( 'bsearch_db_version', BETTER_SEARCH_DB_VERSION );
}

/**
* Fires after the plugin has been activated.
*
* @since 4.0.0
*/
do_action( 'bsearch_activate' );
}

/**
Expand Down
14 changes: 14 additions & 0 deletions includes/admin/settings/class-settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -445,6 +445,20 @@ public static function settings_search() {
'max' => 100,
'min' => 0,
),
'fuzzy_search_level' => array(
'id' => 'fuzzy_search_level',
'name' => esc_html__( 'Fuzzy search level', 'better-search' ),
'desc' => esc_html__( 'This option will allow you to enable fuzzy search. Adjust the level of flexibility for matching search terms. Higher levels may include more results with potential misspellings. Note that fuzzy searching can be computationally intensive, so it is recommended to have caching enabled, especially on high traffic sites.', 'better-search' ),
'type' => 'select',
'options' => array(
'off' => esc_html__( 'Off', 'better-search' ),
'low' => esc_html__( 'Low', 'better-search' ),
'medium' => esc_html__( 'Medium', 'better-search' ),
'high' => esc_html__( 'High', 'better-search' ),
),
'default' => 'off',
'pro' => true,
),
'search_header' => array(
'id' => 'search_header',
'name' => '<h3>' . esc_html__( 'Inclusion options', 'better-search' ) . '</h3>',
Expand Down
5 changes: 5 additions & 0 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,11 @@ parameters:
count: 2
path: includes/heatmap.php

-
message: "#^Constant DB_NAME not found\\.$#"
count: 1
path: includes/pro/class-fuzzy-search.php

-
message: "#^Access to an undefined property Better_Search_Query\\:\\:\\$topscore\\.$#"
count: 1
Expand Down
3 changes: 3 additions & 0 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ You can report security bugs through the Patchstack Vulnerability Disclosure Pro

* Features:
* New live search feature that shows search results as you type.
* [Pro] New setting to enable and set the fuzzy search level. Once enabled, the plugin will attempt to find results if the search term is misspelled. This only works effectively for English words.
* [Pro] New setting to only show search results above a certain relevance threshold.
* [Pro] New setting *Enable REST API* which allows the REST API to utilize the Better Search search engine when enabled. [Read this knowledge base article for more information ahout how Better Search enhances the Search endpoint](https://webberzone.com/support/knowledgebase/better-search-rest-api/).

Expand All @@ -124,6 +125,8 @@ You can report security bugs through the Patchstack Vulnerability Disclosure Pro
* Display an admin notice if any of the fulltext indexes are missing and **Enable mySQL FULLTEXT searching** is enabled. This is only shown to admins and cannot be dismissed until the indexes are created.
* [Pro] Added a new button to create the indexes and display the index status on the settings page under the **Search tab for Enable mySQL FULLTEXT searching**.

* Bug fixes:
* Quotes in search terms should work correctly now.

For previous changelog entries, please refer to the separate changelog.txt file or [Github Releases page](https://github.com/WebberZone/better-search/releases)

Expand Down
5 changes: 5 additions & 0 deletions uninstall.php → uninstaller.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,11 @@ function bsearch_delete_data() {
$wpdb->query( 'ALTER TABLE ' . $wpdb->posts . ' DROP INDEX bsearch_title' ); //phpcs:ignore WordPress.DB.DirectDatabaseQuery.SchemaChange,WordPress.DB.DirectDatabaseQuery.NoCaching,WordPress.DB.DirectDatabaseQuery.DirectQuery
$wpdb->query( 'ALTER TABLE ' . $wpdb->posts . ' DROP INDEX bsearch_content' ); //phpcs:ignore WordPress.DB.DirectDatabaseQuery.SchemaChange,WordPress.DB.DirectDatabaseQuery.NoCaching,WordPress.DB.DirectDatabaseQuery.DirectQuery

// Drop fuzzy functions.
$wpdb->query( 'DROP FUNCTION IF EXISTS wz_levenshtein' ); //phpcs:ignore WordPress.DB.DirectDatabaseQuery.SchemaChange,WordPress.DB.DirectDatabaseQuery.NoCaching,WordPress.DB.DirectDatabaseQuery.DirectQuery
$wpdb->query( 'DROP FUNCTION IF EXISTS wz_phrase_similarity_levenshtein' ); //phpcs:ignore WordPress.DB.DirectDatabaseQuery.SchemaChange,WordPress.DB.DirectDatabaseQuery.NoCaching,WordPress.DB.DirectDatabaseQuery.DirectQuery
$wpdb->query( 'DROP FUNCTION IF EXISTS wz_phrase_similarity_soundex' ); //phpcs:ignore WordPress.DB.DirectDatabaseQuery.SchemaChange,WordPress.DB.DirectDatabaseQuery.NoCaching,WordPress.DB.DirectDatabaseQuery.DirectQuery

$sql = "
SELECT option_name
FROM {$wpdb->options}
Expand Down

0 comments on commit a7e51e6

Please sign in to comment.