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

-7
View File
@@ -13,13 +13,6 @@ add_action('wp_head', static function () {
add_filter('show_admin_bar', '__return_false');
// ============================================================
// WordPress 链接管理(网址导航 / 书签)
// zibll enables link_manager; AKSRT keeps it for page-links.
// ============================================================
add_filter('pre_option_link_manager_enabled', '__return_true');
// ============================================================
// SMTP 邮件配置注入
// ============================================================
+30 -4
View File
@@ -142,6 +142,8 @@ if (!function_exists('aksrt_capture_user_center_view')) {
'level' => 'level',
'profile' => 'form',
'creator' => 'creator',
'posts' => 'posts',
'follow' => 'follow',
'comments' => 'comments',
'favorites' => 'favorites',
'credits' => 'credits',
@@ -173,7 +175,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', 'creator', 'comments', 'favorites', 'credits', 'vip', 'orders', 'auth', 'revenue', 'settings'];
$built_in_tabs = ['profile', 'level', 'creator', 'posts', 'follow', '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);
}
@@ -446,6 +448,26 @@ if (!function_exists('aksrt_get_user_center_render_context')) {
$follower_count = class_exists('\AKSRT\User\Follow')
? \AKSRT\User\Follow::get_instance()->get_follower_count($user_id)
: 0;
$following_count = class_exists('\AKSRT\User\Follow')
? \AKSRT\User\Follow::get_instance()->get_following_count($user_id)
: 0;
$allowed_post_statuses = ['publish', 'draft', 'pending', 'private'];
$post_status_filter = isset($_GET['post_status']) ? sanitize_key(wp_unslash($_GET['post_status'])) : 'publish';
if (!in_array($post_status_filter, array_merge($allowed_post_statuses, ['all']), true)) {
$post_status_filter = 'publish';
}
$user_status_counts = [];
foreach ($allowed_post_statuses as $status) {
$status_query = new WP_Query([
'author' => $user_id,
'post_type' => 'post',
'post_status' => $status,
'posts_per_page' => 1,
'fields' => 'ids',
'no_found_rows' => false,
]);
$user_status_counts[$status] = (int) $status_query->found_posts;
}
$svgs = aksrt_user_center_empty_svgs();
require_once AKSRT_DIR . '/templates/parts/user-shared-helpers.php';
@@ -478,6 +500,7 @@ if (!function_exists('aksrt_get_user_center_render_context')) {
'favorite_post_ids' => $favorite_post_ids,
'favorite_count' => $favorite_count,
'follower_count' => $follower_count,
'following_count' => $following_count,
'user_contacts' => $user_contacts,
'profile_signals' => $dashboard['profile_signals'] ?? [],
'user_background_url' => $user_background_url,
@@ -487,13 +510,16 @@ if (!function_exists('aksrt_get_user_center_render_context')) {
'messages_url' => $messages_enabled && function_exists('aksrt_get_messages_page_url') ? aksrt_get_messages_page_url() : '',
'revenue_url' => $revenue_url,
'per_page' => 10,
'posts_page' => max(1, isset($_GET['posts_page']) ? (int) $_GET['posts_page'] : 1),
'post_status_filter' => $post_status_filter,
'user_status_counts' => $user_status_counts,
'new_post_url' => function_exists('aksrt_get_new_post_url') ? aksrt_get_new_post_url() : '',
'svg_empty_post' => $svgs['post'],
'comments_page' => max(1, isset($_GET['comments_page']) ? (int) $_GET['comments_page'] : 1),
'favorites_page' => max(1, isset($_GET['favorites_page']) ? (int) $_GET['favorites_page'] : 1),
'svg_empty_comment' => $svgs['comment'],
'svg_empty_favorite' => $svgs['favorite'],
'orders_url' => function_exists('aksrt_get_user_center_tab_url')
? aksrt_get_user_center_tab_url('orders')
: (function_exists('aksrt_get_orders_page_url') ? aksrt_get_orders_page_url() : ''),
'orders_url' => isset($tabs['tabs']['orders']) ? aksrt_get_user_center_tab_url('orders') : '',
'show_vip' => !empty($vip_settings['enabled']),
'show_credit_tabs' => $show_credit_tabs,
'affiliate_enabled' => $show_credit_tabs && !empty($affiliate_settings['enabled']),
+1 -1
View File
@@ -99,7 +99,7 @@ if (!function_exists('aksrt_get_header_nav_context')) :
? (int) aksrt_get_user_unread_notification_count($user_id)
: 0,
'messages_url' => function_exists('aksrt_get_messages_page_url') ? aksrt_get_messages_page_url() : '',
'orders_url' => function_exists('aksrt_get_orders_page_url') ? aksrt_get_orders_page_url() : '',
'orders_url' => function_exists('aksrt_get_user_center_tab_url') ? aksrt_get_user_center_tab_url('orders') : '',
'publish_url' => function_exists('aksrt_get_new_post_url') ? aksrt_get_new_post_url() : admin_url('post-new.php'),
'theme_settings_url' => function_exists('aksrt_get_admin_settings_url')
? aksrt_get_admin_settings_url('')
@@ -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',
],
];
?>
+1 -8
View File
@@ -16,8 +16,6 @@ add_filter('query_vars', function ($vars) {
$vars[] = 'aksrt_user_center';
$vars[] = 'aksrt_user_center_tab';
$vars[] = 'aksrt_author_identifier';
$vars[] = 'aksrt_orders';
$vars[] = 'aksrt_revenue';
return $vars;
});
@@ -57,7 +55,7 @@ add_action('template_redirect', function () {
$tab = $tab === 'balance' ? 'credits' : sanitize_key($tab);
$allowed = class_exists('\\AKSRT\\User\\Center')
? array_keys(\AKSRT\User\Center::get_instance()->get_dashboard_tabs())
: ['profile', 'level', 'creator', 'comments', 'favorites', 'credits', 'vip', 'orders', 'auth', 'revenue', 'settings'];
: ['profile', 'level', 'creator', 'posts', 'follow', 'comments', 'favorites', 'credits', 'vip', 'orders', 'auth', 'revenue', 'settings'];
if (!in_array($tab, $allowed, true)) {
global $wp_query;
if ($wp_query instanceof WP_Query) { $wp_query->set_404(); }
@@ -70,13 +68,8 @@ add_action('init', function () {
add_rewrite_tag('%aksrt_user_center%', '([^&]+)');
add_rewrite_tag('%aksrt_user_center_tab%', '([^/]+)');
add_rewrite_tag('%aksrt_author_identifier%', '([^/]+)');
add_rewrite_tag('%aksrt_orders%', '([0-1])');
add_rewrite_tag('%aksrt_revenue%', '([0-1])');
add_rewrite_rule('^user/([a-z0-9_-]+)/?$', 'index.php?aksrt_user_center=1&aksrt_user_center_tab=$matches[1]', 'top');
add_rewrite_rule('^author/([^/]+)/?$', 'index.php?aksrt_author_identifier=$matches[1]', 'top');
// Commerce center aliases (work even before WP page is assigned).
add_rewrite_rule('^orders/?$', 'index.php?aksrt_orders=1', 'top');
add_rewrite_rule('^revenue/?$', 'index.php?aksrt_revenue=1', 'top');
});
// --- 3b. 统一模板拦截器(核心)---
@@ -106,19 +106,6 @@ $_aksrt_special_templates = [
'title' => '个人中心',
'fallback' => '/profile/',
],
// Commerce center pages (权益与消费 / 购物车 / 收益)
'orders' => [
'file' => 'templates/pages/page-orders.php',
'slug' => 'orders',
'title' => '我的订单',
'fallback' => '/orders/',
],
'revenue' => [
'file' => 'templates/pages/page-revenue.php',
'slug' => 'revenue',
'title' => '收益中心',
'fallback' => '/revenue/',
],
'messages' => [
'file' => 'templates/pages/page-messages.php',
'slug' => 'messages',
@@ -402,16 +389,6 @@ function aksrt_get_current_special_template_path(): string {
return $profile_template ?: '';
}
if (get_query_var('aksrt_orders')) {
$orders_template = aksrt_locate_template_file('templates/pages/page-orders.php');
return $orders_template ?: '';
}
if (get_query_var('aksrt_revenue')) {
$revenue_template = aksrt_locate_template_file('templates/pages/page-revenue.php');
return $revenue_template ?: '';
}
if (get_query_var('aksrt_sign')) {
$auth_template = aksrt_get_auth_template_file((string) get_query_var('aksrt_auth_tab'), true);
$auth_template_path = aksrt_locate_template_file($auth_template);
-31
View File
@@ -54,37 +54,6 @@ function aksrt_get_new_post_url(int $edit_id = 0): string {
}
endif;
if (!function_exists('aksrt_get_orders_page_url')) :
/**
* 订单中心 URL — 嵌在用户中心 tab=orders(zibll 同构)。
* 旧 /orders/ 页面模板会 302 到此地址。
*/
function aksrt_get_orders_page_url(): string {
if (function_exists('aksrt_get_user_center_tab_url')) {
return aksrt_get_user_center_tab_url('orders');
}
if (function_exists('aksrt_get_user_center_url')) {
return aksrt_get_user_center_url('orders');
}
return home_url('/user/orders/');
}
endif;
if (!function_exists('aksrt_get_revenue_page_url')) :
/**
* 收益中心 URL — 嵌在用户中心 tab=revenue。
*/
function aksrt_get_revenue_page_url(): string {
if (function_exists('aksrt_get_user_center_tab_url')) {
return aksrt_get_user_center_tab_url('revenue');
}
if (function_exists('aksrt_get_user_center_url')) {
return aksrt_get_user_center_url('revenue');
}
return home_url('/user/revenue/');
}
endif;
if (!function_exists('aksrt_get_messages_page_url')) :
/**
* 消息中心页面 URL(模板 templates/pages/page-messages.php)。