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:
@@ -137,7 +137,12 @@ if (!function_exists('aksrt_get_single_meta_box')) :
|
||||
}
|
||||
$more .= '<button type="button" class="post-drop-meta__item" data-share-copy data-share-url="' . esc_url((string) $permalink) . '"><i class="fa fas fa-link" aria-hidden="true"></i><span>' . esc_html__('复制链接', 'aksrt') . '</span></button>';
|
||||
if (is_user_logged_in()) {
|
||||
$more .= '<button type="button" class="post-drop-meta__item" data-aksrt-report=\'{"target_type":"post","target_id":' . (int) $post_id . '}\'><i class="fa fas fa-flag" aria-hidden="true"></i><span>' . esc_html__('举报', 'aksrt') . '</span></button>';
|
||||
$report_payload = wp_json_encode([
|
||||
'target_type' => 'post',
|
||||
'target_id' => (int) $post_id,
|
||||
'target_name' => get_the_title($post_id),
|
||||
]);
|
||||
$more .= '<button type="button" class="post-drop-meta__item" data-aksrt-report="' . esc_attr((string) $report_payload) . '"><i class="fa fas fa-flag" aria-hidden="true"></i><span>' . esc_html__('举报', 'aksrt') . '</span></button>';
|
||||
} else {
|
||||
$more .= '<a href="' . esc_url($login_url) . '" class="post-drop-meta__item"><i class="fa fas fa-flag" aria-hidden="true"></i><span>' . esc_html__('登录后举报', 'aksrt') . '</span></a>';
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user