Yoast\WP\SEO\Schema_Aggregator\Application\Schema_Map
Schema_Map_Builder::build
Builds the schema map based on indexable counts and threshold.
Метод класса: Schema_Map_Builder{}
Хуков нет.
Возвращает
Массив
Использование
$Schema_Map_Builder = new Schema_Map_Builder(); $Schema_Map_Builder->build( $indexable_counts ): array;
- $indexable_counts(Indexable_Count_Collection) (обязательный)
- The indexable counts per post type.
Код Schema_Map_Builder::build() Schema Map Builder::build Yoast 27.7
public function build( Indexable_Count_Collection $indexable_counts ): array {
$schema_map = [];
foreach ( $indexable_counts->get_indexable_counts() as $indexable_count ) {
$post_type = $indexable_count->get_post_type();
$count = $indexable_count->get_count();
$threshold = $this->config->get_per_page( $post_type );
$total_pages = (int) \ceil( $count / $threshold );
for ( $page = 1; $page <= $total_pages; $page++ ) {
if ( $page === 1 && $total_pages === 1 ) {
$url = $this->get_rest_route( $post_type );
}
elseif ( $page === 1 ) {
$url = $this->get_rest_route( $post_type );
}
else {
$url = $this->get_rest_route( $post_type, $page );
}
$lastmod = $this->schema_map_repository->get_lastmod_for_post_type( $post_type, $page, $threshold );
$page_count = ( $page === $total_pages ) ? ( $count - ( ( $page - 1 ) * $threshold ) ) : $threshold;
$schema_map[] = [
'post_type' => $post_type,
'url' => $url,
'lastmod' => $lastmod,
'count' => $page_count,
];
}
}
return $schema_map;
}