=== CRX Cron Health Monitor ===
Contributors: dcwiklik
Tags: cron, wp-cron, monitoring, uptime, scheduled tasks
Requires at least: 6.0
Tested up to: 7.0
Requires PHP: 8.1
Stable tag: 0.3.1
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

WP-Cron health, task attribution and a dead man's switch for your site. Know that your scheduled jobs actually ran.

== Description ==

**Your cron did not fail. It never ran.** WP-Cron only fires when someone visits your site. That is why nightly backups silently wait until morning, why `DISABLE_WP_CRON` without a real cron kills every scheduled task without a word, and why a single fatal error can jam the whole queue while every dashboard stays green.

Cronitorex shows you what is actually happening on your site, and tells you exactly who is responsible.

= See your cron for the first time =

* **Cron Health Score (0-100)** with named deductions: every lost point is a concrete problem with a concrete fix, never an opaque number
* **Task attribution**: every cron hook mapped to the plugin or theme that registered it, with its version. An alert says "WooCommerce 9.x", not a cryptic hook name
* **Real execution data**: how long each task took, how late it ran versus its schedule, peak memory, and fatals or timeouts caught mid-task
* **A task table that answers questions**: what runs here, who owns it, when it runs next, how its last run went

= Ten detections that name the problem =

1. WP-Cron disabled with nothing triggering it (the most common silent death in WordPress)
2. Night-time cron gaps: your site sleeps, so your nightly jobs do too
3. Tasks running long after their scheduled time
4. Overdue events piling up in the queue
5. Tasks dying mid-run from fatal errors or PHP timeouts
6. Orphaned events left behind by removed plugins
7. Duplicated events doing the same work twice
8. Tasks slow enough to hurt real visitors
9. Emails failing to send (wp_mail failures are silent by default)
10. Mail going through PHP mail() without SMTP, the classic road to the spam folder

Each detection appears in the dashboard with a suggested fix, and in the native **Site Health** screen (Tools - Site Health), where WordPress admins already look.

= The dead man's switch =

Everything above runs locally and needs no account. But a tool that lives inside WordPress has a blind spot it cannot escape: **when WP-Cron dies, the tool dies with it**. A dead scheduler looks exactly like a healthy one from the inside.

Connecting a free Cronitorex account closes that gap. The plugin sends a heartbeat every five minutes; when your cron stops, the heartbeat stops, and the silence itself raises an alert from outside within minutes. Nothing that runs inside your site can do this.

= Per-task monitors (paid plans) =

On paid plans, every recurring cron task gets its own monitor with its own history and alerts:

* Monitors are created for you, within your plan limit, with alert windows derived from how the task actually behaves (95th percentile of observed runs), not from guesses
* Every run reports start, completion or failure, with duration
* A task that disappears from the schedule gets its monitor paused, never deleted: destroying history stays a human decision

= For developers =

* **WP-CLI**: `wp cronitorex status`, `wp cronitorex doctor`, `wp cronitorex sync`
* No external libraries, no JavaScript frameworks, no build step
* Instrumentation never touches other plugins' code and never slows a request: all reporting is non-blocking, and every failure of the monitoring itself is swallowed by design

= Privacy =

The plugin sends nothing anywhere until you connect an account. Once connected, telemetry is aggregate numbers and task names only: run counts, durations, lag. No task arguments, no post content, no emails, no personal data. Ever.

== Installation ==

1. Install and activate the plugin.
2. Open the Cronitorex menu in wp-admin. The dashboard works immediately.
3. Optional: create a free account at cronitorex.com, paste your Ingest API key (ck_) and, if you want the monitor created for you, a scoped Management API key (mk_, read + write).

== External Services ==

This plugin can connect to the Cronitorex monitoring service (cronitorex.com). **Nothing is sent anywhere until you enter your API keys** on the Configuration tab; without keys the plugin is fully local.

Once connected, it talks to two endpoints:

* `https://api.cronitorex.com` - receives monitoring pings: the site heartbeat (aggregate counters: number of runs, failures, worst duration and delay) and, on paid plans with per-task monitors enabled, one ping per task run (task hook name, status, duration). Sent from your server whenever monitored tasks run.
* `https://app.cronitorex.com/api/v1` - the management API, called only from explicit admin or WP-CLI actions (creating the heartbeat monitor, syncing per-task monitors, reading your plan limits).

Data sent never includes task arguments, post content, emails or personal data.

Service provided by Cronitorex: [Terms of Service](https://cronitorex.com/legal/terms-of-service), [Privacy Policy](https://cronitorex.com/legal/privacy-policy).

== Screenshots ==

1. Dashboard: Cron Health Score ring, stat tiles, run duration sparkline, detected problems and recent runs.
2. Tasks: every scheduled task attributed to the plugin or theme that owns it, with schedule and last run.
3. Configuration: account keys and the per-task monitor picker with sensible defaults.
4. Site Health integration: cron state as a native WordPress health test.

== Frequently Asked Questions ==

= Does this replace WP-Cron? =

No. Cronitorex observes and reports; it never takes over scheduling. If your site needs a real cron trigger, the plugin will tell you and link the instructions, but the change stays in your hands.

= What happens when I deactivate the plugin? =

Cron behaviour returns to exactly what it was. Uninstalling also removes every option the plugin stored. Monitors in your Cronitorex account are left untouched, because deleting monitoring history should be a deliberate decision made in the panel, not a side effect.

== Changelog ==

= 0.3.1 =
* Fixed: monitors that already existed were never configured, so the site heartbeat had no expected interval and could not alert when WP-Cron died. The plugin now reconciles interval, grace period and tags on every connect and sync, not only when it creates a monitor.
* Monitors are tagged with the site domain even when they were created automatically by the first ping, so the dashboard shows which site they belong to.

= 0.3.0 =
* Renamed the plugin to CRX Cron Health Monitor (slug: crx-cron-health-monitor) to avoid confusion with unrelated third-party services.
* Removed bundled translation files; translations now go through translate.wordpress.org.
* Menu icon styling now uses wp_add_inline_style() instead of an inline <style> tag.

= 0.2.0 =
* Per-task monitors (paid plans): every recurring cron hook gets its own monitor, history and alerts, created for you within your plan limit and paused (never deleted) when a hook disappears.
* Mail watch: wp_mail() send counters, failure capture, and detection of PHP mail() setups without SMTP.
* Site Health integration: cron state as a native test under Tools - Site Health.
* WP-CLI: wp cronitorex status | doctor | sync.
* Grace periods for per-task monitors are derived from observed run times (p95), not guesses.
* Brand icon in the admin menu.

= 0.1.0 =
* Initial release: local cron dashboard with health score, attribution and detections; site heartbeat with automatic monitor creation.
