WordPress.org

Make WordPress Core

#38341 closed defect (bug) (fixed)

Hide 'Empty Trash' button when trash is already empty

Reported by: swissspidy Owned by: swissspidy
Milestone: 4.8 Priority: normal
Severity: normal Version:
Component: Posts, Post Types Keywords: good-first-bug has-patch has-screenshots needs-unit-tests
Focuses: ui, administration Cc:

Description

Noticed while working on #37407.

Here's a screenshot:

https://cldup.com/TxxKy9pM0E.png

Attachments (11)

38341.diff (1.7 KB) - added by ivantedja 20 months ago.
38341-media.diff (689 bytes) - added by ivantedja 20 months ago.
38341-complete.diff (2.3 KB) - added by ivantedja 20 months ago.
trash.jpg (134.0 KB) - added by Presskopp 20 months ago.
38341.2.diff (2.0 KB) - added by Presskopp 20 months ago.
38341.3.diff (2.1 KB) - added by printsachen1 16 months ago.
38341.patch (2.2 KB) - added by Jaydeep Rami 16 months ago.
Attached patch from root
38341.4.diff (2.7 KB) - added by mathieuhays 15 months ago.
38341.5.diff (3.4 KB) - added by mathieuhays 15 months ago.
add php-unit test
38314.6.diff (3.5 KB) - added by cazm 15 months ago.
Fixing missing button when Spam is deleted and no trash
38341.6.diff (4.1 KB) - added by swissspidy 15 months ago.
Adds another test for the comments list table

Download all attachments as: .zip

Change History (31)

#1 @swissspidy
20 months ago

Note that you'll typically only see this right after emptying the trash. When the trash is already empty, there's not even a link to the trash.

@ivantedja
20 months ago

#2 follow-up: @ivantedja
20 months ago

Patch attached :) It covers:

  • posts
  • pages
  • comments

I notice something, the code has "Empty Trash" button in "media" as well But media always deleted permanently so "Empty Trash" for media is never shown up Is it legacy code?

#3 @Presskopp
20 months ago

  • Keywords has-patch added; needs-patch removed

#4 @lukecavanagh
20 months ago

@ivantedja

Patch applies cleanly,

#5 in reply to: ↑ 2 @afercia
20 months ago

Replying to ivantedja:

But media always deleted permanently so "Empty Trash" for media is never shown up

There's a constant define( 'MEDIA_TRASH', true ) to enable trash for media.

#6 @ivantedja
20 months ago

Thanks @afercia ! Previously I only saw this info: https://en.support.wordpress.com/trash/#permanently-deleting-an-upload hence I thought there is no way to delete non-permanently

@lukecavanagh attached additional patch for "media"

#7 @swissspidy
20 months ago

  • Keywords needs-screenshots added
  • Milestone changed from Awaiting Review to Future Release

@ivantedja Thanks! Would you mind combining these two patches into 1? Makes it easier to test.

#8 @ivantedja
20 months ago

@swissspidy sure, has been attached :)

@Presskopp
20 months ago

#9 @Presskopp
20 months ago

  • Keywords needs-screenshots removed

Patch applies cleanly, screenshots attached, patch refreshed

Last edited 20 months ago by Presskopp (previous) (diff)

@Presskopp
20 months ago

#10 @swissspidy
20 months ago

  • Keywords has-screenshots added

#11 @lukecavanagh
20 months ago

Patch still applies cleanly and resolves the issue.

#12 @nonproftechie
19 months ago

  • Keywords needs-unit-tests added

#13 @swissspidy
16 months ago

  • Milestone changed from Future Release to 4.8

#14 @printsachen1
16 months ago

The patch 38341.2.diff did not apply cleanly because it was not created from the project root directory. 38341.3.diff fixes this.

One other thing I noticed is that when restoring the last comment in the comments trash, the button remains since the page is not reloaded. This is only a minor issue, but may be something to consider.

#15 @swissspidy
16 months ago

Thanks @printsachen1 and good catch with the restore! I think it should be easy to make it work in that scenario, provided that the JS isn't that big of a mess.

@Jaydeep Rami
16 months ago

Attached patch from root

#16 @mathieuhays
15 months ago

I've just sent a new diff which hides the Empty Trash button for the use case mentioned by @printsachen1.

When testing I also noticed that when the Pages' trash is empty, there quite a lot of spacing due to the fact that there no button or filter anymore. Is it something that should fixed or is it expected to remain like that? Can be seen on the screenshot posted by @Presskopp.

@mathieuhays
15 months ago

add php-unit test

#17 @mathieuhays
15 months ago

I just pushed a new diff adding a simple PHP-Unit test.

@cazm
15 months ago

Fixing missing button when Spam is deleted and no trash

#18 @cazm
15 months ago

In certain conditions, when an item of Spam was "deleted perminently" and Trash = 0, the "empty spam" button disappeared, even when there was more than one item of spam still in the list.

#19 @swissspidy
15 months ago

One other thing I noticed is that when restoring the last comment in the comments trash, the button remains since the page is not reloaded. This is only a minor issue, but may be something to consider.

Good catch. I think it makes sense to address this in a new ticket.

@swissspidy
15 months ago

Adds another test for the comments list table

#20 @swissspidy
15 months ago

  • Owner set to swissspidy
  • Resolution set to fixed
  • Status changed from new to closed

In 40297:

List Tables: Hide 'Empty Trash' and 'Empty Spam' buttons when view is already empty.

Props ivantedja, Presskopp, printsachen1, Jaydeep Rami, mathieuhays, cazm.
Fixes #38341.

Note: See TracTickets for help on using tickets.