Automattic\WooCommerce\Internal\ProductFilters

TaxonomyHierarchyData::build_term_treeprivateWC 1.0

Recursively build hierarchical term tree with depth and parent.

Метод класса: TaxonomyHierarchyData{}

Хуков нет.

Возвращает

null. Ничего (null).

Использование

// private - только в коде основоного (родительского) класса
$result = $this->build_term_tree( $tree, $term_id, $children, $temp_terms, $depth );
$tree(массив) (обязательный) (передается по ссылке — &)
Reference to tree array being built.
$term_id(int) (обязательный)
Current term ID.
$children(массив) (обязательный)
Children relationships map (parent_id => [child_ids]).
$temp_terms(массив) (обязательный)
Term data indexed by term_id.
$depth(int)
Current depth level in hierarchy.

Код TaxonomyHierarchyData::build_term_tree() WC 11.0.1

private function build_term_tree( &$tree, $term_id, $children, $temp_terms, $depth = 0 ) {
	$tree[ $term_id ]          = $temp_terms[ $term_id ];
	$tree[ $term_id ]['depth'] = $depth;

	if ( ! empty( $children[ $term_id ] ) ) {
		foreach ( $children[ $term_id ] as $child_id ) {
			$this->build_term_tree( $tree[ $term_id ]['children'], $child_id, $children, $temp_terms, $depth + 1 );
		}
	}
}