Yoast\WP\SEO\Builders
Indexable_Hierarchy_Builder::is_invalid_ancestor()
Checks if an ancestor is valid to add.
Метод класса: Indexable_Hierarchy_Builder{}
Хуков нет.
Возвращает
true|false
.
Использование
// private - только в коде основоного (родительского) класса $result = $this->is_invalid_ancestor( $ancestor, $indexable_id, $parents );
- $ancestor(Indexable) (обязательный)
- The ancestor (presumed indexable) to check.
- $indexable_id(int) (обязательный)
- The indexable id we're adding ancestors for.
- $parents(int[]) (обязательный)
- The indexable ids of the parents already added.
Код Indexable_Hierarchy_Builder::is_invalid_ancestor() Indexable Hierarchy Builder::is invalid ancestor Yoast 24.3
private function is_invalid_ancestor( $ancestor, $indexable_id, $parents ) { // If the ancestor is not an Indexable, it is invalid by default. if ( ! \is_a( $ancestor, 'Yoast\WP\SEO\Models\Indexable' ) ) { return true; } // Don't add ancestors if they're unindexed, already added or the same as the main object. if ( $ancestor->post_status === 'unindexed' ) { return true; } $ancestor_id = $this->get_indexable_id( $ancestor ); if ( \array_key_exists( $ancestor_id, $parents ) ) { return true; } if ( $ancestor_id === $indexable_id ) { return true; } return false; }