function get_term_ancestors($taxonomy) { $ancestors = get_option("{$taxonomy}_ancestors_rs"); if (is_array($ancestors)) { return $ancestors; } $ancestors = array(); $terms = $GLOBALS['scoper']->get_terms($taxonomy, UNFILTERED_RS); if ($terms) { $parents = array(); foreach ($terms as $term) { if ($term->parent) { $parents[$term->term_id] = $term->parent; } } foreach ($terms as $term) { $term_id = $term->term_id; $ancestors[$term_id] = ScoperAncestry::_walk_ancestors($term_id, array(), $parents); if (empty($ancestors[$term_id])) { unset($ancestors[$term_id]); } } update_option("{$taxonomy}_ancestors_rs", $ancestors); } return $ancestors; }