Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
103 lines (99 sloc) 4.88 KB
--- sitemap-core.php 2012-12-25 13:59:09.000000000 +0800
+++ sitemap-core.php.new 2012-12-25 13:58:50.000000000 +0800
@@ -1661,8 +1661,8 @@
if($p) {
$homePid = $p->ID;
if (!$qt["enabled"])
- $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 qt_permalink($qt, trailingslashit($home), null, ($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"), $this);
+ $this->AddUrl(trailingslashit($home),$this->GetTimestampFromMySql(get_lastpostmodified('GMT')),$this->GetOption("cf_home"),$this->GetOption("pr_home"));
+ else qt_permalink($qt, trailingslashit($home), null, get_lastpostmodified('GMT'), $this->GetOption("cf_home"), $this->GetOption("pr_home"), $this);
}
} else {
if (!$qt["enabled"])
@@ -1963,9 +1963,22 @@
if($cats && is_array($cats) && count($cats)>0) {
foreach($cats AS $cat) {
if(!in_array($cat->term_id, $exclCats)) {
+ // Get the modify date of the latest post in each tag
+ $query_posts_args = array(
+ 'sort_order' => 'DESC',
+ 'sort_column' => 'post_modified',
+ 'numberposts' => 1,
+ 'post_status' => 'publish',
+ 'category' => $cat->term_id
+ );
+ $cat_posts = get_posts($query_posts_args);
+ $cat_lastmod = 0;
+ if (count($cat_posts) > 0) {
+ $cat_lastmod = $this->GetTimestampFromMySql($cat_posts[0]->post_modified_gmt);
+ }
if (!$qt["enabled"])
- $this->AddUrl(get_category_link($cat->term_id),0,$this->GetOption("cf_cats"),$this->GetOption("pr_cats"));
- else qt_permalink($qt, get_category_link($cat->term_id), null, 0, $this->GetOption("cf_cats"), $this->GetOption("pr_cats"), $this);
+ $this->AddUrl(get_category_link($cat->term_id),$cat_lastmod,$this->GetOption("cf_cats"),$this->GetOption("pr_cats"));
+ else qt_permalink($qt, get_category_link($cat->term_id), null, $cat_lastmod, $this->GetOption("cf_cats"), $this->GetOption("pr_cats"), $this);
}
}
}
@@ -1981,9 +1994,9 @@
//WP2.1 introduced post_status='future', for earlier WP versions we need to check the post_date_gmt
$arcresults = $wpdb->get_results("
SELECT DISTINCT
- YEAR(post_date_gmt) AS `year`,
- MONTH(post_date_gmt) AS `month`,
- MAX(post_date_gmt) as last_mod,
+ YEAR(post_modified_gmt) AS `year`,
+ MONTH(post_modified_gmt) AS `month`,
+ MAX(post_modified_gmt) as last_mod,
count(ID) as posts
FROM
$wpdb->posts
@@ -1991,12 +2004,12 @@
post_date < '$now'
AND post_status = 'publish'
AND post_type = 'post'
- " . (floatval($wp_version) < 2.1?"AND {$wpdb->posts}.post_date_gmt <= '" . gmdate('Y-m-d H:i:59') . "'":"") . "
+ " . (floatval($wp_version) < 2.1?"AND {$wpdb->posts}.post_modified_gmt <= '" . gmdate('Y-m-d H:i:59') . "'":"") . "
GROUP BY
- YEAR(post_date_gmt),
- MONTH(post_date_gmt)
+ YEAR(post_modified_gmt),
+ MONTH(post_modified_gmt)
ORDER BY
- post_date_gmt DESC");
+ post_modified_gmt DESC");
if ($arcresults) {
foreach ($arcresults as $arcresult) {
@@ -2078,11 +2091,25 @@
$tags = get_terms("post_tag",array("hide_empty"=>true,"hierarchical"=>false));
if($tags && is_array($tags) && count($tags)>0) {
foreach($tags AS $tag) {
+ // Get the modify date of the latest post in each tag
+ $query_posts_args = array(
+ 'sort_order' => 'DESC',
+ 'sort_column' => 'post_modified',
+ 'numberposts' => 1,
+ 'post_status' => 'publish',
+ 'tag_id' => $tag->term_id
+ );
+ $tag_posts = get_posts($query_posts_args);
+ $tag_lastmod = 0;
+ if (count($tag_posts) > 0) {
+ $tag_lastmod = $this->GetTimestampFromMySql($tag_posts[0]->post_modified_gmt);
+ }
if (!$qt["enabled"])
- $this->AddUrl(get_tag_link($tag->term_id),0,$this->GetOption("cf_tags"),$this->GetOption("pr_tags"));
- else qt_permalink($qt, get_tag_link($tag->term_id), null, 0, $this->GetOption("cf_tags"), $this->GetOption("pr_tags"), $this);
+ $this->AddUrl(get_tag_link($tag->term_id),$tag_lastmod,$this->GetOption("cf_tags"),$this->GetOption("pr_tags"));
+ else qt_permalink($qt, get_tag_link($tag->term_id), null, $tag_lastmod, $this->GetOption("cf_tags"), $this->GetOption("pr_tags"), $this);
}
}
+ fclose($file);
if($debug) $this->AddElement(new GoogleSitemapGeneratorDebugEntry("Debug: End Tags"));
}
@@ -2564,4 +2591,4 @@
}
-}
\ No newline at end of file
+}
You can’t perform that action at this time.