Yoast\WP\SEO\Builders
Indexable_Author_Builder::check_if_user_should_be_indexed()
Checks if the user should be indexed. Returns an exception with an appropriate message if not.
Метод класса: Indexable_Author_Builder{}
Хуки из метода
Возвращает
Author_Not_Built_Exception|null
. The exception if it should not be indexed, or null if it should.
Использование
// protected - в коде основоного (родительского) или дочернего класса $result = $this->check_if_user_should_be_indexed( $user_id );
- $user_id(строка) (обязательный)
- The user id.
Код Indexable_Author_Builder::check_if_user_should_be_indexed() Indexable Author Builder::check if user should be indexed Yoast 24.0
protected function check_if_user_should_be_indexed( $user_id ) { $exception = null; if ( $this->author_archive->are_disabled() ) { $exception = Author_Not_Built_Exception::author_archives_are_disabled( $user_id ); } // We will check if the author has public posts the WP way, instead of the indexable way, to make sure we get proper results even if SEO optimization is not run. // In case the user has no public posts, we check if the user should be indexed anyway. if ( $this->options_helper->get( 'noindex-author-noposts-wpseo', false ) === true && $this->author_archive->author_has_public_posts_wp( $user_id ) === false ) { $exception = Author_Not_Built_Exception::author_archives_are_not_indexed_for_users_without_posts( $user_id ); } /** * Filter: Include or exclude a user from being build and saved as an indexable. * Return an `Author_Not_Built_Exception` when the indexable should not be build, with an appropriate message telling why it should not be built. * Return `null` if the indexable should be build. * * @param Author_Not_Built_Exception|null $exception An exception if the indexable is not being built, `null` if the indexable should be built. * @param string $user_id The ID of the user that should or should not be excluded. */ return \apply_filters( 'wpseo_should_build_and_save_user_indexable', $exception, $user_id ); }