Version Description
- rewrite and add_feed calls improvements
- bugfix: double entry when static page is frontpage
Download this release
Release Info
Developer | RavanH |
Plugin | XML Sitemap & Google News feeds |
Version | 3.2 |
Comparing to | |
See all releases |
Code changes from version 3.0 to 3.2
- template-xml.php → feed-xml.php +27 -16
- template-xsl.php → feed-xsl.php +6 -6
- readme.txt +49 -24
- xml-sitemap.php +49 -28
template-xml.php → feed-xml.php
RENAMED
@@ -1,25 +1,26 @@
|
|
1 |
<?php
|
2 |
-
|
3 |
-
|
4 |
-
|
5 |
|
6 |
-
if (!empty($_SERVER['SCRIPT_FILENAME']) && '
|
7 |
die ('Please do not load this page directly. Thanks!');
|
8 |
|
9 |
-
header('Content-Type: text/xml; charset=' . get_option('blog_charset'), true);
|
10 |
-
$more = 1;
|
11 |
-
|
12 |
-
$lastpostmodified = get_lastpostmodified('GMT');
|
13 |
|
|
|
14 |
$post_priority = 0.7;
|
15 |
$minpost_priority = 0.3;
|
16 |
$maxpost_priority = 0.9;
|
17 |
$page_priority = 0.6;
|
18 |
$frontpage_priority = 1.0;
|
19 |
|
20 |
-
|
21 |
-
|
22 |
-
|
|
|
|
|
|
|
|
|
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" -->
|
@@ -35,9 +36,20 @@ $frontpage_priority = 1.0;
|
|
35 |
<priority>1.0</priority>
|
36 |
</url>
|
37 |
<?php
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
38 |
|
39 |
-
|
|
|
40 |
|
|
|
41 |
if ($post_ids) {
|
42 |
global $wp_query;
|
43 |
$wp_query->in_the_loop = true;
|
@@ -51,15 +63,15 @@ if ($post_ids) {
|
|
51 |
$priority_down = (($lastpostmodified - $post_modified_time) > 0) ? ($lastpostmodified - $post_modified_time)/10 : 0;
|
52 |
$priority_up = ($post->comment_count > 0) ? $post->comment_count/10 : 0;
|
53 |
$priority = $post_priority - $priority_down + $priority_up;
|
54 |
-
$priority = (
|
55 |
-
$priority = (
|
56 |
?>
|
57 |
<url>
|
58 |
<loc><?php the_permalink_rss() ?></loc>
|
59 |
<lastmod><?php echo mysql2date('Y-m-d\TH:i:s+00:00', $post_modified_time, false) ?></lastmod>
|
60 |
<?php if($post->post_type == "page") { ?>
|
61 |
<changefreq>monthly</changefreq>
|
62 |
-
<priority
|
63 |
<?php } else {
|
64 |
if($post->comment_count > 0) { ?>
|
65 |
<changefreq>weekly</changefreq>
|
@@ -67,7 +79,6 @@ if ($post_ids) {
|
|
67 |
<changefreq>monthly</changefreq>
|
68 |
<?php } ?>
|
69 |
<priority><?php echo $priority ?></priority>
|
70 |
-
<?php //echo "<test>" . $post_priority . " - " . $priority_down . " + " . $priority_up . "</test>" ?>
|
71 |
<?php } ?>
|
72 |
</url>
|
73 |
<?php }
|
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 |
|
10 |
+
// priority presets
|
11 |
$post_priority = 0.7;
|
12 |
$minpost_priority = 0.3;
|
13 |
$maxpost_priority = 0.9;
|
14 |
$page_priority = 0.6;
|
15 |
$frontpage_priority = 1.0;
|
16 |
|
17 |
+
$lastpostmodified = get_lastpostmodified('GMT');
|
18 |
+
|
19 |
+
// start the xml output
|
20 |
+
@header('Content-Type: text/xml; charset=' . get_option('blog_charset'));
|
21 |
+
|
22 |
+
echo '<?xml version="1.0" encoding="'.get_option('blog_charset').'"?>
|
23 |
+
<?xml-stylesheet type="text/xsl" href="'.get_option('siteurl').'/?feed=sitemap.xsl"?>
|
24 |
<!-- generated-on="'.date('Y-m-d\TH:i:s+00:00').'" -->
|
25 |
<!-- generator="XML Sitemap Feed plugin for WordPress" -->
|
26 |
<!-- generator-url="http://4visions.nl/en/index.php?section=57" -->
|
36 |
<priority>1.0</priority>
|
37 |
</url>
|
38 |
<?php
|
39 |
+
// first check if there is a static page set as frontpage and exclude it to avoid double url
|
40 |
+
$has_page_as_front = $wpdb->get_results("SELECT option_value FROM $wpdb->options WHERE option_name = 'show_on_front'");
|
41 |
+
if ($has_page_as_front[0]->option_value == "page") {
|
42 |
+
$frontpage = $wpdb->get_results("SELECT option_value FROM $wpdb->options WHERE option_name = 'page_on_front'");
|
43 |
+
$frontpage_id = $frontpage[0]->option_value;
|
44 |
+
} else {
|
45 |
+
$frontpage_id = -1;
|
46 |
+
|
47 |
+
}
|
48 |
|
49 |
+
// get all posts and pages
|
50 |
+
$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");
|
51 |
|
52 |
+
// and loop away!
|
53 |
if ($post_ids) {
|
54 |
global $wp_query;
|
55 |
$wp_query->in_the_loop = true;
|
63 |
$priority_down = (($lastpostmodified - $post_modified_time) > 0) ? ($lastpostmodified - $post_modified_time)/10 : 0;
|
64 |
$priority_up = ($post->comment_count > 0) ? $post->comment_count/10 : 0;
|
65 |
$priority = $post_priority - $priority_down + $priority_up;
|
66 |
+
$priority = ($priority > $maxpost_priority) ? $maxpost_priority : $priority;
|
67 |
+
$priority = ($priority < $minpost_priority) ? $minpost_priority : $priority;
|
68 |
?>
|
69 |
<url>
|
70 |
<loc><?php the_permalink_rss() ?></loc>
|
71 |
<lastmod><?php echo mysql2date('Y-m-d\TH:i:s+00:00', $post_modified_time, false) ?></lastmod>
|
72 |
<?php if($post->post_type == "page") { ?>
|
73 |
<changefreq>monthly</changefreq>
|
74 |
+
<priority><?php echo $page_priority ?></priority>
|
75 |
<?php } else {
|
76 |
if($post->comment_count > 0) { ?>
|
77 |
<changefreq>weekly</changefreq>
|
79 |
<changefreq>monthly</changefreq>
|
80 |
<?php } ?>
|
81 |
<priority><?php echo $priority ?></priority>
|
|
|
82 |
<?php } ?>
|
83 |
</url>
|
84 |
<?php }
|
template-xsl.php → feed-xsl.php
RENAMED
@@ -1,12 +1,12 @@
|
|
1 |
<?php
|
2 |
-
|
3 |
-
|
4 |
-
|
5 |
|
6 |
-
if (!empty($_SERVER['SCRIPT_FILENAME']) && '
|
7 |
die ('Please do not load this page directly. Thanks!');
|
8 |
|
9 |
-
header('Content-Type: text/xsl; charset=' . get_option('blog_charset'), true);
|
10 |
|
11 |
echo '<?xml version="1.0" encoding="UTF-8"?>'; ?>
|
12 |
<xsl:stylesheet version="2.0"
|
@@ -97,7 +97,7 @@ echo '<?xml version="1.0" encoding="UTF-8"?>'; ?>
|
|
97 |
</table>
|
98 |
</div>
|
99 |
<div id="footer">
|
100 |
-
Generated by <a href="http://4visions.nl/en/index.php?section=57" title="XML Sitemap Feed plugin for WordPress">XML Sitemap Feed
|
101 |
</div>
|
102 |
</body>
|
103 |
</html>
|
1 |
<?php
|
2 |
+
/* -------------------------------------
|
3 |
+
XML Sitemap Feed Styleheet Template
|
4 |
+
------------------------------------- */
|
5 |
|
6 |
+
if (!empty($_SERVER['SCRIPT_FILENAME']) && 'feed-xsl.php' == basename($_SERVER['SCRIPT_FILENAME']))
|
7 |
die ('Please do not load this page directly. Thanks!');
|
8 |
|
9 |
+
@header('Content-Type: text/xsl; charset=' . get_option('blog_charset'), true);
|
10 |
|
11 |
echo '<?xml version="1.0" encoding="UTF-8"?>'; ?>
|
12 |
<xsl:stylesheet version="2.0"
|
97 |
</table>
|
98 |
</div>
|
99 |
<div id="footer">
|
100 |
+
Generated by <a href="http://4visions.nl/en/index.php?section=57" title="XML Sitemap Feed plugin for WordPress">XML Sitemap Feed <?php echo XMLSFVERSION ?></a> running on <a href="http://wordpress.org/">WordPress</a>.<br />
|
101 |
</div>
|
102 |
</body>
|
103 |
</html>
|
readme.txt
CHANGED
@@ -4,15 +4,15 @@ Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=ravan
|
|
4 |
Tags: xml sitemap, sitemap, google sitemap, yahoo sitemap, msn sitemap, ask sitemap, search engine, feed
|
5 |
Requires at least: 2.5
|
6 |
Tested up to: 2.8
|
7 |
-
Stable tag: 3.
|
8 |
|
9 |
-
Creates a feed that complies
|
10 |
|
11 |
== Description ==
|
12 |
|
13 |
-
This plugin dynamically creates an XML feed that complies
|
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.
|
16 |
|
17 |
= Advantages =
|
18 |
|
@@ -38,7 +38,9 @@ XML Sitemap Feed is based on the plugin Standard XML Sitemap Generator (disconti
|
|
38 |
= Wordpress =
|
39 |
|
40 |
Just use that slick installation and auto update feature on your Pugins page
|
41 |
-
|
|
|
|
|
42 |
follow these simple steps:
|
43 |
|
44 |
1. Download archive and unpack.
|
@@ -55,13 +57,20 @@ The plugin also works from the /mu-plugins/ folder where it runs quietly in the
|
|
55 |
|
56 |
== Frequently Asked Questions ==
|
57 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
58 |
= Can I manipulate values for priority and changefreq? =
|
59 |
|
60 |
Yes and No. Since this plugin has no options page there is no way (yet) to manually set the priority of urls in the sitemap. Since version 2.0 there is some basic automatic priority calculation (based on post age and comment activity) doing the work for you.
|
61 |
|
62 |
This feature can be used to your advantage: by resaving older posts from time to time, keeping the lastmod date fairly recent, you can ensure a priority of 70% (0.7) for those urls. And if you have comments on on those pages, the priority can even go up to 90% (0.9).
|
63 |
|
64 |
-
If you cannot live with these rules, edit the values
|
65 |
|
66 |
= How are the values for priority and changefreq calculated? =
|
67 |
|
@@ -71,18 +80,36 @@ Dynamic pages like category pages, tag pages and archive pages are not listed in
|
|
71 |
|
72 |
= Do I need to submit the sitemap to search engines? =
|
73 |
|
74 |
-
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.
|
75 |
|
76 |
= Does this plugin ping search engines? =
|
77 |
|
78 |
-
No. While other XML Sitemap plugins provide pinging to some search engines upon each post edit or publication, this plugin does not. For the average website, in my experience, pinging Google or others after each little change does not benefit anything except a theoretical smaller delay in re-indexation of your website. This is only theoretical because if your site is popular and active, major search engines will likely be crawling your site on a very regular basis anyway. And if, on the other hand, your site is not high in the agenda with the major search engines, they will likely give no priority to your pings
|
79 |
|
80 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
81 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
82 |
= Can I change the sitemap name/URL? =
|
83 |
|
84 |
-
No.
|
85 |
-
The feed is also available via yourblogurl.tld/feed/sitemap
|
86 |
|
87 |
= I see no sitemap.xml file in my server space! =
|
88 |
|
@@ -90,31 +117,29 @@ The sitemap is dynamically generated just like a feed. There is no actual file c
|
|
90 |
|
91 |
= Where can I customize the xml output? =
|
92 |
|
93 |
-
You may edit the XML output in xml-sitemap-feed/
|
|
|
|
|
94 |
|
95 |
= Do I need to change my robots.txt? =
|
96 |
|
97 |
-
No. Your sitemap url will be automatically added to your dynamic robots.txt when plugin actived. Unless you use a static robots.txt file in your website root. In that case you
|
98 |
|
99 |
-
= I get a 404 page instead of robots.txt! =
|
100 |
|
101 |
-
|
102 |
`
|
103 |
User-agent: *
|
104 |
Disallow:
|
105 |
`
|
106 |
-
Reactivate your plugins one by one to find out which one is causing the problem. Then report the bug to the plugin developer.
|
107 |
-
... OR ...
|
108 |
-
Manually upload your own robots.txt file to your website root containing at least:
|
109 |
-
`
|
110 |
-
Sitemap: http://beauxdupeyron.fr/sitemap.xml
|
111 |
-
|
112 |
-
User-agent: *
|
113 |
-
Disallow:
|
114 |
-
`
|
115 |
|
116 |
== Changelog ==
|
117 |
|
|
|
|
|
|
|
|
|
118 |
= 3.0 =
|
119 |
* added styling to the xml feed to make it human readable
|
120 |
|
4 |
Tags: xml sitemap, sitemap, google sitemap, yahoo sitemap, msn sitemap, ask sitemap, search engine, feed
|
5 |
Requires at least: 2.5
|
6 |
Tested up to: 2.8
|
7 |
+
Stable tag: 3.2
|
8 |
|
9 |
+
Creates a feed that complies with the XML Sitemap protocol ready for indexing by Google, Yahoo, MSN, Ask.com 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?feed=sitemap.xml if you do not use a fancy permalink structure) ready to be submitted to 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, you will have to create your own robots.txt file. See FAQ's.
|
16 |
|
17 |
= Advantages =
|
18 |
|
38 |
= Wordpress =
|
39 |
|
40 |
Just use that slick installation and auto update feature on your Pugins page
|
41 |
+
|
42 |
+
… OR …
|
43 |
+
|
44 |
follow these simple steps:
|
45 |
|
46 |
1. Download archive and unpack.
|
57 |
|
58 |
== Frequently Asked Questions ==
|
59 |
|
60 |
+
= My WordPress powered blog is installed in a subdirectory. Does that change anything? =
|
61 |
+
|
62 |
+
That depends on where the index.php 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:
|
63 |
+
`
|
64 |
+
Sitemap: http://yourblogurl.tld/subdir/sitemap.xml
|
65 |
+
`
|
66 |
+
|
67 |
= Can I manipulate values for priority and changefreq? =
|
68 |
|
69 |
Yes and No. Since this plugin has no options page there is no way (yet) to manually set the priority of urls in the sitemap. Since version 2.0 there is some basic automatic priority calculation (based on post age and comment activity) doing the work for you.
|
70 |
|
71 |
This feature can be used to your advantage: by resaving older posts from time to time, keeping the lastmod date fairly recent, you can ensure a priority of 70% (0.7) for those urls. And if you have comments on on those pages, the priority can even go up to 90% (0.9).
|
72 |
|
73 |
+
If you cannot live with these rules, edit the values `$post_priority`, `$minpost_priority`, `$maxpost_priority`, `$page_priority`, `$frontpage_priority` in xml-sitemap-feed/template-xml.php
|
74 |
|
75 |
= How are the values for priority and changefreq calculated? =
|
76 |
|
80 |
|
81 |
= Do I need to submit the sitemap to search engines? =
|
82 |
|
83 |
+
No. In normal circumstances, your WordPress 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.
|
84 |
|
85 |
= Does this plugin ping search engines? =
|
86 |
|
87 |
+
No. While other XML Sitemap plugins provide pinging to some search engines upon each post edit or publication, this plugin does not. For the average website, in my experience, pinging Google or others after each little change does not benefit anything except a theoretical smaller delay in re-indexation of your website. This is only theoretical because if your site is popular and active, major search engines will likely be crawling your site on a very regular basis anyway. And if, on the other hand, your site is not high in the agenda with the major search engines, they will likely give no priority to your pings at all.
|
88 |
|
89 |
+
Besides, WordPress has a built-in pinging feature. Go in your WP Admin section to Settings > Writing and make sure that the field under **Update services** contains at least
|
90 |
+
`
|
91 |
+
http://rpc.pingomatic.com
|
92 |
+
`
|
93 |
+
Read more on [Ping-O-Matic](http://pingomatic.com) about what excellent service you are actually getting for free with your WordPress installation!
|
94 |
+
|
95 |
+
You can also take a [Google Webmaster Tools account](https://www.google.com/webmasters/tools/) which will tell you many interesting things about your website and your readers. Try it!
|
96 |
|
97 |
+
= Do I need to make use of a fancy Permalink structure? =
|
98 |
+
|
99 |
+
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:
|
100 |
+
|
101 |
+
Check to see if the URL yourblogurl.tld/?feed=sitemap.xml (notice the **?feed=**!) does produce a feed. Now manually upload your own robots.txt file to your website root containing:
|
102 |
+
`
|
103 |
+
Sitemap: http://yourblogurl.tld/?feed=sitemap.xml
|
104 |
+
|
105 |
+
User-agent: *
|
106 |
+
Disallow:
|
107 |
+
`
|
108 |
+
You can also choose to notify major search engines of your new XML sitemap manually.
|
109 |
+
|
110 |
= Can I change the sitemap name/URL? =
|
111 |
|
112 |
+
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/?feed=sitemap.xml` (notice the *?feed=*).
|
|
|
113 |
|
114 |
= I see no sitemap.xml file in my server space! =
|
115 |
|
117 |
|
118 |
= Where can I customize the xml output? =
|
119 |
|
120 |
+
You may edit the XML output in `xml-sitemap-feed/feed-xml.php` but be carefull not to break Sitemap protocol comliance. Read more on [Sitemaps XML format](http://www.sitemaps.org/protocol.php).
|
121 |
+
|
122 |
+
The stylesheet (to make the sitemap human readable) can be edited in `xml-sitemap-feed/feed-xsl.php`.
|
123 |
|
124 |
= Do I need to change my robots.txt? =
|
125 |
|
126 |
+
No. Your sitemap url will be automatically added to your dynamic robots.txt when plugin actived. Unless you use a static robots.txt file in your website root. In that case you are advised to open it in a text editor and add a line like `Sitemap: http://yourblogurl.tld/sitemap.xml` (adapt to your site url).
|
127 |
|
128 |
+
= I get a 404 page instead of sitemap.xml and robots.txt! =
|
129 |
|
130 |
+
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:
|
131 |
`
|
132 |
User-agent: *
|
133 |
Disallow:
|
134 |
`
|
135 |
+
Reactivate your plugins one by one to find out which one is causing the problem. Then report the bug to the plugin developer.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
136 |
|
137 |
== Changelog ==
|
138 |
|
139 |
+
= 3.2 =
|
140 |
+
* rewrite and add_feed calls improvements
|
141 |
+
* bugfix: double entry when static page is frontpage
|
142 |
+
|
143 |
= 3.0 =
|
144 |
* added styling to the xml feed to make it human readable
|
145 |
|
xml-sitemap.php
CHANGED
@@ -2,8 +2,8 @@
|
|
2 |
/*
|
3 |
Plugin Name: XML Sitemap Feed
|
4 |
Plugin URI: http://4visions.nl/en/index.php?section=57
|
5 |
-
Description: Creates a dynamic XML feed that complies
|
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,44 +26,65 @@ 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 |
global $wp_rewrite;
|
|
|
|
|
|
|
33 |
$wp_rewrite->flush_rules();
|
34 |
}
|
35 |
-
|
36 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
37 |
function xml_sitemap_feed_rewrite($wp_rewrite) {
|
38 |
$feed_rules = array(
|
39 |
-
'
|
40 |
-
'^feed/sitemap$' => 'index.php?feed=sitemap',
|
41 |
-
'^sitemap.
|
|
|
42 |
);
|
43 |
$wp_rewrite->rules = $feed_rules + $wp_rewrite->rules;
|
44 |
}
|
45 |
-
add_filter('generate_rewrite_rules', 'xml_sitemap_feed_rewrite');
|
46 |
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
else
|
52 |
-
load_template( $dir . '/template-xml.php' );
|
53 |
}
|
54 |
-
add_action('do_feed_sitemap', 'xml_sitemap_do_feed', 10, 1);
|
55 |
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
load_template( $dir . '/xml-sitemap-feed/template-xsl.php' );
|
60 |
-
else
|
61 |
-
load_template( $dir . '/template-xsl.php' );
|
62 |
-
}
|
63 |
-
add_action('do_feed_sitemapxsl', 'xml_sitemap_xsl_do_feed', 10, 1);
|
64 |
|
65 |
-
|
66 |
-
|
67 |
-
|
|
|
68 |
add_action('do_robotstxt', 'xml_sitemap_robots');
|
69 |
?>
|
2 |
/*
|
3 |
Plugin Name: XML Sitemap Feed
|
4 |
Plugin URI: http://4visions.nl/en/index.php?section=57
|
5 |
+
Description: Creates a dynamic XML feed that complies with the XML Sitemap protocol to aid Google, Yahoo, MSN, Ask.com indexing your blog. Based on the Standard XML Sitemap Generator by Patrick Chia.
|
6 |
+
Version: 3.2
|
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 |
+
/* --------------------
|
30 |
+
VALUES
|
31 |
+
-------------------- */
|
32 |
|
33 |
+
// set version
|
34 |
+
define('XMLSFVERSION','3.2');
|
35 |
+
|
36 |
+
// check if xml-sitemap.php was moved one dir up to mu-plugins in wpmu
|
37 |
+
$xmlsf_dir = dirname(__FILE__);
|
38 |
+
if (file_exists($xmlsf_dir.'/xml-sitemap-feed'))
|
39 |
+
$xmlsf_dir = $xmlsf_dir . '/xml-sitemap-feed';
|
40 |
+
|
41 |
+
/* --------------------
|
42 |
+
FUNCTIONS
|
43 |
+
-------------------- */
|
44 |
+
|
45 |
+
// FEEDS //
|
46 |
+
// set the XML feeds up
|
47 |
+
function xml_sitemap_add_feeds() {
|
48 |
global $wp_rewrite;
|
49 |
+
add_feed('sitemap.xml','xml_sitemap_do_feed');
|
50 |
+
add_feed('sitemap.xsl','xml_sitemap_xsl_do_feed');
|
51 |
+
add_action('generate_rewrite_rules', 'xml_sitemap_feed_rewrite');
|
52 |
$wp_rewrite->flush_rules();
|
53 |
}
|
54 |
+
// load XML template
|
55 |
+
function xml_sitemap_do_feed() {
|
56 |
+
global $xmlsf_dir;
|
57 |
+
load_template( $xmlsf_dir . '/feed-xml.php' );
|
58 |
+
}
|
59 |
+
// load XSL (style) template
|
60 |
+
function xml_sitemap_xsl_do_feed() {
|
61 |
+
global $xmlsf_dir;
|
62 |
+
load_template( $xmlsf_dir . '/feed-xsl.php' );
|
63 |
+
}
|
64 |
+
// add the rewrite rules
|
65 |
function xml_sitemap_feed_rewrite($wp_rewrite) {
|
66 |
$feed_rules = array(
|
67 |
+
//'feed/(.+)' => 'index.php?feed='.$wp_rewrite->preg_index(1),
|
68 |
+
//'^feed/sitemap$' => 'index.php?feed=sitemap',
|
69 |
+
'^sitemap.xml$' => 'index.php?feed=sitemap.xml',
|
70 |
+
'^sitemap.xsl$' => 'index.php?feed=sitemap.xsl'
|
71 |
);
|
72 |
$wp_rewrite->rules = $feed_rules + $wp_rewrite->rules;
|
73 |
}
|
|
|
74 |
|
75 |
+
// ROBOTSTXT //
|
76 |
+
// get sitemap location in robots.txt generated by WP
|
77 |
+
function xml_sitemap_robots() {
|
78 |
+
echo "\nSitemap: ".get_option('siteurl')."/sitemap.xml\n\n";
|
|
|
|
|
79 |
}
|
|
|
80 |
|
81 |
+
/* --------------------
|
82 |
+
HOOKS
|
83 |
+
-------------------- */
|
|
|
|
|
|
|
|
|
|
|
84 |
|
85 |
+
// FEEDS
|
86 |
+
add_action('init', 'xml_sitemap_add_feeds');
|
87 |
+
|
88 |
+
// ROBOTSTXT
|
89 |
add_action('do_robotstxt', 'xml_sitemap_robots');
|
90 |
?>
|