用户中心减层:收敛本人入口与 panel 契约
This commit is contained in:
1 parent
dec33ea15a
commit
15642db1a2
3 files changed
+62
-68
No files matched your search
@@ -14,7 +14,10 @@ defined('ABSPATH') || exit;
|
||||
* Get aggregated dashboard view data for a user.
|
||||
*
|
||||
* @param int $user_id Target user ID.
|
||||
* @param array $args Optional. 'viewer_id' => current viewer ID.
|
||||
* @param array $args Optional. Supported keys:
|
||||
* - viewer_id: Current viewer ID.
|
||||
* - include_recent_posts: Whether to query recent posts.
|
||||
* - include_governance: Whether to resolve notice/report data.
|
||||
* @return array {
|
||||
* @type int $post_count Published post count.
|
||||
* @type int $comment_count Approved comment count.
|
||||
@@ -31,8 +34,10 @@ defined('ABSPATH') || exit;
|
||||
* }
|
||||
*/
|
||||
function aksrt_get_user_dashboard_view(int $user_id, array $args = []): array {
|
||||
$viewer_id = (int) ($args['viewer_id'] ?? get_current_user_id());
|
||||
$is_own_profile = is_user_logged_in() && $viewer_id === $user_id;
|
||||
$viewer_id = (int) ($args['viewer_id'] ?? get_current_user_id());
|
||||
$include_recent_posts = !array_key_exists('include_recent_posts', $args) || (bool) $args['include_recent_posts'];
|
||||
$include_governance = !array_key_exists('include_governance', $args) || (bool) $args['include_governance'];
|
||||
$is_own_profile = is_user_logged_in() && $viewer_id === $user_id;
|
||||
|
||||
$post_count = (int) count_user_posts($user_id, 'post', true);
|
||||
$comment_count = (int) get_comments([
|
||||
@@ -45,15 +50,17 @@ function aksrt_get_user_dashboard_view(int $user_id, array $args = []): array {
|
||||
? aksrt_get_user_interaction_posts('_aksrt_favorite_posts', $user_id)
|
||||
: [];
|
||||
$favorite_count = count($favorite_post_ids);
|
||||
$recent_posts = get_posts([
|
||||
'author' => $user_id,
|
||||
'post_type' => 'post',
|
||||
'post_status' => 'publish',
|
||||
'posts_per_page' => 5,
|
||||
'orderby' => 'date',
|
||||
'order' => 'DESC',
|
||||
'no_found_rows' => true,
|
||||
]);
|
||||
$recent_posts = $include_recent_posts
|
||||
? get_posts([
|
||||
'author' => $user_id,
|
||||
'post_type' => 'post',
|
||||
'post_status' => 'publish',
|
||||
'posts_per_page' => 5,
|
||||
'orderby' => 'date',
|
||||
'order' => 'DESC',
|
||||
'no_found_rows' => true,
|
||||
])
|
||||
: [];
|
||||
|
||||
$user_contacts = get_user_meta($user_id, 'aksrt_user_contacts', true) ?: [];
|
||||
if (!is_array($user_contacts)) {
|
||||
@@ -74,7 +81,9 @@ function aksrt_get_user_dashboard_view(int $user_id, array $args = []): array {
|
||||
? AKSRT_Settings::get_currency_name()
|
||||
: __('积分', 'aksrt');
|
||||
|
||||
$user_home_manager = class_exists('AKSRT_User_Home') ? AKSRT_User_Home::get_instance() : null;
|
||||
$user_home_manager = $include_governance && class_exists('AKSRT_User_Home')
|
||||
? AKSRT_User_Home::get_instance()
|
||||
: null;
|
||||
$profile_signals = $user_home_manager ? $user_home_manager->get_profile_signals($user_id) : [];
|
||||
$profile_notice = $user_home_manager ? $user_home_manager->get_profile_notice($user_id) : [];
|
||||
$show_report = $user_home_manager ? $user_home_manager->show_report_entry() : false;
|
||||
|
||||
Reference in new issue
Block a user