[wp-trac] [WordPress Trac] #42942: Provide a post_date_column_time hook for media files

WordPress Trac noreply at wordpress.org
Thu May 3 17:29:19 UTC 2018


#42942: Provide a post_date_column_time hook for media files
------------------------------------+---------------------
 Reporter:  ivanlutrov              |       Owner:  (none)
     Type:  feature request         |      Status:  new
 Priority:  normal                  |   Milestone:  5.0
Component:  Media                   |     Version:  trunk
 Severity:  normal                  |  Resolution:
 Keywords:  has-patch dev-feedback  |     Focuses:
------------------------------------+---------------------

Comment (by lopo):

 I proposed a new filter for a number of related reasons:

 * UI for media list and post list is different, we are talking of two
 different classes/files after all;
 * defining the same hook in two different files can be misleading and
 poorly maintainable (if we ever have to change it, it will have to be done
 in both locations, etc.);
 * in `class-wp-posts-list-table.php` the filter has a `$mode` parameter
 which is not defined for media:
 {{{
 apply_filters( 'post_date_column_time', $h_time, $post, 'date', $mode )
 }}}
 * it's true that media are stored and managed as `WP_Post` objects, but
 they're quite different in various regards (they usually have `inherit`
 status, their `post_date` is usually set at upload and doesn't change...)
 * it could happen that you want to use the hook for posts/pages/custom
 type items but not for media, and with two distinct hooks you can do it
 easily without having to resort to `if`/`switch`/whatever: for example
 when you are dealing with future posts, which makes no sense for media (I
 think it's one of the most likely use cases);
 * conversely, if you want to hook the same function to both filters it cna
 be done with just one line more.

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


More information about the wp-trac mailing list