Yoast\WP\SEO\Builders
Indexable_Hierarchy_Builder::add_ancestors_for_term()
Adds ancestors for a term.
Метод класса: Indexable_Hierarchy_Builder{}
Хуков нет.
Возвращает
null
. Ничего (null).
Использование
// private - только в коде основоного (родительского) класса $result = $this->add_ancestors_for_term( $indexable_id, $term_id, $parents );
- $indexable_id(int) (обязательный)
- The indexable id, this is the id of the original indexable.
- $term_id(int) (обязательный)
- The term id, this is the id of the term currently being evaluated.
- $parents(int[]) (передается по ссылке — &)
- The indexable IDs of all parents.
По умолчанию: []
Код Indexable_Hierarchy_Builder::add_ancestors_for_term() Indexable Hierarchy Builder::add ancestors for term Yoast 24.1
private function add_ancestors_for_term( $indexable_id, $term_id, &$parents = [] ) { $term = \get_term( $term_id ); $term_parents = $this->get_term_parents( $term ); foreach ( $term_parents as $parent ) { $ancestor = $this->indexable_repository->find_by_id_and_type( $parent->term_id, 'term' ); if ( $this->is_invalid_ancestor( $ancestor, $indexable_id, $parents ) ) { continue; } $parents[ $this->get_indexable_id( $ancestor ) ] = $ancestor; } }