From 5c071dbc1658f4b6321e12bb5b3b243e800b6eae Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Thu, 5 Jun 2014 00:38:33 +0000 Subject: [PATCH] Add a filter to human_time_diff(). props slimndap. fixes #27271. git-svn-id: https://develop.svn.wordpress.org/trunk@28670 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-includes/formatting.php | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/wp-includes/formatting.php b/src/wp-includes/formatting.php index aef9c5555c..a07a020629 100644 --- a/src/wp-includes/formatting.php +++ b/src/wp-includes/formatting.php @@ -2335,8 +2335,9 @@ function sanitize_email( $email ) { * @return string Human readable time difference. */ function human_time_diff( $from, $to = '' ) { - if ( empty( $to ) ) + if ( empty( $to ) ) { $to = time(); + } $diff = (int) abs( $to - $from ); @@ -2373,7 +2374,17 @@ function human_time_diff( $from, $to = '' ) { $since = sprintf( _n( '%s year', '%s years', $years ), $years ); } - return $since; + /** + * Filter the human readable difference between two timestamps. + * + * @since 4.0.0 + * + * @param string $since The difference in human readable text. + * @param int $diff The difference in seconds. + * @param int $from Unix timestamp from which the difference begins. + * @param int $to Unix timestamp to end the time difference. + */ + return apply_filters( 'human_time_diff', $since, $diff, $from, $to ); } /**