';
+ $html .= '
';
+ $html .= '
 . ')
';
+ $html .= '
' . esc_html(sprintf(__('%s的徽章', 'aksrt'), $display));
+ if ($wear !== '') {
+ $map = self::get_dictionary_map();
+ if (isset($map[$wear])) {
+ $html .= ' ' . esc_html(sprintf(__('佩戴:%s', 'aksrt'), (string) $map[$wear]['label'])) . '';
+ }
+ } else {
+ $html .= ' ' . esc_html__('暂无徽章', 'aksrt') . '';
+ }
+ $html .= '
';
+ $html .= '
';
+ $html .= '
';
+
+ $html .= '
';
+ return $html;
+ }
+
+ /**
+ * Single badge card modal.
+ */
+ public static function render_single_modal_html(string $slug, int $user_id = 0): string {
+ $map = self::get_dictionary_map();
+ $slug = sanitize_key($slug);
+ if ($slug === '' || !isset($map[$slug])) {
+ return '';
+ $html .= '
';
+ $html .= '
';
+ if (!empty($item['icon_url'])) {
+ $html .= '
 $item['icon_url']) . ')
';
+ } else {
+ $html .= '
';
+ }
+ $html .= '
' . esc_html((string) $item['label']) . '
';
+ if ($is_self) {
+ $html .= $has
+ ? '
' . esc_html__('已获得', 'aksrt') . '
'
+ : '
' . esc_html__('暂未获得', 'aksrt') . '
';
+ }
+ $html .= '
';
+ if ($is_self && $has && !$is_wear) {
+ $html .= '
';
+ } elseif ($is_self && $is_wear) {
+ $html .= '
' . esc_html__('当前佩戴此徽章', 'aksrt') . '
';
+ }
+ $html .= '
';
+ return $html;
+ }
+
+ /**
+ * Remote-modal trigger for a user's badge list (zibll zib_get_user_medal_info_link).
+ */
+ public static function get_info_link(int $user_id, string $class = '', ?string $text = null): string {
+ if ($user_id <= 0 || !self::enabled()) {
+ return '';
+ }
+ if ($text === null) {
+ $text = __('徽章明细', 'aksrt');
+ }
+ if (!function_exists('aksrt_get_remote_modal_link')) {
+ return '';
+ }
+ $url = add_query_arg(
+ [
+ 'action' => 'aksrt_user_badge_info_modal',
+ 'id' => $user_id,
+ ],
+ admin_url('admin-ajax.php')
+ );
+ return aksrt_get_remote_modal_link([
+ 'tag' => 'a',
+ 'class' => trim('user-medal-info ' . $class),
+ 'text' => $text,
+ 'url' => $url,
+ 'data_class' => 'full-sm',
+ 'height' => 240,
+ 'mobile_bottom' => true,
+ ]);
}
public function register_routes(): void {
diff --git a/src/AKSRT/Widgets/SearchWidget.php b/src/AKSRT/Widgets/SearchWidget.php
index 394da33f..080eb543 100644
--- a/src/AKSRT/Widgets/SearchWidget.php
+++ b/src/AKSRT/Widgets/SearchWidget.php
@@ -47,21 +47,25 @@ class SearchWidget extends \WP_Widget {
}
?>
-
-
-
-
-
+
+
+
+
+
';
- echo $args['after_widget'];
- }
-
- public function form($instance): void {
- $defaults = [
- 'title' => __('商品精选', 'aksrt'),
- 'tabs' => "热门推荐|\n最新上架|",
- 'per_page' => 8,
- ];
- $instance = wp_parse_args($instance, $defaults);
- ?>
-
-
-
-
-
-
-
-
-
-
-
-
- sanitize_text_field($new_instance['title'] ?? ''),
- 'tabs' => sanitize_textarea_field($new_instance['tabs'] ?? ''),
- 'per_page' => max(1, min(20, (int) ($new_instance['per_page'] ?? 8))),
- ];
- }
+ public function update($new_instance, $old_instance): array {
+ return [
+ 'title' => sanitize_text_field((string) ($new_instance['title'] ?? '')),
+ 'tabs' => sanitize_textarea_field((string) ($new_instance['tabs'] ?? '')),
+ 'per_page' => max(1, min(20, (int) ($new_instance['per_page'] ?? 8))),
+ 'style' => sanitize_key((string) ($new_instance['style'] ?? 'default')),
+ 'paginate' => sanitize_key((string) ($new_instance['paginate'] ?? 'ajax')),
+ ];
+ }
}
diff --git a/templates/parts/user/author-hero.php b/templates/parts/user/author-hero.php
index 02dee3cf..62248511 100644
--- a/templates/parts/user/author-hero.php
+++ b/templates/parts/user/author-hero.php
@@ -102,6 +102,16 @@ $pm_url = ($pm_enabled && $messages_url !== '')
+ ' . $badge_link . '
'; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
+ }
+ }
+ ?>
+
description) : ?>