feat(identity): tip QR upload, metrics engine, comment moderate caps

Close identity 1:1 gaps after p1: user-center weixin/alipay tip QR
upload+save, AKSRT_User_Metrics counters for medal get_type and level
XP bridges, forum/revenue/signin hooks, comment moderate via user_caps,
and clearer free-task deep links/status CTAs.
This commit is contained in:
kate522 committed 2026-07-17 01:52:35 +08:00
1 parent 4e3eb0414d
commit 487681a6c4
18 files changed
+854 -36

No files matched your search

+2
View File
@@ -604,6 +604,7 @@ if (!function_exists('aksrt_set_post_views')) :
if (function_exists('aksrt_update_post_counter')) {
aksrt_update_post_counter($post_id, '_aksrt_res_view_count', 1);
aksrt_update_post_counter($post_id, 'aksrt_post_views', 1);
do_action('aksrt_post_viewed', (int) $post_id, get_current_user_id());
} else {
$resource_count = (int) get_post_meta($post_id, '_aksrt_res_view_count', true);
update_post_meta($post_id, '_aksrt_res_view_count', $resource_count + 1);
@@ -613,6 +614,7 @@ if (!function_exists('aksrt_set_post_views')) :
} else {
if (function_exists('aksrt_update_post_counter')) {
aksrt_update_post_counter($post_id, 'aksrt_post_views', 1);
do_action('aksrt_post_viewed', (int) $post_id, get_current_user_id());
} else {
$count = (int) get_post_meta($post_id, 'aksrt_post_views', true);
update_post_meta($post_id, 'aksrt_post_views', $count + 1);
+26
View File
@@ -91,6 +91,32 @@ if (!function_exists('aksrt_save_user_center_profile')) {
}
update_user_meta($user_id, 'aksrt_user_contacts', aksrt_normalize_user_contacts($input['contacts'] ?? []));
// Tip QR images (attachment id or URL). Empty clears.
if (array_key_exists('rewards_weixin', $input) || array_key_exists('rewards_alipay', $input)) {
foreach (['rewards_weixin' => 'aksrt_rewards_weixin', 'rewards_alipay' => 'aksrt_rewards_alipay'] as $field => $meta) {
if (!array_key_exists($field, $input)) {
continue;
}
$raw = is_string($input[$field]) ? trim(wp_unslash($input[$field])) : '';
if ($raw === '' || $raw === '0') {
delete_user_meta($user_id, $meta);
continue;
}
if (ctype_digit($raw)) {
$att = (int) $raw;
if ($att > 0 && wp_attachment_is_image($att)) {
update_user_meta($user_id, $meta, $att);
}
continue;
}
$url = esc_url_raw($raw);
if ($url !== '') {
update_user_meta($user_id, $meta, $url);
}
}
}
return true;
}
}
@@ -52,22 +52,48 @@ $aksrt_points_task_action = static function (string $key): array {
'href' => $submit !== '' ? $submit : $home,
];
case 'comment_new':
return [
'type' => 'link',
'label' => __('去完成', 'aksrt'),
'href' => $home,
];
case 'login':
case 'post_like':
case 'post_favorite':
case 'followed':
case 'comment_like':
return [
'type' => 'link',
'label' => __('去看看', 'aksrt'),
'href' => $home,
];
case 'bbs_posts_new':
$posts = get_posts(['numberposts' => 1, 'post_status' => 'publish', 'orderby' => 'date', 'order' => 'DESC']);
$href = $home;
if (!empty($posts[0]) && $posts[0] instanceof WP_Post) {
$link = get_permalink($posts[0]);
if (is_string($link) && $link !== '') {
$href = $link . '#comments';
}
}
return [
'type' => 'link',
'label' => __('去完成', 'aksrt'),
'href' => $href,
];
case 'login':
return [
'type' => 'none',
'label' => __('登录即可领取', 'aksrt'),
];
case 'post_like':
case 'post_favorite':
case 'comment_like':
$posts = get_posts(['numberposts' => 1, 'post_status' => 'publish', 'orderby' => 'comment_count', 'order' => 'DESC']);
$href = $home;
if (!empty($posts[0]) && $posts[0] instanceof WP_Post) {
$link = get_permalink($posts[0]);
if (is_string($link) && $link !== '') {
$href = $link;
}
}
return [
'type' => 'link',
'label' => __('去看看', 'aksrt'),
'href' => $href,
];
case 'followed':
$center = function_exists('aksrt_get_user_center_url') ? (string) aksrt_get_user_center_url() : $home;
return [
'type' => 'link',
'label' => __('去主页', 'aksrt'),
'href' => $center !== '' ? $center : $home,
];
case 'bbs_posts_new':
case 'bbs_reply':
if (!$forum_on) {
return ['type' => 'none', 'label' => ''];
@@ -180,16 +206,19 @@ $pane = isset($points_tasks_pane) ? sanitize_key((string) $points_tasks_pane)
<div class="focus-color em14">
<i class="fas fa-coins mr6 em09" aria-hidden="true"></i>+ <?php echo esc_html((string) (int) $task['points']); ?>
</div>
<?php if (($action['type'] ?? 'none') === 'signin') : ?>
<button type="button" class="uc-points-tasks__action muted-color em09 mt6" data-aksrt-signin-goto>
<?php echo esc_html((string) $action['label']); ?><i class="fa fa-angle-right em12 ml3" aria-hidden="true"></i>
</button>
<?php elseif (($action['type'] ?? 'none') === 'link' && !empty($action['href'])) : ?>
<a class="uc-points-tasks__action muted-color em09 mt6" href="<?php echo esc_url((string) $action['href']); ?>">
<?php echo esc_html((string) $action['label']); ?><i class="fa fa-angle-right em12 ml3" aria-hidden="true"></i>
</a>
<?php endif; ?>
</div>
<?php if ($done) : ?>
<span class="uc-points-tasks__action muted-color em09 mt6"><?php esc_html_e('今日已完成', 'aksrt'); ?></span>
<?php elseif (($action['type'] ?? 'none') === 'signin') : ?>
<button type="button" class="uc-points-tasks__action muted-color em09 mt6" data-aksrt-signin-goto>
<?php echo esc_html((string) $action['label']); ?><i class="fa fa-angle-right em12 ml3" aria-hidden="true"></i>
</button>
<?php elseif (($action['type'] ?? 'none') === 'link' && !empty($action['href'])) : ?>
<a class="uc-points-tasks__action muted-color em09 mt6" href="<?php echo esc_url((string) $action['href']); ?>">
<?php echo esc_html((string) $action['label']); ?><i class="fa fa-angle-right em12 ml3" aria-hidden="true"></i>
</a>
<?php elseif (($action['type'] ?? 'none') === 'none' && !empty($action['label'])) : ?>
<span class="uc-points-tasks__action muted-color em09 mt6"><?php echo esc_html((string) $action['label']); ?></span>
<?php endif; ?> </div>
</div>
</div>
<?php endforeach; ?>
@@ -32,6 +32,56 @@ extract($context, EXTR_SKIP); // phpcs:ignore WordPress.PHP.DontExtract.extract_
<?php require __DIR__ . '/form-contacts.php'; ?>
<?php
$rewards_on = function_exists('aksrt_rewards_enabled') ? aksrt_rewards_enabled() : false;
$rw = (string) get_user_meta((int) $user_id, 'aksrt_rewards_weixin', true);
$ra = (string) get_user_meta((int) $user_id, 'aksrt_rewards_alipay', true);
$rw_url = '';
$ra_url = '';
if (function_exists('aksrt_get_user_rewards_img_urls')) {
$urls = aksrt_get_user_rewards_img_urls((int) $user_id);
$rw_url = (string) ($urls['weixin'] ?? '');
$ra_url = (string) ($urls['alipay'] ?? '');
}
?>
<?php if ($rewards_on) : ?>
<div class="widget-card">
<h3 class="widget-title"><?php esc_html_e('打赏收款码', 'aksrt'); ?></h3>
<p class="profile-hint"><?php esc_html_e('上传微信/支付宝收款码后,读者可在文章与作者卡赞赏你。留空则不显示赞赏按钮。', 'aksrt'); ?></p>
<div class="aksrt-reward-upload-grid">
<div class="aksrt-reward-upload">
<label class="aksrt-reward-upload__label"><?php esc_html_e('微信收款码', 'aksrt'); ?></label>
<div class="aksrt-reward-upload__preview" data-reward-preview="weixin">
<?php if ($rw_url !== '') : ?>
<img src="<?php echo esc_url($rw_url); ?>" alt="" />
<?php else : ?>
<span class="muted-2-color em09"><?php esc_html_e('未上传', 'aksrt'); ?></span>
<?php endif; ?>
</div>
<input type="hidden" name="rewards_weixin" id="rewards-weixin" value="<?php echo esc_attr($rw); ?>" />
<input type="file" id="rewards-weixin-file" accept="image/*" class="aksrt-reward-upload__file" data-reward-kind="weixin" />
<button type="button" class="btn-primary btn-sm" data-reward-upload="weixin"><?php esc_html_e('选择图片', 'aksrt'); ?></button>
<button type="button" class="btn-sm" data-reward-clear="weixin"><?php esc_html_e('清除', 'aksrt'); ?></button>
</div>
<div class="aksrt-reward-upload">
<label class="aksrt-reward-upload__label"><?php esc_html_e('支付宝收款码', 'aksrt'); ?></label>
<div class="aksrt-reward-upload__preview" data-reward-preview="alipay">
<?php if ($ra_url !== '') : ?>
<img src="<?php echo esc_url($ra_url); ?>" alt="" />
<?php else : ?>
<span class="muted-2-color em09"><?php esc_html_e('未上传', 'aksrt'); ?></span>
<?php endif; ?>
</div>
<input type="hidden" name="rewards_alipay" id="rewards-alipay" value="<?php echo esc_attr($ra); ?>" />
<input type="file" id="rewards-alipay-file" accept="image/*" class="aksrt-reward-upload__file" data-reward-kind="alipay" />
<button type="button" class="btn-primary btn-sm" data-reward-upload="alipay"><?php esc_html_e('选择图片', 'aksrt'); ?></button>
<button type="button" class="btn-sm" data-reward-clear="alipay"><?php esc_html_e('清除', 'aksrt'); ?></button>
</div>
</div>
</div>
<?php endif; ?>
<div class="profile-form__submit">
<button type="submit" class="btn-primary btn-lg" id="profile-save-btn">
<?php esc_html_e('保存修改', 'aksrt'); ?>