Automattic\WooCommerce\Blocks\BlockTypes
ProductFilterTaxonomy::sort_hierarchy_terms
Sort hierarchical terms recursively maintaining parent-child relationships.
Метод класса: ProductFilterTaxonomy{}
Хуков нет.
Возвращает
array. Sorted hierarchical terms.
Использование
// private - только в коде основоного (родительского) класса $result = $this->sort_hierarchy_terms( $terms, $orderby, $order, $taxonomy_counts );
- $terms(массив) (обязательный)
- Hierarchical terms array with children.
- $orderby(строка) (обязательный)
- Sort field (name, count, menu_order).
- $order(строка) (обязательный)
- Sort direction (ASC, DESC).
- $taxonomy_counts(массив) (обязательный)
- Context-aware term counts.
Код ProductFilterTaxonomy::sort_hierarchy_terms() ProductFilterTaxonomy::sort hierarchy terms WC 11.1.2
private function sort_hierarchy_terms( $terms, $orderby, $order, $taxonomy_counts ) {
foreach ( $terms as $term ) {
if ( ! empty( $term['children'] ) ) {
$term['children'] = $this->sort_terms_by_criteria( $term['children'], $orderby, $order, $taxonomy_counts );
}//end if
}//end foreach
$sorted = $this->sort_terms_by_criteria( $terms, $orderby, $order, $taxonomy_counts );
return $sorted;
}