WordPress.org

Make WordPress Core

Opened 3 years ago

Last modified 17 months ago

#21015 new defect (bug)

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

Reported by: CoenJacobs Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version: 3.1
Component: Posts, Post Types Keywords: has-patch
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 3 years ago.
Filters out the posts with 'auto-draft' as status in counting query
21015.2.diff (503 bytes) - added by MikeHansenMe 3 years ago.
filters trash status as well.
21015.3.patch (745 bytes) - added by MikeHansenMe 3 years ago.
21015.4.patch (846 bytes) - added by CoenJacobs 3 years ago.
21015.5.patch (775 bytes) - added by CoenJacobs 2 years ago.
Revised patch, tested against current trunk
21015.6.diff (732 bytes) - added by MikeHansenMe 3 months ago.
Refreshed for 4.3

Download all attachments as: .zip

Change History (16)

@CoenJacobs3 years ago

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

@MikeHansenMe3 years ago

filters trash status as well.

comment:1 @MikeHansenMe3 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.

comment:2 @MikeHansenMe3 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.

@MikeHansenMe3 years ago

comment:3 @CoenJacobs3 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 3 years ago by CoenJacobs (previous) (diff)

@CoenJacobs3 years ago

comment:4 @MikeHansenMe3 years ago

Looks good

comment:5 @SergeyBiryukov3 years ago

#22033 was marked as a duplicate.

@CoenJacobs2 years ago

Revised patch, tested against current trunk

comment:6 @CoenJacobs2 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 needs a second set of eyes to test.

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

comment:7 @rmarks2 years ago

  • Cc rmarks@… added

comment:8 @jeremyfelt19 months ago

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

comment:9 @seanchayes17 months 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.

comment:10 @samuelsidler17 months ago

  • Keywords needs-testing removed

@MikeHansenMe3 months ago

Refreshed for 4.3

Note: See TracTickets for help on using tickets.