$user_id, 'count' => true, 'status' => 'approve', ]); $favorite_post_ids = function_exists('aksrt_get_user_interaction_posts') ? aksrt_get_user_interaction_posts('_aksrt_favorite_posts', $user_id) : []; $favorite_count = count($favorite_post_ids); $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, ]) : []; $profile_details = function_exists('aksrt_get_visible_user_profile_details') ? aksrt_get_visible_user_profile_details($user_id, $viewer_id) : ['gender' => '', 'website' => '', 'qq' => '', 'wechat' => '', 'github' => '']; $background_url = function_exists('aksrt_get_user_cover_url') ? aksrt_get_user_cover_url($user_id) : ''; $credits_enabled = class_exists('\AKSRT\Settings\Settings') && \AKSRT\Settings\Settings::credits_enabled(); $credit_balance = $credits_enabled && $is_own_profile ? (float) aksrt_user_points($user_id) : 0.0; $currency_name = $credits_enabled && class_exists('\AKSRT\Settings\Settings') ? \AKSRT\Settings\Settings::get_currency_name() : __('积分', 'aksrt'); $recharge = class_exists('\AKSRT\Settings\Settings') ? \AKSRT\Settings\Settings::get_payment_recharge_settings() : []; $balance_enabled = $is_own_profile && !empty($recharge['enabled']); $wallet_balance = $balance_enabled ? aksrt_user_balance_decimal($user_id) : '0.00'; $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; $verify_state = $user_home_manager ? $user_home_manager->get_verify_state($user_id) : ['state' => '', 'label' => '']; return [ 'post_count' => $post_count, 'comment_count' => $comment_count, 'favorite_count' => $favorite_count, 'favorite_post_ids'=> $favorite_post_ids, 'recent_posts' => $recent_posts, 'profile_details' => $profile_details, 'profile_signals' => $profile_signals, 'profile_notice' => $profile_notice, 'verify_state' => $verify_state, 'show_report' => $show_report, 'background_url' => $background_url, 'credit_balance' => $credit_balance, 'currency_name' => $currency_name, 'credits_enabled' => $credits_enabled, 'balance_enabled' => $balance_enabled, 'wallet_balance' => $wallet_balance, 'is_own_profile' => $is_own_profile, ]; } add_action('wp_login', static function ($user_login, $user = null): void { $user_id = 0; if ($user instanceof WP_User) { $user_id = (int) $user->ID; } elseif (is_string($user_login) && $user_login !== '') { $found = get_user_by('login', $user_login); $user_id = $found instanceof WP_User ? (int) $found->ID : 0; } if ($user_id > 0) { update_user_meta($user_id, 'aksrt_last_login', time()); } }, 20, 2);