66 lines
4.0 KiB
PHP
66 lines
4.0 KiB
PHP
<?php
|
|
/**
|
|
* User center creator workspace.
|
|
*
|
|
* @package AKSRT
|
|
*/
|
|
|
|
defined('ABSPATH') || exit;
|
|
|
|
$context = is_array($args['context'] ?? null) ? $args['context'] : [];
|
|
extract($context, EXTR_SKIP); // phpcs:ignore WordPress.PHP.DontExtract.extract_extract
|
|
|
|
$can_submit = class_exists('\\AKSRT\\Core\\FrontSubmit')
|
|
&& \AKSRT\Core\FrontSubmit::get_instance()->can_submit((int) $user_id);
|
|
$counts = isset($user_status_counts) && is_array($user_status_counts) ? $user_status_counts : [];
|
|
$total = array_sum(array_map('intval', $counts));
|
|
$creator_filter = isset($_GET['creator_status']) ? sanitize_key(wp_unslash($_GET['creator_status'])) : 'all';
|
|
if (!in_array($creator_filter, ['all', 'publish', 'draft', 'pending', 'private'], true)) {
|
|
$creator_filter = 'all';
|
|
}
|
|
$creator_url = aksrt_get_user_center_tab_url('creator');
|
|
$filters = [
|
|
'all' => __('全部文章', 'aksrt'),
|
|
'publish' => __('已发布', 'aksrt'),
|
|
'draft' => __('草稿', 'aksrt'),
|
|
'pending' => __('待审核', 'aksrt'),
|
|
'private' => __('私密', 'aksrt'),
|
|
];
|
|
?>
|
|
<div class="creator-workspace">
|
|
<header class="creator-workspace__hero">
|
|
<div>
|
|
<p class="creator-workspace__eyebrow"><?php esc_html_e('内容工作台', 'aksrt'); ?></p>
|
|
<h2 class="creator-workspace__title"><?php esc_html_e('创作中心', 'aksrt'); ?></h2>
|
|
<p class="creator-workspace__intro"><?php esc_html_e('管理你的内容,查看发布进度,持续分享有价值的文章。', 'aksrt'); ?></p>
|
|
</div>
|
|
<?php if ($can_submit && !empty($new_post_url)) : ?>
|
|
<a class="creator-workspace__primary btn-primary" href="<?php echo esc_url($new_post_url); ?>">
|
|
<i class="fas fa-plus" aria-hidden="true"></i><?php esc_html_e('写新文章', 'aksrt'); ?>
|
|
</a>
|
|
<?php endif; ?>
|
|
</header>
|
|
|
|
<section class="creator-workspace__stats" aria-label="<?php esc_attr_e('创作数据', 'aksrt'); ?>">
|
|
<div class="creator-stat-card creator-stat-card--total"><span class="creator-stat-card__icon"><i class="fas fa-layer-group" aria-hidden="true"></i></span><span><strong><?php echo esc_html((string) $total); ?></strong><small><?php esc_html_e('全部文章', 'aksrt'); ?></small></span></div>
|
|
<div class="creator-stat-card"><span class="creator-stat-card__icon"><i class="fas fa-check" aria-hidden="true"></i></span><span><strong><?php echo esc_html((string) ($counts['publish'] ?? 0)); ?></strong><small><?php esc_html_e('已发布', 'aksrt'); ?></small></span></div>
|
|
<div class="creator-stat-card"><span class="creator-stat-card__icon"><i class="fas fa-pen" aria-hidden="true"></i></span><span><strong><?php echo esc_html((string) ($counts['draft'] ?? 0)); ?></strong><small><?php esc_html_e('草稿', 'aksrt'); ?></small></span></div>
|
|
<div class="creator-stat-card"><span class="creator-stat-card__icon"><i class="fas fa-clock" aria-hidden="true"></i></span><span><strong><?php echo esc_html((string) ($counts['pending'] ?? 0)); ?></strong><small><?php esc_html_e('待审核', 'aksrt'); ?></small></span></div>
|
|
</section>
|
|
|
|
<section class="creator-workspace__panel widget-card">
|
|
<div class="creator-workspace__toolbar">
|
|
<div><h3><?php esc_html_e('内容管理', 'aksrt'); ?></h3><p><?php esc_html_e('按状态查看并管理你的文章', 'aksrt'); ?></p></div>
|
|
<nav class="creator-workspace__filters" aria-label="<?php esc_attr_e('文章筛选', 'aksrt'); ?>">
|
|
<?php foreach ($filters as $key => $label) : $url = add_query_arg(['tab' => 'creator', 'creator_status' => $key], remove_query_arg(['creator_page'])); ?>
|
|
<a class="creator-filter<?php echo $creator_filter === $key ? ' is-active' : ''; ?>" href="<?php echo esc_url($url); ?>" aria-current="<?php echo $creator_filter === $key ? 'page' : 'false'; ?>"><?php echo esc_html($label); ?> <b><?php echo esc_html((string) ('all' === $key ? $total : ($counts[$key] ?? 0))); ?></b></a>
|
|
<?php endforeach; ?>
|
|
</nav>
|
|
</div>
|
|
<?php
|
|
$creator_args = ['status' => $creator_filter];
|
|
get_template_part('templates/parts/user-center/creator-posts', null, ['context' => $context, 'creator_args' => $creator_args]);
|
|
?>
|
|
</section>
|
|
</div>
|