WordPress.org

Make WordPress Core

Opened 6 months ago

Last modified 7 weeks ago

#42942 new feature request

Provide a post_date_column_time hook for media files

Reported by: ivanlutrov Owned by:
Milestone: 5.0 Priority: normal
Severity: normal Version: trunk
Component: Media Keywords: has-patch dev-feedback
Focuses: Cc:

Description

Class class-wp-posts-list-table.php has column_date() function which uses post_date_column_time hook to filter the date.

Class class-wp-media-list-table.php has column_date() function which has no hook to filter the date.

Attachments (1)

42942.diff (716 bytes) - added by lopo 4 months ago.
Add a media_date_column_time filter

Download all attachments as: .zip

Change History (6)

@lopo
4 months ago

Add a media_date_column_time filter

#1 @lopo
4 months ago

  • Keywords has-patch added

#2 @Mte90
4 months ago

  • Keywords dev-feedback added

#3 @SergeyBiryukov
4 months ago

  • Milestone changed from Awaiting Review to 5.0

#4 @ivanlutrov
2 months ago

Is there a reason we can't just use post_date_column_time for this? That filter is used by WP for posts and pages, as well as custom post types so it makes sense just to use the same filter for all of them.

#5 @lopo
7 weeks ago

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.
Note: See TracTickets for help on using tickets.