feat(user-center): add dedicated creator workspace

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
kate522andClaude Fable 5 committed 2026-08-06 17:23:31 +08:00
1 parent c5b7deaa59
commit ceff04ce54
7 files changed
+127 -5

No files matched your search

+4 -3
View File
@@ -108,7 +108,7 @@ if (!function_exists('aksrt_get_user_center_tab_url')) {
}
$url = remove_query_arg([
'tab', 'posts_page', 'comments_page', 'favorites_page', 'credits_page',
'post_status', 'saved', 'profile_error',
'post_status', 'creator_page', 'creator_status', 'saved', 'profile_error',
'order_tab', 'otab', 'order_status', 'order_page', 'order_type', 'section',
], aksrt_get_user_center_url());
@@ -148,6 +148,7 @@ if (!function_exists('aksrt_capture_user_center_view')) {
'level' => 'level',
'profile' => 'form',
'posts' => 'posts',
'creator' => 'creator',
'comments' => 'comments',
'favorites' => 'favorites',
'credits' => 'credits',
@@ -179,7 +180,7 @@ if (!function_exists('aksrt_capture_user_center_panel')) {
* Capture a built-in or registered user-center panel body.
*/
function aksrt_capture_user_center_panel(string $tab_key, array $tab, array $context): string {
$built_in_tabs = ['profile', 'level', 'posts', 'comments', 'favorites', 'credits', 'vip', 'orders', 'auth', 'revenue', 'settings'];
$built_in_tabs = ['profile', 'level', 'posts', 'creator', 'comments', 'favorites', 'credits', 'vip', 'orders', 'auth', 'revenue', 'settings'];
if (in_array($tab_key, $built_in_tabs, true)) {
return aksrt_capture_user_center_view($tab_key, $context);
}
@@ -479,7 +480,7 @@ if (!function_exists('aksrt_get_user_center_render_context')) {
$post_status_filter = 'publish';
}
$user_status_counts = ['publish' => 0, 'draft' => 0, 'pending' => 0, 'private' => 0];
if ('posts' === $active_tab) {
if ('posts' === $active_tab || 'creator' === $active_tab) {
$status = aksrt_user_center_post_status_counts($user_id);
$user_status_counts = $status['counts'];
$post_count = $status['total'];
@@ -0,0 +1,65 @@
<?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>
@@ -7,7 +7,7 @@
defined('ABSPATH') || exit;
$creation_url = isset($dashboard_tabs['posts']) ? aksrt_get_user_center_tab_url('posts') : '';
$creation_url = isset($dashboard_tabs['creator']) ? aksrt_get_user_center_tab_url('creator') : '';
$revenue_url = (string) ($revenue_url ?? '');
if ($creation_url === '' && $revenue_url === '') {