Skip to content

Recycle Bin: show item type badges inline next to title#206

Merged
epeicher merged 1 commit into
trunkfrom
205-recycle-bin-type-badges
May 14, 2026
Merged

Recycle Bin: show item type badges inline next to title#206
epeicher merged 1 commit into
trunkfrom
205-recycle-bin-type-badges

Conversation

@epeicher
Copy link
Copy Markdown
Collaborator

@epeicher epeicher commented May 14, 2026

Closes #205.

Summary

  • Adds a small uppercase type badge inline before each row's title in the Recycle Bin window — POST, PAGE, MEDIA, COMMENT, or the CPT's singular label.
  • Avoids a dedicated Type column so row height stays compact; the badge sits with the title, between the optional thumbnail and the title text.
  • CPT-aware: server-side resolves type_label from the post-type object so e.g. a trashed WooCommerce product reads as "Product".
CleanShot 2026-05-14 at 09 40 14@2x

Implementation notes

  • PHP: desktop_mode_recycle_bin_shape_item() and ..._shape_comment_item() now emit a type_label field. Attachments collapse to "Media" to match the toolbar filter; unknown slugs fall back to a title-cased version of the slug.
  • TS: new makeTypeBadge() helper renders the badge with inline styles (the <wpd-table> body lives in a shadow DOM that blocks document stylesheets, so all visual properties have to come from inline style.* assignments). A small desaturated palette keeps the badges readable as metadata, not primary content.
  • The TS renderer also falls back to a JS-side humanization of row.type if type_label is missing, so the badge still shows for rows from a plugin that doesn't populate the new field.
  • Plugins can override the label per row from the existing desktop_mode_recycle_bin_item filter — documented in docs/examples/recycle-bin.md.

Test plan

  • npm run lint clean
  • npx tsc --noEmit clean
  • npm run test:js — 1155 tests pass
  • npm run build succeeds
  • Verified in local dev (wp-develop): badges render for posts, pages, media, comments, and folder/desktop entries
Open WordPress Playground Preview

Closes #205. Each row in the Recycle Bin now carries a small
uppercase badge ("POST", "PAGE", "MEDIA", "COMMENT", or the CPT's
singular label) inline before the title, so mixed-trash lists are
scannable without opening each item.

- Server: shape every row with a `type_label` field, resolved from
  the post-type object for posts and CPTs (so e.g. trashed
  WooCommerce products read as "Product"), hard-coded to "Media"
  for attachments and "Comment" for comments.
- Client: render the badge inline in the title cell with inline
  styles (`<wpd-table>` body lives in a shadow DOM that blocks
  document stylesheets), with a desaturated per-type color palette
  and a generic fallback for unknown slugs.
- Plugins can override the label from
  `desktop_mode_recycle_bin_item` — documented in the example.
@github-actions
Copy link
Copy Markdown

✅ 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 enabled auto-merge (squash) May 14, 2026 07:46
@epeicher epeicher merged commit 317f92c into trunk May 14, 2026
5 checks passed
@epeicher epeicher deleted the 205-recycle-bin-type-badges branch May 14, 2026 07:47
epeicher added a commit that referenced this pull request May 14, 2026
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.
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.

Recycle Bin list should display item type badges

1 participant