=== Disk Guard ===
Contributors: xyruscode
Tags: disk space, storage, monitoring, alerts, quota
Requires at least: 5.9
Tested up to: 6.7
Requires PHP: 7.4
Stable tag: 1.0.1
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Watches WordPress storage against your host's limit and emails you, plus anyone you delegate to, before WordPress runs out of room to write.

== Description ==

WordPress writes constantly: uploads, plugin and theme installs, caches, backups, revision history. When the disk fills, uploads fail and pages start returning errors. On most shared hosts you get no warning before that happens.

Disk Guard measures the files under your WordPress folder, compares the total against the limit your host gives you, and emails you and your delegates when usage crosses thresholds you choose.

**What it does**

* Measures real file sizes by walking the WordPress folder. It does not rely on `disk_free_space`, which on shared hosting reports the whole server's disk rather than your plan's allowance.
* Detects your storage total automatically, and tells you plainly when the detected figure looks like the wrong disk.
* Accepts a manual limit, which always wins over detection.
* Measures overnight. The tick runs hourly and the scan happens in the window you set (01:00 to 05:00 by default), so the quiet hours are when it works.
* Emails the site admin plus any addresses you add.
* Pins a notice in wp-admin while usage is above a threshold.
* Stays quiet while nothing changes. You get mail on a change of state, plus a nudge only after the repeat window you set.
* Shows which folders are using the space, so you know what to clean up.

**What it does not do**

* It does not delete anything. Cleaning up is your call.
* It does not run its own server monitoring. It only measures storage.

== Installation ==

1. Upload the `disk-guard` folder to `/wp-content/plugins/`.
2. Activate the plugin through the Plugins screen.
3. Open Disk Guard in the admin menu.
4. Check the storage limit it found against the size your host lists. If they differ, type your host's number into the storage limit field and save.

== Frequently Asked Questions ==

= What does "detected" mean on shared hosting? =

Many shared hosts answer with the total size of the machine your account sits on, not the allowance assigned to your account. Disk Guard checks the measured usage against that figure and tells you when the result is implausibly low, which is the usual sign the figure is the wrong one. Type your host's number when that happens.

= Does it delete anything? =

No. It only measures and reports.

= Will it fill my own storage? =

It keeps a capped history of recent readings in the options table and writes nothing to disk. Its own footprint is a few kilobytes of options plus one CSS file and one script file.

= When does it check? =

WP-Cron only fires when someone visits the site. Disk Guard schedules an hourly tick and does the actual measurement inside the night window you set, which is 01:00 to 05:00 by default in your site timezone. If nothing has been measured for six hours, a check runs anyway, so a quiet site is never left unchecked for long.

= My site has no traffic. Will it still be monitored? =

Only up to a point. WP-Cron depends on visits, so on a very quiet site checks can be sparse. If you need a schedule that does not depend on traffic, add a real system cron:

`0 * * * * php /path/to/wp-content/plugins/disk-guard/disk-guard-cron.php >> /dev/null 2>&1`

Add `--force` to measure outside the night window.

= How accurate is the measurement? =

It is a real byte total from walking the folder tree. On a large install the walk can hit the time limit partway through, and Disk Guard marks the reading as a lower bound when that happens rather than reporting a confident wrong number.

= Does it work on multisite? =

Checks and alerts apply to the site where the settings are saved. Uninstall cleans up every site in the network.

== Changelog ==

= 1.0.1 =
* Fixed the admin menu icon, which did not appear. WordPress only accepts a
  dashicon class, an image URL, or a base64 SVG data URI for a top-level menu
  icon, and the inline SVG was stripped to nothing.
* Fixed the folder list in the alert email, which put the folder name inside the
  size column.
* The alert email no longer repeats the same fact in the subject, the heading and
  the first line.
* Alerts are sent with MIME line endings the spec requires, and a malformed
  address is dropped rather than rejecting the whole message.

= 1.0.0 =
* Measures storage by walking the WordPress folder, since disk_free_space reports
  the whole server disk on most shared hosting rather than the plan's allowance.
* Detects the storage total, with a manual override that always takes priority,
  and warns when the detected figure looks like the wrong disk.
* Emails the site admin plus any delegates, on a change of state rather than on
  every check.
* Pins a notice in wp-admin above the critical threshold.
* Schedules an hourly tick and measures during a night window, with a forced check
  when the gap grows long, plus a CLI entry point for a real system cron.
* Reports which folders are using the space.