Skip to content

Commit

Permalink
Comments: Allow to pass $comment_ID parameter to get_comment_time().
Browse files Browse the repository at this point in the history
Props spacedmonkey, travisaxton, SergeyBiryukov, d-signed, audrasjb, rudlinkon, h4l9k, mukesh27, costdev.
Fixes #52322.

Built from https://develop.svn.wordpress.org/trunk@55284


git-svn-id: http://core.svn.wordpress.org/trunk@54817 1a063a9b-81f0-0310-95a4-ce76da25c4cd
  • Loading branch information
audrasjb committed Feb 7, 2023
1 parent e374552 commit c03b342
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
19 changes: 13 additions & 6 deletions wp-includes/comment-template.php
Original file line number Diff line number Diff line change
Expand Up @@ -1031,15 +1031,22 @@ function comment_text( $comment_ID = 0, $args = array() ) {
* Retrieves the comment time of the current comment.
*
* @since 1.5.0
* @since 6.2.0 Added the ability for `$comment_ID` to also accept a WP_Comment object.
*
* @param string $format Optional. PHP time format. Defaults to the 'time_format' option.
* @param bool $gmt Optional. Whether to use the GMT date. Default false.
* @param bool $translate Optional. Whether to translate the time (for use in feeds).
* Default true.
* @param string $format Optional. PHP date format. Defaults to the 'time_format' option.
* @param bool $gmt Optional. Whether to use the GMT date. Default false.
* @param bool $translate Optional. Whether to translate the time (for use in feeds).
* Default true.
* @param int|WP_Comment $comment_ID Optional. WP_Comment or ID of the comment for which to get the date.
* Default is 0, or the global comment.
* @return string The formatted time.
*/
function get_comment_time( $format = '', $gmt = false, $translate = true ) {
$comment = get_comment();
function get_comment_time( $format = '', $gmt = false, $translate = true, $comment_ID = 0 ) {
$comment = get_comment( $comment_ID );

if ( null === $comment ) {
return '';
}

$comment_date = $gmt ? $comment->comment_date_gmt : $comment->comment_date;

Expand Down
2 changes: 1 addition & 1 deletion wp-includes/version.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
*
* @global string $wp_version
*/
$wp_version = '6.2-alpha-55283';
$wp_version = '6.2-alpha-55284';

/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
Expand Down

0 comments on commit c03b342

Please sign in to comment.