Make WordPress Core

Opened 6 years ago

Closed 2 years ago

Last modified 2 years ago

#42942 closed feature request (fixed)

Provide a post_date_column_time hook for media files

Reported by: ivanlutrov's profile ivanlutrov Owned by: davidbaumwald's profile davidbaumwald
Milestone: 6.0 Priority: normal
Severity: normal Version: 5.1
Component: Administration Keywords: has-patch dev-feedback needs-docs add-to-field-guide
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 (5)

42942.diff (716 bytes) - added by lopo 6 years ago.
Add a media_date_column_time filter
42942.2.diff (733 bytes) - added by lopo 4 years ago.
Patch refreshed
42942.3.diff (883 bytes) - added by lopo 3 years ago.
Patch refreshed
42942.4.2.diff (883 bytes) - added by lopo 2 years ago.
Patch refreshed
42942.5.diff (885 bytes) - added by lopo 2 years ago.
Patch updated after suggestion about version in Docblock

Download all attachments as: .zip

Change History (22)

@lopo
6 years ago

Add a media_date_column_time filter

#1 @lopo
6 years ago

  • Keywords has-patch added

#2 @Mte90
6 years ago

  • Keywords dev-feedback added

#3 @SergeyBiryukov
6 years ago

  • Milestone changed from Awaiting Review to 5.0

#4 @ivanlutrov
6 years 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
6 years 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.
Version 0, edited 6 years ago by lopo (next)

This ticket was mentioned in Slack in #core-media by joemcgill. View the logs.


6 years ago

#7 @peterwilsoncc
6 years ago

  • Milestone changed from 5.0 to 5.1

Moving to the 5.1 milestone due to the WordPress 5.0 focus on the new
editor (Gutenberg).

This ticket was mentioned in Slack in #core-media by joemcgill. View the logs.


5 years ago

#9 @desrosj
5 years ago

  • Component changed from Media to Administration
  • Milestone changed from 5.1 to Future Release

This one still needs a review. It also feels like more of an Administration component request, so updating accordingly. Going to punt it so that the component maintainers can milestone it according to their ability to address this.

@lopo
4 years ago

Patch refreshed

@lopo
3 years ago

Patch refreshed

@lopo
2 years ago

Patch refreshed

#10 @audrasjb
2 years ago

  • Milestone changed from Future Release to 6.0

Moving for 6.0 consideration since the patch looks ready to ship.

#11 @audrasjb
2 years ago

The only suggestion I'd have would be to replace 6.0 with 6.0.0 in the docblock, otherwise it looks good to me :)

@lopo
2 years ago

Patch updated after suggestion about version in Docblock

#12 @lopo
2 years ago

@audrasjb thanks for the suggestion, just applied

@antpb can you give some advice about or point me to someone who can? Thanks in advance!

#13 @davidbaumwald
2 years ago

  • Owner set to davidbaumwald
  • Status changed from new to reviewing

#14 @davidbaumwald
2 years ago

  • Resolution set to fixed
  • Status changed from reviewing to closed

In 52950:

Administration: Add a media_date_column_time filter to the media list table date column.

Similar to the existing post_date_column_time filter in the posts list table, this change adds a new hook to filter the "Date" column output in the media list view.

Props ivanlutrov, lopo, audrasjb.
Fixes #42942.

#15 @davidbaumwald
2 years ago

  • Keywords needs-dev-note added

Marking needs-dev-note as this at least deserves a small mention in the Misc Dev Note.

#16 @milana_cap
2 years ago

  • Keywords needs-docs added

#17 @milana_cap
2 years ago

  • Keywords add-to-field-guide added; needs-dev-note removed

As this is the only Administration ticket marked for docs it probably won't find a fitting Dev note so I'm marking it for mention in Field guide.

Note: See TracTickets for help on using tickets.