evaluate((int) $user->ID); } } public function maybe_for_current_user(): void { if (!is_user_logged_in() || is_admin()) { return; } // Throttle: once per 10 minutes per user. $uid = get_current_user_id(); $key = 'aksrt_badge_auto_' . $uid; if (get_transient($key)) { return; } set_transient($key, 1, 10 * MINUTE_IN_SECONDS); $this->evaluate($uid); } public function on_content_change($arg = null): void { $uid = get_current_user_id(); if ($uid > 0) { $this->evaluate($uid); } } public function on_follow(int $follower_id, int $following_id): void { if ($following_id > 0) { $this->evaluate($following_id); } if ($follower_id > 0) { $this->evaluate($follower_id); } } public function on_checkin(int $user_id): void { if ($user_id > 0) { $this->evaluate($user_id); } } public function evaluate(int $user_id): void { if ($user_id <= 0 || !class_exists('\AKSRT\User\Badges') || !Badges::enabled()) { return; } Badges::auto_evaluate($user_id); } }