feat(admin): order detail view, invite-code batching, product tag term fields

Add native order detail page under 支付中心订单, standalone invite-code
batch generate/disable on users.php, and aksrt_product_tag taxonomy form
fields. Source only; no SPA build artifacts.
This commit is contained in:
kate522 committed 2026-07-15 02:32:25 +08:00
1 parent 1770e8e0db
commit e2f7fcad89
3 files changed
+357 -14

No files matched your search

@@ -45,6 +45,12 @@ class AKSRT_Shop_Term_Meta {
add_action('aksrt_product_cat_edit_form_fields', [$this, 'render_cat_edit_fields'], 10, 1);
add_action('created_aksrt_product_cat', [$this, 'save_cat_term_fields']);
add_action('edited_aksrt_product_cat', [$this, 'save_cat_term_fields']);
// Product tag display fields.
add_action('aksrt_product_tag_add_form_fields', [$this, 'render_tag_add_fields']);
add_action('aksrt_product_tag_edit_form_fields', [$this, 'render_tag_edit_fields'], 10, 1);
add_action('created_aksrt_product_tag', [$this, 'save_tag_term_fields']);
add_action('edited_aksrt_product_tag', [$this, 'save_tag_term_fields']);
}
// ─── Taxonomy Registration ───────────────────────────────────
@@ -677,4 +683,69 @@ class AKSRT_Shop_Term_Meta {
update_term_meta($term_id, $key, $value);
}
}
public function render_tag_add_fields(): void {
foreach ($this->get_tag_field_definitions() as $key => $def) {
echo '<div class="form-field">';
echo '<label for="' . esc_attr($key) . '">' . esc_html((string) ($def['description'] ?? $key)) . '</label>';
$this->render_tag_field_control($key, $def['default'] ?? '');
echo '</div>';
}
}
public function render_tag_edit_fields($term): void {
if (!($term instanceof WP_Term)) {
return;
}
foreach ($this->get_tag_field_definitions() as $key => $def) {
$value = get_term_meta($term->term_id, $key, true);
if ($value === '' || $value === false) {
$value = $def['default'] ?? '';
}
echo '<tr class="form-field"><th scope="row"><label for="' . esc_attr($key) . '">' . esc_html((string) ($def['description'] ?? $key)) . '</label></th><td>';
$this->render_tag_field_control($key, $value);
echo '</td></tr>';
}
}
/**
* @param mixed $value
*/
private function render_tag_field_control(string $key, $value): void {
$val = (string) $value;
if ($key === 'shop_tag_is_important') {
echo '<label><input type="checkbox" name="' . esc_attr($key) . '" value="1" ' . checked($val, '1', false) . '> ' . esc_html__('启用', 'aksrt') . '</label>';
return;
}
$type = $key === 'shop_tag_priority' ? 'number' : 'text';
printf(
'<input type="%s" class="regular-text" name="%s" id="%s" value="%s" />',
esc_attr($type),
esc_attr($key),
esc_attr($key),
esc_attr($val)
);
}
public function save_tag_term_fields(int $term_id): void {
if (!current_user_can('manage_categories')) {
return;
}
foreach ($this->get_tag_field_definitions() as $key => $def) {
if ($key === 'shop_tag_is_important') {
$raw = isset($_POST[$key]) ? '1' : '';
} else {
if (!isset($_POST[$key])) {
continue;
}
$raw = wp_unslash($_POST[$key]);
}
if (isset($def['sanitize']) && is_callable($def['sanitize'])) {
$value = call_user_func($def['sanitize'], $raw);
} else {
$value = sanitize_text_field((string) $raw);
}
update_term_meta($term_id, $key, $value);
}
}
}