Example #1
0
/**
 * Start sitemap XML document, writing its heading and <urlset> tag with namespaces.
 *
 * @module sitemaps
 *
 * @param $charset string Charset for current XML document.
 *
 * @return string
 */
function jetpack_sitemap_initstr($charset)
{
    global $wp_rewrite;
    // URL to XSLT
    if ($wp_rewrite->using_index_permalinks()) {
        $xsl = home_url('/index.php/sitemap.xsl');
    } else {
        if ($wp_rewrite->using_permalinks()) {
            $xsl = home_url('/sitemap.xsl');
        } else {
            $xsl = home_url('/?jetpack-sitemap-xsl=true');
        }
    }
    $initstr = '<?xml version="1.0" encoding="' . $charset . '"?>' . "\n";
    $initstr .= '<?xml-stylesheet type="text/xsl" href="' . esc_url($xsl) . '"?>' . "\n";
    $initstr .= '<!-- generator="jetpack-' . JETPACK__VERSION . '" -->' . "\n";
    $initstr .= '<urlset';
    foreach (jetpack_sitemap_namespaces() as $attribute => $value) {
        $initstr .= ' ' . esc_html($attribute) . '="' . esc_attr($value) . '"';
    }
    $initstr .= ' />';
    return $initstr;
}
/**
 * Start sitemap XML document, writing its heading and <urlset> tag with namespaces.
 *
 * @module sitemaps
 *
 * @param $charset string Charset for current XML document.
 *
 * @return string
 */
function jetpack_sitemap_initstr($charset)
{
    // URL to XSLT
    $xsl = get_option('permalink_structure') ? home_url('/sitemap.xsl') : home_url('/?jetpack-sitemap-xsl=true');
    $initstr = '<?xml version="1.0" encoding="' . $charset . '"?>' . "\n";
    $initstr .= '<?xml-stylesheet type="text/xsl" href="' . esc_url($xsl) . '"?>' . "\n";
    $initstr .= '<!-- generator="jetpack-' . JETPACK__VERSION . '" -->' . "\n";
    $initstr .= '<urlset';
    foreach (jetpack_sitemap_namespaces() as $attribute => $value) {
        $initstr .= ' ' . esc_html($attribute) . '="' . esc_attr($value) . '"';
    }
    $initstr .= ' />';
    return $initstr;
}