进行了一些小优化

This commit is contained in:
2026-08-30 21:48:59 +08:00
parent a73fa9a6c0
commit 71444b139a
12 changed files with 280 additions and 147 deletions
+7 -6
View File
@@ -11,10 +11,11 @@ if (!function_exists('aksrt_header_user_checkin_btn')) :
/**
* Check-in CTA for header dropdown and compact card placements.
*
* @param int $user_id Current user ID.
* @param bool $compact Render a short card-friendly label.
* @param int $user_id Current user ID.
* @param bool $compact Render a short card-friendly label.
* @param string|null $class Override the button classes (keeps data-signin behavior).
*/
function aksrt_header_user_checkin_btn(int $user_id = 0, bool $compact = false): string {
function aksrt_header_user_checkin_btn(int $user_id = 0, bool $compact = false, ?string $class = null): string {
$user_id = $user_id > 0 ? $user_id : get_current_user_id();
if ($user_id <= 0 || !class_exists('\AKSRT\Credits\Signin')) {
return '';
@@ -28,15 +29,15 @@ if (!function_exists('aksrt_header_user_checkin_btn')) :
$signed = \AKSRT\Credits\Signin::get_instance()->is_signed_today($user_id);
$compact_class = $compact ? ' aksrt-header-checkin--compact' : '';
$classes = $class ?? ('but block c-yellow aksrt-header-checkin' . ($compact ? ' aksrt-header-checkin--compact' : ''));
if ($signed) {
return '<button type="button" class="but block c-yellow aksrt-header-checkin' . $compact_class . ' is-done" data-signin-btn data-signin-idle-label="' . esc_attr__('签到', 'aksrt') . '" data-signin-done-label="' . esc_attr__('已签到', 'aksrt') . '" disabled>'
return '<button type="button" class="' . esc_attr($classes . ' is-done') . '" data-signin-btn data-signin-idle-label="' . esc_attr__('签到', 'aksrt') . '" data-signin-done-label="' . esc_attr__('已签到', 'aksrt') . '" disabled>'
. '<i class="fa fas fa-calendar-check" aria-hidden="true"></i>'
. '<span data-signin-label>' . esc_html($compact ? __('已签到', 'aksrt') : __('今日已签到', 'aksrt')) . '</span>'
. '</button>';
}
return '<button type="button" class="but block c-yellow aksrt-header-checkin' . $compact_class . '" data-signin-btn data-signin-idle-label="' . esc_attr__('签到', 'aksrt') . '" data-signin-done-label="' . esc_attr__('已签到', 'aksrt') . '">'
return '<button type="button" class="' . esc_attr($classes) . '" data-signin-btn data-signin-idle-label="' . esc_attr__('签到', 'aksrt') . '" data-signin-done-label="' . esc_attr__('已签到', 'aksrt') . '">'
. '<i class="fa fas fa-calendar-check" aria-hidden="true"></i>'
. '<span data-signin-label>' . esc_html($compact ? __('签到', 'aksrt') : __('签到领取今日奖励', 'aksrt')) . '</span>'
. '</button>';