=== Init Live Search === Contributors: brokensmile.2103 Tags: live search, ajax search, instant search, rest api, keyword suggestion Requires at least: 5.2 Tested up to: 6.8 Requires PHP: 7.4 Stable tag: 1.3 License: GPLv2 or later License URI: https://www.gnu.org/licenses/gpl-2.0.html Modern, fast live search with a modal UI. Built in Vanilla JS with REST API, keyword suggestions, keyboard & voice support. == Description == Init Live Search is a modern, fast, and fully keyboard-accessible live search plugin for WordPress. It replaces the default with a sleek modal interface that fetches results instantly via the REST API — no jQuery, no page reloads, just instant feedback. With optional voice input, dark mode, keyword suggestions, and full developer extensibility, it’s perfect for both blogs and advanced headless sites. When users focus on an field, a lightweight search modal appears. Results are fetched through the REST API and shown instantly. The plugin supports: - Arrow key navigation - Enter to select - Escape to close - Voice input via native browser API This plugin is part of the [Init Plugin Suite](https://inithtml.com/init-plugin-suite-bo-plugin-wordpress-toi-gian-manh-me-mien-phi/) — a collection of minimalist, fast, and developer-focused tools for WordPress. New in version 1.3: - Triple-click on blank areas to open modal - Ctrl + / keyboard shortcut - Filter results by category without extra API calls - Show post type in results (Post, Page, etc.) - Clear button inside search input for quick reset == Features == Everything you expect from a modern live search — and more: - Live search powered by WordPress REST API (no admin-ajax) - Modern modal interface (no theme override required) - Fully keyboard accessible (Arrow keys, Enter, Escape) - Fallback to default search if nothing selected - Built with pure JavaScript (no jQuery) - Optional dark mode (.dark class or global config) - Keyword suggestions (manual or auto-generated) - Optional result caching via localStorage - UTM parameter support for link tracking - Voice input support using SpeechRecognition - Category filter (client-side only, zero API calls) - Settings page for fine-grained control (debounce, post types, fallback, etc.) == Screenshots == 1. Settings page with keyword suggestions and fallback options 2. Modal interface with search input and suggestions 3. Search results with category filter and post type labels 4. Seamless dark mode support for modern themes == REST API Endpoint == - Namespace: initlise/v1 - Endpoint: /search - Method: GET - Parameter: term (string, required) Example: https://yourdomain.com/wp-json/initlise/v1/search?term=example == Installation == 1. Upload the plugin folder to /wp-content/plugins/ or install via the admin panel. 2. Activate the plugin from the Plugins menu. 3. It will automatically enhance all fields. 4. (Optional) Configure advanced settings in Settings → Init Live Search. == Dark Mode Support == Enable dark mode for the modal by either: 1. Adding the dark class: document.querySelector('#ils-modal')?.classList.add('dark'); 2. Or using a global config: window.InitPluginSuiteLiveSearchConfig = { theme: 'dark' }; Options: 'dark', 'light', 'auto' == Admin Settings == - Choose post types to include in search - Set debounce time, max results, and search mode - Toggle fallback logic (bigrams/trim) - Enable/disable default CSS - Enable result caching (localStorage) - Define or auto-generate keyword suggestions - Add default UTM parameter to result links == Keyboard Navigation == - Arrow Up/Down — navigate results - Enter — open selected result or submit - Escape — close modal and reset state == Filters for Developers == = init_plugin_suite_live_search_enable_fallback = Enable or disable fallback logic. Params: bool $enabled, string $term, WP_REST_Request $request Example: add_filter( 'init_plugin_suite_live_search_enable_fallback', function ( $enabled, $term, $request ) { return false; }, 10, 3 ); = init_plugin_suite_live_search_post_ids = Customize the array of post IDs returned from the database query. Params: array $post_ids, string $term, WP_REST_Request $request add_filter( 'init_plugin_suite_live_search_post_ids', function ( $ids, $term, $request ) { return array_slice( $ids, 0, 5 ); }, 10, 3 ); = init_plugin_suite_live_search_result_item = Modify individual result items before display. Params: array $item, int $post_id, string $term, WP_REST_Request $request add_filter( 'init_plugin_suite_live_search_result_item', function ( $item, $post_id, $term, $request ) { $item['author'] = get_post_meta( $post_id, 'author_name', true ); return $item; }, 10, 4 ); = init_plugin_suite_live_search_results = Filter the final array of all result items. Params: array $results, array $post_ids, string $term, WP_REST_Request $request add_filter( 'init_plugin_suite_live_search_results', function ( $results, $post_ids, $term, $request ) { return array_reverse( $results ); }, 10, 4 ); = init_plugin_suite_live_search_category = Customize the category label shown in the frontend result filter. Params: string $category_name, int $post_id add_filter( 'init_plugin_suite_live_search_category', function ( $cat, $post_id ) { return strtoupper( $cat ); }, 10, 2 ); = init_plugin_suite_live_search_stop_words = Adjust the stop-word list used when generating keyword suggestions. Params: array $stop_words, string $locale add_filter( 'init_plugin_suite_live_search_stop_words', function ( $words, $locale ) { $words[] = 'custom phrase'; return $words; }, 10, 2 ); == FAQ == = Does this plugin use jQuery? = No, it's written in modern Vanilla JavaScript. = How is search triggered? = It automatically detects and overrides . = Is voice input supported? = Yes, via the browser's built-in SpeechRecognition API (if supported). = Can I generate keyword suggestions automatically? = Yes, in the settings panel via a button. = Is caching enabled by default? = No, but you can enable localStorage caching from the admin settings. = What happens if no result is selected? = Fallbacks to default WordPress search behavior. = Can I use this on mobile? = Yes, it's fully responsive and mobile-friendly. = What’s the triple-click trigger? = Click three times rapidly on empty areas to open the modal. == Changelog == = 1.3 – May 22, 2025 = - Triple-click to open modal - Keyboard shortcut Ctrl + / - Display post type name - Category filter (client-side only) - Clear icon inside search input - New developer filter prefix = 1.2 – May 20, 2025 = - Voice input (SpeechRecognition) - Fallback logic and CSS settings - Developer filters = 1.1 – May 18, 2025 = - Improved fallback matching - Prefill previous term - Character limit - UTM and cache support - Theme control = 1.0 – May 17, 2025 = - Initial release - REST API-powered modal search - Manual keyword suggestion == License == This plugin is licensed under the GPLv2 or later. You are free to use, modify, and distribute it under the same license.