Smilia: children's dental clinic website (WordPress theme and plugin)
This commit is contained in:
commit
4f4b5f2c0a
266 files changed
+16459
No files matched your search
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
namespace Smilia\Core;
|
||||
|
||||
use SimpleXMLElement;
|
||||
use WP_Sitemaps_Renderer;
|
||||
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
final class Sitemap_Renderer extends WP_Sitemaps_Renderer {
|
||||
|
||||
private const XHTML = 'http://www.w3.org/1999/xhtml';
|
||||
|
||||
public function get_sitemap_xml( $url_list ) {
|
||||
$urlset = new SimpleXMLElement(
|
||||
'<?xml version="1.0" encoding="UTF-8" ?>' . $this->stylesheet . '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:xhtml="' . self::XHTML . '" />'
|
||||
);
|
||||
foreach ( $url_list as $item ) {
|
||||
$url = $urlset->addChild( 'url' );
|
||||
$url->addChild( 'loc', esc_url( $item['loc'] ) );
|
||||
foreach ( array( 'lastmod', 'changefreq', 'priority' ) as $name ) {
|
||||
if ( isset( $item[ $name ] ) ) {
|
||||
$url->addChild( $name, esc_xml( (string) $item[ $name ] ) );
|
||||
}
|
||||
}
|
||||
foreach ( (array) ( $item['alternates'] ?? array() ) as $language => $href ) {
|
||||
$link = $url->addChild( 'xhtml:link', null, self::XHTML );
|
||||
$link->addAttribute( 'rel', 'alternate' );
|
||||
$link->addAttribute( 'hreflang', (string) $language );
|
||||
$link->addAttribute( 'href', esc_url( $href ) );
|
||||
}
|
||||
}
|
||||
return $urlset->asXML();
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user