Yoast\WP\SEO\Builders
Indexable_Link_Builder::update_related_indexables()
Updates the link counts for related indexables.
Метод класса: Indexable_Link_Builder{}
Хуков нет.
Возвращает
null
. Ничего (null).
Использование
// protected - в коде основоного (родительского) или дочернего класса $result = $this->update_related_indexables( $indexable, $links );
- $indexable(Indexable) (обязательный)
- The indexable.
- $links(SEO_Links[]) (обязательный)
- The link models.
Код Indexable_Link_Builder::update_related_indexables() Indexable Link Builder::update related indexables Yoast 24.7
protected function update_related_indexables( $indexable, $links ) { // Old links were only stored by post id, so remove all old seo links for this post that have no indexable id. // This can be removed if we ever fully clear all seo links. if ( $indexable->object_type === 'post' ) { $this->seo_links_repository->delete_all_by_post_id_where_indexable_id_null( $indexable->object_id ); } $updated_indexable_ids = []; $old_links = $this->seo_links_repository->find_all_by_indexable_id( $indexable->id ); $links_to_remove = $this->links_diff( $old_links, $links ); $links_to_add = $this->links_diff( $links, $old_links ); if ( ! empty( $links_to_remove ) ) { $this->seo_links_repository->delete_many_by_id( \wp_list_pluck( $links_to_remove, 'id' ) ); } if ( ! empty( $links_to_add ) ) { $this->seo_links_repository->insert_many( $links_to_add ); } foreach ( $links_to_add as $link ) { if ( $link->target_indexable_id ) { $updated_indexable_ids[] = $link->target_indexable_id; } } foreach ( $links_to_remove as $link ) { if ( $link->target_indexable_id ) { $updated_indexable_ids[] = $link->target_indexable_id; } } $this->update_incoming_links_for_related_indexables( $updated_indexable_ids ); }