sitemap->type, [ 'general', 'rss' ], true ) ) { return; } // phpcs:disable VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable $charset = get_option( 'blog_charset' ); $advanced = aioseo()->options->sitemap->general->advancedSettings->enable; $excludeImages = aioseo()->options->sitemap->general->advancedSettings->excludeImages; $generation = ! isset( aioseo()->sitemap->isStatic ) || aioseo()->sitemap->isStatic ? __( 'statically', 'all-in-one-seo-pack' ) : __( 'dynamically', 'all-in-one-seo-pack' ); echo '\r\n"; echo ''; switch ( aioseo()->sitemap->indexName ) { case 'rss': $xslUrl = home_url() . '/default.xsl'; if ( ! is_multisite() ) { $title = get_bloginfo( 'name' ); $description = get_bloginfo( 'blogdescription' ); $link = home_url(); } else { $title = get_blog_option( get_current_blog_id(), 'blogname' ); $description = get_blog_option( get_current_blog_id(), 'blogdescription' ); $link = get_blog_option( get_current_blog_id(), 'siteurl' ); } // Yandex doesn't support some tags so we need to check the user agent. $isYandexBot = false; if ( preg_match( '#.*Yandex.*#', $_SERVER['HTTP_USER_AGENT'] ) ) { $isYandexBot = true; } echo "\r\n\r\n\r\n"; include_once( AIOSEO_DIR . '/app/Common/Views/sitemap/xml/rss.php' ); break; case 'root': if ( aioseo()->options->sitemap->general->indexes ) { $xslUrl = add_query_arg( 'sitemap', aioseo()->sitemap->indexName, home_url() . '/default.xsl' ); echo "\r\n\r\n\r\n"; include( AIOSEO_DIR . '/app/Common/Views/sitemap/xml/root.php' ); break; } // If non-indexed, fall through to default. default: $xslUrl = add_query_arg( 'sitemap', aioseo()->sitemap->indexName, home_url() . '/default.xsl' ); echo "\r\n\r\n\r\n"; include( AIOSEO_DIR . '/app/Common/Views/sitemap/xml/default.php' ); break; } } /** * Escapes and echoes the given XML tag value. * * @since 4.0.0 * * @param string $value The tag value. * @param string $wrap Whether the value should we wrapped in a CDATA section. * @return void */ public function escapeAndEcho( $value, $wrap = true ) { $safeText = wp_check_invalid_utf8( $value, true ); if ( ! $safeText ) { return; } $cdataRegex = '\<\!\[CDATA\[.*?\]\]\>'; $regex = "/(?=.*?{$cdataRegex})(?(.*?))(?({$cdataRegex}))|(?(.*))/sx"; $safeText = (string) preg_replace_callback( $regex, static function( $matches ) { if ( ! $matches[0] ) { return ''; } if ( ! empty( $matches['non_cdata'] ) ) { // Escape HTML entities in the non-CDATA section. return _wp_specialchars( $matches['non_cdata'], ENT_XML1 ); } // Return the CDATA Section unchanged, escape HTML entities in the rest. return _wp_specialchars( $matches['non_cdata_followed_by_cdata'], ENT_XML1 ) . $matches['cdata']; }, $safeText ); if ( ! $wrap || isset( $_GET['aioseo-dev'] ) ) { return print( $safeText ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped } printf( '', $safeText ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped } /** * Returns the URL for the sitemap stylesheet. * * This is needed for compatibility with multilingual plugins such as WPML. * * @since 4.0.0 * * @return string The URL to the sitemap stylesheet. */ private function xslUrl() { return esc_url( apply_filters( 'aioseo_sitemap_xsl_url', aioseo()->helpers->localizedUrl( '/sitemap.xsl' ) ) ); } }