Skip to content

Trash bin polish: URL badge, live placement badge, no media auto-trash#214

Merged
epeicher merged 1 commit into
trunkfrom
improve-trash-bin-view
May 14, 2026
Merged

Trash bin polish: URL badge, live placement badge, no media auto-trash#214
epeicher merged 1 commit into
trunkfrom
improve-trash-bin-view

Conversation

@epeicher

@epeicher epeicher commented May 14, 2026

Copy link
Copy Markdown
Collaborator

Follow-up to #206. Three small Trash-bin improvements from post-merge feedback.

Summary

  • URL placements get a dedicated 'URL' badge. A trashed "New URL" tile now reads URL in the inline type badge instead of the generic Placement. Other placement kinds keep their existing humanized bucket label.
  • Dock badge updates live when a URL / shortcut / folder is moved to Trash. The desktop-files trash helper was emitting { reason: 'trash' }, which the badge subscriber couldn't decode — so the dock badge stayed stale until the next Heartbeat tick (15–60s). Now it emits the cross-window convention { source, action, ids } that posts/pages/attachments already use, and the badge subscribes to the placement.changed / shortcut.changed / folder.changed channels.
  • Media files revert to vanilla WordPress behaviour. The plugin no longer intercepts pre_delete_attachment, so Media-library delete actually permanent-deletes on first click. This resolves the "plugin .zip shows up in Trash bin as Media" feedback at the source — nothing auto-trashes those files anymore. Sites that want media-in-trash can opt in by setting define( 'MEDIA_TRASH', true ); in wp-config.php; the Recycle Bin still tracks attachment in its default capture list, so trashed media surfaces automatically when any path (REST, programmatic wp_trash_post, MEDIA_TRASH-enabled flow) routes it there.

Test plan

  • Create a "New URL" placement on the desktop, drag it to Trash. The Recycle Bin row should display a red-ish URL badge instead of PLACEMENT.
  • While trashing the URL above, watch the Trash dock icon — the badge count should bump +1 immediately, no Heartbeat-tick delay. Restoring via the Undo toast should bump it back −1, also live.
  • Same live-badge behavior for trashing a plugin shortcut and trashing a user folder.
  • Upload a plugin .zip into the Media library, delete it from the Media library. It should be gone immediately, no Trash entry.
  • Trash a post or page — should still route through Trash as before (regression check).
  • Restore a previously-trashed media file from the Recycle Bin (if any pre-existing items are in the bin from before this PR) — should still work.

Coverage

  • 4 new PHPUnit cases for the URL label and the media-permanent-delete default
  • 3 new vitest cases for the placement / shortcut / folder broadcast shape
  • Full suites green: 1214 JS, 678 PHP
Open WordPress Playground Preview

Three Trash-bin improvements driven by PR #206 feedback:

- URL placements (file_type='link') now carry a 'URL' type_label,
  so the inline badge reads "URL" instead of the generic "Placement".
  Other placement kinds keep the existing humanized bucket label.

- Trash icon badge updates live when a URL/shortcut/folder is moved
  to Trash. The desktop-files trash helper was emitting
  { reason: 'trash' } which the badge subscriber couldn't decode;
  it now follows the cross-window convention { source, action, ids }
  matching how posts/pages/attachments already broadcast. The badge
  also subscribes to the placement / shortcut / folder channels.

- Removes the `pre_delete_attachment` interception so media files
  follow vanilla WordPress behavior — permanent-delete on first
  click, no auto-routing through Trash. This resolves the
  "plugin .zips show up as Media in Trash bin" feedback at the
  source: nothing auto-trashes them anymore. Sites that want
  media-in-trash can opt in by setting `MEDIA_TRASH=true` in
  `wp-config.php`; the Recycle Bin still tracks `attachment` in
  its default capture_post_types list, so trashed media surfaces
  automatically when something else (REST, programmatic trash,
  MEDIA_TRASH-enabled delete flow) routes it there.

Coverage: 4 PHPUnit cases for the URL label, the no-auto-trash
default, and the unaffected post-trash flow. 3 vitest cases
verifying the placement / shortcut / folder broadcast shape.
@github-actions

Copy link
Copy Markdown
Contributor

✅ WordPress Plugin Check Report

✅ Status: Passed

📊 Report

All checks passed! No errors or warnings found.


🤖 Generated by WordPress Plugin Check Action • Learn more about Plugin Check

@epeicher epeicher merged commit 3595606 into trunk May 14, 2026
5 checks passed
@epeicher epeicher deleted the improve-trash-bin-view branch May 14, 2026 14:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant