get_param('taxonomy')); if (!in_array($taxonomy, self::TAXONOMIES, true)) { $taxonomy = 'category'; } $terms = get_terms([ 'taxonomy' => $taxonomy, 'hide_empty' => false, 'number' => 500, 'orderby' => 'name', ]); $termList = []; if (!is_wp_error($terms)) { foreach ($terms as $term) { $termList[] = [ 'id' => (int) $term->term_id, 'name' => $term->name, 'parent' => (int) $term->parent, ]; } } return $this->sendSuccess(['taxonomy' => $taxonomy, 'terms' => $termList]); } }