PluginProbe
Yatra – Travel Booking & Tour Operator Software / 3.0.14.2
Yatra – Travel Booking & Tour Operator Software v3.0.14.2
3.0.15 3.0.14 3.0.14.1 3.0.14.2 3.0.12 3.0.13 3.0.11 3.0.10 3.0.9 3.0.8 3.0.7 3.0.6 3.0.5 3.0.5.1 3.0.4 3.0.3 3.0.2.9 3.0.2.7 3.0.2.8 3.0.2.6 trunk 1.0.0 2.0.0 2.0.1 2.0.10 All 83 releases
yatra / app / Sitemap / Integrations / AioseoIntegration.php

AioseoIntegration.php in Yatra – Travel Booking & Tour Operator Software 3.0.14.2, at app/Sitemap/Integrations/AioseoIntegration.php

53 lines 1.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 declare(strict_types=1);
4
5 namespace Yatra\Sitemap\Integrations;
6
7 use Yatra\Sitemap\SitemapService;
8 use Yatra\Sitemap\SitemapRouter;
9
10 /**
11 * Links Yatra's consolidated sitemap into All in One SEO's sitemap index via
12 * the `aioseo_sitemap_indexes` filter — a simple URL pointer (loc/lastmod/
13 * count), which is lower-risk than AIOSEO's page-object `additional_pages`
14 * filter. AIOSEO then lists /yatra-sitemap.xml as a sub-sitemap in its index.
15 *
16 * Note: AIOSEO must have XML sitemaps enabled. Even if this index injection is
17 * unavailable on a given AIOSEO version, the robots.txt advertisement still
18 * exposes /yatra-sitemap.xml, so discovery is never lost.
19 */
20 class AioseoIntegration
21 {
22 private SitemapService $service;
23 private SitemapRouter $router;
24
25 public function __construct(SitemapService $service, SitemapRouter $router)
26 {
27 $this->service = $service;
28 $this->router = $router;
29 }
30
31 public function register(): void
32 {
33 add_filter('aioseo_sitemap_indexes', [$this, 'addIndex']);
34 }
35
36 /**
37 * @param mixed $indexes
38 * @return array<int, array<string, mixed>>
39 */
40 public function addIndex($indexes): array
41 {
42 $indexes = is_array($indexes) ? $indexes : [];
43
44 $indexes[] = [
45 'loc' => $this->router->sitemapUrl(),
46 'lastmod' => $this->service->getLatestLastmod() ?: gmdate('Y-m-d\TH:i:s+00:00'),
47 'count' => $this->service->getCount(),
48 ];
49
50 return $indexes;
51 }
52 }
53