PluginProbe
Yoast SEO – Advanced SEO with real-time guidance and built-in AI / trunk
Yoast SEO – Advanced SEO with real-time guidance and built-in AI vtrunk
28.5 28.4 28.3 28.2 28.1 28.0 27.9 27.8 27.7 27.6 27.5 trunk 18.0 18.1 18.2 18.3 18.4 18.4.1 18.5 18.5.1 18.6 18.7 18.8 18.9 19.0 All 129 releases
← All changes | inc/sitemaps/class-sitemaps-renderer.php +24 -40 18.3 → trunk View file →
@@ -60,9 +60,9 @@
60 60
61 61 /**
62 62 * Builds the sitemap index.
63 63 *
64 - * @param array $links Set of sitemaps index links.
64 + * @param array<string> $links Set of sitemaps index links.
65 65 *
66 66 * @return string
67 67 */
68 68 public function get_index( $links ) {
@@ -86,11 +86,11 @@
86 86
87 87 /**
88 88 * Builds the sitemap.
89 89 *
90 - * @param array $links Set of sitemap links.
91 - * @param string $type Sitemap type.
92 - * @param int $current_page Current sitemap page number.
90 + * @param array<string> $links Set of sitemap links.
91 + * @param string $type Sitemap type.
92 + * @param int $current_page Current sitemap page number.
93 93 *
94 94 * @return string
95 95 */
96 96 public function get_sitemap( $links, $type, $current_page ) {
@@ -95,16 +95,23 @@
95 95 */
96 96 public function get_sitemap( $links, $type, $current_page ) {
97 97
98 98 $urlset = '<urlset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:image="http://www.google.com/schemas/sitemap-image/1.1" '
99 - . 'xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd '
100 - . 'http://www.google.com/schemas/sitemap-image/1.1 http://www.google.com/schemas/sitemap-image/1.1/sitemap-image.xsd" '
101 - . 'xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">' . "\n";
99 + . 'xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd '
100 + . 'http://www.google.com/schemas/sitemap-image/1.1 http://www.google.com/schemas/sitemap-image/1.1/sitemap-image.xsd" '
101 + . 'xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">' . "\n";
102 102
103 103 /**
104 + * Filters the `urlset` for all sitemaps.
105 + *
106 + * @param string $urlset The output for the sitemap's `urlset`.
107 + */
108 + $urlset = apply_filters( 'wpseo_sitemap_urlset', $urlset );
109 +
110 + /**
104 111 * Filters the `urlset` for a sitemap by type.
105 112 *
106 - * @api string $urlset The output for the sitemap's `urlset`.
113 + * @param string $urlset The output for the sitemap's `urlset`.
107 114 */
108 115 $xml = apply_filters( "wpseo_sitemap_{$type}_urlset", $urlset );
109 116
110 117 foreach ( $links as $url ) {
@@ -165,8 +172,10 @@
165 172 /**
166 173 * Set a custom stylesheet for this sitemap. Set to empty to just remove the default stylesheet.
167 174 *
168 175 * @param string $stylesheet Full XML-stylesheet declaration.
176 + *
177 + * @return void
169 178 */
170 179 public function set_stylesheet( $stylesheet ) {
171 180 $this->stylesheet = $stylesheet;
172 181 }
@@ -173,9 +182,9 @@
173 182
174 183 /**
175 184 * Build the `<sitemap>` tag for a given URL.
176 185 *
177 - * @param array $url Array of parts that make up this entry.
186 + * @param array<string> $url Array of parts that make up this entry.
178 187 *
179 188 * @return string
180 189 */
181 190 protected function sitemap_index_url( $url ) {
@@ -200,9 +209,9 @@
200 209 * Build the `<url>` tag for a given URL.
201 210 *
202 211 * Public access for backwards compatibility reasons.
203 212 *
204 - * @param array $url Array of parts that make up this entry.
213 + * @param array<string> $url Array of parts that make up this entry.
205 214 *
206 215 * @return string
207 216 */
208 217 public function sitemap_url( $url ) {
@@ -229,36 +238,11 @@
229 238 }
230 239
231 240 $output .= "\t\t<image:image>\n";
232 241 $output .= "\t\t\t<image:loc>" . $this->encode_and_escape( $img['src'] ) . "</image:loc>\n";
233 -
234 - if ( ! empty( $img['title'] ) ) {
235 -
236 - $title = $img['title'];
237 -
238 - if ( $this->needs_conversion ) {
239 - $title = mb_convert_encoding( $title, $this->output_charset, $this->charset );
240 - }
241 -
242 - $title = _wp_specialchars( html_entity_decode( $title, ENT_QUOTES, $this->output_charset ) );
243 - $output .= "\t\t\t<image:title><![CDATA[{$title}]]></image:title>\n";
244 - }
245 -
246 - if ( ! empty( $img['alt'] ) ) {
247 -
248 - $alt = $img['alt'];
249 -
250 - if ( $this->needs_conversion ) {
251 - $alt = mb_convert_encoding( $alt, $this->output_charset, $this->charset );
252 - }
253 -
254 - $alt = _wp_specialchars( html_entity_decode( $alt, ENT_QUOTES, $this->output_charset ) );
255 - $output .= "\t\t\t<image:caption><![CDATA[{$alt}]]></image:caption>\n";
256 - }
257 -
258 242 $output .= "\t\t</image:image>\n";
259 243 }
260 - unset( $img, $title, $alt );
244 + unset( $img );
261 245
262 246 $output .= "\t</url>\n";
263 247
264 248 /**
@@ -263,11 +247,10 @@
263 247
264 248 /**
265 249 * Filters the output for the sitemap URL tag.
266 250 *
267 - * @api string $output The output for the sitemap url tag.
268 - *
269 - * @param array $url The sitemap URL array on which the output is based.
251 + * @param string $output The output for the sitemap url tag.
252 + * @param array $url The sitemap URL array on which the output is based.
270 253 */
271 254 return apply_filters( 'wpseo_sitemap_url', $output, $url );
272 255 }
273 256
@@ -293,8 +276,9 @@
293 276 protected function encode_and_escape( $url ) {
294 277 $url = $this->encode_url_rfc3986( $url );
295 278 $url = esc_url( $url );
296 279 $url = str_replace( '&#038;', '&amp;', $url );
280 + $url = str_replace( '&#039;', '&apos;', $url );
297 281
298 282 if ( strpos( $url, '//' ) === 0 ) {
299 283 // Schema-relative URL for which esc_url() does not add a scheme.
300 284 $url = 'http:' . $url;
@@ -354,9 +338,9 @@
354 338 * @return string The XSL URL that needs to be used.
355 339 */
356 340 protected function get_xsl_url() {
357 341 if ( home_url() !== site_url() ) {
358 - return home_url( 'main-sitemap.xsl' );
342 + return apply_filters( 'wpseo_sitemap_public_url', home_url( 'main-sitemap.xsl' ) );
359 343 }
360 344
361 345 /*
362 346 * Fallback to circumvent a cross-domain security problem when the XLS file is