fix(users): keep management inside center

This commit is contained in:
kate522 committed 2026-08-12 20:59:31 +08:00
1 parent c3bfd12c69
commit ce2b266890
44 files changed
+194 -2584

No files matched your search

@@ -57,7 +57,12 @@ if ($q->have_posts()) :
?>
</div>
<?php
aksrt_render_profile_pagination((int) $q->max_num_pages, $posts_page, 'posts_page');
aksrt_render_profile_pagination(
(int) $q->max_num_pages,
$posts_page,
'posts_page',
add_query_arg('post_status', $post_status_filter, aksrt_get_user_center_tab_url('posts'))
);
wp_reset_postdata();
else :
aksrt_render_profile_empty(
@@ -26,10 +26,9 @@ $status_chip_defs = [
continue;
}
$chip_url = add_query_arg([
'tab' => 'posts',
'post_status' => $status_key,
'posts_page' => 1,
], remove_query_arg(['posts_page']));
], aksrt_get_user_center_tab_url('posts'));
$chip_active = ($post_status_filter === $status_key);
?>
<a href="<?php echo esc_url($chip_url); ?>" class="profile-status-chip<?php echo $chip_active ? ' is-active' : ''; ?>" role="tab" aria-selected="<?php echo $chip_active ? 'true' : 'false'; ?>">
@@ -44,10 +44,7 @@ if ($show_credits) {
// Tabbed ledgers (Zibll record tabs).
if ($show_wallet || $show_credits) :
$active_record = isset($_GET['asset_tab']) ? sanitize_key(wp_unslash($_GET['asset_tab'])) : '';
if ($active_record === '' || !in_array($active_record, ['balance', 'points', 'points_free', 'points_date'], true)) {
$active_record = $show_wallet ? 'balance' : 'points';
}
$active_record = $show_wallet ? 'balance' : 'points';
$show_tasks = $show_credits && class_exists('\AKSRT\Credits\PointsFree') && \AKSRT\Credits\PointsFree::enabled();
?>
<div class="uc-asset-tabs">
@@ -0,0 +1,67 @@
<?php
/**
* Private follow management panel.
*
* @package AKSRT
*/
defined('ABSPATH') || exit;
$context = is_array($args['context'] ?? null) ? $args['context'] : [];
extract($context, EXTR_SKIP); // phpcs:ignore WordPress.PHP.DontExtract.extract_extract
$follow = class_exists('\\AKSRT\\User\\Follow') ? \AKSRT\User\Follow::get_instance() : null;
$active_list = isset($_GET['follow_list']) ? sanitize_key(wp_unslash($_GET['follow_list'])) : 'followers';
if (!in_array($active_list, ['followers', 'following'], true)) {
$active_list = 'followers';
}
$page = max(1, isset($_GET['follow_page']) ? (int) $_GET['follow_page'] : 1);
$result = $follow
? ($active_list === 'following' ? $follow->get_following((int) $user_id, $page, 20) : $follow->get_followers((int) $user_id, $page, 20))
: ['items' => [], 'total_pages' => 1];
$messages_enabled = !empty($messages_url);
?>
<div class="widget-card uc-follow-management">
<div class="profile-list-header">
<div>
<h2 class="widget-title widget-title--inline"><?php esc_html_e('粉丝与关注', 'aksrt'); ?></h2>
<p class="muted-2-color em09"><?php esc_html_e('查看谁关注了你,并管理你关注的作者。', 'aksrt'); ?></p>
</div>
</div>
<div class="profile-status-filter" role="tablist" aria-label="<?php esc_attr_e('关注关系筛选', 'aksrt'); ?>">
<?php foreach (['followers' => __('粉丝', 'aksrt'), 'following' => __('我关注的', 'aksrt')] as $key => $label) :
$url = add_query_arg(['follow_list' => $key, 'follow_page' => 1], aksrt_get_user_center_tab_url('follow'));
?>
<a class="profile-status-chip<?php echo $active_list === $key ? ' is-active' : ''; ?>" href="<?php echo esc_url($url); ?>" data-tab="follow" role="tab" aria-selected="<?php echo $active_list === $key ? 'true' : 'false'; ?>">
<?php echo esc_html($label); ?> <span class="profile-status-chip__count"><?php echo esc_html(number_format_i18n((int) ($key === 'followers' ? $follower_count : $following_count))); ?></span>
</a>
<?php endforeach; ?>
</div>
<?php if (!empty($result['items'])) : ?>
<div class="uc-follow-management__list">
<?php foreach ($result['items'] as $item) :
$member_id = (int) ($item['user_id'] ?? 0);
$home_url = function_exists('aksrt_get_user_home_url') ? aksrt_get_user_home_url($member_id) : '';
$message_url = $messages_enabled ? add_query_arg('msg_type', 'conversation', $messages_url) : '';
?>
<div class="uc-follow-management__item" data-follow-user="<?php echo esc_attr((string) $member_id); ?>">
<a href="<?php echo esc_url($home_url); ?>" class="uc-follow-management__avatar"><?php echo get_avatar($member_id, 48, '', (string) ($item['display_name'] ?? '')); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?></a>
<div class="uc-follow-management__identity"><a href="<?php echo esc_url($home_url); ?>"><?php echo esc_html((string) ($item['display_name'] ?? '')); ?></a><span><?php echo esc_html(sprintf(__('关注于 %s', 'aksrt'), get_date_from_gmt((string) ($item['created_at'] ?? ''), get_option('date_format')))); ?></span></div>
<div class="uc-follow-management__actions">
<a class="btn-ghost btn-sm" href="<?php echo esc_url($home_url); ?>"><?php esc_html_e('主页', 'aksrt'); ?></a>
<?php if ($messages_enabled) : ?><a class="btn-ghost btn-sm" href="<?php echo esc_url($message_url); ?>"><?php esc_html_e('私信', 'aksrt'); ?></a><?php endif; ?>
<?php if ($active_list === 'following') : ?><button type="button" class="btn-outline btn-sm is-following" data-aksrt-follow="<?php echo esc_attr((string) $member_id); ?>"><i class="fas fa-heart" aria-hidden="true"></i><span><?php esc_html_e('已关注', 'aksrt'); ?></span></button><?php endif; ?>
</div>
</div>
<?php endforeach; ?>
</div>
<?php aksrt_render_profile_pagination(
(int) ($result['total_pages'] ?? 1),
$page,
'follow_page',
add_query_arg('follow_list', $active_list, aksrt_get_user_center_tab_url('follow'))
); ?>
<?php else : ?>
<?php aksrt_render_profile_empty('<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5"><path d="M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2"/><circle cx="9" cy="7" r="4"/><path d="M22 21v-2a4 4 0 0 0-3-3.87M16 3.13a4 4 0 0 1 0 7.75"/></svg>', $active_list === 'followers' ? __('还没有粉丝', 'aksrt') : __('还没有关注任何作者', 'aksrt')); ?>
<?php endif; ?>
</div>
@@ -28,7 +28,7 @@ $points = (float) ($credit_balance ?? 0);
</a>
<?php endif; ?>
<?php if ($show_credits) : ?>
<a class="uc-summary-card uc-summary-card--points" href="<?php echo esc_url(add_query_arg('asset_tab', 'points', $assets_url)); ?>" data-tab="credits">
<a class="uc-summary-card uc-summary-card--points" href="<?php echo esc_url($assets_url); ?>" data-tab="credits">
<span class="uc-summary-card__head"><?php echo esc_html((string) ($currency_name ?? __('积分', 'aksrt'))); ?><i class="fas fa-angle-right" aria-hidden="true"></i></span>
<span class="uc-summary-card__body">
<strong><?php echo esc_html(function_exists('aksrt_format_credits') ? aksrt_format_credits((int) $points) : number_format_i18n((int) $points)); ?></strong>
@@ -7,13 +7,12 @@
defined('ABSPATH') || exit;
$public_home_url = function_exists('aksrt_get_user_home_url') ? aksrt_get_user_home_url($target_user ?? null) : '';
$stats = [
[
'label' => __('文章', 'aksrt'),
'value' => (int) ($post_count ?? 0),
'url' => isset($dashboard_tabs['posts']) ? aksrt_get_user_center_tab_url('posts') : $public_home_url,
'tab' => isset($dashboard_tabs['posts']) ? 'posts' : '',
'url' => aksrt_get_user_center_tab_url('posts'),
'tab' => 'posts',
],
[
'label' => __('评论', 'aksrt'),
@@ -30,7 +29,8 @@ $stats = [
[
'label' => __('粉丝', 'aksrt'),
'value' => (int) ($follower_count ?? 0),
'url' => $public_home_url !== '' ? add_query_arg(['tab' => 'follow', 'follow_sub' => 'followers'], $public_home_url) : '',
'url' => aksrt_get_user_center_tab_url('follow'),
'tab' => 'follow',
],
];
?>