[wp-trac] [WordPress Trac] #29881: Better abstraction for WP_Posts_List_Table so it's easier to subclass
WordPress Trac
noreply at wordpress.org
Tue Oct 7 20:16:23 UTC 2014
#29881: Better abstraction for WP_Posts_List_Table so it's easier to subclass
----------------------------+-----------------------------
Reporter: joehoyle | Owner:
Type: enhancement | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Administration | Version: 3.1
Severity: normal | Keywords:
Focuses: administration |
----------------------------+-----------------------------
Currently `WP_Posts_List_Table` is a bit of a complicated mess as all
columns are in a big switch statement in the `single_row()` method. This
annoying for a couple of reasons.
1. The code is a messy, huge method making it difficult to maintain and
understand.
2. Subclassing is a pain as you can't override a single column the way the
magic method calling of `column_$column_name` should work.
3. Subclasses don't automatically get the `column_$column_name`
functionality as `WP_Posts_List_Table` (for whatever reason) closes out
this functionality by overriding the `single_row()` method.
I'm not a fan of changing things for the sake of it, but I think this is
an important cleanup. `WP_Comment_List_Table` is pretty well implemented
in comparison, but I imagine `WP_Posts_List_Table` is the most often
subclassed due to the heavy use of custom post types.
Apologies if this has been discussed before and/or rejected. I tried to
use search... which I seem to kind of fail at finding tickets.
I attached a preliminary path that is functional but needs a couple of
edge cases cleaned up. It basically splits out all the columns into their
own method which are automatically called from `single_row_columns()`.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/29881>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list