diff -ru google-sitemap-generator.orig/sitemap-core.php google-sitemap-generator/sitemap-core.php --- google-sitemap-generator.orig/sitemap-core.php 2010-04-17 08:18:18.000000000 +0100 +++ google-sitemap-generator/sitemap-core.php 2010-04-14 23:12:34.000000000 +0100 @@ -302,6 +302,12 @@ var $_lastMod; /** + * @var array $_image An array of the format Array ('url'=>The URL of the post thumbnail, 'title'=>A title for the image) + * @access private + */ + var $_image; + + /** * Initialize a new page object * * @since 3.0 @@ -392,6 +398,24 @@ $this->_lastMod=intval($lastMod); } + /** + * Gets the image URL associated with the post + * + * @return array An array of the format Array ('url'=>The URL of the post thumbnail, 'title'=>A title for the image) + */ + function GetImage() { + return $this->_image; + } + + /** + * Sets the image URL associated with the post + * + * @param array An array of the format Array ('url'=>The URL of the post thumbnail, 'title'=>A title for the image) + */ + function SetImage($image) { + $this->_image = $image; + } + function Render() { if($this->_url == "/" || empty($this->_url)) return ''; @@ -399,6 +423,16 @@ $r=""; $r.= "\t\n"; $r.= "\t\t" . $this->EscapeXML($this->_url) . "\n"; + $image = $this->GetImage(); + if(is_array($image)) { + $r .= "\t\t\n"; + $r .= "\t\t\t".$image['url']."\n"; + $r .= "\t\t\t".$image['title']."\n"; + if ($image['license'] != "") { + $r .= "\t\t\t".$image['license']."\n"; + } + $r .= "\t\t\n"; + } if($this->_lastMod>0) $r.= "\t\t" . date('Y-m-d\TH:i:s+00:00',$this->_lastMod) . "\n"; if(!empty($this->_changeFreq)) $r.= "\t\t" . $this->_changeFreq . "\n"; if($this->_priority!==false && $this->_priority!=="") $r.= "\t\t" . number_format($this->_priority,1) . "\n"; @@ -804,6 +838,11 @@ var $_fileZipHandle = null; /** + * @var int The post ID of the currently processing URL (If applicable) + */ + var $_currentPost = null; + + /** * Holds the user interface object * * @since 3.1.1 @@ -933,6 +972,8 @@ $this->_options["sm_in_home"]=true; //Include homepage $this->_options["sm_in_posts"]=true; //Include posts + $this->_options["sm_in_postimages"]=false; //Include post images + $this->_options["sm_b_postimages_license"]=""; //Post images Licence URL $this->_options["sm_in_posts_sub"]=false; //Include post pages ( tag) $this->_options["sm_in_pages"]=true; //Include static pages $this->_options["sm_in_cats"]=false; //Include categories @@ -1504,6 +1545,20 @@ //Strip out the last modification time if activated if($this->GetOption('in_lastmod')===false) $lastMod = 0; $page = new GoogleSitemapGeneratorPage($loc, $priority, $changeFreq, $lastMod); + if (isset($this->_currentPost) && $this->_currentPost != null && $this->GetOption('in_postimages')) { + if ((function_exists('has_post_thumbnail')) && (has_post_thumbnail($this->_currentPost))) { + $image_id = get_post_thumbnail_id($this->_currentPost); + $image_url = wp_get_attachment_image_src($image_id,'large'); + $image_url = $image_url[0]; + $temp_query = new WP_Query('post_type=any&p='.$this->_currentPost); + $temp_query->the_post(); + $image_title = get_the_title(); + $page->SetImage(Array('url'=>$image_url, + 'title'=>$image_title, + 'license'=>$this->GetOption('b_postimages_license'))); + } + unset($this->_currentPost); + } $this->AddElement($page); } @@ -1669,7 +1724,7 @@ } //Go XML! - $this->AddElement(new GoogleSitemapGeneratorXmlEntry('')); + $this->AddElement(new GoogleSitemapGeneratorXmlEntry('')); $home = get_bloginfo('url'); @@ -1682,6 +1737,7 @@ $p = get_page($pageOnFront); if($p) { $homePid = $p->ID; + $this->_currentPost = $p->ID; $this->AddUrl(trailingslashit($home),$this->GetTimestampFromMySql(($p->post_modified_gmt && $p->post_modified_gmt!='0000-00-00 00:00:00'?$p->post_modified_gmt:$p->post_date_gmt)),$this->GetOption("cf_home"),$this->GetOption("pr_home")); } } else { @@ -1886,6 +1942,7 @@ } //Add it + $this->_currentPost = $post->ID; $this->AddUrl($permalink,$this->GetTimestampFromMySql(($post->post_modified_gmt && $post->post_modified_gmt!='0000-00-00 00:00:00'?$post->post_modified_gmt:$post->post_date_gmt)),($isPage?$cf_pages:$cf_posts),$prio); if($inSubPages) { @@ -1897,6 +1954,7 @@ $subPage = trailingslashit($permalink) . user_trailingslashit($p+1, 'single_paged'); } + $this->_currentPost = $post->ID; $this->AddUrl($subPage,$this->GetTimestampFromMySql(($post->post_modified_gmt && $post->post_modified_gmt!='0000-00-00 00:00:00'?$post->post_modified_gmt:$post->post_date_gmt)),($isPage?$cf_pages:$cf_posts),$prio); } } @@ -1906,6 +1964,7 @@ global $q_config; foreach(qtrans_getEnabledLanguages($post->post_content) as $language) { if($language!=$q_config['default_language']) { + $this->_currentPost = $post->ID; $this->AddUrl(qtrans_convertURL($permalink,$language),$this->GetTimestampFromMySql(($post->post_modified_gmt && $post->post_modified_gmt!='0000-00-00 00:00:00'?$post->post_modified_gmt:$post->post_date_gmt)),($isPage?$cf_pages:$cf_posts),$prio); } } diff -ru google-sitemap-generator.orig/sitemap-ui.php google-sitemap-generator/sitemap-ui.php --- google-sitemap-generator.orig/sitemap-ui.php 2010-04-17 08:18:18.000000000 +0100 +++ google-sitemap-generator/sitemap-ui.php 2010-04-17 08:20:58.000000000 +0100 @@ -183,7 +183,7 @@ //Options of the category "Basic Settings" are boolean, except the filename and the autoprio provider if(substr($k,0,5)=="sm_b_") { - if($k=="sm_b_filename" || $k=="sm_b_fileurl_manual" || $k=="sm_b_filename_manual" || $k=="sm_b_prio_provider" || $k=="sm_b_manual_key" || $k == "sm_b_yahookey" || $k == "sm_b_style" || $k == "sm_b_memory") { + if($k=="sm_b_filename" || $k=="sm_b_fileurl_manual" || $k=="sm_b_filename_manual" || $k=="sm_b_prio_provider" || $k=="sm_b_manual_key" || $k == "sm_b_yahookey" || $k == "sm_b_style" || $k == "sm_b_memory" || $k == "sm_b_postimages_license") { if($k=="sm_b_filename_manual" && strpos($_POST[$k],"\\")!==false){ $_POST[$k]=stripslashes($_POST[$k]); } @@ -251,6 +251,10 @@ $this->sg->SetOption('b_auto_delay',false); } + if (!function_exists('has_post_thumbnail')) { + $this->sg->SetOption('in_post_images',false); + } + //Apply page changes from POST $this->sg->_pages=$this->sg->HtmlApplyPages(); @@ -1007,6 +1011,15 @@
  • +
    +
    +
  • +