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

+9 -14
View File
@@ -13,11 +13,20 @@ defined('ABSPATH') || exit;
if (!function_exists('jio_submit_render_term_checks')) :
function jio_submit_render_term_checks(array $terms, array $checked, string $name, int $parent = 0, int $depth = 0): void {
$children_map = [];
$present = [];
foreach ($terms as $term) {
if ($term instanceof WP_Term) {
$present[(int) $term->term_id] = true;
}
}
foreach ($terms as $term) {
if (!$term instanceof WP_Term) {
continue;
}
$pid = (int) $term->parent;
if ($pid !== 0 && !isset($present[$pid])) {
$pid = 0;
}
if (!isset($children_map[$pid])) {
$children_map[$pid] = [];
}
@@ -38,20 +47,6 @@ if (!function_exists('jio_submit_render_term_checks')) :
}
};
// If include list was used without hierarchy, still render flat.
if (empty($children_map) && !empty($terms)) {
foreach ($terms as $term) {
if (!$term instanceof WP_Term) {
continue;
}
$tid = (int) $term->term_id;
echo '<div><label class="jio-submit-check">';
echo '<input type="checkbox" name="' . esc_attr($name) . '[]" value="' . esc_attr((string) $tid) . '"' . (in_array($tid, $checked, true) ? ' checked' : '') . '>';
echo '<span>' . esc_html($term->name) . '</span></label></div>';
}
return;
}
$render($parent, $depth);
}
endif;