Skip to content

feat(recycle-bin): hide Media filter tab when MEDIA_TRASH is off#216

Merged
epeicher merged 1 commit into
trunkfrom
hide-media-tab-without-media-trash
May 14, 2026
Merged

feat(recycle-bin): hide Media filter tab when MEDIA_TRASH is off#216
epeicher merged 1 commit into
trunkfrom
hide-media-tab-without-media-trash

Conversation

@epeicher
Copy link
Copy Markdown
Collaborator

@epeicher epeicher commented May 14, 2026

Summary

  • The Recycle Bin toolbar was showing a Media type-filter segment on every install. On the default WP setup MEDIA_TRASH is false, so the Media library permanent-deletes attachments on first click and the bucket can never have rows — the tab always read empty and confused users.
  • Render the Media segment only when defined( 'MEDIA_TRASH' ) && MEDIA_TRASH. Sites that opt in via define( 'MEDIA_TRASH', true ); in wp-config.php get the tab back without any additional configuration.
  • Sibling segments (Posts, Pages, Comments, Desktop) are unaffected.

The constant is the right gate because attachments only ever end up in trash when WordPress itself routes them there — which only happens when MEDIA_TRASH is truthy.

Test plan

  • PHPUnit: new `Tests_DesktopMode_RecycleBinMediaTab` case verifies the Media segment is absent on the default `MEDIA_TRASH=false` env, and that the four sibling segments stay rendered. Self-skips if a future tests-env flips the constant on (PHP constants can't be flipped at runtime).
  • Manual: open the Recycle Bin without `MEDIA_TRASH` defined → toolbar reads "All | Posts | Pages | Comments | Desktop", no Media tab.
  • Manual: add `define( 'MEDIA_TRASH', true );` to `wp-config.php`, reload → Media tab appears between Pages and Comments and filters correctly.
  • Full PHP suite: 679 / 679 green.
  • Full JS suite: 1214 / 1214 green.
Open WordPress Playground Preview

The Recycle Bin's type-filter toolbar shipped a Media segment
regardless of whether attachments could actually end up in trash.
On a default WP install — `MEDIA_TRASH` defaults to false in
`wp_initial_constants()` — the Media library permanent-deletes
on first click, so that tab will never have rows under it and
just confuses users.

Render the Media segment conditionally on the constant being
truthy. Sites that opt in via `define( 'MEDIA_TRASH', true );`
in `wp-config.php` get the tab back. Sibling segments (Posts,
Pages, Comments, Desktop) are unaffected.

Adds a PHPUnit case for the default off-state. The on-state
isn't reachable from PHPUnit because the constant is locked in
`wp_initial_constants()` before tests load — documented in the
test class and covered by manual QA.
@epeicher epeicher changed the title fix(recycle-bin): hide Media filter tab when MEDIA_TRASH is off feat(recycle-bin): hide Media filter tab when MEDIA_TRASH is off May 14, 2026
@epeicher epeicher enabled auto-merge (squash) May 14, 2026 17:02
@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 merged commit 287c269 into trunk May 14, 2026
5 checks passed
@epeicher epeicher deleted the hide-media-tab-without-media-trash branch May 14, 2026 17:03
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