sakurairo是没有首页显示文章更新功能的功能的, 经过实验, 我写了一份可以运行的显示更新时间的代码.

在Sakurairo/inc/theme-plus.php中末尾添加:(注意, 我们不能更改原代码的代码行数, 否则会影响翻译)

function update_time_since( $older_date, $comment_date = false, $text = false ) {
  $chunks = array(
    array( 24 * 60 * 60, __( '天前', 'sakurairo' ) ),
    array( 60 * 60 , __( '小时前', 'sakurairo' ) ),
    array( 60 , __( '分钟前', 'sakurairo' ) ),
    array( 1, __( '秒前', 'sakurairo' ) )
  );
  $newer_date = current_time('timestamp') - (iro_opt('time_zone_fix')*60*60);
  $since = abs( $newer_date - $older_date );
  if($text){
    $output = '';
  }else{
    $output = __('更新于','sakurairo');
  }

  if ( $since < 30 * 24 * 60 * 60 ) {
    foreach( $chunks as $chunk ) {
      $seconds = $chunk[0];
      $name    = $chunk[1];
      if ( ( $count = floor( $since / $seconds ) ) != 0 ) {
        break;
      }
    }
    $output .= $count . $name;
  } else {
    $output .= $comment_date ? date( 'Y-m-d H:i', $older_date ) : date( 'Y-m-d', $older_date );
  }

  return $output;
}

然后在Sakurairo/tpl/content-thumbcard.php中165行末尾添加 <?= esc_html(update_time_since(strtotime($post->post_modified))) ?>

现在我们实现了在首页显示, 还需要在文章页显示.这个在iro设置有.开启即可.

此作者没有提供个人介绍。
最后更新于 2025-10-05