=== WPMaintenance ===
Contributors: domainsupport
Donate link: https://webd.uk/product/wordpress-maintenance-upgrade/
Tags: maintenance, cleanup, database, performance, wordpress maintenance
Requires at least: 6.0
Tested up to: 7.1
Requires PHP: 7.0
Stable tag: 1.6.3
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Maintenance tools for WordPress, including database cleanup, configuration controls and Cloudflare utilities.

== Description ==

WPMaintenance provides practical tools for maintaining and tidying a WordPress site from the admin area.

= Features =

* Remove unused translations, inactive widgets and cron events without registered callbacks.
* Clean post revisions, automatic drafts, comments, transients, oEmbed caches and orphaned metadata; export orphaned metadata before deleting it.
* Review, delete and de-autoload database options, including groups of options not observed in use.
* Manually start, clear or stop option usage tracking when options thresholds indicate an issue. Tracking stops automatically when a maintenance check finds that the issue has cleared.
* Set scheduled revision retention and manage debug logging, WordPress cron, file editing and automatic updates.
* Close comments, pingbacks and trackbacks on existing posts and disable them for new posts.
* Convert eligible database tables to InnoDB and access WordPress database repair and optimization tools.
* Recover custom CSS from a previous theme, change the administrator email without a confirmation email, disable the legacy links manager and remove a custom upload path.
* Deploy, disable, re-enable or remove the disabled Memcached object-cache.php drop-in when supported by the server.
* Inspect server load, CPU recommendations, PHP information, persistent cache usage, cache hit rates and PHP OPcache statistics from the admin area and dashboard.
* View Redis memory and eviction-policy guidance, flush compatible persistent object caches and PHP OPcache, and automatically flush supported persistent caches when usage exceeds 99% of capacity.
* Configure Cloudflare API access, inspect security levels and manually enable or disable Under Attack mode.
* Automatically enable Cloudflare Under Attack mode when server load is excessive or the active firewalls detect 50 new distinct attacking IPs within a rolling ten-minute window, and disable it when recovery conditions are met.
* When Wordfence or Deny All Firewall is active, synchronise qualifying attacker IPs to a shared Cloudflare list and block rule on each token-visible domain. Updates run in an authenticated background request after Wordfence imports or changes to active Deny All Firewall threat logs; addresses expire 24 hours after their last detection.
* Known server public addresses are excluded from Cloudflare attacker lists. Public-IP discovery is cached for 24 hours and shared with the callback allow rule; list updates pause if required discovery fails.
* Deny All Firewall threat logs are checked using metadata only on WordPress page loads while that plugin is active. Changed logs wake a deduplicated background import of both sources; neither firewall needs to write to the other's database.
* View Cloudflare sync status, last-confirmed blocked IPs, pending additions/removals, active operations, protection status and sync errors in the Dashboard widget.
* Receive Cloudflare protection notifications and log one summary per successful protection change, with per-domain API timings only on failures. Failed attacker batches are also logged; successful synchronisations are silent.
* Spread enabled WPvivid backup schedules across a stable random start time between 00:00:00 and 04:59:59 UTC while retaining the selected backup frequency and destination.
* Check disk space and email administrators when backup storage is running low; optionally send service notifications about pending updates and outdated PHP.
* Clean Flamingo contacts and messages, and prevent Flamingo from saving new contacts.
* Purge compatible StackCache content caches when posts or terms change.

== Installation ==

1. Upload the plugin ZIP through **Plugins > Add New > Upload Plugin**.
2. Activate WPMaintenance from the Plugins screen.
3. Open **Tools > Maintenance** to access the available maintenance tools.

== Frequently Asked Questions ==

= Does this plugin delete data? =

Several tools permanently delete selected data. Review each tool's description and make a database backup before running cleanup actions.

= Do I need Cloudflare? =

No. Cloudflare features are optional and require an API token with the appropriate permissions. Firewall IP blocking also requires Zone WAF Edit and Account Filter Lists Edit and access to the relevant accounts and zones, plus capacity for one managed IP list per account and one custom rule per zone. Account and permitted-zone discovery is cached for 24 hours and refreshed early after access or missing-resource errors. Discovery refreshes automatically after access errors. Failed work retries automatically with increasing delays capped at 15 minutes unless Cloudflare requests a longer wait. The optional "Retry Cloudflare Sync Now" control bypasses the delay after you change token access. WPMaintenance restores its own managed rule if it has been changed and preserves unrelated rules. Permission failures are recorded through PHP error logging, including the affected operation and account or zone; token saving does not perform permission checks. Background updates require working loopback requests. One-off expiry and recovery events use WP-Cron; there is no recurring minute-by-minute poll. Deleting the API token stops synchronisation and automatic expiry but does not remove existing Cloudflare rules or list entries.

= Does option tracking prove that an option is safe to delete? =

No. Tracking records options observed in use while it is enabled. An option that has not been observed may still be needed by an infrequently used feature or scheduled task. Review each option before deleting it. Clearing or stopping tracking removes only the collected observations, not the options being analysed.

= Does the WPvivid integration enable scheduled backups? =

No. It adjusts the schedule only when WPvivid is active and backup scheduling is already enabled. Existing schedules are checked during hourly maintenance; new and renewed schedules use the assigned time immediately. Twice-daily schedules retain their second run twelve hours later. Actual execution depends on WP-Cron and may occur after the scheduled time.
