=== Hintr - Lightning-Fast, Advanced Search Suggestions ===
Contributors: martincipriano
Donate link: https://www.paypal.me/martincipriano
Tags: search, suggestion
Tested up to: 6.7
Stable tag: 1.2.0
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Enhance your WordPress site's search functionality by offering search suggestions sourced from selected post types and metadata.

== Description ==

**Hintr** is a WordPress plugin designed to improve search by providing lightning-fast suggestions. Easily configure which post types to pull search suggestions from. You can also show suggestions if the search keyword is found in a post's metadata, such as price, SKU, serial number, etc.

**Features:**
- Effortlessly select which post types search suggestions should be pulled from.
- Show suggestions when the search keyword is found in a post's metadata.
- Customize search behavior for different input fields via data attributes.
- Lightweight and highly configurable, ensuring seamless integration.

This plugin is perfect for blogs, e-commerce sites, or any WordPress site that can benefit from enhanced search capabilities.

== Installation ==

1. Download the plugin file and extract it.
2. Activate the plugin through the 'Plugins' screen in WordPress.
3. Go to **Settings > Hintr** to configure the plugin options.

== Usage ==
- Automatic Application: Search suggestions are automatically applied to text inputs with the data attribute name="s".
- Custom Implementation: To customize behavior, add the data-hintr attribute to a text input.
  - Override the default settings by assigning a JSON-formatted settings value to the data-hintr attribute.
  - Example: <input data-hintr='{"count":"10","search_in":{"post":["meta_key_1","meta_key_2","meta_key_3"],"page":["meta_key_1","meta_key_2","meta_key_3"]}}' type="text" name="s" />

== Frequently Asked Questions ==

= What does Hintr do? =
Hintr enhances your search input with a dynamic list of suggestions. It allows you to retrieve suggestions from specific post types and display posts when the search keyword matches their metadata.

= Can I use this plugin with custom post types? =
Yes! Hintr works with any public custom post type registered on your site.

= Do I need to code anything? =
- No coding required when using the global settings for effortless setup.
- Fine-tune search suggestions for multiple search inputs with basic knowledge of:
  - Writing a JSON string.
  - Using HTML data attributes.

= How can I apply different search suggestion settings to multiple search inputs? =
To apply custom settings for each search input, add the `data-hintr` attribute to the respective `<input type="text"> or <input type="search">` fields.

**Here's what you can configure:**

- `count` (int/string): The number of suggestions to display.
- `search_in` (array): Define the post types and corresponding metadata to search against.
  - `key` (string): The post type from which suggestions will be pulled (e.g., 'post', 'page').
  - `value` (array): An array of meta keys that will be compared to the search keyword.  

**Example json value for data-hintr attribute:**

<pre>
{
  "count": "10",
  "search_in": {
    "post": ["meta_key_1", "meta_key_2", "meta_key_3"],
    "page": ["meta_key_1", "meta_key_2", "meta_key_3"]
  }
}
</pre>

= Will this plugin slow down my site? =
Hintr is optimized for speed, but performance can be affected by the number of posts being searched.

== Changelog ==

= 1.0.0 =
* Added: Admin settings page for selecting post types and metadata.
* Added: REST API endpoint based on selected settings.
* Added: JavaScript to store posts in the browser's local storage.
* Added: JavaScript to show search suggestions in a dropdown.

= 1.1.0 =
* Added: Count limit field in settings page.
* Added: JavaScript to limit the number of suggestions displayed in the dropdown.

= 1.1.1 =
* Apply fixes for text domain mismatch required by WordPress

= 1.1.2 =
* Cache the database query results for getting metadata used by a post type in the settings page

= 1.1.3 =
* Added donation link and screenshots to the readme file.

= 1.1.4 =
* Added: Add a suggestion count to improve performance and prevent showing too many suggestions.
* Added: Added a script to prevent access to the main plugin file.
* Updated: assets/js/hintr.js to replace the use of hashed post. Instead check when the local storage was last updated before updating the local storage.
* Updated: Updated slimselect.js to use the uinminified version.
* Deleted: Remove load_plugin_textdomain() since it is not being used since WordPress 4.6.

= 1.2.0 =
* Added: Added a checkbox input in the settings to allow the users to disable the suggestions from the default WordPress search.
* Added: Added a condition in the javascript before applying the suggestions to default WordPress search inputs.
* Added: Save the suggestions to a json file in the uploads directory so a query to the database isn't required every time a local storage is going to be created.
* Removed: Remove the scripts for creating a custom endpoint.

== Upgrade Notice ==

= 1.2.0 =
* Performance imporvement using a json file in the uploads directory instead of getting the posts from a custom endpoint.

== License ==

This plugin is licensed under the GNU General Public License v2.0 or later.  
You may obtain a copy of the license at: https://www.gnu.org/licenses/gpl-2.0.html

== Screenshots ==
1. Post type field in the settings determines where to pull the suggestions from.
  *Description: Displays post suggestions pulled from the selected post types.*

2. Custom field key input in the settings enables search using custom field value.
  *Description: Displays post suggestions if the keyword partially matches its custom field value*

3. Example use case.
  *Description: Searching for "capacitor" will display posts with the keyword in their title. Searching "electronics" will show posts where the keyword is present in the posts custom field.*