WordPress.org

Make WordPress Core

Opened 12 months ago

Closed 7 months ago

#44821 closed enhancement (invalid)

Add filter for custom taxonomy per page value in `WP_Term_List_Table`

Reported by: desrosj Owned by:
Milestone: Priority: normal
Severity: normal Version:
Component: Taxonomy Keywords:
Focuses: administration Cc:

Description

In WP_Terms_List_Table->prepare_items() there are two filters, edit_tags_per_page and edit_categories_per_page. Neither of these filters are run if the taxonomy being viewed is not a core taxonomy (category or tag).

A new filter should be added that allows the filtering of the per page value for custom taxonomies.

Attachments (4)

44821.diff (988 bytes) - added by nateallen 12 months ago.
Adds a filter for custom taxonomy terms per page
44821.2.diff (972 bytes) - added by nateallen 12 months ago.
Fixes indents (spaces should be tabs)
44821.3.diff (965 bytes) - added by nateallen 12 months ago.
Fixes more indent issues
44821.4.diff (1.9 KB) - added by SergeyBiryukov 11 months ago.

Download all attachments as: .zip

Change History (13)

@nateallen
12 months ago

Adds a filter for custom taxonomy terms per page

#1 @nateallen
12 months ago

  • Keywords has-patch added

@nateallen
12 months ago

Fixes indents (spaces should be tabs)

@nateallen
12 months ago

Fixes more indent issues

#2 follow-up: @SergeyBiryukov
11 months ago

  • Milestone changed from Awaiting Review to 4.9.9

44821.3.diff seems like a good start.

For consistency with the edit_{$post_type}_per_page filter though, the new filter should probably apply to core taxonomies as well. Any objections to 44821.4.diff?

#3 in reply to: ↑ 2 @nateallen
11 months ago

Replying to SergeyBiryukov:

44821.3.diff seems like a good start.

For consistency with the edit_{$post_type}_per_page filter though, the new filter should probably apply to core taxonomies as well. Any objections to 44821.4.diff?

Thank you for the feedback. Yes, I think 44821.4.diff makes more sense.

#4 @desrosj
11 months ago

  • Keywords close added

I think that I created a ticket prematurely.

In reviewing 44821.4.diff, I noticed that the WP_List_Table->get_items_per_page() method will actually pass the value through a dynamic filter with the exact same name as the $option parameter passed to it. Given a custom taxonomy called my_custom_tax, the filter that runs would be called edit_my_custom_tax_per_page. This has been in place since [15569], but is not immediately obvious in classes extending WP_List_Table.

The edit_tags_per_page and edit_categories_per_page were old filter names that seem to be left for backward compatibility.

WP_Posts_List_Table is the only other WP_List_Table that applies a filter to the per page value (edit_posts_per_page), but, this filter is called in two other places in core, and is different than edit_post_per_page (singular) which would be called by the WP_List_Table->get_items_per_page() method.

I am marking this as a close candidate. The goal of this ticket is already possible.

#5 @pento
11 months ago

  • Milestone changed from 4.9.9 to 5.0.1

#6 @pento
8 months ago

  • Milestone changed from 5.0.1 to 5.0.2

#7 @pento
8 months ago

  • Milestone changed from 5.0.2 to 5.0.3

#8 @audrasjb
8 months ago

  • Milestone changed from 5.0.3 to 5.1

5.0.3 is going to be released in a couple of weeks. We are currently sorting the remaining tickets in the milestone. It doesn't appear that ticket can be handled in the next couple of weeks (especially as it is tagged "close"). If necessary, let's address it in 5.1 which is coming in February. Feel free to change/ask to change the milestone if you think this issue can be quickly resolved.

#9 @desrosj
7 months ago

  • Keywords good-first-bug has-patch close removed
  • Milestone 5.1 deleted
  • Resolution set to invalid
  • Status changed from new to closed

Closing this out since it is already possible as noted in ticket:44821#comment:4. If the need for a more specifically named filter arises this can be reopened.

Note: See TracTickets for help on using tickets.