Version Description
- complete rewrite of plugin internals
- speed improvements
- WP 3.0 (normal and MS mode) ready
Download this release
Release Info
Developer | RavanH |
Plugin | XML Sitemap & Google News feeds |
Version | 3.5 |
Comparing to | |
See all releases |
Code changes from version 3.4 to 3.5
- feed-sitemap.xml.php +0 -86
- readme.txt +58 -48
- sitemap.xml.php +83 -0
- feed-sitemap.xsl.php → sitemap.xsl.php +69 -71
- xml-sitemap.php +68 -36
feed-sitemap.xml.php
DELETED
@@ -1,86 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/* ---------------------------
|
3 |
-
XML Sitemap Feed Template
|
4 |
-
--------------------------- */
|
5 |
-
|
6 |
-
if (!empty($_SERVER['SCRIPT_FILENAME']) && 'feed-xml.php' == basename($_SERVER['SCRIPT_FILENAME']))
|
7 |
-
die ('Please do not load this page directly. Thanks!');
|
8 |
-
|
9 |
-
// priority presets
|
10 |
-
$frontpage_priority = 1.0;
|
11 |
-
$post_priority = 0.7;
|
12 |
-
$minpost_priority = 0.1;
|
13 |
-
$maxpost_priority = 0.9;
|
14 |
-
$page_priority = 0.5;
|
15 |
-
|
16 |
-
$lastpostmodified = get_lastpostmodified('GMT');
|
17 |
-
|
18 |
-
// start the xml output
|
19 |
-
@header('Content-Type: text/xml; charset=' . get_option('blog_charset'));
|
20 |
-
|
21 |
-
echo '<?xml version="1.0" encoding="'.get_option('blog_charset').'"?>
|
22 |
-
<?xml-stylesheet type="text/xsl" href="'.get_option('home').'/sitemap.xsl?v='.XMLSFVERSION.'"?>
|
23 |
-
<!-- generated-on="'.date('Y-m-d\TH:i:s+00:00').'" -->
|
24 |
-
<!-- generator="XML Sitemap Feed plugin for WordPress" -->
|
25 |
-
<!-- generator-url="http://4visions.nl/en/index.php?section=57" -->
|
26 |
-
<!-- generator-version="'.XMLSFVERSION.'" -->
|
27 |
-
'; ?>
|
28 |
-
<urlset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
29 |
-
xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd"
|
30 |
-
xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
|
31 |
-
<url>
|
32 |
-
<loc><?php bloginfo_rss('url') ?>/</loc>
|
33 |
-
<lastmod><?php echo mysql2date('Y-m-d\TH:i:s+00:00', $lastpostmodified, false); ?></lastmod>
|
34 |
-
<changefreq>daily</changefreq>
|
35 |
-
<priority>1.0</priority>
|
36 |
-
</url>
|
37 |
-
<?php
|
38 |
-
// first check if there is a static page set as frontpage and exclude it to avoid double url
|
39 |
-
$has_page_as_front = $wpdb->get_results("SELECT option_value FROM $wpdb->options WHERE option_name = 'show_on_front'");
|
40 |
-
if ($has_page_as_front[0]->option_value == "page") {
|
41 |
-
$frontpage = $wpdb->get_results("SELECT option_value FROM $wpdb->options WHERE option_name = 'page_on_front'");
|
42 |
-
$frontpage_id = $frontpage[0]->option_value;
|
43 |
-
} else {
|
44 |
-
$frontpage_id = -1;
|
45 |
-
|
46 |
-
}
|
47 |
-
|
48 |
-
// get all posts and pages
|
49 |
-
$post_ids = $wpdb->get_col("SELECT ID FROM $wpdb->posts WHERE post_status = 'publish' AND ID != $frontpage_id ORDER BY post_date_gmt DESC LIMIT 1000");
|
50 |
-
|
51 |
-
// and loop away!
|
52 |
-
if ($post_ids) {
|
53 |
-
global $wp_query;
|
54 |
-
$wp_query->in_the_loop = true;
|
55 |
-
|
56 |
-
while ( $next_posts = array_splice($post_ids, 0, 20) ) {
|
57 |
-
$where = "WHERE ID IN (".join(',', $next_posts).")";
|
58 |
-
$posts = $wpdb->get_results("SELECT * FROM $wpdb->posts $where ORDER BY post_date_gmt DESC");
|
59 |
-
foreach ($posts as $post) {
|
60 |
-
setup_postdata($post);
|
61 |
-
$post_modified_time = get_post_modified_time('Y-m-d H:i:s', true);
|
62 |
-
$priority_down = (($lastpostmodified - $post_modified_time) > 0) ? ($lastpostmodified - $post_modified_time)/10 : 0;
|
63 |
-
$priority_up = ($post->comment_count > 0) ? $post->comment_count/10 : 0;
|
64 |
-
$priority = $post_priority - $priority_down + $priority_up;
|
65 |
-
$priority = ($priority > $maxpost_priority) ? $maxpost_priority : $priority;
|
66 |
-
$priority = ($priority < $minpost_priority) ? $minpost_priority : $priority;
|
67 |
-
?>
|
68 |
-
<url>
|
69 |
-
<loc><?php the_permalink_rss() ?></loc>
|
70 |
-
<lastmod><?php echo mysql2date('Y-m-d\TH:i:s+00:00', $post_modified_time, false) ?></lastmod>
|
71 |
-
<?php if($post->post_type == "page") { ?>
|
72 |
-
<changefreq>monthly</changefreq>
|
73 |
-
<priority><?php echo $page_priority ?></priority>
|
74 |
-
<?php } else {
|
75 |
-
if($post->comment_count > 0) { ?>
|
76 |
-
<changefreq>weekly</changefreq>
|
77 |
-
<?php } else { ?>
|
78 |
-
<changefreq>monthly</changefreq>
|
79 |
-
<?php } ?>
|
80 |
-
<priority><?php echo $priority ?></priority>
|
81 |
-
<?php } ?>
|
82 |
-
</url>
|
83 |
-
<?php }
|
84 |
-
}
|
85 |
-
} ?>
|
86 |
-
</urlset>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
readme.txt
CHANGED
@@ -1,20 +1,20 @@
|
|
1 |
=== XML Sitemap Feed ===
|
2 |
Contributors: RavanH
|
3 |
Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=ravanhagen%40gmail%2ecom&item_name=XML%20Sitemap&item_number=2%2e6%2e2%2e9&no_shipping=0&tax=0&bn=PP%2dDonationsBF&charset=UTF%2d8
|
4 |
-
Tags: sitemap, xml sitemap, google, yahoo, feed, wpmu
|
5 |
-
Requires at least: 2.
|
6 |
Tested up to: 3.0
|
7 |
-
Stable tag: 3.
|
8 |
|
9 |
-
Creates a feed that complies with the XML Sitemap protocol ready for indexing by Google, Yahoo,
|
10 |
|
11 |
== Description ==
|
12 |
|
13 |
-
This plugin dynamically creates an XML feed that complies with the XML Sitemap protocol. There are no options to be set and the feed becomes instantly available after activation on yourblogurl.tld/sitemap.xml (or yourblogurl.tld/index.php?
|
14 |
|
15 |
-
An entry `Sitemap: http://yourblogurl.tld/sitemap.xml` is added to the (by WordPress dynamically created) robots.txt on yourblogurl.tld/robots.txt to tell search engines where to find your XML Sitemap. If you do not use fancy URL's in WordPress, you will have to create your own robots.txt file. See FAQ's.
|
16 |
|
17 |
-
= Advantages =
|
18 |
|
19 |
* The main advantage of this plugin over other XML Sitemap plugins is **simplicity**. No need to change file or folder permissions, move files or spend time on a difficult plugin options page. In fact, there are no options at all!
|
20 |
* Works out-of-the-box on **multi-site / shared codebase / multi-blog setups** like [WordPress MU](http://mu.wordpress.org/), WP 3.0 in MS mode and others.
|
@@ -25,15 +25,14 @@ An entry `Sitemap: http://yourblogurl.tld/sitemap.xml` is added to the (by WordP
|
|
25 |
|
26 |
* The feed contains the front page and all posts and pages but _excludes_ category, tag and other dynamic archive pages. This should not be a problem and by some it is even advised. There are SEO plugins around that even make these archive pages non-indexable by search engines.
|
27 |
* Except by _resaving_ older posts from time to time (keeping the lastmod date fairly recent to ensure automatic high priority calculation for those urls) there is no way to manually set the priority of individual posts/pages in the sitemap. See the Faq's for more.
|
28 |
-
* This plugin does not ping any search engines. But then, WordPress does this by default already via the Ping-o-Matic service so why bother?
|
29 |
-
* The number of posts listed in the sitemap is limited to 1000. This should satisfy most blogs while limiting the sitemap size on bigger blogs by stripping of the oldest posts. Please let me know if you need more than your most recent 1000 posts listed in your sitemap.xml :)
|
30 |
|
31 |
= Translations =
|
32 |
|
33 |
There is nothing to translate. The sitemap protocol is international, there is no options page nor any front-end / widget output. Nothing to see here, please move along ;)
|
34 |
|
35 |
= Credits =
|
36 |
-
XML Sitemap Feed was originally based on the (discontinued?) plugin Standard XML Sitemap Generator by Patrick Chia. Many thanks!
|
37 |
|
38 |
|
39 |
== Installation ==
|
@@ -54,6 +53,10 @@ follow these simple steps:
|
|
54 |
|
55 |
Done! Check your sparkling new XML Sitemap by visiting yourblogurl.tld/sitemap.xml (adapted to your domain name ofcourse) with a browser or any online XML Sitemap validator. You might also want to check if the sitemap is listed in your yourblogurl.tld/robots.txt file.
|
56 |
|
|
|
|
|
|
|
|
|
57 |
= Wordpress MU =
|
58 |
|
59 |
The plugin works best from the **/mu-plugins/** folder where it runs quietly in the background without bothering any blog owner with new options or the need for special knowledge of XML Sitemap submission. Just upload the complete package content to /mu-plugins/ and move the file xml-sitemap.php from the new /mu-plugins/xml-sitemap-feed/ to /mu-plugins/.
|
@@ -62,33 +65,31 @@ Installed in /mu-plugins/ alongside [WordPress MU Sitewide Tags Pages](http://wo
|
|
62 |
|
63 |
== Frequently Asked Questions ==
|
64 |
|
65 |
-
|
66 |
-
|
67 |
-
= Sitemap / Robots =
|
68 |
|
69 |
-
|
70 |
-
|
71 |
-
**A:** The front page has a fixed priority of 100% (1.0), pages are always 50% (0.5) and new posts have a default priority of 70% (0.7) but can vary between 10% (0.1) and 90% (0.9) depending on comments and post age. The cangefreq of the frontpage is set to daily, monthly for pages and either monthly or weekly for posts depending on comments.
|
72 |
|
73 |
Dynamic pages like category pages, tag pages and archive pages are not listed in the XML Sitemap.
|
74 |
|
75 |
-
|
|
|
|
|
76 |
|
77 |
-
|
78 |
|
79 |
-
|
80 |
|
81 |
-
|
82 |
|
83 |
-
|
84 |
|
85 |
-
|
86 |
|
87 |
-
|
88 |
|
89 |
-
|
90 |
|
91 |
-
|
92 |
|
93 |
1. WordPress has a built-in pinging feature. Go in your WP Admin section to Settings > Writing and make sure that the text area under **Update services** contains at least
|
94 |
`
|
@@ -100,62 +101,62 @@ Read more on [Ping-O-Matic](http://pingomatic.com) about what excellent service
|
|
100 |
|
101 |
You can always take a [Google Webmaster Tools account](https://www.google.com/webmasters/tools/) which will tell you many interesting things about your website, search terms and your visitors. Try it!
|
102 |
|
103 |
-
|
104 |
|
105 |
-
|
106 |
|
107 |
-
|
108 |
|
109 |
-
|
110 |
|
111 |
-
|
112 |
|
113 |
-
|
114 |
|
115 |
-
|
|
|
|
|
116 |
`
|
117 |
Sitemap: http://yourblogurl.tld/subdir/sitemap.xml
|
118 |
`
|
119 |
|
120 |
If you already have a robots.txt file with a line like that, you might want to read more about creating an XML Sitemap Index on [sitemaps.org](http://www.sitemaps.org/protocol.php#index).
|
121 |
|
122 |
-
|
123 |
|
124 |
-
|
125 |
|
126 |
-
Check to see if the URL yourblogurl.tld
|
127 |
`
|
128 |
-
Sitemap: http://yourblogurl.tld
|
129 |
|
130 |
User-agent: *
|
131 |
Allow: /
|
132 |
`
|
133 |
-
You can also choose to notify major search engines of your new XML sitemap manually. Start with getting a [Google Webmaster Tools account](https://www.google.com/webmasters/tools/).
|
134 |
-
|
135 |
-
= Advanced / Troubleshooting =
|
136 |
|
137 |
-
|
138 |
|
139 |
-
|
140 |
|
141 |
-
|
142 |
|
143 |
-
|
144 |
|
145 |
-
The stylesheet (to make the sitemap human readable) can be edited in `xml-sitemap-feed/
|
146 |
|
147 |
-
|
148 |
|
149 |
-
|
150 |
`
|
151 |
User-agent: *
|
152 |
Disallow:
|
153 |
`
|
154 |
Reactivate your plugins one by one to find out which one is causing the problem. Then report the bug to the plugin developer.
|
155 |
|
156 |
-
|
157 |
|
158 |
-
|
159 |
|
160 |
To get around this, you might either at least write one post and give it _Private_ status or alternatively create your own robots.txt file containing:
|
161 |
`
|
@@ -166,8 +167,17 @@ Allow: /
|
|
166 |
`
|
167 |
and upload it to your web root...
|
168 |
|
|
|
|
|
|
|
|
|
169 |
== Changelog ==
|
170 |
|
|
|
|
|
|
|
|
|
|
|
171 |
= 3.4 =
|
172 |
* bugfix: use home instead of siteurl for blog url for sitemap reference in robots.txt
|
173 |
* code streamline and cleanup
|
1 |
=== XML Sitemap Feed ===
|
2 |
Contributors: RavanH
|
3 |
Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=ravanhagen%40gmail%2ecom&item_name=XML%20Sitemap&item_number=2%2e6%2e2%2e9&no_shipping=0&tax=0&bn=PP%2dDonationsBF&charset=UTF%2d8
|
4 |
+
Tags: sitemap, xml sitemap, google, yahoo, bing, feed, wpmu
|
5 |
+
Requires at least: 2.6
|
6 |
Tested up to: 3.0
|
7 |
+
Stable tag: 3.5
|
8 |
|
9 |
+
Creates a feed that complies with the XML Sitemap protocol ready for indexing by Google, Yahoo, Bing, Ask and others.
|
10 |
|
11 |
== Description ==
|
12 |
|
13 |
+
This plugin dynamically creates an XML feed that complies with the XML Sitemap protocol. There are no options to be set and the feed becomes instantly available after activation on yourblogurl.tld/sitemap.xml (or yourblogurl.tld/index.php?sitemap=1 if you do not use a fancy permalink structure) ready for indexing by search engines like Google, Yahoo, MSN, Ask.com and others.
|
14 |
|
15 |
+
An entry `Sitemap: http://yourblogurl.tld/sitemap.xml` is added to the (by WordPress dynamically created) robots.txt on yourblogurl.tld/robots.txt to tell search engines where to find your XML Sitemap. If you do not use fancy URL's in WordPress, have WP installed in a subdirectory or if you use WP for pages only and do not have any posts, WordPress does not generate a robots.txt output. You will have to create your own robots.txt file and upload it to your site root. See FAQ's.
|
16 |
|
17 |
+
= Advantages =
|
18 |
|
19 |
* The main advantage of this plugin over other XML Sitemap plugins is **simplicity**. No need to change file or folder permissions, move files or spend time on a difficult plugin options page. In fact, there are no options at all!
|
20 |
* Works out-of-the-box on **multi-site / shared codebase / multi-blog setups** like [WordPress MU](http://mu.wordpress.org/), WP 3.0 in MS mode and others.
|
25 |
|
26 |
* The feed contains the front page and all posts and pages but _excludes_ category, tag and other dynamic archive pages. This should not be a problem and by some it is even advised. There are SEO plugins around that even make these archive pages non-indexable by search engines.
|
27 |
* Except by _resaving_ older posts from time to time (keeping the lastmod date fairly recent to ensure automatic high priority calculation for those urls) there is no way to manually set the priority of individual posts/pages in the sitemap. See the Faq's for more.
|
28 |
+
* This plugin does not ping any search engines. But then, WordPress does this by default already via the Ping-o-Matic service so why bother? See the Faq's for more.
|
|
|
29 |
|
30 |
= Translations =
|
31 |
|
32 |
There is nothing to translate. The sitemap protocol is international, there is no options page nor any front-end / widget output. Nothing to see here, please move along ;)
|
33 |
|
34 |
= Credits =
|
35 |
+
XML Sitemap Feed was originally based on the (discontinued?) plugin Standard XML Sitemap Generator by Patrick Chia. Many thanks! Since then, it has been completely rewriten.
|
36 |
|
37 |
|
38 |
== Installation ==
|
53 |
|
54 |
Done! Check your sparkling new XML Sitemap by visiting yourblogurl.tld/sitemap.xml (adapted to your domain name ofcourse) with a browser or any online XML Sitemap validator. You might also want to check if the sitemap is listed in your yourblogurl.tld/robots.txt file.
|
55 |
|
56 |
+
= WordPress 3+ in Multi Site mode =
|
57 |
+
|
58 |
+
Same as above but do a **Network Activate** to make a XML sitemap available for each site on your network.
|
59 |
+
|
60 |
= Wordpress MU =
|
61 |
|
62 |
The plugin works best from the **/mu-plugins/** folder where it runs quietly in the background without bothering any blog owner with new options or the need for special knowledge of XML Sitemap submission. Just upload the complete package content to /mu-plugins/ and move the file xml-sitemap.php from the new /mu-plugins/xml-sitemap-feed/ to /mu-plugins/.
|
65 |
|
66 |
== Frequently Asked Questions ==
|
67 |
|
68 |
+
= How are the values for priority and changefreq calculated? =
|
|
|
|
|
69 |
|
70 |
+
The front page has a fixed priority of 100% (1.0), pages are always 40% (0.4) and new posts have a default priority of 70% (0.7) but can vary between 10% (0.1) and 90% (0.9) depending on comments and post age. The cangefreq of the frontpage is set to monthly for pages and either monthly, weekly or daily for posts depending on comments.
|
|
|
|
|
71 |
|
72 |
Dynamic pages like category pages, tag pages and archive pages are not listed in the XML Sitemap.
|
73 |
|
74 |
+
= Can I manipulate values for priority and changefreq? =
|
75 |
+
|
76 |
+
Yes and No. This plugin has no options page so there is no way to manually set the priority of urls in the sitemap. But there is automatic post priority calculation based on _post modifaction date_ and comment activity, that can either make post priority go to 90% (0.9) for fairly recent posts with many comments or 10% (0.1) for very old posts with no comments.
|
77 |
|
78 |
+
This feature can be used to your advantage: by resaving your most important older posts from time to time, keeping the **lastmod date** fairly recent, you can ensure a priority of at least 70% (0.7) for those urls. And if you have comments on on those pages, the priority will even go up to 90% (0.9).
|
79 |
|
80 |
+
If you cannot live with these rules, edit the values `$post_priority`, `$minpost_priority`, `$maxpost_priority`, `$page_priority`, `$frontpage_priority` in xml-sitemap-feed/sitemap.xml.php
|
81 |
|
82 |
+
= Do I need to submit the sitemap to search engines? =
|
83 |
|
84 |
+
No. In normal circumstances, your site will be indexed by the major search engines before you know it. The search engines will be looking for a robots.txt file and (with this plugin activated) find a pointer in it to the XML Sitemap on your blog. The search engines will return on a regular basis to see if your site has updates.
|
85 |
|
86 |
+
Read more about _Ping-O-Matic_ under **Does this plugin ping search engines** (below) to make sure your site is under _normal circumstances_ ;)
|
87 |
|
88 |
+
But if you have a server without rewrite rules, use your blog without fancy URLs or have it installed in a subdirectory, read **Do I need to change my robots.txt** for more instructions.
|
89 |
|
90 |
+
= Does this plugin ping search engines? =
|
91 |
|
92 |
+
No. While other XML Sitemap plugins provide pinging to some search engines upon each post edit or publication, this plugin does not. There are two reasons for that:
|
93 |
|
94 |
1. WordPress has a built-in pinging feature. Go in your WP Admin section to Settings > Writing and make sure that the text area under **Update services** contains at least
|
95 |
`
|
101 |
|
102 |
You can always take a [Google Webmaster Tools account](https://www.google.com/webmasters/tools/) which will tell you many interesting things about your website, search terms and your visitors. Try it!
|
103 |
|
104 |
+
= I see no sitemap.xml file in my server space! =
|
105 |
|
106 |
+
The sitemap is dynamically generated just like a feed. There is no actual file created.
|
107 |
|
108 |
+
= Do I need to change my robots.txt? =
|
109 |
|
110 |
+
That depends. In normal circumstances, if you have no physical robots.txt file in your site root, the new sitemap url will be automatically added to the dynamic robots.txt that is generated by WordPress. But in some cases this might not be the case.
|
111 |
|
112 |
+
If you use a static robots.txt file in your website root, you will need to open it in a text editor and add a line like `Sitemap: http://yourblogurl.tld/sitemap.xml` (adapt to your site url) to make search engines find your XML Sitemap.
|
113 |
|
114 |
+
Or if you have WP installed in a subdirectory, on a server without rewrite_rules or if you do not use fancy URLs in your Permalink structure settings. In these cases, WordPress will need a little help in getting ready for XML Sitemap indexing. Read on in the **WordPress** section for more.
|
115 |
|
116 |
+
= My WordPress powered blog is installed in a subdirectory. Does that change anything? =
|
117 |
+
|
118 |
+
That depends on where the index.php and .htaccess of your installation resides. If it is in the root, meaning WP is installed in a subdir but the blog is accessible from your domain root, you do not have to do anything. It should work out of the box. However, if the index.php is (e.g. still with your wp-config.php and all other WP files) in a subdir, meaning your blog is only accessible via that subdir, you need to manage your own robots.txt file in your domain root. It _has_ to be in the root (!) and needs a line starting with `Sitemap:` followed by the full URL to the sitemap feed provided by XML Sitemap Feed plugin. Like:
|
119 |
`
|
120 |
Sitemap: http://yourblogurl.tld/subdir/sitemap.xml
|
121 |
`
|
122 |
|
123 |
If you already have a robots.txt file with a line like that, you might want to read more about creating an XML Sitemap Index on [sitemaps.org](http://www.sitemaps.org/protocol.php#index).
|
124 |
|
125 |
+
= Do I need to use a fancy Permalink structure? =
|
126 |
|
127 |
+
No. While I would advise you to use any one of the nicer Permalink structures, you might not be able to (or don't want to) do that. If so, you can still use this plugin:
|
128 |
|
129 |
+
Check to see if the URL yourblogurl.tld/index.php?sitemap=1 (notice the **?sitemap=** !) does produce a feed. Now manually upload your own robots.txt file to your website root containing:
|
130 |
`
|
131 |
+
Sitemap: http://yourblogurl.tld/index.php?sitemap=1
|
132 |
|
133 |
User-agent: *
|
134 |
Allow: /
|
135 |
`
|
136 |
+
You can also choose to notify major search engines of your new XML sitemap manually. Start with getting a [Google Webmaster Tools account](https://www.google.com/webmasters/tools/) or head over to [XML-Sitemaps.com](http://www.xml-sitemaps.com/validate-xml-sitemap.html) and enter your sites sitemap URL.
|
|
|
|
|
137 |
|
138 |
+
= Can I change the sitemap name/URL? =
|
139 |
|
140 |
+
No. If you have fancy URL's turned ON in WordPress (Permalinks), the sitemap url that you manually submit to Google (if you are impatient) should be `yourblogurl.tld/sitemap.xml` but if you have the Default option set the feed is only available via `yourblogurl.tld/?sitemap=1`.
|
141 |
|
142 |
+
= Where can I customize the xml output? =
|
143 |
|
144 |
+
You may edit the XML output in `xml-sitemap-feed/sitemap.xml.php` but be carefull not to break Sitemap protocol comliance. Read more on [Sitemaps XML format](http://www.sitemaps.org/protocol.php).
|
145 |
|
146 |
+
The stylesheet (to make the sitemap human readable) can be edited in `xml-sitemap-feed/sitemap.xsl.php`.
|
147 |
|
148 |
+
= I get a 404 page instead of both sitemap.xml and robots.txt! =
|
149 |
|
150 |
+
There are plugins like Event Calendar (at least v.3.2.beta2) known to mess with rewrite rules, causing problems with WordPress internal feeds and robots.txt generation and thus conflict with the XML Sitemap Feed plugin. Deactivate all plugins and see if you get a basic robots.txt file showing:
|
151 |
`
|
152 |
User-agent: *
|
153 |
Disallow:
|
154 |
`
|
155 |
Reactivate your plugins one by one to find out which one is causing the problem. Then report the bug to the plugin developer.
|
156 |
|
157 |
+
= I get a 404 page instead of robots.txt while sitemap.xml works fine! =
|
158 |
|
159 |
+
There is a know issue with WordPress (at least up to 2.8) not generating a robots.txt when there are _no posts_ with _published_ status. If you use WordPress as a CMS with only _pages_, this will affect you.
|
160 |
|
161 |
To get around this, you might either at least write one post and give it _Private_ status or alternatively create your own robots.txt file containing:
|
162 |
`
|
167 |
`
|
168 |
and upload it to your web root...
|
169 |
|
170 |
+
= Can I do a Network Activate with this plugin on WP3.0 MS / WPMU ? =
|
171 |
+
|
172 |
+
Yes.
|
173 |
+
|
174 |
== Changelog ==
|
175 |
|
176 |
+
= 3.5 =
|
177 |
+
* complete rewrite of plugin internals
|
178 |
+
* speed improvements
|
179 |
+
* WP 3.0 (normal and MS mode) ready
|
180 |
+
|
181 |
= 3.4 =
|
182 |
* bugfix: use home instead of siteurl for blog url for sitemap reference in robots.txt
|
183 |
* code streamline and cleanup
|
sitemap.xml.php
ADDED
@@ -0,0 +1,83 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/* ---------------------------
|
3 |
+
XML Sitemap Feed Template
|
4 |
+
--------------------------- */
|
5 |
+
|
6 |
+
// priority presets
|
7 |
+
$frontpage_priority = 1.0;
|
8 |
+
$post_priority = 0.7;
|
9 |
+
$minpost_priority = 0.1;
|
10 |
+
$maxpost_priority = 0.9;
|
11 |
+
$page_priority = 0.4;
|
12 |
+
|
13 |
+
$lastpostmodified = get_lastpostmodified('GMT');
|
14 |
+
$totalcommentcount = get_comment_count();
|
15 |
+
|
16 |
+
global $post;
|
17 |
+
query_posts( array(
|
18 |
+
'posts_per_page' => '-1',
|
19 |
+
'post_type' => 'any',
|
20 |
+
'post_status' => 'publish',
|
21 |
+
'caller_get_posts' => '1'
|
22 |
+
)
|
23 |
+
);
|
24 |
+
|
25 |
+
// start the xml output
|
26 |
+
header('Content-Type: text/xml; charset=' . get_option('blog_charset'), true);
|
27 |
+
echo '<?xml version="1.0" encoding="'.get_option('blog_charset').'"?>
|
28 |
+
<?xml-stylesheet type="text/xsl" href="'.get_option('home').'/'.str_replace(ABSPATH,"", XMLSF_PLUGIN_DIR).'/sitemap.xsl.php?v='.XMLSF_VERSION.'"?>
|
29 |
+
<!-- generated-on="'.date('Y-m-d\TH:i:s+00:00').'" -->
|
30 |
+
<!-- generator="XML Sitemap Feed plugin for WordPress" -->
|
31 |
+
<!-- generator-url="http://4visions.nl/en/index.php?section=57" -->
|
32 |
+
<!-- generator-version="'.XMLSF_VERSION.'" -->
|
33 |
+
'; ?>
|
34 |
+
<urlset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
35 |
+
xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd"
|
36 |
+
xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
|
37 |
+
<url>
|
38 |
+
<loc><?php bloginfo_rss('url') ?>/</loc>
|
39 |
+
<lastmod><?php echo mysql2date('Y-m-d\TH:i:s+00:00', $lastpostmodified, false); ?></lastmod>
|
40 |
+
<changefreq>daily</changefreq>
|
41 |
+
<priority>1.0</priority>
|
42 |
+
</url>
|
43 |
+
<?php
|
44 |
+
// first check if there is a static page set as frontpage and exclude it to avoid double url
|
45 |
+
//$has_page_as_front = $wpdb->get_results("SELECT option_value FROM $wpdb->options WHERE option_name = 'show_on_front'");
|
46 |
+
//if ($has_page_as_front[0]->option_value == "page") {
|
47 |
+
// $frontpage = $wpdb->get_results("SELECT option_value FROM $wpdb->options WHERE option_name = 'page_on_front'");
|
48 |
+
// $frontpage_id = $frontpage[0]->option_value;
|
49 |
+
//} else {
|
50 |
+
// $frontpage_id = -1;
|
51 |
+
//}
|
52 |
+
|
53 |
+
// and loop away!
|
54 |
+
while ( have_posts() ) : the_post();
|
55 |
+
|
56 |
+
//setup_postdata($post);
|
57 |
+
$post_modified_time = get_post_modified_time('Y-m-d H:i:s', true);
|
58 |
+
$post_comment_count = get_comment_count($post->ID);
|
59 |
+
$priority_down = (($lastpostmodified - $post_modified_time) > 0) ? ($lastpostmodified - $post_modified_time)/10 : 0;
|
60 |
+
$priority_up = ($post_comment_count['approved'] > 0) ? ($post_comment_count['approved']/$totalcommentcount['approved'])*10 : 0;
|
61 |
+
$priority = $post_priority - $priority_down + $priority_up;
|
62 |
+
$priority = ($priority > $maxpost_priority) ? $maxpost_priority : $priority;
|
63 |
+
$priority = ($priority < $minpost_priority) ? $minpost_priority : $priority;
|
64 |
+
?>
|
65 |
+
<url>
|
66 |
+
<loc><?php the_permalink_rss() ?></loc>
|
67 |
+
<lastmod><?php echo mysql2date('Y-m-d\TH:i:s+00:00', $post_modified_time, false) ?></lastmod>
|
68 |
+
<?php if($post->post_type == "page") { ?>
|
69 |
+
<changefreq>monthly</changefreq>
|
70 |
+
<priority><?php echo $page_priority ?></priority>
|
71 |
+
<?php } else {
|
72 |
+
if($post_comment_count['approved'] > 10) { ?>
|
73 |
+
<changefreq>daily</changefreq>
|
74 |
+
<?php } else if($post_comment_count['approved'] > 0) { ?>
|
75 |
+
<changefreq>weekly</changefreq>
|
76 |
+
<?php } else { ?>
|
77 |
+
<changefreq>monthly</changefreq>
|
78 |
+
<?php } ?>
|
79 |
+
<priority><?php echo $priority ?></priority>
|
80 |
+
<?php } ?>
|
81 |
+
</url>
|
82 |
+
<?php endwhile; ?>
|
83 |
+
</urlset>
|
feed-sitemap.xsl.php → sitemap.xsl.php
RENAMED
@@ -3,77 +3,75 @@
|
|
3 |
XML Sitemap Feed Styleheet Template
|
4 |
------------------------------------- */
|
5 |
|
6 |
-
|
7 |
-
die ('Please do not load this page directly. Thanks!');
|
8 |
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
<xsl:
|
13 |
-
<xsl:
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
<
|
18 |
-
<
|
19 |
-
<style type="text/css">
|
20 |
body{font-family:"Lucida Grande","Lucida Sans Unicode",Tahoma,Verdana,sans-serif;font-size:13px}
|
21 |
-
#header,#footer{padding:2px;margin:10px;font-size:8pt;color:gray}
|
22 |
-
a{color:black}
|
23 |
-
td{font-size:11px}
|
24 |
-
th{text-align:left;padding-right:30px;font-size:11px}
|
25 |
-
tr.high{background-color:whitesmoke}
|
26 |
-
</style>
|
27 |
-
</head>
|
28 |
-
<body>
|
29 |
-
<h1>XML Sitemap Feed</h1>
|
30 |
-
<div id="header">
|
31 |
-
This is an XML Sitemap to aid search engines like <a href="http://www.google.com">Google</a>, <a href="http://
|
32 |
-
</div>
|
33 |
-
<div id="content">
|
34 |
-
<table cellpadding="5">
|
35 |
-
<tr style="border-bottom:1px black solid;">
|
36 |
-
<th>#</th>
|
37 |
-
<th>URL</th>
|
38 |
-
<th>Priority</th>
|
39 |
-
<th>Change Frequency</th>
|
40 |
-
<th>Last Changed</th>
|
41 |
-
</tr>
|
42 |
-
<xsl:variable name="lower" select="'abcdefghijklmnopqrstuvwxyz'"/>
|
43 |
-
<xsl:variable name="upper" select="'ABCDEFGHIJKLMNOPQRSTUVWXYZ'"/>
|
44 |
-
<xsl:for-each select="sitemap:urlset/sitemap:url">
|
45 |
-
<tr>
|
46 |
-
<xsl:if test="position() mod 2 != 1">
|
47 |
-
<xsl:attribute name="class">high</xsl:attribute>
|
48 |
-
</xsl:if>
|
49 |
-
<td>
|
50 |
-
<xsl:value-of select="position()"/>
|
51 |
-
</td>
|
52 |
-
<td>
|
53 |
-
<xsl:variable name="itemURL">
|
54 |
-
<xsl:value-of select="sitemap:loc"/>
|
55 |
-
</xsl:variable>
|
56 |
-
<a href="{$itemURL}">
|
57 |
-
<xsl:value-of select="sitemap:loc"/>
|
58 |
-
</a>
|
59 |
-
</td>
|
60 |
-
<td>
|
61 |
-
<xsl:value-of select="concat(sitemap:priority*100,'%')"/>
|
62 |
-
</td>
|
63 |
-
<td>
|
64 |
-
<xsl:value-of select="concat(translate(substring(sitemap:changefreq, 1, 1),concat($lower, $upper),concat($upper, $lower)),substring(sitemap:changefreq, 2))"/>
|
65 |
-
</td>
|
66 |
-
<td>
|
67 |
-
<xsl:value-of select="concat(substring(sitemap:lastmod,0,11),concat(' ', substring(sitemap:lastmod,12,5)))"/>
|
68 |
-
</td>
|
69 |
-
</tr>
|
70 |
-
</xsl:for-each>
|
71 |
-
</table>
|
72 |
-
</div>
|
73 |
-
<div id="footer">
|
74 |
-
Generated by <a href="http://4visions.nl/en/index.php?section=57" title="XML Sitemap Feed plugin for WordPress">XML Sitemap Feed <?php echo
|
75 |
-
</div>
|
76 |
-
</body>
|
77 |
-
</html>
|
78 |
-
</xsl:template>
|
79 |
</xsl:stylesheet>
|
3 |
XML Sitemap Feed Styleheet Template
|
4 |
------------------------------------- */
|
5 |
|
6 |
+
header('Content-Type: text/xsl; charset=utf-8', true);
|
|
|
7 |
|
8 |
+
echo '<?xml version="1.0" encoding="UTF-8"?>
|
9 |
+
'; ?>
|
10 |
+
<xsl:stylesheet version="2.0" xmlns:html="http://www.w3.org/TR/REC-html40" xmlns:sitemap="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
|
11 |
+
<xsl:output method="html" version="1.0" encoding="UTF-8" indent="yes"/>
|
12 |
+
<xsl:template match="/">
|
13 |
+
<html xmlns="http://www.w3.org/1999/xhtml">
|
14 |
+
<head>
|
15 |
+
<title>XML Sitemap Feed</title>
|
16 |
+
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
17 |
+
<style type="text/css">
|
|
|
18 |
body{font-family:"Lucida Grande","Lucida Sans Unicode",Tahoma,Verdana,sans-serif;font-size:13px}
|
19 |
+
#header,#footer{padding:2px;margin:10px;font-size:8pt;color:gray}
|
20 |
+
a{color:black}
|
21 |
+
td{font-size:11px}
|
22 |
+
th{text-align:left;padding-right:30px;font-size:11px}
|
23 |
+
tr.high{background-color:whitesmoke}
|
24 |
+
</style>
|
25 |
+
</head>
|
26 |
+
<body>
|
27 |
+
<h1>XML Sitemap Feed</h1>
|
28 |
+
<div id="header">
|
29 |
+
This is an XML Sitemap to aid search engines like <a href="http://www.google.com">Google</a>, <a href="http://www.bing.com/">Bing</a>, <a href="http://www.yahoo.com">Yahoo!</a> and <a href="http://www.ask.com">Ask</a> indexing your site better. Read more about XML sitemaps on <a href="http://sitemaps.org">Sitemaps.org</a>.
|
30 |
+
</div>
|
31 |
+
<div id="content">
|
32 |
+
<table cellpadding="5">
|
33 |
+
<tr style="border-bottom:1px black solid;">
|
34 |
+
<th>#</th>
|
35 |
+
<th>URL</th>
|
36 |
+
<th>Priority</th>
|
37 |
+
<th>Change Frequency</th>
|
38 |
+
<th>Last Changed</th>
|
39 |
+
</tr>
|
40 |
+
<xsl:variable name="lower" select="'abcdefghijklmnopqrstuvwxyz'"/>
|
41 |
+
<xsl:variable name="upper" select="'ABCDEFGHIJKLMNOPQRSTUVWXYZ'"/>
|
42 |
+
<xsl:for-each select="sitemap:urlset/sitemap:url">
|
43 |
+
<tr>
|
44 |
+
<xsl:if test="position() mod 2 != 1">
|
45 |
+
<xsl:attribute name="class">high</xsl:attribute>
|
46 |
+
</xsl:if>
|
47 |
+
<td>
|
48 |
+
<xsl:value-of select="position()"/>
|
49 |
+
</td>
|
50 |
+
<td>
|
51 |
+
<xsl:variable name="itemURL">
|
52 |
+
<xsl:value-of select="sitemap:loc"/>
|
53 |
+
</xsl:variable>
|
54 |
+
<a href="{$itemURL}">
|
55 |
+
<xsl:value-of select="sitemap:loc"/>
|
56 |
+
</a>
|
57 |
+
</td>
|
58 |
+
<td>
|
59 |
+
<xsl:value-of select="concat(sitemap:priority*100,'%')"/>
|
60 |
+
</td>
|
61 |
+
<td>
|
62 |
+
<xsl:value-of select="concat(translate(substring(sitemap:changefreq, 1, 1),concat($lower, $upper),concat($upper, $lower)),substring(sitemap:changefreq, 2))"/>
|
63 |
+
</td>
|
64 |
+
<td>
|
65 |
+
<xsl:value-of select="concat(substring(sitemap:lastmod,0,11),concat(' ', substring(sitemap:lastmod,12,5)))"/>
|
66 |
+
</td>
|
67 |
+
</tr>
|
68 |
+
</xsl:for-each>
|
69 |
+
</table>
|
70 |
+
</div>
|
71 |
+
<div id="footer">
|
72 |
+
Generated by <a href="http://4visions.nl/en/index.php?section=57" title="XML Sitemap Feed plugin for WordPress">XML Sitemap Feed <?php echo $_GET['v'] ?></a> running on <a href="http://wordpress.org/">WordPress</a>.
|
73 |
+
</div>
|
74 |
+
</body>
|
75 |
+
</html>
|
76 |
+
</xsl:template>
|
77 |
</xsl:stylesheet>
|
xml-sitemap.php
CHANGED
@@ -1,9 +1,9 @@
|
|
1 |
<?php
|
2 |
/*
|
3 |
Plugin Name: XML Sitemap Feed
|
4 |
-
Plugin URI: http://4visions.nl/
|
5 |
-
Description: Creates a
|
6 |
-
Version: 3.
|
7 |
Author: RavanH
|
8 |
Author URI: http://4visions.nl/
|
9 |
Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=ravanhagen%40gmail%2ecom&item_name=XML%20Sitemap%20Feed&item_number=2%2e6%2e2%2e9&no_shipping=0&tax=0&bn=PP%2dDonationsBF&charset=UTF%2d8
|
@@ -26,84 +26,116 @@ Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=ravan
|
|
26 |
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
27 |
*/
|
28 |
|
|
|
|
|
|
|
|
|
|
|
|
|
29 |
/* --------------------
|
30 |
-
|
31 |
-------------------- */
|
32 |
|
33 |
// set version
|
34 |
-
define('
|
35 |
|
36 |
// dir
|
37 |
$xmlsf_dir = dirname(__FILE__);
|
38 |
|
39 |
// check if xml-sitemap.php is moved one dir up like in WPMU's /mu-plugins/
|
40 |
if (file_exists($xmlsf_dir.'/xml-sitemap-feed'))
|
41 |
-
|
|
|
|
|
|
|
|
|
|
|
42 |
|
43 |
/* --------------------
|
44 |
FUNCTIONS
|
45 |
-------------------- */
|
46 |
|
47 |
-
//
|
48 |
-
//
|
49 |
-
function
|
50 |
-
|
51 |
-
|
52 |
-
}
|
53 |
-
// load XML template
|
54 |
-
if ( !function_exists(do_feed_sitemapxml) ) {
|
55 |
-
function do_feed_sitemapxml() {
|
56 |
-
global $xmlsf_dir;
|
57 |
-
load_template( $xmlsf_dir . '/feed-sitemap.xml.php' );
|
58 |
-
}
|
59 |
}
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
|
|
|
|
|
|
65 |
}
|
66 |
}
|
|
|
|
|
67 |
// add the rewrite rules
|
68 |
-
function
|
69 |
-
$
|
70 |
-
'
|
71 |
-
|
72 |
-
|
73 |
-
$wp_rewrite->rules = $feed_rules + $wp_rewrite->rules;
|
74 |
}
|
75 |
-
// recreate rewrite rules
|
76 |
-
function
|
77 |
global $wp_rewrite;
|
78 |
$wp_rewrite->flush_rules();
|
79 |
}
|
80 |
|
81 |
// ROBOTSTXT //
|
82 |
-
//
|
83 |
function xml_sitemap_robots() {
|
84 |
echo "Sitemap: ".get_option('home')."/sitemap.xml\n\n";
|
85 |
}
|
86 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
87 |
/* --------------------
|
88 |
HOOKS
|
89 |
-------------------- */
|
90 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
91 |
if ( $wpdb->blogid && function_exists('get_site_option') && get_site_option('tags_blog_id') == $wpdb->blogid ) {
|
92 |
// we are on wpmu and this is a tags blog!
|
93 |
// create NO sitemap since it will be full
|
94 |
// of links outside the blogs own domain...
|
95 |
return;
|
96 |
} else {
|
97 |
-
//
|
98 |
-
|
|
|
|
|
|
|
99 |
|
100 |
// REWRITES
|
101 |
-
add_filter('
|
102 |
|
103 |
// ROBOTSTXT
|
104 |
add_action('do_robotstxt', 'xml_sitemap_robots');
|
105 |
}
|
106 |
|
107 |
-
// ACTIVATION
|
108 |
register_activation_hook( __FILE__, 'xml_sitemap_activate' );
|
|
|
|
|
109 |
?>
|
1 |
<?php
|
2 |
/*
|
3 |
Plugin Name: XML Sitemap Feed
|
4 |
+
Plugin URI: http://4visions.nl/portfolio/wordpress-plugins/xml-sitemap-feed/
|
5 |
+
Description: Creates a feed that complies with the XML Sitemap protocol ready for indexing by Google, Yahoo, Bing, Ask and others.
|
6 |
+
Version: 3.5
|
7 |
Author: RavanH
|
8 |
Author URI: http://4visions.nl/
|
9 |
Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=ravanhagen%40gmail%2ecom&item_name=XML%20Sitemap%20Feed&item_number=2%2e6%2e2%2e9&no_shipping=0&tax=0&bn=PP%2dDonationsBF&charset=UTF%2d8
|
26 |
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
27 |
*/
|
28 |
|
29 |
+
// ALTERNATIVE to investigate 3.5:
|
30 |
+
// Use "template_redirect" just like do_robots does and make sitemap.xml available via /?sitemapxml=1
|
31 |
+
// and make a rewrite to sitemap.xml for it... Nearly works but :( ...
|
32 |
+
// PROBLEMS so far:
|
33 |
+
// * Redirect rules no longer working ?!?
|
34 |
+
|
35 |
/* --------------------
|
36 |
+
CONSTANTS
|
37 |
-------------------- */
|
38 |
|
39 |
// set version
|
40 |
+
define('XMLSF_VERSION','3.5');
|
41 |
|
42 |
// dir
|
43 |
$xmlsf_dir = dirname(__FILE__);
|
44 |
|
45 |
// check if xml-sitemap.php is moved one dir up like in WPMU's /mu-plugins/
|
46 |
if (file_exists($xmlsf_dir.'/xml-sitemap-feed'))
|
47 |
+
define('XMLSF_PLUGIN_DIR', $xmlsf_dir.'/xml-sitemap-feed');
|
48 |
+
else
|
49 |
+
define('XMLSF_PLUGIN_DIR', $xmlsf_dir);
|
50 |
+
|
51 |
+
// url
|
52 |
+
define('XMLSF_PLUGIN_URL', WP_PLUGIN_URL.'/'.basename($xmlsf_dir));
|
53 |
|
54 |
/* --------------------
|
55 |
FUNCTIONS
|
56 |
-------------------- */
|
57 |
|
58 |
+
// QUERY VARS //
|
59 |
+
// add the needed query vars
|
60 |
+
function xml_sitemap_vars($vars) {
|
61 |
+
$vars[] = 'sitemap';
|
62 |
+
return $vars;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
63 |
}
|
64 |
+
|
65 |
+
// TEMPLATES //
|
66 |
+
// set the XML redirects up
|
67 |
+
function xml_sitemap_redirect () {
|
68 |
+
global $wpdb;
|
69 |
+
if ( get_query_var('sitemap') ) {
|
70 |
+
include( XMLSF_PLUGIN_DIR . '/sitemap.xml.php' );
|
71 |
+
exit;
|
72 |
}
|
73 |
}
|
74 |
+
|
75 |
+
// REWRITES //
|
76 |
// add the rewrite rules
|
77 |
+
function xml_sitemap_rewrite($rules) {
|
78 |
+
$xml_feed_rules = array(
|
79 |
+
'sitemap\.xml$' => 'index.php?sitemap=1',
|
80 |
+
);
|
81 |
+
return $xml_feed_rules + $rules;
|
|
|
82 |
}
|
83 |
+
// recreate rewrite rules
|
84 |
+
function xml_sitemap_flush_rewrite_rules() {
|
85 |
global $wp_rewrite;
|
86 |
$wp_rewrite->flush_rules();
|
87 |
}
|
88 |
|
89 |
// ROBOTSTXT //
|
90 |
+
// add sitemap location in robots.txt generated by WP
|
91 |
function xml_sitemap_robots() {
|
92 |
echo "Sitemap: ".get_option('home')."/sitemap.xml\n\n";
|
93 |
}
|
94 |
|
95 |
+
// DE/ACTIVATION
|
96 |
+
function xml_sitemap_activate() {
|
97 |
+
update_option('xml-sitemap-feed-version', XMLSF_VERSION);
|
98 |
+
xml_sitemap_flush_rewrite_rules();
|
99 |
+
}
|
100 |
+
function xml_sitemap_deactivate() {
|
101 |
+
remove_filter('query_vars', 'xml_sitemap_vars');
|
102 |
+
remove_filter('rewrite_rules_array', 'xml_sitemap_rewrite');
|
103 |
+
delete_option('xml-sitemap-feed-version');
|
104 |
+
xml_sitemap_flush_rewrite_rules();
|
105 |
+
}
|
106 |
+
|
107 |
/* --------------------
|
108 |
HOOKS
|
109 |
-------------------- */
|
110 |
|
111 |
+
// FLUSH RULES check
|
112 |
+
// limited to after (site wide) plugin upgrade
|
113 |
+
if (get_option('xml-sitemap-feed-version') != XMLSF_VERSION) {
|
114 |
+
add_action('init', 'xml_sitemap_flush_rewrite_rules' );
|
115 |
+
update_option('xml-sitemap-feed-version', XMLSF_VERSION);
|
116 |
+
}
|
117 |
+
|
118 |
if ( $wpdb->blogid && function_exists('get_site_option') && get_site_option('tags_blog_id') == $wpdb->blogid ) {
|
119 |
// we are on wpmu and this is a tags blog!
|
120 |
// create NO sitemap since it will be full
|
121 |
// of links outside the blogs own domain...
|
122 |
return;
|
123 |
} else {
|
124 |
+
// QUERY VARS
|
125 |
+
add_filter('query_vars', 'xml_sitemap_vars');
|
126 |
+
|
127 |
+
// TEMPLATES
|
128 |
+
add_action('template_redirect', 'xml_sitemap_redirect');
|
129 |
|
130 |
// REWRITES
|
131 |
+
add_filter('rewrite_rules_array', 'xml_sitemap_rewrite');
|
132 |
|
133 |
// ROBOTSTXT
|
134 |
add_action('do_robotstxt', 'xml_sitemap_robots');
|
135 |
}
|
136 |
|
137 |
+
// DE/ACTIVATION
|
138 |
register_activation_hook( __FILE__, 'xml_sitemap_activate' );
|
139 |
+
register_deactivation_hook( __FILE__, 'xml_sitemap_deactivate' );
|
140 |
+
|
141 |
?>
|