feat(user-center): upgrade posts panel to creator center

This commit is contained in:
kate522 committed 2026-08-06 16:24:59 +08:00
1 parent 7891ce7096
commit 2f9384f368
7 files changed
+123 -36

No files matched your search

+1
View File
@@ -344,6 +344,7 @@ if (!function_exists('aksrt_user_center_runtime_config')) {
'userId' => $user_id,
'restUrl' => rest_url('aksrt/v1'),
'restNonce' => wp_create_nonce('wp_rest'),
'submitNonce' => wp_create_nonce('aksrt_submit'),
'defaultTab' => $default_tab,
'activeTab' => $active_tab,
'tabAliases' => [
@@ -21,27 +21,37 @@ $ps_args = [
'update_post_term_cache' => true,
];
$q = new WP_Query($ps_args);
$front_submit = class_exists('\\AKSRT\\Core\\FrontSubmit') ? \AKSRT\Core\FrontSubmit::get_instance() : null;
if ($q->have_posts()) :
?>
<div class="profile-list">
<div class="profile-list creator-center-post-list">
<?php
while ($q->have_posts()) :
$q->the_post();
$st = get_post_status();
$status_label = '';
if ('publish' !== $st) {
$st_map = [
'draft' => __('草稿', 'aksrt'),
'pending' => __('待审', 'aksrt'),
'private' => __('私密', 'aksrt'),
'future' => __('定时', 'aksrt'),
];
$status_label = $st_map[$st] ?? $st;
}
$edit_link = get_edit_post_link();
$status_map = [
'publish' => __('已发布', 'aksrt'),
'draft' => __('草稿', 'aksrt'),
'pending' => __('待审', 'aksrt'),
'private' => __('私密', 'aksrt'),
'future' => __('定时', 'aksrt'),
];
$status_label = $status_map[$st] ?? $st;
$can_delete = $front_submit && $front_submit->can_delete_post(get_the_ID(), (int) $user_id);
$edit_link = $front_submit && $front_submit->can_edit_post(get_the_ID(), (int) $user_id)
? aksrt_get_new_post_url(get_the_ID())
: '';
$view_link = get_permalink();
$action = $edit_link
? ['type' => 'edit', 'url' => $edit_link, 'label' => __('编辑', 'aksrt')]
: ('publish' === $st && $view_link ? ['type' => 'view', 'url' => $view_link, 'label' => __('预览', 'aksrt')] : []);
get_template_part('templates/parts/content', 'profile-list-item', [
'action' => $edit_link ? ['type' => 'edit', 'url' => $edit_link, 'label' => __('编辑', 'aksrt')] : [],
'status' => $status_label,
'action' => $action,
'status' => $status_label,
'delete_action' => [
'enabled' => $can_delete,
'nonce' => wp_create_nonce('aksrt_submit'),
],
]);
endwhile;
?>
@@ -54,7 +64,7 @@ else :
$svg_empty_post,
__('还没有文章', 'aksrt'),
__('试试发布你的第一篇文章吧。', 'aksrt'),
admin_url('post-new.php'),
!empty($new_post_url) ? $new_post_url : '',
__('写文章', 'aksrt')
);
endif;
@@ -9,16 +9,29 @@ defined('ABSPATH') || exit;
$context = is_array($args['context'] ?? null) ? $args['context'] : [];
extract($context, EXTR_SKIP); // phpcs:ignore WordPress.PHP.DontExtract.extract_extract
$can_submit_posts = class_exists('\\AKSRT\\Core\\FrontSubmit')
&& \AKSRT\Core\FrontSubmit::get_instance()->can_submit((int) $user_id);
?>
<div class="widget-card">
<div class="profile-list-header">
<h3 class="widget-title widget-title--inline">
<?php
/* translators: %d: post count */
printf(esc_html__('我的文章(%d 篇)', 'aksrt'), $post_count);
?>
</h3>
<?php require __DIR__ . '/posts-status-filter.php'; ?>
<div class="profile-list-header creator-center-header">
<div class="creator-center-heading">
<h2 class="widget-title widget-title--inline"><?php esc_html_e('创作中心', 'aksrt'); ?></h2>
<p class="creator-center-heading__summary">
<?php
/* translators: %d: total post count */
printf(esc_html__('管理你的文章、草稿和审核状态(共 %d 篇)', 'aksrt'), $post_count);
?>
</p>
</div>
<div class="creator-center-actions">
<?php if (!empty($new_post_url) && $can_submit_posts) : ?>
<a class="btn-primary btn-sm" href="<?php echo esc_url($new_post_url); ?>">
<span aria-hidden="true">+</span>
<?php esc_html_e('新建文章', 'aksrt'); ?>
</a>
<?php endif; ?>
<?php require __DIR__ . '/posts-status-filter.php'; ?>
</div>
</div>
<?php require __DIR__ . '/posts-list.php'; ?>
</div>