| @@ -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 ) { |
| @@ -231,9 +240,9 @@ | ||
| 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 | 242 | $output .= "\t\t</image:image>\n"; |
| 234 | 243 | } |
| 235 | - unset( $img, $title, $alt ); | |
| 244 | + unset( $img ); | |
| 236 | 245 | |
| 237 | 246 | $output .= "\t</url>\n"; |
| 238 | 247 | |
| 239 | 248 | /** |
| @@ -238,11 +247,10 @@ | ||
| 238 | 247 | |
| 239 | 248 | /** |
| 240 | 249 | * Filters the output for the sitemap URL tag. |
| 241 | 250 | * |
| 242 | - * @api string $output The output for the sitemap url tag. | |
| 243 | - * | |
| 244 | - * @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. | |
| 245 | 253 | */ |
| 246 | 254 | return apply_filters( 'wpseo_sitemap_url', $output, $url ); |
| 247 | 255 | } |
| 248 | 256 | |
| @@ -268,8 +276,9 @@ | ||
| 268 | 276 | protected function encode_and_escape( $url ) { |
| 269 | 277 | $url = $this->encode_url_rfc3986( $url ); |
| 270 | 278 | $url = esc_url( $url ); |
| 271 | 279 | $url = str_replace( '&', '&', $url ); |
| 280 | + $url = str_replace( ''', ''', $url ); | |
| 272 | 281 | |
| 273 | 282 | if ( strpos( $url, '//' ) === 0 ) { |
| 274 | 283 | // Schema-relative URL for which esc_url() does not add a scheme. |
| 275 | 284 | $url = 'http:' . $url; |
| @@ -329,9 +338,9 @@ | ||
| 329 | 338 | * @return string The XSL URL that needs to be used. |
| 330 | 339 | */ |
| 331 | 340 | protected function get_xsl_url() { |
| 332 | 341 | if ( home_url() !== site_url() ) { |
| 333 | - return home_url( 'main-sitemap.xsl' ); | |
| 342 | + return apply_filters( 'wpseo_sitemap_public_url', home_url( 'main-sitemap.xsl' ) ); | |
| 334 | 343 | } |
| 335 | 344 | |
| 336 | 345 | /* |
| 337 | 346 | * Fallback to circumvent a cross-domain security problem when the XLS file is |