diff --git a/assets/js/report.js b/assets/js/report.js index 2a05bba4..5bfc3e6d 100644 --- a/assets/js/report.js +++ b/assets/js/report.js @@ -80,7 +80,7 @@ // 弹窗头:参考主题 edit-header 同构(关闭钮 + 红色警示徽标 + 标题)。 html += '
'; html += ''; - html += '' + escapeHtml(title) + ''; + html += '' + escapeHtml(title) + ''; html += '
'; html += '
'; @@ -144,7 +144,7 @@ // 底栏:参考主题 but-average modal-buts 双按钮。 html += ''; html += '
'; diff --git a/inc/helpers/aksrt-icons.php b/inc/helpers/aksrt-icons.php index 5cd02037..828498b8 100644 --- a/inc/helpers/aksrt-icons.php +++ b/inc/helpers/aksrt-icons.php @@ -88,6 +88,8 @@ if (!function_exists('aksrt_normalize_icon_key')) : * * Examples: 'fa fab fa-github' | 'fa-github' | 'github' | 'weixin' → 'github' | 'wechat' * + * Legacy FA4 values (a bare `fa` token followed by `fa-`) are stripped too. + * * @param string $name Raw icon key or FA class string. * @return string Short key (may be empty). */ @@ -97,8 +99,11 @@ function aksrt_normalize_icon_key(string $name): string { return ''; } - // Strip the FA5 layout/style prefixes and glyph prefix. + // Strip the FA5 layout/style prefixes, the glyph prefix and the legacy FA4 + // double-`fa` form (a bare `fa` token followed by `fa-`). The site + // ships FA5 only, but stored values may predate it. $name = preg_replace('/^fa\s+(?:fas|far|fab)\s+/i', '', $name); + $name = preg_replace('/^fa\s+fa-/i', '', (string) $name); $name = preg_replace('/^(?:fas|far|fab)\s+/i', '', (string) $name); $name = preg_replace('/^fa-/i', '', (string) $name); $name = trim((string) $name, "- \t\n\r\0\x0B"); @@ -299,9 +304,12 @@ if (!function_exists('aksrt_icon_markup')) : * Supported values: * - "fa fas fa-star" / "fa fab fa-weixin" — FA5 class string * - "fa-star" — bare glyph, rendered as solid FA5 + * - legacy FA4 string — double-`fa` form, upgraded to FA5 * - "zibsvg-hot" — theme built-in SVG sprite key * - "customsvg-" — inline user SVG markup * + * Output is always FA5 — the legacy FA4 double-`fa` prefix is never emitted. + * * @param string $value Raw stored value. * @param array|string $extra_classes Extra classes for the rendered element. * @return string Safe HTML, empty string for empty values. @@ -343,7 +351,13 @@ function aksrt_icon_markup(string $value, $extra_classes = []): string { return ''; } - if (!str_contains($value, 'fa ') && str_contains($value, 'fa-')) { + // 本站统一 FA5 输出:遗留 FA4 双 fa 前缀、裸字形 "fa-xxx" 与缺少 fa 前缀的 + // "fas/far/fab fa-xxx" 均归一为 "fa fas fa-xxx"(末尾附加类名原样保留)。 + if (preg_match('/^fa\s+fa-/i', $value)) { + $value = preg_replace('/^fa\s+/i', 'fa fas ', $value, 1); + } elseif (preg_match('/^fa-/i', $value)) { + $value = 'fa fas ' . $value; + } elseif (preg_match('/^(?:fas|far|fab)\s+fa-/i', $value)) { $value = 'fa ' . $value; } return ''; diff --git a/inc/helpers/comments/item.php b/inc/helpers/comments/item.php index 4268aaf5..f7125321 100644 --- a/inc/helpers/comments/item.php +++ b/inc/helpers/comments/item.php @@ -178,7 +178,7 @@ if (!function_exists('aksrt_get_comment_report_html')) : 'target_avatar' => get_avatar_url((int) $comment->user_id > 0 ? (int) $comment->user_id : 0, ['size' => 40]) ?: '', ]); - return '
  • ' . esc_html__('举报', 'aksrt') . '
  • '; + return '
  • ' . esc_html__('举报', 'aksrt') . '
  • '; } endif; diff --git a/tests/widget-system/icon-picker-contract.test.cjs b/tests/widget-system/icon-picker-contract.test.cjs index 7ffb8be5..84c5e5ca 100644 --- a/tests/widget-system/icon-picker-contract.test.cjs +++ b/tests/widget-system/icon-picker-contract.test.cjs @@ -127,6 +127,18 @@ test('nav menu icons render every format without legacy fa-prefix mangling', () assert.doesNotMatch(helper, /'