fix(widgets): stabilize user card layout

This commit is contained in:
kate522 committed 2026-08-14 21:15:47 +08:00
1 parent 15b4c818c5
commit 246084648f
4 files changed
+176 -48

No files matched your search

+10 -6
View File
@@ -9,9 +9,12 @@ defined('ABSPATH') || exit;
if (!function_exists('aksrt_header_user_checkin_btn')) :
/**
* Check-in CTA for header dropdown (uses REST /aksrt/v1/signin).
* Check-in CTA for header dropdown and compact card placements (uses REST /aksrt/v1/signin).
*
* @param int $user_id Current user ID.
* @param bool $compact Render a short card-friendly label.
*/
function aksrt_header_user_checkin_btn(int $user_id = 0): string {
function aksrt_header_user_checkin_btn(int $user_id = 0, bool $compact = false): string {
$user_id = $user_id > 0 ? $user_id : get_current_user_id();
if ($user_id <= 0 || !class_exists('\AKSRT\Credits\Signin')) {
return '';
@@ -39,16 +42,17 @@ if (!function_exists('aksrt_header_user_checkin_btn')) :
$signed = false;
}
$compact_class = $compact ? ' aksrt-header-checkin--compact' : '';
if ($signed) {
return '<button type="button" class="but block c-yellow aksrt-header-checkin is-done" disabled>'
return '<button type="button" class="but block c-yellow aksrt-header-checkin' . $compact_class . ' is-done" disabled>'
. '<i class="fas fa-calendar-check" aria-hidden="true"></i>'
. '<span>' . esc_html__('今日已签到', 'aksrt') . '</span>'
. '<span>' . esc_html($compact ? __('已签到', 'aksrt') : __('今日已签到', 'aksrt')) . '</span>'
. '</button>';
}
return '<button type="button" class="but block c-yellow aksrt-header-checkin" data-aksrt-checkin="1">'
return '<button type="button" class="but block c-yellow aksrt-header-checkin' . $compact_class . '" data-aksrt-checkin="1">'
. '<i class="fas fa-calendar-check" aria-hidden="true"></i>'
. '<span>' . esc_html__('签到领取今日奖励', 'aksrt') . '</span>'
. '<span>' . esc_html($compact ? __('签到', 'aksrt') : __('签到领取今日奖励', 'aksrt')) . '</span>'
. '</button>';
}
endif;