94 lines
3.8 KiB
PHP
94 lines
3.8 KiB
PHP
<?php
|
|
/**
|
|
* Article header author bar.
|
|
*
|
|
* Contract: get_template_part(..., null, $args)
|
|
* show_time bool Relative publish/update time (default true)
|
|
* meta_html string Prebuilt single-metabox HTML
|
|
*
|
|
* @package AKSRT
|
|
*/
|
|
|
|
defined('ABSPATH') || exit;
|
|
|
|
$args = is_array($args ?? null) ? $args : [];
|
|
$show_time = !array_key_exists('show_time', $args) || !empty($args['show_time']);
|
|
$meta_html = (string) ($args['meta_html'] ?? '');
|
|
|
|
$author_id = (int) get_the_author_meta('ID');
|
|
$author_name = get_the_author();
|
|
$author_url = function_exists('aksrt_get_user_home_url') ? aksrt_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 ? __('更新', 'aksrt') : __('发布', 'aksrt');
|
|
$abs_fmt = $use_modified
|
|
? sprintf(__('%s更新', 'aksrt'), get_the_modified_time('Y年m月d日 H:i'))
|
|
: sprintf(__('%s发布', 'aksrt'), get_the_time('Y年m月d日 H:i'));
|
|
$time_text = human_time_diff($rel_base, (int) current_time('timestamp')) . $rel_label;
|
|
$description = function_exists('aksrt_get_user_description')
|
|
? aksrt_get_user_description($author_id)
|
|
: trim((string) get_the_author_meta('description'));
|
|
$name_html = aksrt_get_user_name([
|
|
'id' => $author_id,
|
|
'class' => 'name flex ac flex1',
|
|
'name_class' => '',
|
|
'vip' => true,
|
|
'medal' => true,
|
|
'auth' => true,
|
|
'level' => true,
|
|
'follow' => false,
|
|
]);
|
|
$follow_html = aksrt_get_user_follow('px12-sm ml10 follow but c-red', $author_id);
|
|
$reward_button = get_current_user_id() !== $author_id && function_exists('aksrt_get_rewards_button')
|
|
? aksrt_get_rewards_button($author_id, 'ml6 but c-yellow px12-sm', get_the_ID())
|
|
: '';
|
|
?>
|
|
|
|
<div class="article-avatar">
|
|
<div class="user-info flex ac article-avatar">
|
|
<a href="<?php echo esc_url($author_url); ?>">
|
|
<span class="avatar-img">
|
|
<?php if (function_exists('aksrt_get_avatar_html')) : ?>
|
|
<?php echo aksrt_get_avatar_html($author_id, 42, ['class' => 'avatar avatar-id-' . $author_id]); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
|
|
<?php else : ?>
|
|
<?php echo get_avatar($author_id, 42, '', esc_attr($author_name), ['class' => 'avatar avatar-id-' . $author_id]); ?>
|
|
<?php endif; ?>
|
|
</span>
|
|
</a>
|
|
<div class="user-right flex flex1 ac jsb ml10">
|
|
<div class="flex1">
|
|
<?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>
|
|
<?php elseif ($description !== '') : ?>
|
|
<span class="icon-circle"><?php echo esc_html($description); ?></span>
|
|
<?php endif; ?>
|
|
<?php
|
|
$post_city = function_exists('aksrt_get_post_author_city_badge_html')
|
|
? aksrt_get_post_author_city_badge_html($author_id, 'badg badg-sm')
|
|
: '';
|
|
if ($post_city !== '') {
|
|
echo $post_city; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
|
|
}
|
|
?>
|
|
</div>
|
|
</div>
|
|
<div class="flex0 user-action">
|
|
<?php echo $follow_html; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
|
|
<?php if ($reward_button !== '') : ?>
|
|
<?php echo $reward_button; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
|
|
<?php aksrt_render_rewards_modal_for_user($author_id, get_the_ID()); ?>
|
|
<?php endif; ?>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="single-meta-row">
|
|
<i class="line-form-line" aria-hidden="true"></i>
|
|
<?php echo $meta_html; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
|
|
</div>
|
|
</div>
|