feat(admin): deeper order/income filters, post pay-type, topic sales meta

Add order user/payment filters, income/rebate user_id filter, posts list
pay_type dropdown, topic virtual_sales/coupon meta, and forum unlock
facade methods used by hidecontent/payshow.
This commit is contained in:
kate522 committed 2026-07-15 11:35:35 +08:00
1 parent 8d31e65ccd
commit f197745830
11 files changed
+222 -30

No files matched your search

+68
View File
@@ -35,6 +35,9 @@ class AKSRT_Post_Meta_Box {
add_action('quick_edit_custom_box', [$this, 'render_quick_edit'], 10, 2);
add_action('bulk_edit_custom_box', [$this, 'render_quick_edit'], 10, 2);
add_action('admin_footer-edit.php', [$this, 'admin_quick_edit_script']);
// Pay-type dropdown on posts list (zibll zibpay_type filter).
add_action('restrict_manage_posts', [$this, 'render_pay_type_filter']);
add_action('pre_get_posts', [$this, 'filter_posts_by_pay_type']);
}
/**
@@ -539,6 +542,71 @@ class AKSRT_Post_Meta_Box {
echo '</div>';
}
/**
* Dropdown filter for content pay_type on edit.php?post_type=post.
*/
public function render_pay_type_filter(string $post_type): void {
if ($post_type !== 'post' || !class_exists('AKSRT_Domain_Model')) {
return;
}
$current = isset($_GET['aksrt_pay_type']) ? sanitize_key((string) wp_unslash($_GET['aksrt_pay_type'])) : '';
$labels = AKSRT_Domain_Model::pay_type_labels();
echo '<select name="aksrt_pay_type">';
echo '<option value="">' . esc_html__('全部付费类型', 'aksrt') . '</option>';
foreach ($labels as $key => $label) {
printf(
'<option value="%s"%s>%s</option>',
esc_attr($key),
selected($current, $key, false),
esc_html($label)
);
}
echo '</select>';
}
/**
* Apply aksrt_pay_type filter via denormalized _aksrt_pay_type meta.
*/
public function filter_posts_by_pay_type(\WP_Query $query): void {
if (!is_admin() || !$query->is_main_query()) {
return;
}
$screen_post_type = $query->get('post_type');
if ($screen_post_type !== 'post') {
return;
}
if (empty($_GET['aksrt_pay_type'])) {
return;
}
$pay_type = sanitize_key((string) wp_unslash($_GET['aksrt_pay_type']));
if ($pay_type === '' || !class_exists('AKSRT_Domain_Model')) {
return;
}
$pay_type = AKSRT_Domain_Model::normalize_pay_type($pay_type);
$meta_query = (array) $query->get('meta_query');
if ($pay_type === AKSRT_Domain_Model::PAY_TYPE_NO) {
$meta_query[] = [
'relation' => 'OR',
[
'key' => AKSRT_Domain_Model::PAY_TYPE_KEY,
'value' => AKSRT_Domain_Model::PAY_TYPE_NO,
'compare' => '=',
],
[
'key' => AKSRT_Domain_Model::PAY_TYPE_KEY,
'compare' => 'NOT EXISTS',
],
];
} else {
$meta_query[] = [
'key' => AKSRT_Domain_Model::PAY_TYPE_KEY,
'value' => $pay_type,
'compare' => '=',
];
}
$query->set('meta_query', $meta_query);
}
/**
* §3.8 Render quick edit and bulk edit fields.
*/