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

+7
View File
@@ -441,6 +441,10 @@ final class SubmissionVersion {
}
wp_set_post_categories($post_id, $cats);
}
if (!empty($settings['allow_topics']) && array_key_exists('topics', $snapshot)) {
$topics = is_array($snapshot['topics']) ? $snapshot['topics'] : [];
wp_set_post_terms($post_id, SubmitTopics::filter_ids($topics, $settings), 'topics');
}
if (array_key_exists('tags', $snapshot)) {
$tags = is_array($snapshot['tags']) ? $snapshot['tags'] : [];
wp_set_post_tags($post_id, array_values(array_filter(array_map('sanitize_text_field', $tags))));
@@ -480,6 +484,9 @@ final class SubmissionVersion {
if (isset($snapshot['categories']) && is_array($snapshot['categories'])) {
$clean['categories'] = array_values(array_unique(array_filter(array_map('absint', $snapshot['categories']))));
}
if (isset($snapshot['topics']) && is_array($snapshot['topics'])) {
$clean['topics'] = array_values(array_unique(array_filter(array_map('absint', $snapshot['topics']))));
}
if (isset($snapshot['tags'])) {
$tags = is_array($snapshot['tags']) ? $snapshot['tags'] : preg_split('/[,,\n]+/u', (string) $snapshot['tags']);
$clean['tags'] = array_values(array_filter(array_map('sanitize_text_field', (array) $tags)));