mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2025-10-16 12:05:38 +00:00
Comments: Allow to pass $comment_ID parameter to get_comment_time().
Props spacedmonkey, travisaxton, SergeyBiryukov, d-signed, audrasjb, rudlinkon, h4l9k, mukesh27, costdev. Fixes #52322. git-svn-id: https://develop.svn.wordpress.org/trunk@55284 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
6fc77d21d3
commit
8a2902db8d
@ -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;
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user