feat(topics): restore topic taxonomy workflow

This commit is contained in:
kate522 committed 2026-11-10 22:31:11 +08:00
1 parent f3dd1ec3b1
commit a254cbd3e9
59 files changed
+771 -192

No files matched your search

+3 -6
View File
@@ -3,11 +3,8 @@
* Admin post list enhancements: interaction + sales columns and the
* quick/bulk edit fields behind them.
*
* Mirrors the reference theme's post list: a sortable “销售数据” column, a
* product-type filter, and four quick-edit field groups (interaction data,
* article config, pay parameters, custom filters). The reference theme hooks
* those boxes onto its topics taxonomy column; this project has no topics
* taxonomy, so they hang off the interaction-data column instead.
* Adds a sortable sales column, a product-type filter, and quick-edit fields
* for interaction data, article config, pay parameters, and custom filters.
*
* @package Jio
*/
@@ -280,7 +277,7 @@ class PostListEnhance {
* @param string $post_type
*/
public function render_edit_boxes($column_name, $post_type): void {
if ($post_type !== 'post' || (string) $column_name !== self::COLUMN_STATS) {
if ($post_type !== 'post' || (string) $column_name !== 'taxonomy-topics') {
return;
}
+5 -4
View File
@@ -21,7 +21,7 @@ class PageDisplayController extends ControllerBase {
}
public function register_routes(): void {
register_rest_route(self::API_NAMESPACE, '/settings/schema/page_display/search/(?P<source>posts|categories|tags)', [
register_rest_route(self::API_NAMESPACE, '/settings/schema/page_display/search/(?P<source>posts|categories|tags|topics|terms)', [
'methods' => 'GET',
'callback' => [$this, 'search_options'],
'permission_callback' => [$this, 'check_permission'],
@@ -52,7 +52,7 @@ class PageDisplayController extends ControllerBase {
return $this->success(['data' => $items]);
}
$taxonomy = $source === 'categories' ? 'category' : 'post_tag';
$taxonomy = ['categories' => 'category', 'tags' => 'post_tag', 'topics' => 'topics', 'terms' => ['category', 'topics']][$source] ?? 'category';
$terms = get_terms([
'taxonomy' => $taxonomy,
'hide_empty' => false,
@@ -64,8 +64,9 @@ class PageDisplayController extends ControllerBase {
if (is_wp_error($terms)) {
return $this->error($terms->get_error_message(), 400);
}
$items = array_map(static function ($term): array {
return ['label' => $term->name, 'value' => (int) $term->term_id];
$items = array_map(static function ($term) use ($source): array {
$label = $source === 'terms' ? ($term->taxonomy === 'topics' ? __('专题:', 'jio') : __('分类:', 'jio')) . $term->name : $term->name;
return ['label' => $label, 'value' => (int) $term->term_id];
}, $terms);
return $this->success(['data' => $items]);
}
+2 -1
View File
@@ -297,12 +297,13 @@ class GlobalSchema {
['key' => 'search_custom_key_s', 'label' => '自定义匹配范围', 'type' => 'switch', 'default' => true, 'help' => '启用后可配置搜索匹配字段范围(标题/内容/分类/标签等)'],
['key' => 'search_custom_key', 'label' => '匹配字段', 'type' => 'checkbox', 'default' => ['title', 'content', 'excerpt', 'category', 'post_tag'], 'options' => [
['label' => '标题', 'value' => 'title'], ['label' => '内容', 'value' => 'content'], ['label' => '简介', 'value' => 'excerpt'],
['label' => '分类', 'value' => 'category'], ['label' => '标签', 'value' => 'post_tag'],
['label' => '分类', 'value' => 'category'], ['label' => '标签', 'value' => 'post_tag'], ['label' => '专题', 'value' => 'topics'],
['label' => '评论', 'value' => 'coment'], ['label' => '作者昵称', 'value' => 'user'],
]],
['key' => 'search_facets', 'label' => '搜索筛选', 'type' => 'fieldset', 'sanitize_type' => 'array', 'default' => [], 'dependsOn' => ['key' => 'search_ms_s', 'value' => false], 'help' => '搜索结果中显示的筛选列表;启用 Meilisearch 后由搜索引擎生成关联筛选。', 'fields' => [
['key' => 'category', 'label' => '[文章] 分类', 'type' => 'taxonomy_select', 'taxonomy' => 'category', 'multiple' => true, 'default' => []],
['key' => 'post_tag', 'label' => '[文章] 标签', 'type' => 'taxonomy_select', 'taxonomy' => 'post_tag', 'multiple' => true, 'default' => []],
['key' => 'topics', 'label' => '[文章] 专题', 'type' => 'taxonomy_select', 'taxonomy' => 'topics', 'multiple' => true, 'default' => []],
]],
]],
['key' => 'category-search', 'title' => '分类搜索', 'fields' => [
@@ -33,6 +33,7 @@ class SchemaPostListList {
['label' => '首页', 'value' => 'home'],
['label' => '分类页', 'value' => 'cat'],
['label' => '标签页', 'value' => 'tag'],
['label' => '专题页', 'value' => 'topics'],
]],
],
],
@@ -49,10 +50,11 @@ class SchemaPostListList {
['label' => '点赞数', 'value' => 'like'],
['label' => '评论', 'value' => 'comm'],
]],
['key' => 'list_badge_show', 'label' => '显示列表标签', 'type' => 'checkbox', 'default' => ['pay', 'cat', 'tag'], 'options' => [
['key' => 'list_badge_show', 'label' => '显示列表标签', 'type' => 'checkbox', 'default' => ['pay', 'tag', 'topics', 'cat'], 'options' => [
['label' => '付费信息', 'value' => 'pay'],
['label' => '分类', 'value' => 'cat'],
['label' => '标签', 'value' => 'tag'],
['label' => '专题', 'value' => 'topics'],
]],
],
],
@@ -72,8 +74,9 @@ class SchemaPostListList {
], 'help' => '文字、自动图文和多图模式仅在开启侧栏的页面有效。'],
['key' => 'list_card_home', 'label' => '首页列表卡片模式', 'type' => 'switch', 'default' => false, 'dependsOn' => ['key' => 'list_type', 'not' => true, 'value' => 'card']],
['key' => 'list_card_tag', 'label' => '标签页列表卡片模式', 'type' => 'switch', 'default' => false, 'dependsOn' => ['key' => 'list_type', 'not' => true, 'value' => 'card']],
['key' => 'list_card_topics', 'label' => '专题页列表卡片模式', 'type' => 'switch', 'default' => false, 'dependsOn' => ['key' => 'list_type', 'not' => true, 'value' => 'card']],
['key' => 'list_card_author', 'label' => '用户页列表卡片模式', 'type' => 'switch', 'default' => false, 'dependsOn' => ['key' => 'list_type', 'not' => true, 'value' => 'card']],
['key' => 'list_card_cat', 'label' => '分类页自定义卡片模式', 'type' => 'taxonomy_select', 'taxonomy' => 'category', 'multiple' => true, 'default' => [], 'dependsOn' => ['key' => 'list_type', 'not' => true, 'value' => 'card']],
['key' => 'list_card_cat', 'label' => '分类、专题页自定义卡片模式', 'type' => 'taxonomy_select', 'taxonomy' => 'category,topics', 'multiple' => true, 'default' => [], 'dependsOn' => ['key' => 'list_type', 'not' => true, 'value' => 'card']],
[
'key' => 'list_list_option',
'label' => '列表模式 UI 配置',
+25 -4
View File
@@ -22,6 +22,7 @@ class SchemaPageDisplay {
'homepage' => self::homepage(),
'category' => self::category(),
'tag' => self::tag(),
'topics' => self::topics(),
'user-home' => self::user_home(),
'other' => self::other(),
],
@@ -60,7 +61,7 @@ class SchemaPageDisplay {
private static function header_components(): array {
return self::section('header-components', '顶部多功能组件', [
self::notice('顶部多功能组件显示在导航栏下方,支持视频、图片、幻灯片、搜索和图标卡片;各组件可按电脑端、移动端单独启用。'),
self::field('header_slider_show', '启用顶部多功能组件', 'checkbox', [], ['description' => '选择允许显示组件的页面;未选择任何页面时,前端不会显示。', 'options' => self::options(['home' => '首页', 'category' => '分类页', 'tag' => '标签页', 'author' => '公开用户主页', 'user_center' => '用户中心', 'single' => '文章页', 'search' => '搜索页', 'page' => '其它页面'])]),
self::field('header_slider_show', '启用顶部多功能组件', 'checkbox', [], ['description' => '选择允许显示组件的页面;未选择任何页面时,前端不会显示。', 'options' => self::options(['home' => '首页', 'category' => '分类页', 'tag' => '标签页', 'topics' => '专题页', 'author' => '公开用户主页', 'user_center' => '用户中心', 'single' => '文章页', 'search' => '搜索页', 'page' => '其它页面'])]),
self::field('header_slider_show_type', '顶部多功能组件的显示规则', 'radio', '', ['dependsOn' => self::not_empty('header_slider_show'), 'inline' => true, 'options' => self::options(['' => '全部显示', 'only_pc' => '仅在PC端显示', 'only_sm' => '仅在移动端显示'])]),
self::field('header_slider_nav_color', '导航栏文字颜色', 'color', '#ffffff', ['dependsOn' => self::not_empty('header_slider_show')]),
self::field('header_slider', '背景内容', 'group', self::header_slider_defaults(), ['dependsOn' => self::not_empty('header_slider_show'), 'min' => 1, 'button_title' => '添加背景项目', 'fields' => self::slider_item_fields()]),
@@ -112,7 +113,7 @@ class SchemaPageDisplay {
self::field('index_list_title', '显示标题', 'textarea', '', ['dependsOn' => self::enabled('home_posts_list_s'), 'sanitize_type' => 'html', 'rows' => 1]),
self::field('home_exclude_posts', '排除文章', 'async_select', '', ['dependsOn' => self::enabled('home_posts_list_s'), 'source' => 'posts', 'multiple' => true, 'sortable' => true]),
self::field('home_exclude_cats', '排除分类', 'async_select', '', ['dependsOn' => self::enabled('home_posts_list_s'), 'source' => 'categories', 'multiple' => true, 'sortable' => true]),
self::field('home_lists', '更多栏目', 'group', [], ['dependsOn' => self::enabled('home_posts_list_s'), 'button_title' => '添加栏目', 'fields' => [self::field('title', '自定义标题', 'textarea', '', ['sanitize_type' => 'html', 'rows' => 1]), self::field('term_id', '显示内容', 'async_select', '', ['source' => 'categories']), self::field('orderby', '排序方式设置', 'select', '', ['options' => self::post_order_options(true)])]]),
self::field('home_lists', '更多栏目', 'group', [], ['dependsOn' => self::enabled('home_posts_list_s'), 'button_title' => '添加栏目', 'fields' => [self::field('title', '自定义标题', 'textarea', '', ['sanitize_type' => 'html', 'rows' => 1]), self::field('term_id', '显示内容', 'async_select', '', ['source' => 'terms']), self::field('orderby', '排序方式设置', 'select', '', ['options' => self::post_order_options(true)])]]),
]);
}
@@ -123,11 +124,13 @@ class SchemaPageDisplay {
self::field('cat_default_cover', '封面图', 'upload', self::asset('assets/img/user_t.jpg'), ['dependsOn' => self::enabled('page_cover_cat_s'), 'help' => '默认封面图,建议尺寸2000x800。']),
self::field('cat_orderby_s', '排序方式按钮', 'switcher', true),
self::field('cat_orderby_option', '排序方式设置', 'fieldset', [], ['dependsOn' => self::enabled('cat_orderby_s'), 'fields' => self::orderby_fields()]),
self::notice('AJAX筛选菜单列表:显示分类、标签菜单,通过 AJAX 获取内容。'),
self::notice('AJAX筛选菜单列表:显示分类、标签、专题菜单,通过 AJAX 获取内容。'),
self::field('ajax_list_cat_cat', '分类筛选', 'switcher', true),
self::field('ajax_list_option_cat_cat', '分类筛选设置', 'fieldset', [], ['dependsOn' => self::enabled('ajax_list_cat_cat'), 'fields' => self::ajax_fields('categories')]),
self::field('ajax_list_cat_tag', '标签筛选', 'switcher', false),
self::field('ajax_list_option_cat_tag', '标签筛选设置', 'fieldset', [], ['dependsOn' => self::enabled('ajax_list_cat_tag'), 'fields' => self::ajax_fields('tags')]),
self::field('ajax_list_cat_topics', '专题筛选', 'switcher', false),
self::field('ajax_list_option_cat_topics', '专题筛选设置', 'fieldset', [], ['dependsOn' => self::enabled('ajax_list_cat_topics'), 'fields' => self::ajax_fields('topics')]),
]);
}
@@ -138,11 +141,29 @@ class SchemaPageDisplay {
self::field('tag_default_cover', '封面图', 'upload', self::asset('assets/img/user_t.jpg'), ['dependsOn' => self::enabled('page_cover_tag_s'), 'help' => '默认封面图,建议尺寸2000x800。']),
self::field('tag_orderby_s', '排序方式按钮', 'switcher', true),
self::field('tag_orderby_option', '排序方式设置', 'fieldset', [], ['dependsOn' => self::enabled('tag_orderby_s'), 'fields' => self::orderby_fields()]),
self::notice('AJAX筛选菜单列表:显示分类、标签菜单,通过 AJAX 获取内容。'),
self::notice('AJAX筛选菜单列表:显示分类、标签、专题菜单,通过 AJAX 获取内容。'),
self::field('ajax_list_tag_cat', '分类筛选', 'switcher', false),
self::field('ajax_list_option_tag_cat', '分类筛选设置', 'fieldset', [], ['dependsOn' => self::enabled('ajax_list_tag_cat'), 'fields' => self::ajax_fields('categories')]),
self::field('ajax_list_tag_tag', '标签筛选', 'switcher', true),
self::field('ajax_list_option_tag_tag', '标签筛选设置', 'fieldset', [], ['dependsOn' => self::enabled('ajax_list_tag_tag'), 'fields' => self::ajax_fields('tags')]),
self::field('ajax_list_tag_topics', '专题筛选', 'switcher', false),
self::field('ajax_list_option_tag_topics', '专题筛选设置', 'fieldset', [], ['dependsOn' => self::enabled('ajax_list_tag_topics'), 'fields' => self::ajax_fields('topics')]),
]);
}
private static function topics(): array {
return self::section('topics', '专题页面', [
self::field('topics_post_count_s', '显示文章数量', 'switcher', true),
self::field('topics_default_cover', '封面图', 'upload', self::asset('assets/img/user_t.jpg'), ['help' => '默认封面图,建议尺寸2000x800。']),
self::field('topics_orderby_s', '排序方式按钮', 'switcher', true),
self::field('topics_orderby_option', '排序方式设置', 'fieldset', [], ['dependsOn' => self::enabled('topics_orderby_s'), 'fields' => self::orderby_fields()]),
self::notice('AJAX筛选菜单列表:显示分类、标签、专题菜单,通过 AJAX 获取内容。'),
self::field('ajax_list_topics_cat', '分类筛选', 'switcher', false),
self::field('ajax_list_option_topics_cat', '分类筛选设置', 'fieldset', [], ['dependsOn' => self::enabled('ajax_list_topics_cat'), 'fields' => self::ajax_fields('categories')]),
self::field('ajax_list_topics_tag', '标签筛选', 'switcher', false),
self::field('ajax_list_option_topics_tag', '标签筛选设置', 'fieldset', [], ['dependsOn' => self::enabled('ajax_list_topics_tag'), 'fields' => self::ajax_fields('tags')]),
self::field('ajax_list_topics_topics', '专题筛选', 'switcher', true),
self::field('ajax_list_option_topics_topics', '专题筛选设置', 'fieldset', [], ['dependsOn' => self::enabled('ajax_list_topics_topics'), 'fields' => self::ajax_fields('topics')]),
]);
}
+8
View File
@@ -136,6 +136,7 @@ class SchemaPostList {
['key' => 'custom_filter_show', 'label' => '高级筛选默认显示', 'type' => 'checkbox', 'default' => [], 'options' => [
['label' => '分类页面显示', 'value' => 'cat'],
['label' => '标签页面显示', 'value' => 'tag'],
['label' => '专题页面显示', 'value' => 'topics'],
], 'description' => '勾选后将会在对应页面默认显示全部筛选,您可以在下方为单独的分类添加自定义筛选'],
['key' => 'custom_filter', 'label' => '自定义高级筛选明细', 'type' => 'repeater', 'default' => [], 'addText' => '添加筛选类别', 'description' => '添加筛选类型及明细', 'fields' => [
['key' => 'name', 'label' => '类型名称', 'type' => 'input', 'default' => ''],
@@ -157,6 +158,11 @@ class SchemaPostList {
['key' => 'lists', 'label' => '按钮列表', 'type' => 'async_select', 'source' => 'tags', 'multiple' => true, 'sortable' => true, 'default' => [], 'description' => '选择并排序需要显示的按钮'],
['key' => 'dropdown', 'label' => '下拉列表', 'type' => 'switch', 'default' => false, 'description' => '用下拉框显示更多内容'],
]],
['key' => 'topics_s', 'label' => '专题筛选', 'type' => 'switch', 'default' => false, 'description' => '在所选分类页显示的专题筛选列表'],
['key' => 'topics_lists', 'label' => ' ', 'type' => 'fieldset', 'default' => ['lists' => [], 'dropdown' => false], 'dependsOn' => ['key' => 'topics_s', 'value' => true], 'fields' => [
['key' => 'lists', 'label' => '按钮列表', 'type' => 'async_select', 'source' => 'topics', 'multiple' => true, 'sortable' => true, 'default' => []],
['key' => 'dropdown', 'label' => '下拉列表', 'type' => 'switch', 'default' => false],
]],
['key' => 'orderby_s', 'label' => '排序方式', 'type' => 'switch', 'default' => true, 'description' => '在所选分类页显示排序方式按钮'],
['key' => 'orderby_lists', 'label' => ' ', 'type' => 'fieldset', 'default' => ['lists' => ['modified', 'views', 'like', 'comment_count'], 'dropdown' => false], 'dependsOn' => ['key' => 'orderby_s', 'value' => true], 'fields' => [
['key' => 'lists', 'label' => '显示排序方式', 'type' => 'select', 'multiple' => true, 'sortable' => true, 'default' => ['modified', 'views', 'like', 'comment_count'], 'options' => [
@@ -264,6 +270,8 @@ class SchemaPostList {
['key' => 'post_article_s', 'label' => '启用前台投稿', 'type' => 'switcher', 'default' => true, 'description' => '此功能启用后,可以在权限管理中设置用户的发布、审核权限'],
['key' => 'post_article_btn_txte', 'label' => '按钮文字', 'type' => 'input', 'default' => '发布文章', 'dependsOn' => ['key' => 'post_article_s', 'value' => true], 'description' => '投稿按钮的显示的文字,推荐4个字更加协调'],
['key' => 'post_article_cat', 'label' => '投稿允许选择的分类', 'type' => 'taxonomy_select', 'taxonomy' => 'category', 'multiple' => true, 'default' => [], 'placeholder' => '输入关键词以搜索分类', 'dependsOn' => ['key' => 'post_article_s', 'value' => true], 'description' => '投稿允许选择的分类,为空则允许选择全部分类,所选分类下如果有子分类则会自动显示,如果选择了上级分类,则不要再选该分类下的子分类。注意:请确保所选分类包含子分类总数不要超过50个,否则可能会引起页面崩溃'],
['key' => 'post_article_topics_s', 'label' => '允许选择专题', 'type' => 'switch', 'default' => false, 'dependsOn' => ['key' => 'post_article_s', 'value' => true]],
['key' => 'post_article_topics', 'label' => '投稿允许选择的专题', 'type' => 'taxonomy_select', 'taxonomy' => 'topics', 'multiple' => true, 'default' => [], 'dependsOn' => ['all' => [['key' => 'post_article_s', 'value' => true], ['key' => 'post_article_topics_s', 'value' => true]]]],
['key' => 'post_article_custom_filter_s', 'label' => '允许选择高级筛选', 'type' => 'switcher', 'default' => true, 'dependsOn' => ['key' => 'post_article_s', 'value' => true], 'description' => '此功能启用后,请先在文章列表/高级筛选中添加高级筛选明细'],
['key' => 'post_article_tag', 'label' => '允许插入标签', 'type' => 'switcher', 'default' => true, 'dependsOn' => ['key' => 'post_article_s', 'value' => true], 'description' => '前台投稿时候允许设置文章标签'],
['key' => 'post_article_user', 'label' => '免登陆投稿发布用户', 'type' => 'user_select', 'default' => 1, 'dependsOn' => ['key' => 'post_article_s', 'value' => true], 'description' => '当选择投稿权限为无需登录就能投稿时,投稿文章的用户'],