Yoast\WP\SEO\Presentations
Indexable_Author_Archive_Presentation::generate_robots
Generates the robots value.
Метод класса: Indexable_Author_Archive_Presentation{}
Хуков нет.
Возвращает
Массив. The robots value.
Использование
$Indexable_Author_Archive_Presentation = new Indexable_Author_Archive_Presentation(); $Indexable_Author_Archive_Presentation->generate_robots();
Код Indexable_Author_Archive_Presentation::generate_robots() Indexable Author Archive Presentation::generate robots Yoast 27.3
public function generate_robots() {
$robots = $this->get_base_robots();
// Global option: "Show author archives in search results".
if ( $this->options->get( 'noindex-author-wpseo', false ) ) {
$robots['index'] = 'noindex';
return $this->filter_robots( $robots );
}
$current_author = \get_userdata( $this->model->object_id );
// Safety check. The call to `get_user_data` could return false (called in `get_queried_object`).
if ( $current_author === false ) {
$robots['index'] = 'noindex';
return $this->filter_robots( $robots );
}
$author_archive_post_types = $this->author_archive->get_author_archive_post_types();
// Global option: "Show archives for authors without posts in search results".
if ( $this->options->get( 'noindex-author-noposts-wpseo', false ) && $this->user->count_posts( $current_author->ID, $author_archive_post_types ) === 0 ) {
$robots['index'] = 'noindex';
return $this->filter_robots( $robots );
}
// User option: "Do not allow search engines to show this author's archives in search results".
if ( $this->user->get_meta( $current_author->ID, 'wpseo_noindex_author', true ) === 'on' ) {
$robots['index'] = 'noindex';
return $this->filter_robots( $robots );
}
return $this->filter_robots( $robots );
}