service = $service; $this->name = 'yatra'; $this->object_type = 'yatra'; } /** * @param int $page_number * @param string $object_subtype * @return array */ public function get_url_list($page_number, $object_subtype = ''): array { $entries = $this->service->getAllEntries(); $perPage = $this->maxUrls(); $offset = ((int) $page_number - 1) * $perPage; $list = []; foreach (array_slice($entries, $offset, $perPage) as $entry) { // Core's renderer reads 'loc'; lastmod is surfaced only if a site // opts in via the wp_sitemaps_index_entry filter. $list[] = ['loc' => $entry['loc'], 'lastmod' => $entry['lastmod']]; } return $list; } /** * @param string $object_subtype */ public function get_max_num_pages($object_subtype = ''): int { $count = $this->service->getCount(); if ($count === 0) { return 0; } return (int) ceil($count / $this->maxUrls()); } private function maxUrls(): int { $max = function_exists('wp_sitemaps_get_max_urls') ? (int) wp_sitemaps_get_max_urls($this->object_type) : 2000; return $max > 0 ? $max : 2000; } }