fix(user-center): close creator income review gaps

This commit is contained in:
2026-08-07 13:16:10 +08:00
parent c16add0807
commit cfb0a1368c
6 changed files with 56 additions and 62 deletions
+2 -44
View File
@@ -147,7 +147,6 @@ if (!function_exists('aksrt_capture_user_center_view')) {
$map = [
'level' => 'level',
'profile' => 'form',
'posts' => 'posts',
'creator' => 'creator',
'comments' => 'comments',
'favorites' => 'favorites',
@@ -180,7 +179,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', 'creator', 'comments', 'favorites', 'credits', 'vip', 'orders', 'auth', 'revenue', 'settings'];
$built_in_tabs = ['profile', 'level', '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);
}
@@ -274,7 +273,6 @@ if (!function_exists('aksrt_user_center_resolve_tabs')) {
? \AKSRT\User\Center::get_instance()->get_dashboard_tabs()
: [
'profile' => ['label' => __('个人信息', 'aksrt'), 'icon' => 'user'],
'posts' => ['label' => __('我的文章', 'aksrt'), 'icon' => 'file-alt'],
'comments' => ['label' => __('我的评论', 'aksrt'), 'icon' => 'comment'],
'favorites' => ['label' => __('我的收藏', 'aksrt'), 'icon' => 'star'],
'settings' => ['label' => __('账号设置', 'aksrt'), 'icon' => 'cog'],
@@ -310,29 +308,6 @@ if (!function_exists('aksrt_user_center_resolve_tabs')) {
}
}
if (!function_exists('aksrt_user_center_post_status_counts')) {
/**
* Count the current user's posts by status (posts tab only).
*
* @return array{counts:array<string,int>,total:int}
*/
function aksrt_user_center_post_status_counts(int $user_id): array {
global $wpdb;
$counts = ['publish' => 0, 'draft' => 0, 'pending' => 0, 'private' => 0];
$rows = $wpdb->get_results($wpdb->prepare(
"SELECT post_status, COUNT(*) AS num FROM {$wpdb->posts} WHERE post_author = %d AND post_type = 'post' AND post_status IN ('publish','draft','pending','private') GROUP BY post_status",
$user_id
));
foreach ((array) $rows as $row) {
$counts[$row->post_status] = (int) $row->num;
}
return [
'counts' => $counts,
'total' => (int) array_sum($counts),
];
}
}
if (!function_exists('aksrt_user_center_runtime_config')) {
/**
* Frontend runtime config injected into the private user center page.
@@ -444,7 +419,7 @@ if (!function_exists('aksrt_get_user_center_render_context')) {
$user_center_settings = class_exists('\AKSRT\Settings\Settings')
? \AKSRT\Settings\Settings::get_user_center_settings()
: [
'tabs' => ['profile', 'posts', 'comments', 'favorites'],
'tabs' => ['profile', 'comments', 'favorites'],
'avatar_upload' => true,
'cover_upload' => true,
'social_links' => true,
@@ -475,17 +450,6 @@ if (!function_exists('aksrt_get_user_center_render_context')) {
? \AKSRT\User\Follow::get_instance()->get_follower_count($user_id)
: 0;
$post_status_filter = isset($_GET['post_status']) ? sanitize_key(wp_unslash($_GET['post_status'])) : 'publish';
if (!in_array($post_status_filter, ['all', 'publish', 'draft', 'pending', 'private'], true)) {
$post_status_filter = 'publish';
}
$user_status_counts = ['publish' => 0, 'draft' => 0, 'pending' => 0, 'private' => 0];
if ('posts' === $active_tab) {
$status = aksrt_user_center_post_status_counts($user_id);
$user_status_counts = $status['counts'];
$post_count = $status['total'];
}
$svgs = aksrt_user_center_empty_svgs();
require_once AKSRT_DIR . '/templates/parts/user-shared-helpers.php';
@@ -499,7 +463,6 @@ if (!function_exists('aksrt_get_user_center_render_context')) {
$runtime_config['avatarUpload'] = aksrt_user_center_avatar_upload_config($allow_avatar_upload);
$revenue_settings = class_exists('\AKSRT\Settings\Settings') ? \AKSRT\Settings\Settings::get_payment_revenue_settings() : [];
$show_revenue_section = !empty($revenue_settings['enabled']) || !empty($affiliate_settings['enabled']);
$new_post_url = function_exists('aksrt_get_new_post_url') ? aksrt_get_new_post_url() : '';
$revenue_url = isset($tabs['tabs']['revenue'])
? aksrt_get_user_center_tab_url('revenue')
: '';
@@ -525,15 +488,10 @@ if (!function_exists('aksrt_get_user_center_render_context')) {
'show_avatar_edit' => $allow_avatar_upload,
'notification_unread_count' => function_exists('aksrt_get_user_unread_notification_count') ? aksrt_get_user_unread_notification_count($user_id) : 0,
'messages_url' => $messages_enabled && function_exists('aksrt_get_messages_page_url') ? aksrt_get_messages_page_url() : '',
'new_post_url' => $new_post_url,
'revenue_url' => $revenue_url,
'per_page' => 10,
'posts_page' => max(1, isset($_GET['posts_page']) ? (int) $_GET['posts_page'] : 1),
'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),
'post_status_filter' => $post_status_filter,
'user_status_counts' => $user_status_counts,
'svg_empty_post' => $svgs['post'],
'svg_empty_comment' => $svgs['comment'],
'svg_empty_favorite' => $svgs['favorite'],
'orders_url' => function_exists('aksrt_get_user_center_tab_url')