Yoast\WP\SEO\Builders

Indexable_Builder::maybe_build_author_indexable()protectedYoast 1.0

Build and author indexable from an author id if it does not exist yet, or if the author indexable needs to be upgraded.

Метод класса: Indexable_Builder{}

Хуков нет.

Возвращает

Indexable|false. The author indexable if it has been built, false if it could not be built.

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

// protected - в коде основоного (родительского) или дочернего класса
$result = $this->maybe_build_author_indexable( $author_id );
$author_id(int) (обязательный)
The author id.

Код Indexable_Builder::maybe_build_author_indexable() Yoast 20.0

protected function maybe_build_author_indexable( $author_id ) {
	$author_indexable = $this->indexable_repository->find_by_id_and_type(
		$author_id,
		'user',
		false
	);
	if ( ! $author_indexable || $this->version_manager->indexable_needs_upgrade( $author_indexable ) ) {
		// Try to build the author.
		$author_defaults  = [
			'object_type' => 'user',
			'object_id'   => $author_id,
		];
		$author_indexable = $this->build( $author_indexable, $author_defaults );
	}
	return $author_indexable;
}