New Plugin: kirby-trash / a "proper" trash can for Kirby (restore deleted pages and files)

Hi everyone,

I would like to share my first Kirby plugin:

kirby-trash - a “proper” trash can for Kirby.

Deleted pages and files are not removed instantly (as per default in Kirby) but moved to a trash where they can be restored or deleted permanently, via a dedicated Panel area:

The trash area in the Kirby Panel

How it works:

the plugin listens to the page.delete:before / file.delete:before hooks and copies the affected content (including all translations, files, subpages and Kirby 5 \_changes versions) into a configurable trash storage before Kirby deletes it. If the safety copy fails, the deletion is blocked, so content never gets deleted without a copy. Restoring puts everything back verbatim, so UUIDs and internal links survive.


Features:

  • Panel area with a table view (original path, size, deletion date, time left / see screenshot) and a details dialog with direct restore/delete actions

  • Automatic cleanup with configurable retention (default 30 days, set to -1 to keep indefinitely) plus a kirby trash:cleanup CLI command for cronjobs (if you need “precision cleanup” - otherwise, cleanup will occur on your next visit to the kirby-trash panel area)

  • Per-role permissions (access, restore, delete), admin-only by default

  • enabled and root options accept closures, e.g. to switch by environment

  • English and German translations


Installation:

composer require sigtrygg-space/kirby-trash

Requires Kirby 5 and PHP 8.2+.


Links:

Plugin page

Repository

Packagist


This is my first plugin. I am very open to feedback of any kind: bug reports, API design opinions, translations, naming, edge cases I have not thought of.

The current version is a v0.1.2 pre-release - issues and PRs are welcome on GitHub, or just reply here.

Thanks for reading, and I hope it is useful to some of you!

A note on the building method

I started working on this Idea a few years back as part of a website project but I never quite got around to finishing it. Claude to the rescue: kirby-trash now exists - not just for my project, but as a free plugin for Kirby 5.

So, yeah - kirby-trash was co-authored by Claude Fable 5: The code was developed on the basis of my unfinished work, then reviewed and tested in an iterative loop between two AI Instances (build + audit) and some human interference from my part, including a full manual test setup.

kirby-trash v0.2.0 is now live

features: menu badge with item count, warn state for expiring items

bumped to kirby-trash v0.2.2

now using precompiled Panel components (no more vue-compiler), graceful handling of unusable trash roots

kirby-trash v0.3.0 is now live

features: menu badge improvements, cleanup-feedback and a button that lets the user postpone automatic deletion


this may very well be the final pre-release before v1.0.0
(unless there is feedback from your side, dear tester)

Just bumped kirby-trash to v0.6.0

v0.4 introduced preview-images for trashed items in the trashcan
v0.5 improved those by adding a size option and improved details dialog and general ui
v0.6 is an improvement of the postpone-deletion feature introduced in v0.3 - you can now schedule a specific deletion date or keep items in trash indefinitely (overwriting default deletion-period). fixed sorting of trashed items on the way (items are now correctly sorted by their time left in the trash)


so, yeah… v0.3 was not the final prerelease.
v0.6 might be :slight_smile:

kirby-trash is now at v0.7.0

I noticed that “Empty Trash” was deleting all items from the trash, including those marked as “Keep indefinitely”. I thought this was rather counterintuitive.

Now, “Empty Trash” only removes items that would be deleted automatically at some point anyway. Items marked as “Keep indefinitely” can only be deleted manually, one by one.