Yoast\WP\SEO\Builders
Indexable_Link_Builder::build()
Builds the links for a post.
Метод класса: Indexable_Link_Builder{}
Хуки из метода
Возвращает
SEO_Links[]
. The created SEO links.
Использование
$Indexable_Link_Builder = new Indexable_Link_Builder(); $Indexable_Link_Builder->build( $indexable, $content );
- $indexable(Indexable) (обязательный)
- The indexable.
- $content(строка) (обязательный)
- The content. Expected to be unfiltered.
Код Indexable_Link_Builder::build() Indexable Link Builder::build Yoast 22.4
public function build( $indexable, $content ) { global $post; if ( $indexable->object_type === 'post' ) { $post_backup = $post; // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited -- To setup the post we need to do this explicitly. $post = $this->post_helper->get_post( $indexable->object_id ); \setup_postdata( $post ); $content = \apply_filters( 'the_content', $content ); \wp_reset_postdata(); // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited -- To setup the post we need to do this explicitly. $post = $post_backup; } $content = \str_replace( ']]>', ']]>', $content ); $links = $this->gather_links( $content ); $images = $this->gather_images( $content ); if ( empty( $links ) && empty( $images ) ) { $indexable->link_count = 0; $this->update_related_indexables( $indexable, [] ); return []; } $links = $this->create_links( $indexable, $links, $images ); $this->update_related_indexables( $indexable, $links ); $indexable->link_count = $this->get_internal_link_count( $links ); return $links; }