feat(admin,forum): download logs, hidecontent, VIP tiers, users commerce

Add aksrt_download_logs workbench, zibll hidecontent alias + topic
partial-hide path, VIP1/VIP2 price matrix for topics, and users list
commerce snapshot column with deep links.
This commit is contained in:
kate522 committed 2026-07-15 11:13:48 +08:00
1 parent cf6ad0e972
commit 8d31e65ccd
14 files changed
+611 -32

No files matched your search

+88 -5
View File
@@ -37,6 +37,8 @@ class AKSRT_Shortcodes {
add_shortcode('reply', [$this, 'render_reply']);
add_shortcode('vip', [$this, 'render_vip']);
add_shortcode('payshow', [$this, 'render_payshow']);
// Zibll-compatible hidecontent alias (type=payshow|reply|login|vip|password|…)
add_shortcode('hidecontent', [$this, 'render_hidecontent']);
add_shortcode('content', [$this, 'render_content_gate']);
// 文章归档 / 个人资料卡 → AKSRT_Templates 模板
add_shortcode('aksrt_archive', [$this, 'render_archive']);
@@ -101,16 +103,13 @@ class AKSRT_Shortcodes {
}
/**
* [payshow]...[/payshow] — 付费后可见
* [payshow]...[/payshow] — 付费后可见(文章 content-pay 或论坛主题解锁)
*/
public function render_payshow(array $atts = [], string $content = ''): string {
$atts = shortcode_atts(['message' => ''], $atts, 'payshow');
$pid = get_the_ID();
$can_view = false;
if ($pid && class_exists('AKSRT_Content_Visibility')) {
$can_view = AKSRT_Content_Visibility::can_view_paid_content($pid);
}
$can_view = $this->viewer_can_see_paid_block($pid);
if ($can_view) {
return '<div class="aksrt-hidden-content aksrt-hidden-content--unlocked aksrt-hidden-content--payshow">'
@@ -132,6 +131,90 @@ class AKSRT_Shortcodes {
return $html;
}
/**
* Zibll [hidecontent type="payshow|reply|login|…"]…[/hidecontent]
*/
public function render_hidecontent(array $atts = [], string $content = ''): string {
$atts = shortcode_atts([
'type' => 'payshow',
'message' => '',
'pass' => '',
], $atts, 'hidecontent');
$type = sanitize_key((string) $atts['type']);
$msg = (string) $atts['message'];
switch ($type) {
case 'reply':
case 'comment':
return $this->render_reply(['message' => $msg], $content);
case 'login':
case 'signin':
return $this->render_hide([
'mode' => 'login',
'message' => $msg !== '' ? $msg : __('登录后可查看隐藏内容', 'aksrt'),
], $content);
case 'password':
case 'pass':
return $this->render_hide([
'mode' => 'password',
'message' => $msg,
'pass' => (string) $atts['pass'],
], $content);
case 'vip':
return $this->render_vip(['message' => $msg], $content);
case 'payshow':
case 'pay':
case 'points':
default:
return $this->render_payshow(['message' => $msg], $content);
}
}
/**
* Whether current viewer may see a paid hide block on this post/topic.
*/
private function viewer_can_see_paid_block(int $pid): bool {
if ($pid <= 0) {
return false;
}
$post = get_post($pid);
if (!$post instanceof WP_Post) {
return false;
}
$uid = get_current_user_id();
if ($uid > 0 && ((int) $post->post_author === $uid || user_can($uid, 'manage_options'))) {
return true;
}
// Forum topics: paid/credits unlock list or orders.
if ($post->post_type === 'aksrt_forum_topic' && class_exists('AKSRT_Forum')) {
$forum = AKSRT_Forum::get_instance();
$visibility = sanitize_key((string) get_post_meta($pid, '_aksrt_visibility', true));
if ($visibility === 'public' || $visibility === '') {
return true;
}
if (method_exists($forum, 'has_user_unlocked_topic') && $forum->has_user_unlocked_topic($uid, $pid)) {
return true;
}
if (method_exists($forum, 'has_user_paid_topic') && $forum->has_user_paid_topic($uid, $pid)) {
return true;
}
// Free VIP price counts as paid for cash topics.
if ($visibility === 'pay' && method_exists($forum, 'resolve_topic_pay_price')) {
$price = $forum->resolve_topic_pay_price($pid, $uid);
if (!empty($price['is_free'])) {
return true;
}
}
return false;
}
if (class_exists('AKSRT_Content_Visibility')) {
return AKSRT_Content_Visibility::can_view_paid_content($pid);
}
return false;
}
/**
* [content type="admin|author|vip"]...[/content] — 按角色/身份控制可见性
*/