diff --git a/better-search.php b/better-search.php
index b7025da..dc1c198 100644
--- a/better-search.php
+++ b/better-search.php
@@ -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
diff --git a/includes/admin/class-activator.php b/includes/admin/class-activator.php
index 108d892..ec86ff9 100644
--- a/includes/admin/class-activator.php
+++ b/includes/admin/class-activator.php
@@ -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' );
}
/**
diff --git a/includes/admin/settings/class-settings.php b/includes/admin/settings/class-settings.php
index 2fe1fef..adf3279 100644
--- a/includes/admin/settings/class-settings.php
+++ b/includes/admin/settings/class-settings.php
@@ -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' => '
' . esc_html__( 'Inclusion options', 'better-search' ) . '
',
diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon
index b1edc9d..86d4e71 100644
--- a/phpstan-baseline.neon
+++ b/phpstan-baseline.neon
@@ -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
diff --git a/readme.txt b/readme.txt
index 40c5b77..fdd6a61 100644
--- a/readme.txt
+++ b/readme.txt
@@ -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/).
@@ -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)
diff --git a/uninstall.php b/uninstaller.php
similarity index 77%
rename from uninstall.php
rename to uninstaller.php
index f253982..a43d0ba 100644
--- a/uninstall.php
+++ b/uninstaller.php
@@ -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}