| 1 |
<?php |
| 2 |
|
| 3 |
// phpcs:disable Yoast.NamingConventions.NamespaceName.TooLong |
| 4 |
namespace Yoast\WP\SEO\Llms_Txt\Infrastructure\Markdown_Services; |
| 5 |
|
| 6 |
use WPSEO_Options; |
| 7 |
use WPSEO_Sitemaps_Router; |
| 8 |
use Yoast\WP\SEO\Llms_Txt\Domain\Markdown\Items\Link; |
| 9 |
|
| 10 |
/** |
| 11 |
* The sitemap link collector. |
| 12 |
*/ |
| 13 |
class Sitemap_Link_Collector { |
| 14 |
|
| 15 |
/** |
| 16 |
* Gets the link for the sitemap. |
| 17 |
* |
| 18 |
* @return Link The link for the sitemap. |
| 19 |
*/ |
| 20 |
public function get_link(): ?Link { |
| 21 |
if ( WPSEO_Options::get( 'enable_xml_sitemap' ) ) { |
| 22 |
$sitemap_url = WPSEO_Sitemaps_Router::get_base_url( 'sitemap_index.xml' ); |
| 23 |
return new Link( 'Sitemap index', $sitemap_url ); |
| 24 |
} |
| 25 |
|
| 26 |
$sitemap_url = \get_sitemap_url( 'index' ); |
| 27 |
|
| 28 |
if ( $sitemap_url !== false ) { |
| 29 |
return new Link( 'Sitemap index', $sitemap_url ); |
| 30 |
} |
| 31 |
|
| 32 |
return null; |
| 33 |
} |
| 34 |
} |
| 35 |
|