[wp-trac] [WordPress Trac] #30325: WP List Table: allow filtering view switcher modes

WordPress Trac noreply at wordpress.org
Wed Nov 12 19:46:21 UTC 2014


#30325: WP List Table: allow filtering view switcher modes
-------------------------+---------------------------------
 Reporter:  ragulka      |       Owner:
     Type:  enhancement  |      Status:  new
 Priority:  normal       |   Milestone:  Awaiting Review
Component:  General      |     Version:  4.0
 Severity:  normal       |  Resolution:
 Keywords:               |     Focuses:  ui, administration
-------------------------+---------------------------------
Changes (by ragulka):

 * focuses:  administration => ui, administration


Comment:

 Looking a bit further into this, I see at least these points that need
 addressing:

 '''`posts_list_mode` user setting affects all post types'''

 All custom post type list tables use the `WP_Posts_List_Table` class,
 which uses the `posts_list_mode` user setting to determine, which view
 mode to use by default. This means that the setting will be the same
 across all different post types. I'm not sure this behaviour is ideal in
 the first place - perhaps I want to use list mode for posts, but excerpt
 mode for books?

 This raises 2 questions:
 1. Should we perhaps consider using a post-type specific user setting
 here, instead? Something like `{$custom_post_type}_list_mode`
 2. Or if we want to keep this still a single user setting, what happens if
 the `posts_list_mode` is `excerpt` and I remove `excerpt` from the
 `$modes`? Let's say we only have `list` and `grid` instead. Should we
 probably just display `grid` (or whichever is the first) and ignore the
 user setting?

 '''Where should we do the filtering?'''

 I can see a few possible places:
 * https://core.trac.wordpress.org/browser/trunk/src/wp-admin/includes
 /class-wp-list-table.php#L128 - this would make the most sense, because we
 know this way the filter would be run only once. However, since `$modes`
 property can be provided in the child class, like
 https://core.trac.wordpress.org/browser/trunk/src/wp-admin/includes/class-
 wp-media-list-table.php#L25, this would mean that the child class would
 have to make sure to apply the filter as well. In core, this shouldn't be
 a problem (only Media list is providing custom modes), but could become
 messy an unreliable with custom list tables, if developers forget to apply
 the filter.
 * https://core.trac.wordpress.org/browser/trunk/src/wp-admin/includes
 /class-wp-list-table.php#L544 - this would ensure that the modes are
 always filtered. This happens at runtime, which could possibly make it
 less efficient, but then again - the view mode switcher is only displayed
 once per screen, so in reality, it doesn't affect performance
 * Perhaps a possible approach would be to make WP_Media_List_table use the
 filter instead of providing view modes in the constructor?

--
Ticket URL: <https://core.trac.wordpress.org/ticket/30325#comment:1>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list