From a2a143467287175a33daef5dbde74ab9b5e07c24 Mon Sep 17 00:00:00 2001 From: Brianna Privett Date: Thu, 18 Oct 2018 07:33:18 -0500 Subject: [PATCH 1/2] Display times with chosen settings in comments MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Replace the lovely human_time_diff() with the get_comment_date() and get_comment_time() functions so that a user’s chosen time display settings are used in comments display. --- classes/class.twentynineteen-walker-comment.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/classes/class.twentynineteen-walker-comment.php b/classes/class.twentynineteen-walker-comment.php index 2b76d942..5546e563 100644 --- a/classes/class.twentynineteen-walker-comment.php +++ b/classes/class.twentynineteen-walker-comment.php @@ -50,7 +50,7 @@ protected function html5_comment( $comment, $depth, $args ) { Date: Thu, 18 Oct 2018 14:21:00 -0500 Subject: [PATCH 2/2] Remove twentynineteen_human_time_diff Remove unused function. --- inc/template-tags.php | 59 ------------------------------------------- 1 file changed, 59 deletions(-) diff --git a/inc/template-tags.php b/inc/template-tags.php index 104989b7..6028f5f2 100644 --- a/inc/template-tags.php +++ b/inc/template-tags.php @@ -175,65 +175,6 @@ function twentynineteen_header_featured_image_css() { } endif; -if ( ! function_exists( 'twentynineteen_human_time_diff' ) ) : -/** - * Same as core's human_time_diff(), only in the "ago" context, - * which is different for some languages. - * - * @param int $from Unix timestamp from which the difference begins. - * @param int $to Optional Unix timestamp to end the time difference. Defaults to time() if not set. - * @return string Human readable time difference. - */ - function twentynineteen_human_time_diff( $from, $to = '' ) { - if ( empty( $to ) ) { - $to = time(); - } - - $diff = (int) abs( $to - $from ); - - if ( $diff < HOUR_IN_SECONDS ) { - $mins = round( $diff / MINUTE_IN_SECONDS ); - if ( $mins <= 1 ) { - $mins = 1; - } - /* translators: min=minute */ - $since = sprintf( _n( '%s min ago', '%s mins ago', $mins, 'twentynineteen' ), $mins ); - } elseif ( $diff < DAY_IN_SECONDS && $diff >= HOUR_IN_SECONDS ) { - $hours = round( $diff / HOUR_IN_SECONDS ); - if ( $hours <= 1 ) { - $hours = 1; - } - $since = sprintf( _n( '%s hour ago', '%s hours ago', $hours, 'twentynineteen' ), $hours ); - } elseif ( $diff < WEEK_IN_SECONDS && $diff >= DAY_IN_SECONDS ) { - $days = round( $diff / DAY_IN_SECONDS ); - if ( $days <= 1 ) { - $days = 1; - } - $since = sprintf( _n( '%s day ago', '%s days ago', $days, 'twentynineteen' ), $days ); - } elseif ( $diff < 30 * DAY_IN_SECONDS && $diff >= WEEK_IN_SECONDS ) { - $weeks = round( $diff / WEEK_IN_SECONDS ); - if ( $weeks <= 1 ) { - $weeks = 1; - } - $since = sprintf( _n( '%s week ago', '%s weeks ago', $weeks, 'twentynineteen' ), $weeks ); - } elseif ( $diff < YEAR_IN_SECONDS && $diff >= 30 * DAY_IN_SECONDS ) { - $months = round( $diff / ( 30 * DAY_IN_SECONDS ) ); - if ( $months <= 1 ) { - $months = 1; - } - $since = sprintf( _n( '%s month ago', '%s months ago', $months, 'twentynineteen' ), $months ); - } elseif ( $diff >= YEAR_IN_SECONDS ) { - $years = round( $diff / YEAR_IN_SECONDS ); - if ( $years <= 1 ) { - $years = 1; - } - $since = sprintf( _n( '%s year ago', '%s years ago', $years, 'twentynineteen' ), $years ); - } - - return $since; - } -endif; - if ( ! function_exists( 'twentynineteen_comment_avatar' ) ) : /** * Returns the HTML markup to generate a user avatar.