=== CB Site Health & Debug ===
Contributors: chrismaryey02
Tags: debug, performance, site health, query monitor, woocommerce
Requires at least: 6.4
Tested up to: 7.1
Requires PHP: 7.4
Stable tag: 1.0.2
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

A developer debug bar plus a plain-English site performance report, with one-click cleanup, trend history, and an optional weekly email digest.

== Description ==

CB Site Health & Debug is a two-part tool for developers and site owners who want to know *why* a page is slow and *what* to fix, without digging through server logs.

**1. Front-end debug bar**

A toolbar item (visible only to logged-in administrators) that opens a panel showing, for the exact page you're looking at:

* Database queries, with timing and the code that triggered each one (requires `SAVEQUERIES`)
* Hooks and actions fired, with counts
* `_doing_it_wrong()` calls and deprecated function/argument/hook usage
* PHP notices, warnings, and errors
* Outbound HTTP API calls and their response times
* Enqueued scripts and styles, with handles, sources, versions, and dependencies
* Loaded text domains, transient writes, and capability checks
* WordPress lifecycle timing (plugins_loaded → init → template_redirect → footer)
* Template hierarchy and conditional tags
* A custom `cbdd_log( $value )` helper you can call from your own code to send values to the panel, the same way you'd use `error_log()`

**2. Site Health & Debug report (Tools menu)**

A page that scans your site for common performance and configuration problems and rates each one Good / Warning / Needs Fixing, with a plain-English explanation and a fix — covering PHP/server settings, database bloat (autoloaded options, revisions, expired transients), caching (object cache, page cache), overdue cron events, unoptimized images, and — when WooCommerce is active — Action Scheduler backlogs.

It also includes:

* **One-click cleanup** — remove expired transients, delete old post revisions, clear the slow-query log
* **Slow query log** — queries over a configurable threshold are saved across visits, not just the current page load
* **History & trend** — a daily snapshot shows what's newly failing or fixed since the last check, and a 10-day trend table
* **Admin menu badge** — a red count bubble on the Tools menu when critical issues exist, refreshed daily even if nobody opens the page
* **Optional weekly email digest** — a summary of critical/warning findings sent to an address you choose

Everything is restricted to users with the `manage_options` capability. Nothing runs for site visitors, and no data leaves your site — there is no external service, tracking, or license check involved.

== Installation ==

1. Upload the plugin files to `/wp-content/plugins/cb-site-health-debug`, or install it through the WordPress Plugins screen directly.
2. Activate the plugin through the "Plugins" screen.
3. Open **Tools → CB Site Health & Debug** for the performance report, or look for the debug bar in the admin toolbar as a logged-in administrator.
4. (Optional) Add `define( 'SAVEQUERIES', true );` to `wp-config.php` to enable database query capture in the debug bar and the slow query log.

== Frequently Asked Questions ==

= Will this slow down my site for visitors? =

No. Every part of the plugin checks `current_user_can( 'manage_options' )` before doing anything, so regular visitors and non-admin users never trigger any of its collectors.

= Why don't I see any database queries? =

Query capture requires `SAVEQUERIES` to be enabled in `wp-config.php` — the same requirement WordPress core itself imposes for this data. The plugin will tell you when it's off instead of showing nothing silently.

= Does the performance report run on every page load? =

No. It only runs when you open Tools → CB Site Health & Debug, plus a lightweight daily WP-Cron check that refreshes the admin-menu badge and trend history.

= Does this send any data outside my site? =

No, unless you turn on the optional weekly email digest, which uses your site's own `wp_mail()` to send to an address you configure. There is no external analytics, license server, or third-party service involved.

= What happens to the data if I delete the plugin? =

Deleting it through the Plugins screen removes its settings and its two small database tables (the slow-query log and the health-check history). Deactivating alone does not delete anything.

== Screenshots ==

1. The CB Site Health & Debug performance report, showing status badges and fixes.
2. The front-end debug bar panel.
3. Settings — slow query threshold, front-end bar toggle, weekly email digest.

== Changelog ==

= 1.0.2 =
* Removed the duplicate "Tested up to" plugin header (this value belongs only in readme.txt, per WordPress.org guidelines).
* Corrected the Contributors list to use the correct WordPress.org username.

= 1.0.1 =
* Code-quality pass: proper prefixing on the internal class/function names, cache-busting version added to registered assets, superglobal values sanitized before use, and all custom-table SQL now uses prepared identifier placeholders instead of direct string interpolation.

= 1.0.0 =
* Initial public release.

== Upgrade Notice ==

= 1.0.0 =
Initial public release.
