WordPress.org

Make WordPress Core

Opened 4 years ago

Closed 13 months ago

Last modified 13 months ago

#21015 closed defect (bug) (fixed)

Months dropdown should not show if only posts are 'auto-draft' status

Reported by: CoenJacobs Owned by: wonderboymusic
Milestone: 4.4 Priority: normal
Severity: normal Version: 3.1
Component: Posts, Post Types Keywords: has-patch needs-screenshots
Focuses: administration Cc:

Description

The months dropdown at the top of edit.php should only show if there are actually posts in the list.

Right now, if you click 'Add new' an auto draft post will be saved. Leave the post edit screen without saving the post (so no draft will be created) and go back to the edit.php screen. There is no post in the list, but the month drop down will be shown because the auto draft is counted.

Attachments (6)

21015.diff (471 bytes) - added by CoenJacobs 4 years ago.
Filters out the posts with 'auto-draft' as status in counting query
21015.2.diff (503 bytes) - added by MikeHansenMe 4 years ago.
filters trash status as well.
21015.3.patch (745 bytes) - added by MikeHansenMe 4 years ago.
21015.4.patch (846 bytes) - added by CoenJacobs 4 years ago.
21015.5.patch (775 bytes) - added by CoenJacobs 3 years ago.
Revised patch, tested against current trunk
21015.6.diff (732 bytes) - added by MikeHansenMe 16 months ago.
Refreshed for 4.3

Download all attachments as: .zip

Change History (22)

@CoenJacobs
4 years ago

Filters out the posts with 'auto-draft' as status in counting query

@MikeHansenMe
4 years ago

filters trash status as well.

#1 @MikeHansenMe
4 years ago

  • Cc MikeHansenMe added

While testing this patch I realized that it was also showing dates of posts that had been deleted or 'trash' status. I updated the file to prevent both.

#2 @MikeHansenMe
4 years ago

  • Keywords needs-testing added

Just realized my patch was removing dates from the trash link above the posts. I updated to allow dates for trash posts for trash status only.

#3 @CoenJacobs
4 years ago

After testing your patch, I found out that it needs to check for the $_GET variable to be set to prevent notices. Patched that, done some testing with it. Looks good to me now.

Last edited 4 years ago by CoenJacobs (previous) (diff)

@CoenJacobs
4 years ago

#4 @MikeHansenMe
4 years ago

Looks good

#5 @SergeyBiryukov
4 years ago

#22033 was marked as a duplicate.

@CoenJacobs
3 years ago

Revised patch, tested against current trunk

#6 @CoenJacobs
3 years ago

Tested this again against current trunk and made a small adjustment (no use checking for $_GET['post_status'] twice, it's there or it's not). This might need a second set of eyes to test.

Version 0, edited 3 years ago by CoenJacobs (next)

#7 @rmarks
3 years ago

  • Cc rmarks@… added

#8 @jeremyfelt
3 years ago

  • Component changed from Administration to Posts, Post Types
  • Focuses admin added

#9 @seanchayes
2 years ago

I emulated the issue with both Posts and Pages. Without the 21015.5 patch applied I saw that the additional month was in the dropdown even though no associated post/page showed in the All Posts/Pages list.

I applied the 21015.5 patch and repeated the exercise and found that only the month(s) with relevant / actively created content showed in the dropdown.

I also added a register_post_type call for "Listings" in my _s theme to generate a custom post type. I observed the same behavior as above in the all "Listings" view edit.php?post_type=listing before and after the patch was applied.

#10 @samuelsidler
2 years ago

  • Keywords needs-testing removed

@MikeHansenMe
16 months ago

Refreshed for 4.3

#11 @swissspidy
13 months ago

  • Milestone changed from Awaiting Review to 4.4

Latest patch still applies and works. Can we get this into 4.4?

#12 follow-up: @jorbin
13 months ago

Wouldn't it also make sense to hide the other two dropdowns as well? You can't do any bulk actions to non existant posts and you can't filter by categories if there are no posts.

#13 in reply to: ↑ 12 @swissspidy
13 months ago

Replying to jorbin:

Wouldn't it also make sense to hide the other two dropdowns as well? You can't do any bulk actions to non existant posts and you can't filter by categories if there are no posts.

There's #21856 for the category dropdown and I just created #33824 for the bulk actions dropdown

#14 @wonderboymusic
13 months ago

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

In 34076:

List Tables: don't render "extra tablenav" if there are no posts. This includes Bulk Actions, Dates Dropdown, Category Dropdowns, Pagination.

Also ensure that the Months dropdown, when it is shown, shows months from the proper set of posts.

Props egower, CoenJacobs, MikeHansenMe, mehulkaklotar.
Fixes #33824, #21015, #21856.

#15 @wonderboymusic
13 months ago

In 34077:

After [34076], fix the logic for post_status in months dropdown.

See #21015.

#16 @ryan
13 months ago

  • Keywords needs-screenshots added
Note: See TracTickets for help on using tickets.