Make WordPress Core

Opened 6 years ago

Last modified 8 weeks ago

#18449 assigned defect (bug)

List Table Factory Needs to be Pluggable

Reported by: miqrogroove Owned by: wonderboymusic
Milestone: Future Release Priority: normal
Severity: normal Version: 3.1
Component: Administration Keywords: has-patch
Focuses: Cc:


Better design planning should have been considered for http://core.trac.wordpress.org/browser/trunk/wp-admin/includes/list-table.php

function _get_list_table() is identical to an object factory pattern, which would make more sense as a static member of WP_List_Table. In other words...

$wp_list_table = _get_list_table('WP_Terms_List_Table');

... which looks simple, is actually confusing because it would be more intuitive if written as ...

$wp_list_table = WP_List_Table::factory('Terms');

Further, the factory hasn't offered any extensibility. Locking edit-tags.php against WP_Terms_List_Table makes it unusable for custom taxonomies that need a custom UI. Despite all of the great API improvements for taxonomies, this case still necessitates duplicating the entire category editing UI within a plugin just to tweak a table column or a link path.

Please adjust the ticket Type and Component as necessary. It could be a taxonomy design flaw or an administration enhancement, depending how you look at it.

Attachments (2)

18449.diff (1.0 KB) - added by Faison 3 years ago.
Adding a filter to _get_list_table() to allow developers to return an object of their own class in place of core classes
18449.2.diff (7.2 KB) - added by peterwilsoncc 3 months ago.

Download all attachments as: .zip

Change History (20)

#1 @nacin
6 years ago

_get_list_table() used to be get_list_table(), and it had a filter to allow for switching out tables.

When we pulled out XHR bits and made the entire API private near the end of 3.1, we renamed it to the current, private version.

When someone finally takes ownership of and rewrites the list table API, I think this would indeed be a good approach.

#2 @scribu
6 years ago

  • Milestone changed from Awaiting Review to Future Release

Somewhere in Space this may all be happening right now.

#4 @sirzooro
6 years ago

  • Cc sirzooro added

#5 @kurtpayne
6 years ago

  • Cc kpayne@… added

#6 @johnbillion
6 years ago

  • Cc johnbillion added
  • Component changed from Taxonomy to Administration

#7 @SergeyBiryukov
4 years ago

#24938 was marked as a duplicate.

#9 @jrbeilke
4 years ago

  • Cc jrbeilke@… added

3 years ago

Adding a filter to _get_list_table() to allow developers to return an object of their own class in place of core classes

#10 @Faison
3 years ago

  • Keywords has-patch added

I recently ran into a situation where I needed to make some extensive customizations to the WP_Media_List_Table class and the filters it provided was not enough. So I'm hoping I can bring life back to this ticket with a patch that would help us all out.

It adds the filter 'pre_get_list_table' to _get_list_table(). It allows a developer to check what class was requested, and return an object of a different class if needed.

#11 @wonderboymusic
2 years ago

  • Milestone changed from Future Release to 4.4
  • Owner set to wonderboymusic
  • Status changed from new to assigned

I've ripped apart List Tables the past 2-3 releases. I think they are downright usable now.

#12 @wonderboymusic
2 years ago

#16987 was marked as a duplicate.

This ticket was mentioned in Slack in #core by sergey. View the logs.

2 years ago

#14 @SergeyBiryukov
2 years ago

The 'pre_get_list_table' filter should probably be 'wp_list_table_class', for consistency with 'wp_admin_bar_class'.

#15 @wonderboymusic
2 years ago

  • Milestone changed from 4.4 to Future Release

I have severe reservations about this endorsement now - I still consider WP_Screen , the random functions that interact with it, and WP_List_Table to be super weird

This ticket was mentioned in Slack in #core by sergey. View the logs.

3 months ago

#17 @peterwilsoncc
3 months ago

  • Milestone changed from Future Release to 4.9

In 18449.2.diff:

  • add the filter following @SergeyBiryukov's advice above
  • removes @access private from all the list table classes (ref #24938, labeled dupe of this ticket)

After six years I think the opportunity for someone to take ownership of the list table API has passed and WordPress is stuck with what's in there already.

Changing the API & breaking backward compatibility in any substantive way will break too many plugins.

I think the future release has come so am putting on the milestone to encourage discussion.

#18 @westonruter
8 weeks ago

  • Milestone changed from 4.9 to Future Release

Discussion doesn't seem to be happening and 4.9-beta3 is in a few hours, so I'm punting.

Note: See TracTickets for help on using tickets.