=== Clearyvo PDF Cleanup ===
Contributors: kishollo001
Tags: pdf, media library, duplicates, unused media, audit
Requires at least: 6.2
Tested up to: 7.1
Requires PHP: 7.4
Stable tag: 0.9.5
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Every PDF in your Media Library: where it is used, exact copies, names to check, and a cleanup of unused files you can undo for 30 days.

== Description ==
PDF Cleanup scans the PDF files of your Media Library and shows:

* where each PDF is used: posts, pages, drafts, reusable blocks, templates, menus, widgets, custom fields and page builder data
* which PDFs have no references (in the places listed below)
* exact duplicates (SHA-256), with a preview of what keeping one copy would free
* file names and titles that deserve a look (random codes, "scan0012.pdf", empty titles)
* size and storage statistics
* a cleanup list: extra copies, PDFs with no references and Media Library items whose file is gone are ticked already, so one click removes them

Removing is safe: right before a file is moved it is checked again, and a file that is linked now, or the last copy of a duplicate group, stays. Removed files go to a private quarantine folder (with the preview images WordPress made) and their Media Library item to the trash. "Restore" puts both back, with the same address, for 30 days; after that they are deleted for good. The plugin never renames, replaces or edits a file, a post or a setting.

How the scan works: it reads your content once, in small steps of about three seconds each, so it is safe on large sites. Each text is searched for ".pdf" links and the links are matched to the attachments; the work grows with the amount of content, not with content multiplied by the number of PDFs.

What is checked: post content and excerpts (publish, private, draft, pending, future), reusable blocks, block templates and navigation, file blocks and PDF/download blocks, shortcodes that carry the file ID, custom fields and menu items with a PDF link or the file ID, widgets and settings with a PDF link.

What is not checked: theme and plugin files, CSS and JavaScript, links from other websites or emails, links built by code or kept in custom tables, and duplicate comparison of files over 25 MB. "No references found" is therefore not proof that a file is unused.

Part of the Clearyvo plugin family: focused plugins that each check one part of your site and share one "Site Toolkit" menu with a Site health score. The Site Toolkit plugin has every checker in one plugin, switched on one by one; when it is installed, this plugin's settings and results are shared with it. More at wp-sitechecker.com.

== Installation ==
1. Upload the plugin folder to /wp-content/plugins/ or install the zip in Plugins > Add New.
2. Activate it and open PDF Cleanup in the admin menu.
3. Press "Scan the PDFs".

== Frequently Asked Questions ==
= What is the /wp-json/clearyvo/v1/app/ address? =
A read-only REST route for the Clearyvo Site Inspector Mac app. It shows the Site health score of the Clearyvo plugins to a signed-in administrator (for example with a WordPress Application Password) and changes nothing. It sends nothing anywhere: the app asks, the site answers.

= Does it change my files? =
The scan only reads. Files change only when you press "Move the selected files to the quarantine", and even then they can be restored for 30 days.

= Where is the quarantine? =
In a folder of wp-content with a random name, closed to visitors (.htaccess and web.config). On nginx the random name keeps it private.

= What does it store? =
The result of the last scan and the list of files in the quarantine, in options. Deleting the plugin removes them and empties the quarantine.

= Is a custom field that holds a number counted as a reference? =
If the number equals a PDF's attachment ID, it is listed as "ID in custom field (possible)". It can be a coincidence, so it is marked as possible.

== Free and Pro ==
Everything in this plugin is free. Clearyvo Pro is one add-on for the Pro features of the whole family (image optimisation, AI ALT texts, alerts by email, white-label reports); this checker has none of its own.

== Changelog ==
= 0.9.5 =
* Shared Clearyvo framework 2.3.1: the SEO checker is listed as Clearyvo SEO (formerly Image Alt & SEO) everywhere, whichever Clearyvo plugin loads the framework.

= 0.9.4 =
* Database: every query goes through $wpdb->prepare(), with %i placeholders for table names.

= 0.9.3 =
* New icons: one design for the whole Clearyvo family, with a colour per group of checkers.

= 0.9.2 =
* The other checkers in the shared menu have their new names (SSL Checker, Security Checker, Indexing Checker and the rest).

= 0.9.1 =
* The plugin links point to wp-sitechecker.com again, until the site has moved to clearyvo.com.

= 0.9.0 =
* New: read-only connection for the Clearyvo Site Inspector Mac app (Site health as data, for administrators with an Application Password).

= 0.8.1 =
* Links to the new home of the Clearyvo WordPress plugins: clearyvo.com/wordpress.

= 0.8.0 =
* First release under the Clearyvo name (folder and text domain: clearyvo-pdf-cleanup). Settings and results of the earlier versions are kept; activating this plugin switches the earlier copy off.
