[wp-trac] [WordPress Trac] #36564: Last Modified for Comments

WordPress Trac noreply at wordpress.org
Tue May 10 00:37:40 UTC 2016


#36564: Last Modified for Comments
-------------------------------------------------+-------------------------
 Reporter:  dshanske                             |       Owner:
     Type:  enhancement                          |      Status:  new
 Priority:  normal                               |   Milestone:  Awaiting
Component:  Comments                             |  Review
 Severity:  trivial                              |     Version:  4.4
 Keywords:  needs-patch dev-feedback needs-      |  Resolution:
  unit-tests                                     |     Focuses:
-------------------------------------------------+-------------------------

Comment (by chrisvanpatten):

 Offhand idea of how to use that: it'd serve as a good way to indicate when
 a comment was edited as a bit of transparency.

 For instance, when you edit a message in Slack, it appends "(edited)",
 with a timestamp of the modification time displayed on hover. Storing the
 comment's post time/modified time might be an easy way to calculate and
 display that in a site that allows comments to be edited by the user.

 Ugly code example:

 {{{#!php
 <?php

 add_filter( 'get_comment_date', function( $date, $d, $comment ) {
     if ( $comment->comment_modified_date != $date ) {
         return "{$date} <time class="modified"
 datetime="{$comment->comment_modified_date}">(Edited)</time>";
     } else {
         return $date;
     }
 }, 10, 3 )
 }}}

 (`get_comment_date` may very well be the wrong place to hook that, and I'm
 also fairly sure you'd need to re-format the datetime string to work in
 the `<time>` element, but you get the idea!)

 Of course people can store that value as comment meta right now, but
 having it baked in would be pretty handy.

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


More information about the wp-trac mailing list