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
This commit is contained in:
parent
f54a73f637
commit
5c071dbc16
@ -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 );
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user