=== AddonLogic Search Query Logger ===
Contributors: snehalpancholi
Tags: search, analytics, content gaps, queries, internal search
Requires at least: 6.0
Tested up to: 6.7
Stable tag: 1.0.0
Requires PHP: 8.1
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Records every internal site-search query with result counts, reveals zero-results content gaps, and helps editors know exactly what visitors cannot find.

== Description ==

**AddonLogic Search Query Logger** silently captures every WordPress native search query, counts how many results were returned, and aggregates repeated searches so you can see the true search demand on your site.

The admin report page surfaces:

* All unique search terms with hit counts and last-seen timestamps.
* A dedicated **Zero Results** tab that highlights every query returning no results — your editorial content-gap list.
* Sortable columns (query text, result count, searches/hits, first seen, last seen).
* Inline "Live Search" link so editors can verify what a query returns right now.
* Summary cards: unique queries, total searches, zero-results count, and the single top query.

No external services are contacted. All data is stored in a single lightweight custom table in your WordPress database.

== Installation ==

1. Upload the `search-query-logger` folder to `/wp-content/plugins/`.
2. Activate the plugin through the **Plugins** menu in WordPress.
3. Visit **Tools → Search Queries** to view the report.
4. Start searching on the front-end — data appears in real time.

== Frequently Asked Questions ==

= Does it work with custom search integrations? =
The plugin hooks into `template_redirect` and reads `is_search()` and `get_search_query()`. It works with any search that passes through WordPress's native query loop. Plugins that bypass the WP_Query search (e.g. Ajax search with a custom handler) will not be captured automatically.

= Are queries stored in plain text? =
Yes. Queries are stored in lowercase, trimmed form and never encrypted, because their purpose is editorial analytics. Do not log searches on sites where queries may contain personal data without updating your privacy policy.

= How do I reset the log? =
Use the **Clear All Queries** button at the bottom of the report page. This truncates the database table immediately.

= Where is the admin page? =
**Tools → Search Queries** in the WordPress admin sidebar.

= Does it count the same query from different users separately? =
No. Queries are deduplicated by their lowercase MD5 hash. Each unique term maintains a single counter (`hits`) that increments on every search regardless of who performs it.

== Screenshots ==

1. Summary cards showing unique queries, total searches, zero-results count, and the top query.
2. All-Queries tab with sortable table and inline Live Search links.
3. Zero-Results tab highlighting content gaps in amber.

== Changelog ==

= 1.0.0 =
* Initial release. Query capture, aggregation, report page, zero-results tab, pagination, clear-all.
