fix(single): align author-bar publish time with the reference

The publish time under the author name diverged from the reference in four
ways: it rendered a leading bullet from `.icon-circle`, its tooltip opened
above instead of below, its wording was "2 天发布" (WordPress'
human_time_diff has no 前 and keeps spaces), and it ignored the
「时间显示数据源」 setting entirely.

- markup: drop `.icon-circle` from the time span and the description fallback;
  add `data-placement="bottom"` so the tooltip opens below like the reference
- wording: use jio_time_ago() (which already ends in 前) and append only
  发布 / 更新, yielding "2天前发布"
- branches: mirror zib_get_post_time_tooltip exactly (date source → publish
  time; unpublished → modified time; published-with-update → modified time
  labelled 更新 while the tooltip keeps the publish time; otherwise publish)
- the setting is read from post_time_source via get_post_list_style_settings()

Tests: new author-bar-time suite drives the real template through a stub
harness across all four branches (4/4); widget suite 833/834 with the
pre-existing frontend-lifecycle failure.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
kate522andClaude Opus 5 committed 2026-11-03 16:58:05 +08:00
1 parent f14e6bd88d
commit f6fde18857
3 files changed
+208 -11

No files matched your search

+47 -11
View File
@@ -18,15 +18,51 @@ $meta_html = (string) ($args['meta_html'] ?? '');
$author_id = (int) get_the_author_meta('ID');
$author_name = get_the_author();
$author_url = function_exists('jio_get_user_home_url') ? jio_get_user_home_url($author_id) : get_author_posts_url($author_id);
$modified_ts = (int) get_the_modified_time('U');
$published_ts = (int) get_the_time('U');
$use_modified = $modified_ts > $published_ts;
$rel_base = $use_modified ? $modified_ts : $published_ts;
$rel_label = $use_modified ? __('更新', 'jio') : __('发布', 'jio');
$abs_fmt = $use_modified
? sprintf(__('%s更新', 'jio'), get_the_modified_time('Y年m月d日 H:i'))
: sprintf(__('%s发布', 'jio'), get_the_time('Y年m月d日 H:i'));
$time_text = human_time_diff($rel_base, (int) current_time('timestamp')) . $rel_label;
// 时间显示:完全按参考主题 zib_get_post_time_tooltip 的分支顺序。
// 1) 数据源 date → 发布时间
// 2) 非已发布状态 → 更新时间
// 3) 更新时间 > 发布时间 → 文案用更新时间+「更新」,tooltip 仍为发布时间+「发布」
// 4) 其余 → 发布时间
$time_source = '';
if (class_exists('\Jio\Settings\Settings')) {
$list_settings = \Jio\Settings\Settings::get_post_list_style_settings();
$time_source = (string) ($list_settings['post_time_source'] ?? 'modified');
}
$is_published = (string) get_post_status(get_the_ID()) === 'publish';
$published_mysql = (string) get_the_time('Y-m-d H:i:s');
$modified_mysql = (string) get_the_modified_time('Y-m-d H:i:s');
$has_update = (int) strtotime($modified_mysql) > (int) strtotime($published_mysql);
$published_title = sprintf(__('%s发布', 'jio'), get_the_time('Y年m月d日 H:i'));
$modified_title = sprintf(__('%s更新', 'jio'), get_the_modified_time('Y年m月d日 H:i'));
if ($time_source === 'date') {
// 1) 强制发布时间源。
$time_mysql = $published_mysql;
$rel_label = __('发布', 'jio');
$abs_fmt = $published_title;
} elseif (!$is_published) {
// 2) 草稿/待审等:参考固定展示更新时间。
$time_mysql = $modified_mysql;
$rel_label = __('更新', 'jio');
$abs_fmt = $modified_title;
} elseif ($has_update) {
// 3) 已发布且有更新:文案取更新时间,tooltip 仍标注发布时间。
$time_mysql = $modified_mysql;
$rel_label = __('更新', 'jio');
$abs_fmt = $published_title;
} else {
// 4) 未更新过:发布时间。
$time_mysql = $published_mysql;
$rel_label = __('发布', 'jio');
$abs_fmt = $published_title;
}
// 相对时间本身已含「前」,只拼接「发布 / 更新」。
$time_ago = function_exists('jio_time_ago')
? jio_time_ago($time_mysql)
: human_time_diff((int) strtotime($time_mysql), (int) current_time('timestamp')) . __('前', 'jio');
$time_text = $time_ago . $rel_label;
$description = function_exists('jio_get_user_description')
? jio_get_user_description($author_id)
: trim((string) get_the_author_meta('description'));
@@ -62,9 +98,9 @@ $reward_button = get_current_user_id() !== $author_id && function_exists('jio_ge
<?php echo $name_html; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
<div class="px12-sm muted-2-color text-ellipsis">
<?php if ($show_time) : ?>
<span class="icon-circle" title="<?php echo esc_attr($abs_fmt); ?>" data-toggle="tooltip"><?php echo esc_html($time_text); ?></span>
<span data-toggle="tooltip" data-placement="bottom" title="<?php echo esc_attr($abs_fmt); ?>"><?php echo esc_html($time_text); ?></span>
<?php elseif ($description !== '') : ?>
<span class="icon-circle"><?php echo esc_html($description); ?></span>
<span><?php echo esc_html($description); ?></span>
<?php endif; ?>
<?php
$post_city = function_exists('jio_get_post_author_city_badge_html')