51 lines
1.9 KiB
PHP
51 lines
1.9 KiB
PHP
<?php
|
|
/**
|
|
* Profile Comment List Item — image-less comment row for user center.
|
|
*
|
|
* 通过 get_template_part() 的 $args 接收(保留 query var 兼容):
|
|
* - aksrt_profile_comment: WP_Comment 对象
|
|
*
|
|
* @package AKSRT
|
|
*/
|
|
|
|
defined('ABSPATH') || exit;
|
|
|
|
$comment = $args['comment'] ?? get_query_var('aksrt_profile_comment');
|
|
if (!$comment instanceof WP_Comment) {
|
|
return;
|
|
}
|
|
|
|
$post = get_post((int) $comment->comment_post_ID);
|
|
if (!$post) {
|
|
return;
|
|
}
|
|
|
|
$snippet = wp_trim_words(wp_strip_all_tags($comment->comment_content), 30, '…');
|
|
$post_title = get_the_title($post);
|
|
$comment_link = get_comment_link($comment);
|
|
$post_link = get_permalink($post);
|
|
$date_iso = get_comment_date('c', $comment);
|
|
$date_label = get_comment_date('Y-m-d', $comment);
|
|
$time_diff = human_time_diff(strtotime($comment->comment_date), current_time('timestamp'));
|
|
?>
|
|
<article class="profile-comment-item">
|
|
<a href="<?php echo esc_url($comment_link); ?>" class="profile-comment-item__quote-link" aria-label="<?php esc_attr_e('查看评论', 'aksrt'); ?>">
|
|
<span class="profile-comment-item__quote-mark" aria-hidden="true">“</span>
|
|
<span class="profile-comment-item__quote-text"><?php echo esc_html($snippet); ?></span>
|
|
</a>
|
|
<div class="profile-comment-item__meta">
|
|
<span class="profile-comment-item__meta-item profile-comment-item__meta-item--post">
|
|
<i class="fa fas fa-file-alt" aria-hidden="true"></i>
|
|
<?php esc_html_e('在', 'aksrt'); ?>
|
|
<a href="<?php echo esc_url($post_link); ?>" class="profile-comment-item__post-link"><?php echo esc_html($post_title); ?></a>
|
|
</span>
|
|
<span class="profile-comment-item__meta-sep" aria-hidden="true">·</span>
|
|
<time class="profile-comment-item__meta-item" datetime="<?php echo esc_attr($date_iso); ?>" title="<?php echo esc_attr($date_label); ?>">
|
|
<?php
|
|
/* translators: %s: human time diff */
|
|
printf(esc_html__('%s前', 'aksrt'), esc_html($time_diff));
|
|
?>
|
|
</time>
|
|
</div>
|
|
</article>
|