diff --git a/functions.php b/functions.php index 36ac10c3..e5e06080 100644 --- a/functions.php +++ b/functions.php @@ -311,6 +311,11 @@ if (is_admin() && class_exists('AKSRT_Plate_Meta_Box')) { if (is_admin() && class_exists('AKSRT_Topic_Admin_List')) { AKSRT_Topic_Admin_List::get_instance()->init(); } +// 论坛帖子治理 meta box +if (is_admin() && class_exists('AKSRT_Topic_Meta_Box')) { + AKSRT_Topic_Meta_Box::get_instance()->init(); +} + diff --git a/inc/bootstrap.php b/inc/bootstrap.php index 6f09a3ec..21fcc75a 100644 --- a/inc/bootstrap.php +++ b/inc/bootstrap.php @@ -324,6 +324,7 @@ require_once AKSRT_DIR . '/inc/classes/shop/class-aksrt-product-meta-box.php'; require_once AKSRT_DIR . '/inc/classes/shop/class-aksrt-product-variants-meta-box.php'; require_once AKSRT_DIR . '/inc/classes/forum/class-aksrt-plate-meta-box.php'; require_once AKSRT_DIR . '/inc/classes/forum/class-aksrt-topic-admin-list.php'; +require_once AKSRT_DIR . '/inc/classes/forum/class-aksrt-topic-meta-box.php'; require_once AKSRT_DIR . '/inc/classes/shop/shop-traits/trait-aksrt-shop-part-1.php'; require_once AKSRT_DIR . '/inc/classes/shop/shop-traits/trait-aksrt-shop-part-2.php'; require_once AKSRT_DIR . '/inc/classes/shop/shop-traits/trait-aksrt-shop-part-3.php'; diff --git a/inc/classes/class-aksrt-shop-term-meta.php b/inc/classes/class-aksrt-shop-term-meta.php index 3f1a7568..b6873863 100644 --- a/inc/classes/class-aksrt-shop-term-meta.php +++ b/inc/classes/class-aksrt-shop-term-meta.php @@ -39,6 +39,12 @@ class AKSRT_Shop_Term_Meta { add_action('shop_discount_edit_form_fields', [$this, 'render_discount_edit_fields'], 10, 1); add_action('created_shop_discount', [$this, 'save_discount_term_fields']); add_action('edited_shop_discount', [$this, 'save_discount_term_fields']); + + // Product category inheritance fields. + add_action('aksrt_product_cat_add_form_fields', [$this, 'render_cat_add_fields']); + 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']); } // ─── Taxonomy Registration ─────────────────────────────────── @@ -565,4 +571,110 @@ class AKSRT_Shop_Term_Meta { update_term_meta($term_id, $key, $value); } } + + public function render_cat_add_fields(): void { + foreach ($this->get_cat_field_definitions() as $key => $def) { + echo '
+ + +
++ + +
+
+
+
+
+ + +
++ + +
++ + +
++ + +
++ + +
++ + +
+ post_type !== 'aksrt_forum_topic' || !current_user_can('edit_post', $post_id)) { + return; + } + + $plate_id = isset($_POST['aksrt_plate_id']) ? max(0, (int) $_POST['aksrt_plate_id']) : 0; + update_post_meta($post_id, '_aksrt_plate_id', $plate_id); + + $sticky = isset($_POST['aksrt_sticky']) ? max(0, min(3, (int) $_POST['aksrt_sticky'])) : 0; + update_post_meta($post_id, '_aksrt_sticky', $sticky); + update_post_meta($post_id, '_aksrt_locked', !empty($_POST['aksrt_locked']) ? 1 : 0); + update_post_meta($post_id, '_aksrt_featured', !empty($_POST['aksrt_featured']) ? 1 : 0); + + $review = isset($_POST['aksrt_review_status']) ? sanitize_key((string) wp_unslash($_POST['aksrt_review_status'])) : 'approved'; + if (!in_array($review, ['approved', 'pending', 'rejected'], true)) { + $review = 'approved'; + } + update_post_meta($post_id, '_aksrt_review_status', $review); + + $bbs_type = isset($_POST['aksrt_bbs_type']) ? sanitize_key((string) wp_unslash($_POST['aksrt_bbs_type'])) : 'standard'; + if (!in_array($bbs_type, ['standard', 'question'], true)) { + $bbs_type = 'standard'; + } + update_post_meta($post_id, '_aksrt_bbs_type', $bbs_type); + + $visibility = isset($_POST['aksrt_visibility']) ? sanitize_key((string) wp_unslash($_POST['aksrt_visibility'])) : 'public'; + update_post_meta($post_id, '_aksrt_visibility', $visibility); + + $allow_view = isset($_POST['aksrt_allow_view']) ? sanitize_key((string) wp_unslash($_POST['aksrt_allow_view'])) : 'public'; + update_post_meta($post_id, '_aksrt_allow_view', $allow_view); + + update_post_meta($post_id, '_aksrt_pay_price', isset($_POST['aksrt_pay_price']) ? max(0, (float) wp_unslash($_POST['aksrt_pay_price'])) : 0); + update_post_meta($post_id, '_aksrt_pay_credits', isset($_POST['aksrt_pay_credits']) ? max(0, (int) wp_unslash($_POST['aksrt_pay_credits'])) : 0); + + // Keep board taxonomy bridge roughly in sync when plate selected. + if ($plate_id > 0 && taxonomy_exists('aksrt_forum_board')) { + $slug = 'plate-' . $plate_id; + $term = get_term_by('slug', $slug, 'aksrt_forum_board'); + if (!$term) { + $title = get_the_title($plate_id) ?: $slug; + $created = wp_insert_term($title, 'aksrt_forum_board', ['slug' => $slug]); + if (!is_wp_error($created) && !empty($created['term_id'])) { + $term_id = (int) $created['term_id']; + } else { + $term_id = 0; + } + } else { + $term_id = (int) $term->term_id; + } + if ($term_id > 0) { + wp_set_object_terms($post_id, [$term_id], 'aksrt_forum_board', false); + } + } + } +}