WPSEO_Sitemaps_Renderer::get_sitemap()
Builds the sitemap.
Метод класса: WPSEO_Sitemaps_Renderer{}
Возвращает
Строку
.
Использование
$WPSEO_Sitemaps_Renderer = new WPSEO_Sitemaps_Renderer(); $WPSEO_Sitemaps_Renderer->get_sitemap( $links, $type, $current_page );
- $links(array
) (обязательный) - Set of sitemap links.
- $type(строка) (обязательный)
- Sitemap type.
- $current_page(int) (обязательный)
- Current sitemap page number.
Код WPSEO_Sitemaps_Renderer::get_sitemap() WPSEO Sitemaps Renderer::get sitemap Yoast 24.7
public function get_sitemap( $links, $type, $current_page ) { $urlset = '<urlset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:image="http://www.google.com/schemas/sitemap-image/1.1" ' . 'xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd ' . 'http://www.google.com/schemas/sitemap-image/1.1 http://www.google.com/schemas/sitemap-image/1.1/sitemap-image.xsd" ' . 'xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">' . "\n"; /** * Filters the `urlset` for all sitemaps. * * @param string $urlset The output for the sitemap's `urlset`. */ $urlset = apply_filters( 'wpseo_sitemap_urlset', $urlset ); /** * Filters the `urlset` for a sitemap by type. * * @param string $urlset The output for the sitemap's `urlset`. */ $xml = apply_filters( "wpseo_sitemap_{$type}_urlset", $urlset ); foreach ( $links as $url ) { $xml .= $this->sitemap_url( $url ); } /** * Filter to add extra URLs to the XML sitemap by type. * * Only runs for the first page, not on all. * * @param string $content String content to add, defaults to empty. */ if ( $current_page === 1 ) { $xml .= apply_filters( "wpseo_sitemap_{$type}_content", '' ); } $xml .= '</urlset>'; return $xml; }