feat(users): level integral XP schema + AKSRT_User_Level runtime
Rewrite /users/level to Zibll-like user_level_s/max/opt and user_integral_opt. Runtime grants XP with day_max, resolves level, hooks login/register/post/comment/like/favorite/follow. Profile signals read integral-backed levels. audit errors=0.
This commit is contained in:
1 parent
e80d8ea45d
commit
1b0eed6ef7
8 files changed
+658
-141
No files matched your search
@@ -279,22 +279,24 @@ class AKSRT_User_Home {
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array{source:string,thresholds:array<int,int>} $level_settings
|
||||
* @param array{source?:string,thresholds?:array<int,int>} $level_settings
|
||||
*/
|
||||
private function get_user_level(int $user_id, array $level_settings): int {
|
||||
if (($level_settings['source'] ?? 'credits_balance') === 'manual_meta') {
|
||||
$source = (string) ($level_settings['source'] ?? 'integral');
|
||||
if ($source === 'manual_meta') {
|
||||
return max(0, (int) get_user_meta($user_id, 'aksrt_user_level', true));
|
||||
}
|
||||
|
||||
if (class_exists('AKSRT_User_Level')) {
|
||||
return AKSRT_User_Level::get_level($user_id);
|
||||
}
|
||||
// Fallback: credits_balance thresholds (legacy) if integral class missing.
|
||||
$score = function_exists('aksrt_user_credits') ? (int) aksrt_user_credits($user_id) : 0;
|
||||
$level = 0;
|
||||
|
||||
foreach ((array) ($level_settings['thresholds'] ?? []) as $candidate => $threshold) {
|
||||
if ($score >= (int) $threshold) {
|
||||
$level = (int) $candidate;
|
||||
}
|
||||
}
|
||||
|
||||
return $level;
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user