119 lines
3.8 KiB
PHP
119 lines
3.8 KiB
PHP
<?php
|
|
/**
|
|
* Author Archive Template — 作者归档页
|
|
*
|
|
* 渲染 /author/{nicename}/ 的完整作者归档页面:
|
|
* - 作者 Hero 区(头图、头像、身份、统计、操作按钮)
|
|
* - 作者文章列表(WordPress 主循环)
|
|
* - 可扩展挂载点:aksrt_author_before_content / aksrt_author_after_content
|
|
*
|
|
* 数据聚合复用 aksrt_get_user_dashboard_view(),与 page-user-home.php 同源。
|
|
*
|
|
* @package AKSRT
|
|
*/
|
|
|
|
defined('ABSPATH') || exit;
|
|
|
|
global $wp_query;
|
|
|
|
$author_id = (int) get_query_var('author');
|
|
$author = $author_id ? get_userdata($author_id) : null;
|
|
|
|
if (!$author || is_wp_error($author)) {
|
|
wp_safe_redirect(home_url('/'));
|
|
exit;
|
|
}
|
|
|
|
get_header();
|
|
|
|
$user_id = (int) $author->ID;
|
|
$dashboard = function_exists('aksrt_get_user_dashboard_view')
|
|
? aksrt_get_user_dashboard_view($user_id, ['viewer_id' => get_current_user_id()])
|
|
: [];
|
|
|
|
$user_home_settings = class_exists('AKSRT_Settings')
|
|
? AKSRT_Settings::get_user_home_settings()
|
|
: [
|
|
'tabs' => ['posts', 'comments', 'favorites'],
|
|
'sidebar' => true,
|
|
'cover' => true,
|
|
'follow' => true,
|
|
'posts_per_page' => 10,
|
|
];
|
|
|
|
require_once AKSRT_DIR . '/templates/parts/user-shared-helpers.php';
|
|
?>
|
|
|
|
<main id="main-content" class="site-main container aksrt-author-page" tabindex="-1">
|
|
<div class="content-wrap">
|
|
<div class="content-layout aksrt-author-page__layout">
|
|
<div class="content-layout__primary">
|
|
|
|
<?php
|
|
$user = $author;
|
|
$is_author_page = true;
|
|
set_query_var('user', $user);
|
|
set_query_var('dashboard', $dashboard);
|
|
set_query_var('user_home_settings', $user_home_settings);
|
|
set_query_var('is_author_page', true);
|
|
get_template_part('templates/parts/user/author-hero');
|
|
?>
|
|
|
|
<?php do_action('aksrt_author_before_content', $user_id); ?>
|
|
|
|
<div class="aksrt-author-page__content aksrt-theme-box">
|
|
<div class="aksrt-author-page__content-header">
|
|
<h2 class="aksrt-author-page__section-title">
|
|
<i class="fas fa-file-alt" aria-hidden="true"></i>
|
|
<?php esc_html_e('发布的文章', 'aksrt'); ?>
|
|
</h2>
|
|
</div>
|
|
|
|
<?php if (have_posts()) : ?>
|
|
<div class="aksrt-author-page__posts">
|
|
<?php while (have_posts()) : the_post(); ?>
|
|
<?php get_template_part('templates/parts/content', 'profile-list-item'); ?>
|
|
<?php endwhile; ?>
|
|
</div>
|
|
|
|
<?php
|
|
$total_pages = (int) $wp_query->max_num_pages;
|
|
$current_page = max(1, (int) get_query_var('paged'));
|
|
if ($total_pages > 1) :
|
|
?>
|
|
<div class="aksrt-author-page__pagination">
|
|
<?php
|
|
echo paginate_links([
|
|
'total' => $total_pages,
|
|
'current' => $current_page,
|
|
'mid_size' => 2,
|
|
'prev_text' => '<i class="fas fa-chevron-left"></i>',
|
|
'next_text' => '<i class="fas fa-chevron-right"></i>',
|
|
]);
|
|
?>
|
|
</div>
|
|
<?php endif; ?>
|
|
|
|
<?php else : ?>
|
|
<div class="aksrt-author-page__empty">
|
|
<div class="aksrt-author-page__empty-icon">
|
|
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" width="30" height="30"><path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"/><path d="M14 2v6h6"/><path d="M9 13h6M9 17h6M9 9h1"/></svg>
|
|
</div>
|
|
<p class="aksrt-author-page__empty-title"><?php esc_html_e('暂无文章', 'aksrt'); ?></p>
|
|
<p class="aksrt-author-page__empty-desc"><?php echo esc_html(sprintf(__('%s 还没有发布任何文章。', 'aksrt'), $author->display_name)); ?></p>
|
|
</div>
|
|
<?php endif; ?>
|
|
</div>
|
|
|
|
<?php do_action('aksrt_author_after_content', $user_id); ?>
|
|
</div>
|
|
|
|
<?php if (!empty($user_home_settings['sidebar'])) : ?>
|
|
<?php get_sidebar(); ?>
|
|
<?php endif; ?>
|
|
</div>
|
|
</div>
|
|
</main>
|
|
|
|
<?php get_footer(); ?>
|