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:
kate522 committed 2026-09-20 13:40:05 +08:00
1 parent 381256ed59
commit 7c730b83d6
9 files changed
+249 -112

No files matched your search

+10 -1
View File
@@ -80,7 +80,16 @@ $unread_count = $is_own ? aksrt_get_user_unread_notification_count($user_id) : 0
<div class="aksrt-cover-menu__panel" role="menu" hidden>
<?php if ($has_more_details) : ?><button type="button" role="menuitem" data-aksrt-profile-details><i class="fa fas fa-address-card" aria-hidden="true"></i><?php esc_html_e('更多资料', 'aksrt'); ?></button><?php endif; ?>
<?php if ($show_report && !$is_own) : ?>
<?php if (is_user_logged_in()) : ?><button type="button" role="menuitem" data-aksrt-report='{"target_type":"user","target_id":<?php echo (int) $user_id; ?>}'><i class="fa fas fa-flag" aria-hidden="true"></i><?php esc_html_e('举报用户', 'aksrt'); ?></button>
<?php
// 统一举报契约:report.js 弹窗展示被举报对象(头像 + 名称)。
$report_payload = [
'target_type' => 'user',
'target_id' => $user_id,
'target_name' => $user->display_name,
'target_avatar' => get_avatar_url($user_id, ['size' => 40]),
];
?>
<?php if (is_user_logged_in()) : ?><button type="button" role="menuitem" data-aksrt-report="<?php echo esc_attr(wp_json_encode($report_payload)); ?>"><i class="fa fas fa-flag" aria-hidden="true"></i><?php esc_html_e('举报用户', 'aksrt'); ?></button>
<?php else : ?><a role="menuitem" href="<?php echo esc_url(aksrt_get_login_url($home_url)); ?>"><i class="fa fas fa-flag" aria-hidden="true"></i><?php esc_html_e('举报用户', 'aksrt'); ?></a><?php endif; ?>
<?php endif; ?>
</div>