feat(user): badge icon urls and wear medal chrome
Extend badge dictionary with optional icon_url, prefer aksrt_wear_badge when assigned, and render medal images in identity chips.
This commit is contained in:
@@ -120,7 +120,7 @@ class AKSRT_Settings_User_Runtime {
|
||||
* @return array{
|
||||
* verify:array{enabled:bool,public_display:bool,badge_text:string,accept_email_verified:bool,require_manual_review:bool},
|
||||
* level:array{enabled:bool,public_display:bool,source:string,label_prefix:string,thresholds:array<int,int>},
|
||||
* badge:array{enabled:bool,public_display:bool,limit:int,dictionary:array<int,array{slug:string,label:string,tone:string}>},
|
||||
* badge:array{enabled:bool,public_display:bool,limit:int,dictionary:array<int,array{slug:string,label:string,tone:string,icon_url?:string}>},
|
||||
* report:array{enabled:bool,public_entry:bool,public_notice:bool,ban_notice_text:string,categories:array<int,array{slug:string,label:string}>}
|
||||
* }
|
||||
*/
|
||||
@@ -238,7 +238,7 @@ class AKSRT_Settings_User_Runtime {
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<int,array{slug:string,label:string,tone:string}>
|
||||
* @return array<int,array{slug:string,label:string,tone:string,icon_url:string}>
|
||||
*/
|
||||
public static function parse_badge_dictionary(string $raw): array {
|
||||
$lines = preg_split('/[\r\n]+/', $raw, -1, PREG_SPLIT_NO_EMPTY);
|
||||
@@ -254,6 +254,7 @@ class AKSRT_Settings_User_Runtime {
|
||||
$slug = sanitize_key((string) $parts[0]);
|
||||
$label = sanitize_text_field((string) $parts[1]);
|
||||
$tone = isset($parts[2]) ? sanitize_key((string) $parts[2]) : 'neutral';
|
||||
$icon_url = isset($parts[3]) ? esc_url_raw((string) $parts[3]) : '';
|
||||
|
||||
if ($slug === '' || $label === '') {
|
||||
continue;
|
||||
@@ -264,9 +265,10 @@ class AKSRT_Settings_User_Runtime {
|
||||
}
|
||||
|
||||
$items[] = [
|
||||
'slug' => $slug,
|
||||
'label' => $label,
|
||||
'tone' => $tone,
|
||||
'slug' => $slug,
|
||||
'label' => $label,
|
||||
'tone' => $tone,
|
||||
'icon_url' => $icon_url,
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user