Yoast\WP\SEO\Builders
Indexable_Builder::save_indexable()
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.
Использование
$Indexable_Builder = new Indexable_Builder(); $Indexable_Builder->$author_indexable = $this->indexable_repository->find_by_id_and_type(;
Код Indexable_Builder::save_indexable() Indexable Builder::save indexable Yoast 24.9
$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; } /** * Checks if the indexable type is one that is not supposed to have object ID for. * * @param string $type The type of the indexable. * * @return bool Whether the indexable type is one that is not supposed to have object ID for. */ protected function is_type_with_no_id( $type ) { return \in_array( $type, [ 'home-page', 'date-archive', 'post-type-archive', 'system-page' ], true ); } // phpcs:disable Squiz.Commenting.FunctionCommentThrowTag.Missing -- Exceptions are handled by the catch statement in the method. /** * Rebuilds an Indexable from scratch. * * @param Indexable $indexable The Indexable to (re)build. * @param array|null $defaults The object type of the Indexable.