WordPress.org

Make WordPress Core

Opened 4 years ago

Closed 4 years ago

#36152 closed enhancement (fixed)

add bypass filter to remove category dropdown on post table

Reported by: davidmosterd Owned by: swissspidy
Milestone: 4.6 Priority: normal
Severity: normal Version: 4.4.2
Component: Posts, Post Types Keywords: good-first-bug has-patch commit
Focuses: administration Cc:
PR Number:

Description

Much like #30254. Only with categories there is no function that handles showing the dropdown. This patch adds that function along with the filter to simply bypass showing the dropdown and prevent any additional SQL or code to run. This is useful for situations where you disable the categories column in the post/list table, but do not wish to remove the use of categories.

Attachments (3)

36152.diff (2.3 KB) - added by davidmosterd 4 years ago.
First patch
36152.2.diff (2.3 KB) - added by davidmosterd 4 years ago.
Comments
36152.3.diff (2.3 KB) - added by swissspidy 4 years ago.

Download all attachments as: .zip

Change History (14)

#1 @swissspidy
4 years ago

  • Keywords needs-patch good-first-bug added
  • Milestone changed from Awaiting Review to Future Release

@davidmosterd
4 years ago

First patch

#2 @davidmosterd
4 years ago

I have added a patch. I figured categories are bound to posts and the function should be in the WP_Posts_List_Table class and not in the WP_List_Table class.

#3 @davidmosterd
4 years ago

  • Keywords has-patch added; needs-patch removed

#4 @swissspidy
4 years ago

The new categories_dropdown() method needs some docs love as per https://make.wordpress.org/core/handbook/best-practices/inline-documentation-standards/php/, but otherwise it looks good.

#5 @swissspidy
4 years ago

  • Owner set to davidmosterd
  • Status changed from new to assigned

Marking the "good-first-bug" as claimed

@davidmosterd
4 years ago

Comments

#6 @davidmosterd
4 years ago

Thanks for pointing that out. Hope I did the comments better now. If not, can you please help me out what to improve?

#7 @swissspidy
4 years ago

  • Milestone changed from Future Release to 4.6
  • Owner changed from davidmosterd to swissspidy
  • Status changed from assigned to reviewing

Thanks for the updated patch and sorry for my late reply!

I'll update the version numbers and perhaps slightly change the wording to be more similar to the one in WP_List_Table::months_dropdown(). After that it's good to go in my opinion!

#8 @DrewAPicture
4 years ago

@swissspidy While you're at it can you add an @access tag to the method and make the check against the filter more strict? I'm not a huge fan of the semi-truthy or semi-falsey kinds of boolean filters, better to be explicit.

@swissspidy
4 years ago

#9 @swissspidy
4 years ago

In 36152.3.diff:

  • Change the version number to 4.6.0
  • Add the @access tag
  • Make filter more explicit
  • Adjust wording

Good to go in my opinion.

#10 @swissspidy
4 years ago

  • Keywords commit added

#11 @swissspidy
4 years ago

  • Resolution set to fixed
  • Status changed from reviewing to closed

In 37856:

Posts list table: Add a filter to disable the categories dropdown.

This allows one to short-circuit its output before any queries are run, similar to how it was done for the months dropdown in [31438].

Props davidmosterd for initial patch.
Fixes #36152.

Note: See TracTickets for help on using tickets.