refactor(widget): simplify search and author cards

This commit is contained in:
kate522 committed 2026-08-15 17:44:57 +08:00
1 parent efb952171d
commit f5d3599756
3 files changed
+21 -40

No files matched your search

+1 -21
View File
@@ -53,10 +53,7 @@ class WidgetAuthorCard extends \WP_Widget {
if (!is_string($bio) || $bio === '') {
$bio = (string) $user->description;
}
$cover = (string) get_user_meta($author_id, 'aksrt_cover', true);
if ($cover === '') {
$cover = (string) get_user_meta($author_id, 'custom_avatar_cover', true);
}
$cover = (string) get_user_meta($author_id, 'aksrt_background_image', true);
$post_count = count_user_posts($author_id, 'post', true);
$followers = 0;
@@ -84,23 +81,6 @@ class WidgetAuthorCard extends \WP_Widget {
if ($bio !== '') {
echo '<div class="aksrt-author-card__bio user-desc muted-2-color em09">' . esc_html(wp_trim_words($bio, 28)) . '</div>';
}
if (class_exists('\AKSRT\User\Badges') && \AKSRT\User\Badges::public_display()) {
$wear = \AKSRT\User\Badges::get_wear($author_id);
if ($wear !== '') {
$map = \AKSRT\User\Badges::get_dictionary_map();
if (isset($map[$wear])) {
$badge = $map[$wear];
echo '<div class="aksrt-author-card__badge author-tag tone-' . esc_attr((string) ($badge['tone'] ?? 'neutral')) . '">';
if (!empty($badge['icon_url'])) {
echo '<img src="' . esc_url((string) $badge['icon_url']) . '" alt="" width="16" height="16" loading="lazy" /> ';
} else {
echo '<i class="fas fa-medal" aria-hidden="true"></i> ';
}
echo esc_html((string) $badge['label']);
echo '</div>';
}
}
}
if ($show_stats) {
echo '<div class="aksrt-author-card__stats">';
echo '<span><b>' . esc_html((string) $post_count) . '</b>' . esc_html__('文章', 'aksrt') . '</span>';