=== PrismSearch ===
Contributors: wteam
Tags: search, ajax-search, site-search, fuzzy-search, frontend-search
Requires at least: 6.2
Tested up to: 7.0
Stable tag: 1.0.5
Requires PHP: 7.4
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Fast AJAX search for WordPress posts, pages, public custom post types and taxonomies using an optimized inverted index.

== Description ==

PrismSearch builds a custom inverted index and provides live AJAX search through theme integration, a native block or shortcode.

= Features =

* Fast inverted-index based search.
* Frontend AJAX search shortcode.
* Integration with Twenty Twenty-Five, Storefront and Astra.
* Replaces standard classic and block search forms where supported.
* Native dynamic PrismSearch block.
* Indexes posts, pages and selected public custom post types.
* Indexes selected public taxonomy terms.
* Displays selected frontend metadata in live results.
* Configurable NLP language for tokenization.
* Fuzzy typo matching fallback.
* Optional replacement for the default WordPress search results page.
* Configurable rate limiting (50 requests per IP per minute by default; 0 disables it).
* Live index updates when selected content is saved, updated, trashed or deleted.
* Optional REST Search Fast Path for eligible anonymous searches.
* Optional frontend.css loading for custom theme styling.
* Optional Enter key redirect to the full search results page.
* Optional voice input through the Web Speech API.
* Theme template overrides.

= Supported NLP languages =

PrismSearch includes processors for: English (en), German (de), French (fr), Spanish (es), Portuguese (pt), Italian (it), Dutch (nl), Danish (da), Swedish (sv), Norwegian (no), Finnish (fi), Polish (pl), Czech (cs), Slovak (sk), Slovenian (sl), Croatian (hr), Serbian (sr), Bulgarian (bg), Romanian (ro), Hungarian (hu), Greek (el), Turkish (tr), Russian (ru), Ukrainian (uk), Lithuanian (lt), Latvian (lv), Estonian (et), Indonesian (id), Vietnamese (vi), Japanese (ja), Chinese (zh), Korean (ko), Arabic (ar), Persian (fa), Hebrew (he) and Thai (th).

Some CJK and script-based languages use basic normalization and token support. Test with your own content before production use.

= Shortcode =

Add the live search box with:

`[prismsearch]`

Optional attributes:

`[prismsearch min_chars="3" limit="10" placeholder="Search..."]`

Enter key redirect:

`[prismsearch enter_redirect="1"]`

`[prismsearch enter_redirect="0"]`

Voice input:

`[prismsearch voice_search="1"]`

`[prismsearch voice_search="0"]`

Voice input uses the configured NLP language. Developers can override it with the `prismsearch_speech_language` filter. The microphone stays hidden when browser speech recognition is unavailable.

= Automatic theme integration =

Enable automatic integration under Settings > PrismSearch > Frontend.

* Twenty Twenty-Five: inserts the PrismSearch block into supported headers.
* Storefront: replaces the built-in header product search.
* Astra: replaces Astra Search elements added through the Header Builder.
* Other themes: replaces existing classic search forms and Core Search blocks. It does not create a new search position.

WooCommerce products must be selected under Content and indexed before they appear in results.

Developers can disable automatic integration with:

`add_filter( 'prismsearch_automatic_theme_integration', '__return_false' );`

= Privacy and external services =

Indexing, tokenization and search run locally in WordPress. PrismSearch does not load remote frontend or admin assets.

When voice search is disabled, PrismSearch does not access the microphone. When enabled and activated, speech recognition is handled by the browser Web Speech API. Audio may be processed locally or by a browser-vendor service. PrismSearch does not receive or store microphone audio; it receives only recognized text.

= Included third-party libraries =

PrismSearch includes Select2 4.1.0 for admin multi-select fields. Select2 is MIT licensed; its license is at `assets/vendor/select2/LICENSE.md`. Source: https://github.com/select2/select2.

= Templates and styling =

PrismSearch loads its default frontend stylesheet unless disabled in settings.

Developers can also disable it with:

`add_filter( 'prismsearch_load_frontend_css', '__return_false' );`

Override plugin templates from your theme under:

`template/prismsearch/`

Example:

`template/prismsearch/item.php`

== Installation ==

1. Upload the `prismsearch` folder to `/wp-content/plugins/`, or install the ZIP through WordPress.
2. Activate PrismSearch.
3. Go to Settings > PrismSearch.
4. Select the posts, pages, public custom post types and taxonomy terms to index.
5. Select frontend meta keys if you want them displayed in live results.
6. Click Build Index.
7. Verify automatic integration, or insert the PrismSearch block / `[prismsearch]` where needed.

Rebuild the index after changing indexed content, taxonomy or NLP language settings.

== Frequently Asked Questions ==

= Does PrismSearch replace the default WordPress search? =

Yes. Enable "Override default WordPress search" to use PrismSearch on the `?s=` results page.

= Can PrismSearch appear without a shortcode? =

Yes. Enable Automatic theme integration, or insert the native PrismSearch block manually.

= What content can PrismSearch index? =

Posts, pages, selected public custom post types and selected public taxonomy terms.

= Can I display custom meta fields in live search results? =

Yes. Select them under "Frontend meta keys". They are displayed in AJAX results but are not indexed for search.

= Does PrismSearch support typo tolerance? =

Yes. Enable fuzzy typo matching. It runs as a fallback when normal search returns too few results.

= What is the default live-search rate limit? =

50 requests per IP per minute. Change it under Settings > PrismSearch > Security, or set 0 to disable it.

= Why do I need to build the index? =

PrismSearch uses its own index. Build it after installation and after changing indexed content or language settings.

= Does PrismSearch update the index automatically? =

Yes, when live index updates are enabled. Selected content is reindexed when saved, updated, trashed or deleted.

= What is REST Search Fast Path? =

An optional mode under Settings > PrismSearch > Advanced. It installs a managed MU-plugin and serves eligible anonymous REST searches after MU-plugins load, before normal plugins and the active theme.

Fast Path is unavailable on multisite or when the MU-plugin location is not writable. Its managed file is removed when disabled, deactivated or uninstalled.

Requests with a login cookie, `Authorization` or `X-WP-Nonce` use normal REST bootstrap. Because Fast Path skips normal plugin/theme hooks, do not enable it when access control, URLs, post-type behavior or filtering depend on them.

Disable Fast Path per request with `prismsearch_rest_fast_path_allowed`, or globally with `PRISMSEARCH_DISABLE_REST_FAST_PATH`.

= Can I disable the plugin frontend CSS? =

Yes. Enable "Disable frontend.css", or use the `prismsearch_load_frontend_css` filter.

= Can Enter open the full search results page? =

Yes. Enable "Redirect on Enter", or use `enter_redirect="1"`.

= Does PrismSearch support voice search? =

Yes. Enable "Voice search", or use `voice_search="1"`. The microphone appears only when supported in a secure context; the browser handles permission and recognition.

= Can I customize result templates? =

Yes. Copy the plugin template files into your theme under `template/prismsearch/` and edit them there.

== Screenshots ==

1. PrismSearch settings screen with content, frontend, NLP language, fuzzy search, security and advanced sections.
2. Live AJAX search dropdown on the frontend.
3. Index management screen with progress indicator and rebuild controls.

== Changelog ==

= 1.0.5 =

* Add optional REST Search Fast Path performance mode for eligible anonymous searches.
* Install and remove the managed Fast Path MU-plugin through the WordPress Filesystem API.
* Use a bundled, reviewable MU-plugin template with only the relative PrismSearch plugin path.
* Run Fast Path after all MU-plugins load, before normal plugins and the active theme.
* Bypass Fast Path for authenticated or nonce-protected requests.
* Remove the managed MU-plugin when Fast Path is disabled, PrismSearch is deactivated or uninstalled.
* Disable Fast Path on multisite and when the MU-plugin location is not writable.
* Add compatibility safeguards and developer controls for Fast Path.
* Add Stop indexing control while an index build is running.
* Resume an interrupted index build from the last processed batch after an admin page refresh.
