feat(admin): expose shop/forum CPTs on native WP sidebar (Phase 0–1)
Align admin ops entry with zibll: product/plate/topic menus and taxonomies show in the WordPress sidebar when shop_s/bbs_s are enabled, gated by AKSRT_Settings. Add IA map + gap matrix docs for the full native-ops migration path. SPA ops pages remain until Phase 2–3 native pages ship.
This commit is contained in:
+82
-44
@@ -92,16 +92,25 @@ function aksrt_register_forum_cpt() {
|
||||
}
|
||||
}
|
||||
|
||||
// Read custom slugs from settings when available
|
||||
$plate_slug = 'board';
|
||||
$topic_slug = 'topic';
|
||||
// Read custom slugs / names from settings when available
|
||||
$plate_slug = 'board';
|
||||
$topic_slug = 'topic';
|
||||
$forum_enabled = true;
|
||||
$forum_settings = [];
|
||||
if (class_exists('AKSRT_Settings')) {
|
||||
$forum = AKSRT_Settings::get_forum_settings();
|
||||
$plate_slug = !empty($forum['other']['plate_slug']) ? $forum['other']['plate_slug'] : 'board';
|
||||
$topic_slug = !empty($forum['other']['posts_slug']) ? $forum['other']['posts_slug'] : 'topic';
|
||||
$forum_settings = AKSRT_Settings::get_forum_settings();
|
||||
$plate_slug = !empty($forum_settings['other']['plate_slug']) ? $forum_settings['other']['plate_slug'] : 'board';
|
||||
$topic_slug = !empty($forum_settings['other']['posts_slug']) ? $forum_settings['other']['posts_slug'] : 'topic';
|
||||
$forum_enabled = !empty($forum_settings['enabled']);
|
||||
}
|
||||
|
||||
// Forum Board taxonomy
|
||||
// Admin always registers types; menu follows bbs_s (zibll: show when forum on).
|
||||
$forum_show_menu = is_admin() ? $forum_enabled : false;
|
||||
$names = !empty($forum_settings['names']) ? $forum_settings['names'] : [];
|
||||
$forum_label = sanitize_text_field((string) ($names['forum'] ?? __('论坛', 'aksrt')));
|
||||
$posts_label = sanitize_text_field((string) ($names['posts'] ?? __('帖子', 'aksrt')));
|
||||
$topic_label = sanitize_text_field((string) ($names['topic'] ?? __('话题', 'aksrt')));
|
||||
$tag_label = sanitize_text_field((string) ($names['tag'] ?? __('标签', 'aksrt')));
|
||||
// Legacy board taxonomy: keep rewrite/bridge, hide from admin (plate CPT is canonical).
|
||||
register_taxonomy('aksrt_forum_board', 'aksrt_forum_topic', [
|
||||
'labels' => [
|
||||
'name' => __('论坛版块', 'aksrt'),
|
||||
@@ -113,58 +122,72 @@ function aksrt_register_forum_cpt() {
|
||||
],
|
||||
'hierarchical' => true,
|
||||
'public' => true,
|
||||
'show_ui' => false,
|
||||
'show_in_menu' => false,
|
||||
'show_in_rest' => true,
|
||||
'show_admin_column' => true,
|
||||
'show_admin_column' => false,
|
||||
'rewrite' => ['slug' => $plate_slug],
|
||||
]);
|
||||
|
||||
// Forum Tag taxonomy
|
||||
register_taxonomy('aksrt_forum_tag', 'aksrt_forum_topic', [
|
||||
'labels' => [
|
||||
'name' => __('论坛标签', 'aksrt'),
|
||||
'singular_name' => __('标签', 'aksrt'),
|
||||
'search_items' => __('搜索标签', 'aksrt'),
|
||||
'all_items' => __('所有标签', 'aksrt'),
|
||||
'edit_item' => __('编辑标签', 'aksrt'),
|
||||
'add_new_item' => __('添加标签', 'aksrt'),
|
||||
'name' => sprintf(/* translators: %s: forum name */ __('%s标签', 'aksrt'), $forum_label),
|
||||
'singular_name' => $tag_label,
|
||||
'search_items' => sprintf(/* translators: %s: tag name */ __('搜索%s', 'aksrt'), $tag_label),
|
||||
'all_items' => sprintf(/* translators: %s: tag name */ __('所有%s', 'aksrt'), $tag_label),
|
||||
'edit_item' => sprintf(/* translators: %s: tag name */ __('编辑%s', 'aksrt'), $tag_label),
|
||||
'add_new_item' => sprintf(/* translators: %s: tag name */ __('添加%s', 'aksrt'), $tag_label),
|
||||
'menu_name' => $tag_label,
|
||||
],
|
||||
'hierarchical' => false,
|
||||
'public' => true,
|
||||
'show_ui' => true,
|
||||
'show_in_menu' => $forum_show_menu,
|
||||
'show_in_rest' => true,
|
||||
'show_admin_column' => false,
|
||||
'show_admin_column' => true,
|
||||
'rewrite' => ['slug' => 'forum-tag'],
|
||||
]);
|
||||
|
||||
// Forum Topic taxonomy (话题,单选,区别于标签)
|
||||
register_taxonomy('aksrt_forum_topic_cat', 'aksrt_forum_topic', [
|
||||
'labels' => [
|
||||
'name' => __('论坛话题', 'aksrt'),
|
||||
'singular_name' => __('话题', 'aksrt'),
|
||||
'search_items' => __('搜索话题', 'aksrt'),
|
||||
'all_items' => __('所有话题', 'aksrt'),
|
||||
'edit_item' => __('编辑话题', 'aksrt'),
|
||||
'add_new_item' => __('添加话题', 'aksrt'),
|
||||
'name' => sprintf(/* translators: %s: forum name */ __('%s话题', 'aksrt'), $forum_label),
|
||||
'singular_name' => $topic_label,
|
||||
'search_items' => sprintf(/* translators: %s: topic name */ __('搜索%s', 'aksrt'), $topic_label),
|
||||
'all_items' => sprintf(/* translators: %s: topic name */ __('所有%s', 'aksrt'), $topic_label),
|
||||
'edit_item' => sprintf(/* translators: %s: topic name */ __('编辑%s', 'aksrt'), $topic_label),
|
||||
'add_new_item' => sprintf(/* translators: %s: topic name */ __('添加%s', 'aksrt'), $topic_label),
|
||||
'menu_name' => $topic_label,
|
||||
],
|
||||
'hierarchical' => false,
|
||||
'public' => true,
|
||||
'show_ui' => true,
|
||||
'show_in_menu' => $forum_show_menu,
|
||||
'show_in_rest' => true,
|
||||
'show_admin_column' => true,
|
||||
'rewrite' => ['slug' => 'forum-topic'],
|
||||
]);
|
||||
|
||||
// Forum Topic CPT
|
||||
// Forum Topic CPT — native sidebar (zibll: forum_post @ pos 40)
|
||||
register_post_type('aksrt_forum_topic', [
|
||||
'labels' => [
|
||||
'name' => __('论坛主题', 'aksrt'),
|
||||
'singular_name' => __('主题', 'aksrt'),
|
||||
'add_new_item' => __('发布新主题', 'aksrt'),
|
||||
'edit_item' => __('编辑主题', 'aksrt'),
|
||||
'view_item' => __('查看主题', 'aksrt'),
|
||||
'name' => $forum_label . $posts_label,
|
||||
'singular_name' => $posts_label,
|
||||
'add_new' => sprintf(/* translators: %s: posts name */ __('添加%s', 'aksrt'), $posts_label),
|
||||
'add_new_item' => sprintf(/* translators: %s: posts name */ __('发布新%s', 'aksrt'), $posts_label),
|
||||
'edit_item' => sprintf(/* translators: %s: posts name */ __('编辑%s', 'aksrt'), $posts_label),
|
||||
'view_item' => sprintf(/* translators: %s: posts name */ __('查看%s', 'aksrt'), $posts_label),
|
||||
'all_items' => sprintf(/* translators: %s: posts name */ __('所有%s', 'aksrt'), $posts_label),
|
||||
'menu_name' => $forum_label . $posts_label,
|
||||
],
|
||||
'public' => true,
|
||||
'show_ui' => true,
|
||||
'show_in_menu' => $forum_show_menu,
|
||||
'show_in_rest' => true,
|
||||
'has_archive' => true,
|
||||
'menu_icon' => 'dashicons-comments',
|
||||
'menu_position' => 40,
|
||||
'menu_icon' => 'dashicons-buddicons-topics',
|
||||
'supports' => ['title', 'editor', 'author', 'comments', 'thumbnail', 'excerpt'],
|
||||
'capability_type' => 'post',
|
||||
'rewrite' => ['slug' => $topic_slug],
|
||||
@@ -186,50 +209,65 @@ function aksrt_register_forum_plate_cpt() {
|
||||
}
|
||||
}
|
||||
|
||||
$plate_slug = 'board';
|
||||
$plate_slug = 'board';
|
||||
$forum_enabled = true;
|
||||
$forum = [];
|
||||
if (class_exists('AKSRT_Settings')) {
|
||||
$forum = AKSRT_Settings::get_forum_settings();
|
||||
$plate_slug = !empty($forum['other']['plate_slug']) ? $forum['other']['plate_slug'] : 'board';
|
||||
$forum = AKSRT_Settings::get_forum_settings();
|
||||
$plate_slug = !empty($forum['other']['plate_slug']) ? $forum['other']['plate_slug'] : 'board';
|
||||
$forum_enabled = !empty($forum['enabled']);
|
||||
}
|
||||
$forum_show_menu = is_admin() ? $forum_enabled : false;
|
||||
$names = !empty($forum['names']) ? $forum['names'] : [];
|
||||
$forum_label = sanitize_text_field((string) ($names['forum'] ?? __('论坛', 'aksrt')));
|
||||
$plate_label = sanitize_text_field((string) ($names['plate'] ?? __('版块', 'aksrt')));
|
||||
|
||||
// Plate category taxonomy (分区)
|
||||
register_taxonomy('aksrt_plate_cat', 'aksrt_forum_plate', [
|
||||
'labels' => [
|
||||
'name' => __('板块分区', 'aksrt'),
|
||||
'name' => sprintf(/* translators: %s: plate name */ __('%s分区', 'aksrt'), $plate_label),
|
||||
'singular_name' => __('分区', 'aksrt'),
|
||||
'search_items' => __('搜索分区', 'aksrt'),
|
||||
'all_items' => __('所有分区', 'aksrt'),
|
||||
'edit_item' => __('编辑分区', 'aksrt'),
|
||||
'add_new_item' => __('添加分区', 'aksrt'),
|
||||
'menu_name' => __('分区', 'aksrt'),
|
||||
],
|
||||
'hierarchical' => true,
|
||||
'public' => true,
|
||||
'show_ui' => true,
|
||||
'show_in_menu' => $forum_show_menu,
|
||||
'show_in_rest' => true,
|
||||
'show_admin_column' => true,
|
||||
'rewrite' => ['slug' => 'plate-cat'],
|
||||
]);
|
||||
|
||||
// Plate CPT (板块)
|
||||
// Plate CPT (板块) — native sidebar (zibll: plate @ pos 40)
|
||||
register_post_type('aksrt_forum_plate', [
|
||||
'labels' => [
|
||||
'name' => __('论坛版块', 'aksrt'),
|
||||
'singular_name' => __('版块', 'aksrt'),
|
||||
'add_new_item' => __('创建版块', 'aksrt'),
|
||||
'edit_item' => __('编辑版块', 'aksrt'),
|
||||
'view_item' => __('查看版块', 'aksrt'),
|
||||
'search_items' => __('搜索版块', 'aksrt'),
|
||||
'not_found' => __('未找到版块', 'aksrt'),
|
||||
'not_found_in_trash' => __('回收站中未找到版块', 'aksrt'),
|
||||
'name' => $forum_label . $plate_label,
|
||||
'singular_name' => $plate_label,
|
||||
'add_new' => sprintf(/* translators: %s: plate name */ __('添加%s', 'aksrt'), $plate_label),
|
||||
'add_new_item' => sprintf(/* translators: %s: plate name */ __('创建%s', 'aksrt'), $plate_label),
|
||||
'edit_item' => sprintf(/* translators: %s: plate name */ __('编辑%s', 'aksrt'), $plate_label),
|
||||
'view_item' => sprintf(/* translators: %s: plate name */ __('查看%s', 'aksrt'), $plate_label),
|
||||
'search_items' => sprintf(/* translators: %s: plate name */ __('搜索%s', 'aksrt'), $plate_label),
|
||||
'not_found' => sprintf(/* translators: %s: plate name */ __('未找到%s', 'aksrt'), $plate_label),
|
||||
'not_found_in_trash' => sprintf(/* translators: %s: plate name */ __('回收站中未找到%s', 'aksrt'), $plate_label),
|
||||
'all_items' => sprintf(/* translators: %s: plate name */ __('所有%s', 'aksrt'), $plate_label),
|
||||
'menu_name' => $forum_label . $plate_label,
|
||||
],
|
||||
'public' => true,
|
||||
'hierarchical' => true,
|
||||
'show_ui' => true,
|
||||
'show_in_menu' => $forum_show_menu,
|
||||
'show_in_rest' => true,
|
||||
'has_archive' => false,
|
||||
'menu_icon' => 'dashicons-grid-view',
|
||||
'menu_position' => 40,
|
||||
'menu_icon' => 'dashicons-buddicons-forums',
|
||||
'supports' => ['title', 'editor', 'author', 'excerpt', 'thumbnail', 'page-attributes'],
|
||||
'capability_type' => 'post',
|
||||
'rewrite' => ['slug' => $plate_slug, 'with_front' => false],
|
||||
'show_in_menu' => false,
|
||||
]);
|
||||
|
||||
// Keep aksrt_forum_topic assignable to plates via taxonomy bridge
|
||||
|
||||
Reference in New Issue
Block a user