Automattic\WooCommerce\Internal\ProductFilters
TaxonomyHierarchyData::compute_descendants
Compute all descendants of a term.
Метод класса: TaxonomyHierarchyData{}
Хуков нет.
Возвращает
array. Array of descendant term IDs.
Использование
// private - только в коде основоного (родительского) класса $result = $this->compute_descendants( $term_id, $children ): array;
- $term_id(int) (обязательный)
- The term ID.
- $children(массив) (обязательный)
- Children relationships map.
Код TaxonomyHierarchyData::compute_descendants() TaxonomyHierarchyData::compute descendants WC 11.2.2
private function compute_descendants( int $term_id, array $children ): array {
$descendants = array();
if ( ! isset( $children[ $term_id ] ) ) {
return $descendants;
}
foreach ( $children[ $term_id ] as $child_id ) {
$descendants[] = $child_id;
$descendants = array_merge( $descendants, $this->compute_descendants( $child_id, $children ) );
}
return array_unique( $descendants );
}