feat(forum): topic pay-hide and points view gates

Align native topic meta box with runtime visibility contract
(_aksrt_credits_cost / pay / VIP / hide-part), blank denied content
payloads, and mark gap-matrix product + topic pay items done.
This commit is contained in:
kate522 committed 2026-07-15 10:19:46 +08:00
1 parent 74bde18880
commit bccb14a487
4 files changed
+207 -28

No files matched your search

@@ -65,6 +65,17 @@ trait AKSRT_Forum_Topic_Service_Part_3 {
? $post->post_excerpt
: wp_trim_words(wp_strip_all_tags((string) $post->post_content), 40);
$pay_hide_part = (int) get_post_meta($topic_id, '_aksrt_pay_hide_part', true) === 1;
$content = (string) $post->post_content;
if (!$can_view) {
// Prevent content leak via payload/API when template forgets can_view check.
// Partial-hide flag only applies after unlock; denied users get empty body.
$content = '';
if (in_array($visibility, [AKSRT_Forum::VISIBILITY_CREDITS, AKSRT_Forum::VISIBILITY_PAY, AKSRT_Forum::VISIBILITY_LOGIN, AKSRT_Forum::VISIBILITY_COMMENT, AKSRT_Forum::VISIBILITY_ROLE, AKSRT_Forum::VISIBILITY_MODERATOR], true)) {
$excerpt = '';
}
}
$sticky_level = $this->resolve_sticky_level($topic_id);
$featured = get_post_meta($topic_id, '_aksrt_featured', true) === '1';
$locked = get_post_meta($topic_id, '_aksrt_locked', true) === '1';
@@ -81,11 +92,16 @@ trait AKSRT_Forum_Topic_Service_Part_3 {
$cover = $this->build_cover_payload($topic_id);
$credits_cost = max(0, (int) get_post_meta($topic_id, '_aksrt_credits_cost', true));
if ($credits_cost <= 0) {
$credits_cost = max(0, (int) get_post_meta($topic_id, '_aksrt_pay_credits', true));
}
return [
'id' => $topic_id,
'title' => (string) get_the_title($topic_id),
'excerpt' => (string) $excerpt,
'content' => (string) $post->post_content,
'content' => $content,
'status' => (string) $post->post_status,
'author_id' => $author_id,
'author' => $this->build_user_summary($author_id),
@@ -127,6 +143,9 @@ trait AKSRT_Forum_Topic_Service_Part_3 {
'can_view' => $can_view,
'can_edit' => $this->forum->can_edit_topic($viewer_user_id, $topic_id),
'can_moderate' => $this->forum->can_moderate_topic($viewer_user_id, $topic_id),
'pay_hide_part' => $pay_hide_part,
'credits_cost' => $credits_cost,
'pay_price' => (float) get_post_meta($topic_id, '_aksrt_pay_price', true),
];
}