Yoast\WP\SEO\Schema_Aggregator\Application\Meta
Response_Meta_Provider::maybe_add_pagination_metadata
Add pagination metadata to the response if applicable.
Метод класса: Response_Meta_Provider{}
Хуков нет.
Возвращает
Массив<Строку,Массив<Строку>>. The updated metadata array.
Использование
// private - только в коде основоного (родительского) класса $result = $this->maybe_add_pagination_metadata( $metadata, $post_type, $page, $page_size ): array;
- $metadata(array<string,array
>) (обязательный) - The metadata array to add pagination info to.
- $post_type(строка) (обязательный)
- The post type being queried.
- $page(int) (обязательный)
- The current page number (1-based).
- $page_size(int) (обязательный)
- The number of items per page.
Код Response_Meta_Provider::maybe_add_pagination_metadata() Response Meta Provider::maybe add pagination metadata Yoast 27.7
private function maybe_add_pagination_metadata(
array $metadata,
string $post_type,
int $page,
int $page_size
): array {
$indexable_count = $this->schema_map_repository->get_indexable_count_for_post_type( $post_type );
$total_items = $indexable_count->get_count();
if ( $total_items === 0 ) {
return $metadata;
}
$total_pages = (int) \ceil( $total_items / $page_size );
if ( $page < $total_pages ) {
$next_page_url = $this->schema_map_builder->get_rest_route( $post_type, ( $page + 1 ) );
$metadata['next'] = $next_page_url;
}
return $metadata;
}