feat(admin): express timeline, coupon scope, plate/topic permission fields

Native shipping can query/show express timelines; coupons accept
include/exclude/category product_scope; plate meta gains allow_view and
add_limit; topic list shows visibility column.
This commit is contained in:
2026-07-15 03:09:43 +08:00
parent 713b368475
commit 9099da3a5d
4 changed files with 194 additions and 7 deletions
@@ -52,6 +52,8 @@ class AKSRT_Plate_Meta_Box {
$applications = get_post_meta($post->ID, '_aksrt_moderator_applications', true);
$applications = is_array($applications) ? $applications : [];
}
$allow_view = (string) (get_post_meta($post->ID, '_aksrt_allow_view', true) ?: 'public');
$add_limit = (string) (get_post_meta($post->ID, '_aksrt_add_limit', true) ?: 'all');
$moderator_labels = [];
foreach ($moderator_ids as $uid) {
@@ -61,6 +63,30 @@ class AKSRT_Plate_Meta_Box {
: (string) (int) $uid;
}
?>
<p>
<label for="aksrt_plate_allow_view"><strong><?php esc_html_e('浏览权限', 'aksrt'); ?></strong></label>
<select id="aksrt_plate_allow_view" name="aksrt_plate_allow_view" class="widefat">
<?php foreach ([
'public' => __('公开', 'aksrt'),
'login' => __('登录可见', 'aksrt'),
'moderator' => __('版主可见', 'aksrt'),
] as $k => $label) : ?>
<option value="<?php echo esc_attr($k); ?>" <?php selected($allow_view, $k); ?>><?php echo esc_html($label); ?></option>
<?php endforeach; ?>
</select>
</p>
<p>
<label for="aksrt_plate_add_limit"><strong><?php esc_html_e('发帖权限', 'aksrt'); ?></strong></label>
<select id="aksrt_plate_add_limit" name="aksrt_plate_add_limit" class="widefat">
<?php foreach ([
'all' => __('所有人', 'aksrt'),
'login' => __('登录用户', 'aksrt'),
'moderator' => __('仅版主', 'aksrt'),
] as $k => $label) : ?>
<option value="<?php echo esc_attr($k); ?>" <?php selected($add_limit, $k); ?>><?php echo esc_html($label); ?></option>
<?php endforeach; ?>
</select>
</p>
<p>
<label for="aksrt_plate_moderators"><strong><?php esc_html_e('版主用户 ID', 'aksrt'); ?></strong></label>
<textarea id="aksrt_plate_moderators" name="aksrt_plate_moderators" rows="3" class="widefat" placeholder="1,2,3"><?php echo esc_textarea(implode(',', array_map('intval', $moderator_ids))); ?></textarea>
@@ -111,6 +137,18 @@ class AKSRT_Plate_Meta_Box {
return;
}
$allow_view = isset($_POST['aksrt_plate_allow_view']) ? sanitize_key((string) wp_unslash($_POST['aksrt_plate_allow_view'])) : 'public';
if (!in_array($allow_view, ['public', 'login', 'moderator'], true)) {
$allow_view = 'public';
}
update_post_meta($post_id, '_aksrt_allow_view', $allow_view);
$add_limit = isset($_POST['aksrt_plate_add_limit']) ? sanitize_key((string) wp_unslash($_POST['aksrt_plate_add_limit'])) : 'all';
if (!in_array($add_limit, ['all', 'login', 'moderator'], true)) {
$add_limit = 'all';
}
update_post_meta($post_id, '_aksrt_add_limit', $add_limit);
$raw = isset($_POST['aksrt_plate_moderators']) ? (string) wp_unslash($_POST['aksrt_plate_moderators']) : '';
$ids = preg_split('/[\s,;]+/', $raw) ?: [];
$ids = array_values(array_unique(array_filter(array_map('intval', $ids))));
@@ -46,6 +46,7 @@ class AKSRT_Topic_Admin_List {
$new['aksrt_locked'] = __('锁定', 'aksrt');
$new['aksrt_review'] = __('审核', 'aksrt');
$new['aksrt_bbs_type']= __('类型', 'aksrt');
$new['aksrt_visibility'] = __('可见性', 'aksrt');
$new['aksrt_views'] = __('阅读', 'aksrt');
}
}
@@ -116,6 +117,20 @@ class AKSRT_Topic_Admin_List {
echo esc_html($type === 'question' ? __('提问', 'aksrt') : __('标准', 'aksrt'));
break;
case 'aksrt_visibility':
$visibility = (string) (get_post_meta($post_id, '_aksrt_visibility', true) ?: 'public');
$map = [
'public' => __('公开', 'aksrt'),
'login' => __('登录', 'aksrt'),
'comment' => __('评论', 'aksrt'),
'role' => __('角色', 'aksrt'),
'credits' => __('积分', 'aksrt'),
'pay' => __('付费', 'aksrt'),
'moderator' => __('版主', 'aksrt'),
];
echo esc_html($map[$visibility] ?? $visibility);
break;
case 'aksrt_views':
echo esc_html((string) (int) get_post_meta($post_id, '_aksrt_views', true));
break;