Make WordPress Core

Changeset 55284

Timestamp:
02/07/2023 05:51:53 PM (18 months ago)
Author:
audrasjb
Message:

Comments: Allow to pass $comment_ID parameter to get_comment_time().

Props spacedmonkey, travisaxton, SergeyBiryukov, d-signed, audrasjb, rudlinkon, h4l9k, mukesh27, costdev.
Fixes #52322.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/comment-template.php

    r54958 r55284  
    10321032 *
    10331033 * @since 1.5.0
    1034  *
    1035  * @param string $format    Optional. PHP time format. Defaults to the 'time_format' option.
    1036  * @param bool   $gmt       Optional. Whether to use the GMT date. Default false.
    1037  * @param bool   $translate Optional. Whether to translate the time (for use in feeds).
    1038  *                          Default true.
     1034 * @since 6.2.0 Added the ability for `$comment_ID` to also accept a WP_Comment object.
     1035 *
     1036 * @param string         $format     Optional. PHP date format. Defaults to the 'time_format' option.
     1037 * @param bool           $gmt        Optional. Whether to use the GMT date. Default false.
     1038 * @param bool           $translate  Optional. Whether to translate the time (for use in feeds).
     1039 *                                   Default true.
     1040 * @param int|WP_Comment $comment_ID Optional. WP_Comment or ID of the comment for which to get the date.
     1041 *                                   Default is 0, or the global comment.
    10391042 * @return string The formatted time.
    10401043 */
    1041 function get_comment_time( $format = '', $gmt = false, $translate = true ) {
    1042     $comment = get_comment();
     1044function get_comment_time( $format = '', $gmt = false, $translate = true, $comment_ID = 0 ) {
     1045    $comment = get_comment( $comment_ID );
     1046
     1047    if ( null === $comment ) {
     1048        return '';
     1049    }
    10431050
    10441051    $comment_date = $gmt ? $comment->comment_date_gmt : $comment->comment_date;
Note: See TracChangeset for help on using the changeset viewer.