• Hi, this is not a bug but a contribution, couldn’t find anywhere else to put it.

    Basically my scenario is that I need to add some extra tags inside each <loc> – in my case it is alternate lang tags, but there are lots of possibilities for other people (this is also one of the ideas on your uservoice)

    By simply applying a filter to the xml as it is being rendered this becomes a simple task of hooking to the filter in another plugin.
    1 extra line of code in your core adds a huge amount of customisation options.

    If you will consider adding this into your core then great, otherwise I will have to make a fork to distribute to my users (which I would rather not!)

    class GoogleSitemapGeneratorPage
    
    public function Render() {
    
    		if($this->_url == "/" || empty($this->_url)) return '';
    
    		$r = "";
    		$r .= "\t<url>\n";
    		$r .= "\t\t<loc>" . $this->EscapeXML($this->_url) . "</loc>\n";
    		if($this->_lastMod > 0) $r .= "\t\t<lastmod>" . date('Y-m-d\TH:i:s+00:00', $this->_lastMod) . "</lastmod>\n";
    		if(!empty($this->_changeFreq)) $r .= "\t\t<changefreq>" . $this->_changeFreq . "</changefreq>\n";
    		if($this->_priority !== false && $this->_priority !== "") $r .= "\t\t<priority>" . number_format($this->_priority, 1) . "</priority>\n";
    		$r .= "\t</url>\n";
    		return $r;
    	}

    And I have changed to:

    public function Render() {
    
    		if($this->_url == "/" || empty($this->_url)) return '';
    
    		$r = "";
    		$r .= "\t<url>\n";
    		$c = "\t\t<loc>" . $this->EscapeXML($this->_url) . "</loc>\n";
    		if($this->_lastMod > 0) $r .= "\t\t<lastmod>" . date('Y-m-d\TH:i:s+00:00', $this->_lastMod) . "</lastmod>\n";
    		if(!empty($this->_changeFreq)) $r .= "\t\t<changefreq>" . $this->_changeFreq . "</changefreq>\n";
    		if($this->_priority !== false && $this->_priority !== "") $r .= "\t\t<priority>" . number_format($this->_priority, 1) . "</priority>\n";
    		$r.= apply_filters("sm_render_xml", $c, $this->_url);
    		$r .= "\t</url>\n";
    		return $r;
    	}

    https://www.ads-software.com/plugins/google-sitemap-generator/

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘Code contribution – hope you can add into next release’ is closed to new replies.