WPSEO_Sitemaps_Renderer::sitemap_index_url()protectedYoast 1.0

Build the <sitemap> tag for a given URL.

Метод класса: WPSEO_Sitemaps_Renderer{}

Хуков нет.

Возвращает

Строку.

Использование

// protected - в коде основоного (родительского) или дочернего класса
$result = $this->sitemap_index_url( $url );
$url(array) (обязательный)
Array of parts that make up this entry.

Код WPSEO_Sitemaps_Renderer::sitemap_index_url() Yoast 22.3

protected function sitemap_index_url( $url ) {

	$date = null;

	if ( ! empty( $url['lastmod'] ) ) {
		$date = YoastSEO()->helpers->date->format( $url['lastmod'] );
	}

	$url['loc'] = htmlspecialchars( $url['loc'], ENT_COMPAT, $this->output_charset, false );

	$output  = "\t<sitemap>\n";
	$output .= "\t\t<loc>" . $url['loc'] . "</loc>\n";
	$output .= empty( $date ) ? '' : "\t\t<lastmod>" . htmlspecialchars( $date, ENT_COMPAT, $this->output_charset, false ) . "</lastmod>\n";
	$output .= "\t</sitemap>\n";

	return $output;
}