=== Undelly – Backup & Restore ===
Contributors: jonayedhasan
Tags: backup, export, posts, content, restore
Requires at least: 6.5
Tested up to: 7.1
Requires PHP: 7.4
Stable tag: 1.0.0
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Back up your post content before you trash or delete it — from the Posts list, or by pasting a list of URLs, all from one dashboard.

== Description ==

Undelly gives you a dedicated **Undelly** dashboard (its own menu in wp-admin) for backing up post and page content before it's trashed or deleted, plus a bulk action and per-row link right on the Posts list itself.

= Key Features =

* **One-click backup** — export any post or page as a JSON record directly from the Posts list, without leaving the screen.
* **Bulk URL Processing** — paste a list of post/page URLs and back up (and optionally trash) all of them in one pass.
* **Category & tag preservation** — categories and tags are captured in every backup and recreated automatically on restore.
* **Self-contained records** — every post's title, content, slug, status, and metadata live together in one JSON file, so restoring doesn't require guessing what belongs where.
* **Admin-gated** — backup and restore actions require the appropriate WordPress capability (editing/deleting the post, or Manage Options for the Manage Backups screen).

= Three ways to back things up =

* **Bulk URL Processing** — paste a list of post/page URLs (one per line) into the Dashboard, and optionally have them moved to Trash automatically right after they're backed up.
* **Bulk action** — select posts or pages in the admin list screen and choose **Backup content** from Bulk Actions.
* **Per-row link** — click **Backup** next to any single post or page.

Every backup produces a package where each post is a fully self-contained `.json` record:

    {
      "title": "10 Hidden Features of WordPress",
      "slug": "hidden-wordpress-features",
      "type": "post",
      "date": "2026-09-11 14:00:00",
      "categories": ["Tutorials", "WordPress"],
      "tags": ["Tips", "Coding"],
      "html_content": "..."
    }

(The actual file also includes `id`, `status`, `link`, `excerpt`, and `featured_image` for a fuller restore.) Because the title, slug, taxonomy, and content all live together in one record, restoring a post is a matter of reading its fields back in — not guesswork from a bare content dump.

When a backup covers more than one post, it's delivered as a ZIP containing each post's `.json` file plus a lightweight `manifest.json` at the root — an index of what's inside (filename, title, slug, type, status, date, link, and size for every item) without duplicating any content, so the Manage Backups screen can show what's in a 200-post package instantly instead of opening 200 files.

= Manage Backups =

Every backup — manual or automatic — is saved to a private folder (`wp-content/uploads/undelly/`, blocked from direct web access) and listed on the **Manage Backups** screen, paginated 10 per page: its ID, content type, item count, filename, size, creation time, and status. The most recent backup gets its own detailed panel above the list, showing everything included in it. Each backup has:

* **Download ZIP** — grab the file again, any time.
* **Restore Backup** — recreates every post in that backup as a brand-new item (never overwriting anything by reusing the old ID, since that ID may belong to something else entirely by now), including its categories and tags.
* **Delete Backup** — removes the backup and its file permanently.

= Backup Before Deletion =

Turn this on in Backup Settings and the plugin will automatically back up a post any time it's trashed or permanently deleted — not just when you use this plugin's own bulk/row actions, but from anywhere in wp-admin, including WordPress's own native bulk actions and Trash auto-emptying after 30 days. Selecting several posts and trashing or deleting them together in one WordPress bulk action produces one backup covering all of them, the same way a manual bulk backup does. These show up on the Manage Backups screen exactly like manual ones do.

== Installation ==

1. Upload the plugin files to `/wp-content/plugins/undelly`, or install the ZIP through **Plugins → Add New → Upload Plugin**.
2. Activate the plugin through the **Plugins** screen.
3. Open the new **Undelly** menu in wp-admin.
4. Use Bulk URL Processing on the Dashboard, or the Bulk Actions/row link on the Posts and Pages list screens.

== Frequently Asked Questions ==

= Does this modify or delete anything on its own? =

Only if you ask it to. Backing up via the Posts list (bulk action or row link) never touches the post itself. Bulk URL Processing can move posts to Trash after backing them up, but only when its "Move to Trash" option is checked — it's off by default, so turn it on if you'd like posts moved to Trash automatically right after backing them up.

= Does this store files on my server? =

Yes. Every backup — however you trigger it — is saved to a private folder (blocked from direct web access) and listed on the Manage Backups screen so you can download it again later, in addition to the immediate download you get right away. Older backups are pruned automatically based on your "Maximum Backups to Keep" setting.

= What happens if my server doesn't support ZIP files? =

A single post is always downloaded (and stored) directly as one `.json` file, which needs no special PHP extension. For multiple posts, the plugin uses a ZIP of individual `.json` files plus a manifest.json index when the PHP zip extension is available, and otherwise automatically falls back to one `.json` file containing an array of every post's record — either way, the backup still completes and every post's record stays fully self-contained.

= Can I control what's included in each backup record? =

Yes. The Settings page has a "Backup Data" card where you can uncheck Title, Content, Excerpt, Featured Image, Categories, and/or Tags — any of these you turn off will simply be left out of every backup made from then on. ID, type, status, date, slug, and link are always included and can't be turned off, since they're needed to identify and restore the post. Turning a field off doesn't change backups you already have; it only affects new ones.

= Which content types are supported? =

Posts and Pages today. Support for additional content types is planned for a future release.

= Who is allowed to use this? =

Bulk actions (including Bulk URL Processing) require the post type's "edit others' posts" capability (Editors and Administrators by default). The per-row link requires the ability to edit that specific post, and Trash requires permission to delete it. The Manage Backups screen and its Download ZIP, Restore, and Delete actions require the ability to manage options (Administrators by default).

= What exactly does Restore do? =

It creates a brand-new post from the backed-up record — with the original title, slug, content, status, date, categories, and tags — rather than overwriting anything. The original post's ID isn't reused, since by the time you restore, that ID may already belong to something else entirely; missing categories are recreated automatically. If a backup covers several posts, restoring it recreates all of them.

== Screenshots ==

1. Dashboard: Bulk URL Processing, Backup Settings, and Content Types.
2. Manage Backups: the last-backup detail panel and the full backup history table.
3. Bulk action option on the Posts list screen.

== Changelog ==

= 1.0.0 =
* Initial release.

== Upgrade Notice ==

= 1.0.0 =
Initial release.
