fix(report): unify the frontend report entry and modal

- enqueue report.js on singular pages too: the single meta box and
  comment report buttons rendered without their script handler, so
  clicking the report item did nothing
- align the report runtime default with the admin schema and the
  reference theme (user_report_s default true) so the public user
  home cover menu shows the report entry
- rebuild report.js on top of AksrtModalRuntime following the
  reference theme modal format: red warning header, preset reason
  badges with an other-reason textarea, violation link field, detail
  description and a cancel/submit footer; submit goes through the
  unified /report/submit endpoint
- keep report inside the comment three-dot dropdown and enrich the
  payload (target name/avatar) for the modal; inject configured
  report categories via aksrtData.reportCategories
- update the report contract test accordingly
This commit is contained in:
2026-09-20 13:40:05 +08:00
parent 381256ed59
commit 7c730b83d6
9 changed files with 249 additions and 112 deletions
+6 -3
View File
@@ -277,9 +277,9 @@ trait ScriptsPart1b {
// 评论区样式由上方 is_singular 统一入口按 needs_comments 加载。
}
// 用户中心 / 公开主页:路由专属 CSS
if ($is_profile_page) {
// 举报脚本(用户主页和个人中心均需要)
// 举报脚本:举报入口渲染于文章页 meta 菜单、评论区与用户主页/个人中心,
// 因此 singular 页面与 profile 路由都需要加载(文章页举报按钮此前无脚本支撑)。
if (is_singular() || $is_profile_page) {
$report_js_path = get_template_directory() . '/assets/js/report.js';
if (file_exists($report_js_path)) {
wp_enqueue_script(
@@ -290,7 +290,10 @@ trait ScriptsPart1b {
true
);
}
}
// 用户中心 / 公开主页:路由专属 CSS
if ($is_profile_page) {
// 关注脚本已在全局栈注册(ScriptsPart1c),data-aksrt-follow 按钮
// 也渲染于文章页作者栏与各处用户卡片,不能仅限本路由加载。