WordPress как на ладони
Недорогой хостинг для сайтов на WordPress: wordpress.jino.ru Получай пассивный доход от сайта
функция не описана

Yoast\WP\SEO\Builders

Indexable_Link_Builder::create_internal_link() protected Yoast 1.0

Creates an internal link.

{} Это метод класса: Indexable_Link_Builder{}

Хуков нет.

Возвращает

SEO_Links. The created link.

Использование

// protected - в коде основоного (родительского) или дочернего класса
$result = $this->create_internal_link( $url, $home_url, $indexable, $is_image );
$url(строка) (обязательный)
The url of the link.
$home_url(массив) (обязательный)
The home url, as parsed by wp_parse_url.
$indexable(Indexable) (обязательный)
The indexable of the post containing the link.
$is_image(true|false)
Whether or not the link is an image.

Код Indexable_Link_Builder::create_internal_link() Yoast 16.8

<?php
protected function create_internal_link( $url, $home_url, $indexable, $is_image = false ) {
	$parsed_url = \wp_parse_url( $url );
	$link_type  = $this->url_helper->get_link_type( $parsed_url, $home_url, $is_image );

	/**
	 * ORM representing a link in the SEO Links table.
	 *
	 * @var SEO_Links $model
	 */
	$model = $this->seo_links_repository->query()->create(
		[
			'url'          => $url,
			'type'         => $link_type,
			'indexable_id' => $indexable->id,
			'post_id'      => $indexable->object_id,
		]
	);

	$model->parsed_url = $parsed_url;

	if ( $model->type === SEO_Links::TYPE_INTERNAL || $model->type === SEO_Links::TYPE_INTERNAL_IMAGE ) {
		$permalink = $this->get_permalink( $url, $home_url );
		if ( $this->url_helper->is_relative( $permalink ) ) {
			// Make sure we're checking against the absolute URL, and add a trailing slash if the site has a trailing slash in its permalink settings.
			$permalink = $this->url_helper->ensure_absolute_url( \user_trailingslashit( $permalink ) );
		}
		$target = $this->indexable_repository->find_by_permalink( $permalink );

		if ( ! $target ) {
			// If target indexable cannot be found, create one based on the post's post ID.
			$post_id = $this->get_post_id( $model->type, $permalink );
			if ( $post_id && $post_id !== 0 ) {
				$target = $this->indexable_repository->find_by_id_and_type( $post_id, 'post' );
			}
		}

		if ( ! $target ) {
			return $model;
		}

		$model->target_indexable_id = $target->id;
		if ( $target->object_type === 'post' ) {
			$model->target_post_id = $target->object_id;
		}
	}

	if ( $is_image && $model->target_post_id ) {
		list( , $width, $height ) = \wp_get_attachment_image_src( $model->target_post_id, 'full' );

		$model->width  = $width;
		$model->height = $height;
		$model->size   = \filesize( \get_attached_file( $model->target_post_id ) );
	}

	if ( $model->target_indexable_id ) {
		$model->language = $target->language;
		$model->region   = $target->region;
	}

	return $model;
}