You appear to be a bot. Output may be restricted
Description
Build the <url>
tag for a given URL.
Public access for backwards compatibility reasons.
Usage
$string = WPSEO_Sitemaps_Renderer::sitemap_url( $url );
Parameters
- $url
- ( array ) required – Array of parts that make up this entry.
Returns
string
Source
File name: wordpress-seo/inc/sitemaps/class-sitemaps-renderer.php
Lines:
1 to 68 of 68
public function sitemap_url( $url ) { $date = null; if ( ! empty( $url['mod'] ) ) { // Create a DateTime object date in the correct timezone. $date = $this->date->format( $url['mod'] ); } $url['loc'] = htmlspecialchars( $url['loc'], ENT_COMPAT, $this->output_charset, false ); $output = "\t<url>\n"; $output .= "\t\t<loc>" . $this->encode_url_rfc3986( $url['loc'] ) . "</loc>\n"; $output .= empty( $date ) ? '' : "\t\t<lastmod>" . htmlspecialchars( $date, ENT_COMPAT, $this->output_charset, false ) . "</lastmod>\n"; if ( empty( $url['images'] ) ) { $url['images'] = []; } foreach ( $url['images'] as $img ) { if ( empty( $img['src'] ) ) { continue; } $output .= "\t\t<image:image>\n"; $output .= "\t\t\t<image:loc>" . esc_html( $this->encode_url_rfc3986( $img['src'] ) ) . "</image:loc>\n"; if ( ! empty( $img['title'] ) ) { $title = $img['title']; if ( $this->needs_conversion ) { $title = mb_convert_encoding( $title, $this->output_charset, $this->charset ); } $title = _wp_specialchars( html_entity_decode( $title, ENT_QUOTES, $this->output_charset ) ); $output .= "\t\t\t<image:title><![CDATA[{$title}]]></image:title>\n"; } if ( ! empty( $img['alt'] ) ) { $alt = $img['alt']; if ( $this->needs_conversion ) { $alt = mb_convert_encoding( $alt, $this->output_charset, $this->charset ); } $alt = _wp_specialchars( html_entity_decode( $alt, ENT_QUOTES, $this->output_charset ) ); $output .= "\t\t\t<image:caption><![CDATA[{$alt}]]></image:caption>\n"; } $output .= "\t\t</image:image>\n"; } unset( $img, $title, $alt ); $output .= "\t</url>\n"; /** * Filters the output for the sitemap URL tag. * * @api string $output The output for the sitemap url tag. * * @param array $url The sitemap URL array on which the output is based. */ return apply_filters( 'wpseo_sitemap_url', $output, $url ); }