XML Sitemap & Google News feeds - Version 3.9

Version Description

Google News Sitemap! And a workaround for memory limit errors for most sites.

=

Download this release

Release Info

Developer RavanH
Plugin Icon 128x128 XML Sitemap & Google News feeds
Version 3.9
Comparing to
See all releases

Code changes from version 3.8.8 to 3.9

XMLSitemapFeed.class.php CHANGED
@@ -18,13 +18,14 @@ class XMLSitemapFeed {
18
  add_action('init', array(__CLASS__, 'init') );
19
 
20
  // FEEDS
21
- add_action('do_feed_sitemap', array(__CLASS__, 'load_template'), 10, 1);
 
22
 
23
  // REWRITES
24
  add_filter('generate_rewrite_rules', array(__CLASS__, 'rewrite') );
25
 
26
  // ROBOTSTXT
27
- add_action('do_robotstxt', array(__CLASS__, 'robots'), 1 );
28
  }
29
 
30
  // DE-ACTIVATION
@@ -32,16 +33,30 @@ class XMLSitemapFeed {
32
  }
33
 
34
  // FEEDS //
35
- // set up the feed template
36
- function load_template() {
37
  load_template( XMLSF_PLUGIN_DIR . '/feed-sitemap.php' );
38
  }
39
 
 
 
 
 
 
 
 
 
 
 
 
 
 
40
  // REWRITES //
41
  // add sitemap rewrite rules
42
  function rewrite($wp_rewrite) {
43
  $feed_rules = array(
44
  'sitemap.xml$' => $wp_rewrite->index . '?feed=sitemap',
 
45
  );
46
  $wp_rewrite->rules = $feed_rules + $wp_rewrite->rules;
47
  }
@@ -52,7 +67,8 @@ class XMLSitemapFeed {
52
  function robots() {
53
 
54
  // hook for filter 'xml_sitemap_url' provides an array here and MUST get an array returned
55
- $sitemap_array = apply_filters('xml_sitemap_url',array(trailingslashit(get_bloginfo('url'))."sitemap.xml"));
 
56
 
57
  echo "\n# XML Sitemap Feed ".XMLSF_VERSION." (http://4visions.nl/en/wordpress-plugins/xml-sitemap-feed/)";
58
 
@@ -64,7 +80,7 @@ class XMLSitemapFeed {
64
 
65
  echo "\n\n";
66
  }
67
-
68
  // DE-ACTIVATION
69
  function deactivate() {
70
  remove_filter('generate_rewrite_rules', array(__CLASS__, 'rewrite') );
18
  add_action('init', array(__CLASS__, 'init') );
19
 
20
  // FEEDS
21
+ add_action('do_feed_sitemap', array(__CLASS__, 'load_template_sitemap'), 10, 1);
22
+ add_action('do_feed_sitemap-news', array(__CLASS__, 'load_template_sitemap_news'), 10, 1);
23
 
24
  // REWRITES
25
  add_filter('generate_rewrite_rules', array(__CLASS__, 'rewrite') );
26
 
27
  // ROBOTSTXT
28
+ add_action('do_robotstxt', array(__CLASS__, 'robots') );
29
  }
30
 
31
  // DE-ACTIVATION
33
  }
34
 
35
  // FEEDS //
36
+ // set up the sitemap template
37
+ function load_template_sitemap() {
38
  load_template( XMLSF_PLUGIN_DIR . '/feed-sitemap.php' );
39
  }
40
 
41
+ // set up the news sitemap template
42
+ function load_template_sitemap_news() {
43
+ load_template( XMLSF_PLUGIN_DIR . '/feed-sitemap-news.php' );
44
+ }
45
+
46
+ // Create a new filtering function that will add a where clause to the query,
47
+ // used for the Google News Sitemap
48
+ function xml_sitemap_feed_news_filter_where($where = '') {
49
+ //posts in the last 2 days
50
+ $where .= " AND post_date > '" . date('Y-m-d', strtotime('-2 days')) . "'";
51
+ return $where;
52
+ }
53
+
54
  // REWRITES //
55
  // add sitemap rewrite rules
56
  function rewrite($wp_rewrite) {
57
  $feed_rules = array(
58
  'sitemap.xml$' => $wp_rewrite->index . '?feed=sitemap',
59
+ 'sitemap-news.xml$' => $wp_rewrite->index . '?feed=sitemap-news',
60
  );
61
  $wp_rewrite->rules = $feed_rules + $wp_rewrite->rules;
62
  }
67
  function robots() {
68
 
69
  // hook for filter 'xml_sitemap_url' provides an array here and MUST get an array returned
70
+ $blog_url = trailingslashit(get_bloginfo('url'));
71
+ $sitemap_array = apply_filters('xml_sitemap_url',array($blog_url."sitemap.xml",$blog_url."sitemap-news.xml"));
72
 
73
  echo "\n# XML Sitemap Feed ".XMLSF_VERSION." (http://4visions.nl/en/wordpress-plugins/xml-sitemap-feed/)";
74
 
80
 
81
  echo "\n\n";
82
  }
83
+
84
  // DE-ACTIVATION
85
  function deactivate() {
86
  remove_filter('generate_rewrite_rules', array(__CLASS__, 'rewrite') );
feed-sitemap-news.php ADDED
@@ -0,0 +1,78 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * XML Sitemap Feed Template for displaying an XML Sitemap feed.
4
+ *
5
+ * @package XML Sitemap Feed plugin for WordPress
6
+ */
7
+
8
+ status_header('200'); // force header('HTTP/1.1 200 OK') for sites without posts
9
+ header('Content-Type: text/xml; charset=' . get_bloginfo('charset'), true);
10
+
11
+ echo '<?xml version="1.0" encoding="'.get_bloginfo('charset').'"?>
12
+ <!-- generated-on="'.date('Y-m-d\TH:i:s+00:00').'" -->
13
+ <!-- generator="XML & Google News Sitemap Feed plugin for WordPress" -->
14
+ <!-- generator-url="http://4visions.nl/en/wordpress-plugins/xml-sitemap-feed/" -->
15
+ <!-- generator-version="'.XMLSF_VERSION.'" -->
16
+ <urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:news="http://www.google.com/schemas/sitemap-news/0.9">';
17
+
18
+ $maxURLS = 1000; // maximum number of URLs allowed in a news sitemap.
19
+
20
+ // editing below here is not advised!
21
+
22
+ // Register the filtering function
23
+ add_filter('posts_where', array('XMLSitemapFeed','xml_sitemap_feed_news_filter_where'), 10, 1 );
24
+
25
+ // Perform the query, the filter will be applied automatically
26
+ query_posts( array(
27
+ 'post_type' => 'post',
28
+ // 'post_status' => 'publish',
29
+ 'caller_get_posts' => 1,
30
+ // 'nopaging' => true,
31
+ 'posts_per_page' => -1 )
32
+ );
33
+
34
+ global $wp_query;
35
+ $wp_query->is_404 = false; // force is_404() condition to false when on site without posts
36
+ $wp_query->is_feed = true; // force is_feed() condition to true so WP Super Cache includes
37
+ // the sitemap in its feeds cache
38
+
39
+ // prepare counter to limit the number of URLs to the absolute max of 50.000
40
+ $counter = 1;
41
+
42
+ // loop away!
43
+ if ( have_posts() ) : while ( have_posts() && $counter < $maxURLS ) : the_post();
44
+
45
+ // check if we are not dealing with an external URL :: Thanks, Francois Deschenes :)
46
+ if(!preg_match('/^' . preg_quote(get_bloginfo('url'), '/') . '/i', get_permalink())) continue;
47
+
48
+ // get the article language
49
+ // qTranslate compatibility, xLanguage no longer developed ?
50
+ //global $q_config;
51
+ //if ( isset($q_config['language']) )
52
+ // $lang = $q_config['language'];
53
+ //elseif ( get_option('WPLANG') )
54
+ // $lang = get_option('WPLANG');
55
+ //else
56
+ // $lang = 'en';
57
+ //$lang_arr = explode( '_', $lang, 5 );
58
+
59
+ // get the article tags
60
+ // TODO : include categories too ??
61
+
62
+ $keys_arr = get_the_tags();
63
+
64
+ ?><url><loc><?php echo esc_url( get_permalink() ) ?></loc><news:news><news:publication><news:name><?php bloginfo('name'); ?></news:name><news:language><?php echo get_option('rss_language'); ?></news:language></news:publication><news:publication_date><?php echo mysql2date('Y-m-d\TH:i:s+00:00', $post->post_date_gmt, false); ?></news:publication_date><news:title><?php the_title(); ?></news:title><news:keywords><?php $comma = 0; if ($keys_arr) foreach($keys_arr as $key) { if ( $comma == 1 ) { echo ', '; } echo $key->name; $comma = 1; } ?></news:keywords><news:genres>Blog</news:genres></news:news></url><?php
65
+
66
+ $counter++;
67
+
68
+ endwhile; endif;
69
+ // see what we can do for :
70
+ //<news:access>Subscription</news:access> (for now always leave off)
71
+ // and
72
+ //<news:genres>Blog</news:genres> (for now leave as Blog)
73
+ // http://www.google.com/support/news_pub/bin/answer.py?answer=93992
74
+
75
+ // lees over indienen:
76
+ // http://www.google.com/support/news_pub/bin/answer.py?hl=nl&answer=74289
77
+
78
+ ?></urlset>
feed-sitemap.php CHANGED
@@ -8,12 +8,11 @@
8
  status_header('200'); // force header('HTTP/1.1 200 OK') for sites without posts
9
  header('Content-Type: text/xml; charset=' . get_bloginfo('charset'), true);
10
 
11
- echo '<?xml version="1.0" encoding="'.get_bloginfo('charset').'"?><?xml-stylesheet type="text/xsl" href="'.get_option('home').'/'.str_replace(ABSPATH,"", XMLSF_PLUGIN_DIR).'/sitemap.xsl.php?v='.XMLSF_VERSION.'"?>
12
  <!-- generated-on="'.date('Y-m-d\TH:i:s+00:00').'" -->
13
- <!-- generator="XML Sitemap Feed plugin for WordPress" -->
14
  <!-- generator-url="http://4visions.nl/en/wordpress-plugins/xml-sitemap-feed/" -->
15
  <!-- generator-version="'.XMLSF_VERSION.'" -->
16
- <urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd">
17
  ';
18
 
19
  // presets are changable
@@ -33,12 +32,24 @@ $month_weight = 0.1; // Fall-back value normally ignored by automatic priority c
33
 
34
  // editing below here is not advised!
35
 
 
 
 
 
 
 
 
 
 
 
 
 
36
  // the main query
37
  query_posts( array(
38
  'post_type' => 'any',
39
- 'post_status' => 'publish',
40
- 'caller_get_posts' => '1',
41
- 'nopaging' => true,
42
  'posts_per_page' => -1 )
43
  );
44
 
@@ -80,7 +91,7 @@ $counter = 1;
80
 
81
  // start with the main URL
82
  ?>
83
- <url><loc><?php
84
  // hook for filter 'xml_sitemap_url' provides a string here and MUST get a string returned
85
  $url = apply_filters( 'xml_sitemap_url', trailingslashit(get_bloginfo('url')) );
86
  if ( is_string($url) ) echo esc_url( $url ); else echo esc_url( trailingslashit(get_bloginfo('url')) );
@@ -133,15 +144,15 @@ if ( have_posts() ) : while ( have_posts() && $counter < $maxURLS ) : the_post()
133
  // trim priority
134
  $priority = ($priority > $max_priority) ? $max_priority : $priority;
135
  $priority = ($priority < $min_priority) ? $min_priority : $priority;
136
- ?><url><loc><?php echo esc_url( get_permalink() ) ?></loc><lastmod><?php echo mysql2date('Y-m-d\TH:i:s+00:00', $thispostmodified_gmt, false) ?></lastmod><?php
137
  if(($lastactivityage/86400) < 7) { // last activity less than 1 week old
138
- ?><changefreq>daily</changefreq><?php
139
  } else if(($lastactivityage/604800) < 12) { // last activity between 1 and 12 weeks old
140
- ?><changefreq>weekly</changefreq><?php
141
  } else if(($lastactivityage/604800) < 52) { // last activity between 12 and 52 weeks old
142
- ?><changefreq>monthly</changefreq><?php
143
- } else { ?><changefreq>yearly</changefreq><?php
144
- } ?><priority><?php echo number_format($priority,1) ?></priority></url><?php
145
  $counter++;
146
 
147
  endwhile; endif;
8
  status_header('200'); // force header('HTTP/1.1 200 OK') for sites without posts
9
  header('Content-Type: text/xml; charset=' . get_bloginfo('charset'), true);
10
 
11
+ echo '<?xml version="1.0" encoding="'.get_bloginfo('charset').'"?><?xml-stylesheet type="text/xsl" href="'.get_option('siteurl').'/'.str_replace(ABSPATH,"", XMLSF_PLUGIN_DIR).'/sitemap.xsl.php?v='.XMLSF_VERSION.'"?>
12
  <!-- generated-on="'.date('Y-m-d\TH:i:s+00:00').'" -->
13
+ <!-- generator="XML & Google News Sitemap Feed plugin for WordPress" -->
14
  <!-- generator-url="http://4visions.nl/en/wordpress-plugins/xml-sitemap-feed/" -->
15
  <!-- generator-version="'.XMLSF_VERSION.'" -->
 
16
  ';
17
 
18
  // presets are changable
32
 
33
  // editing below here is not advised!
34
 
35
+ // Memory issue fix will try to increase allowed PHP memory size to XMLSF_MEMORY_LIMIT constant
36
+ // as set in xml-sitemap.php if the current memory limit is lower than that.
37
+ if ( function_exists('memory_get_usage') && ( (int) @ini_get('memory_limit') < abs(intval(XMLSF_MEMORY_LIMIT)) ) ) {
38
+ if ( $memory_limit = @ini_set('memory_limit', XMLSF_MEMORY_LIMIT) ) {
39
+ echo '<!-- memory-limit-increase="' . ( abs(intval(XMLSF_MEMORY_LIMIT)) - (int) $memory_limit ) . 'M" -->
40
+ ';
41
+ } else {
42
+ echo '<!-- memory-limit="' . @ini_get('memory_limit') . '" -->
43
+ ';
44
+ }
45
+ }
46
+
47
  // the main query
48
  query_posts( array(
49
  'post_type' => 'any',
50
+ // 'post_status' => 'publish',
51
+ // 'caller_get_posts' => 1,
52
+ // 'nopaging' => true,
53
  'posts_per_page' => -1 )
54
  );
55
 
91
 
92
  // start with the main URL
93
  ?>
94
+ <urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd"><url><loc><?php
95
  // hook for filter 'xml_sitemap_url' provides a string here and MUST get a string returned
96
  $url = apply_filters( 'xml_sitemap_url', trailingslashit(get_bloginfo('url')) );
97
  if ( is_string($url) ) echo esc_url( $url ); else echo esc_url( trailingslashit(get_bloginfo('url')) );
144
  // trim priority
145
  $priority = ($priority > $max_priority) ? $max_priority : $priority;
146
  $priority = ($priority < $min_priority) ? $min_priority : $priority;
147
+ ?><url><loc><?php echo esc_url( get_permalink() ) ?></loc><lastmod><?php echo mysql2date('Y-m-d\TH:i:s+00:00', $thispostmodified_gmt, false) ?></lastmod><changefreq><?php
148
  if(($lastactivityage/86400) < 7) { // last activity less than 1 week old
149
+ ?>daily<?php
150
  } else if(($lastactivityage/604800) < 12) { // last activity between 1 and 12 weeks old
151
+ ?>weekly<?php
152
  } else if(($lastactivityage/604800) < 52) { // last activity between 12 and 52 weeks old
153
+ ?>monthly<?php
154
+ } else { ?>yearly<?php
155
+ } ?></changefreq><priority><?php echo number_format($priority,1) ?></priority></url><?php
156
  $counter++;
157
 
158
  endwhile; endif;
readme.txt CHANGED
@@ -1,22 +1,22 @@
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%20Feed&item_number=3%2e8&no_shipping=0&tax=0&bn=PP%2dDonationsBF&charset=UTF%2d8&lc=us
4
- Tags: xml, sitemap, xml sitemap, sitemap.xml, Google, Yahoo, Bing, Live, MSN, seo, wpmu, feed, qtranslate, xlanguage
5
  Requires at least: 2.6
6
  Tested up to: 3.0.1
7
- Stable tag: 3.8.8
8
 
9
- A feed that complies with the XML Sitemap protocol for fast indexing by Google, Yahoo, Bing, Ask and others. Multi-Site and Multi-Lingual compatible!
10
 
11
  == Description ==
12
 
13
- This plugin dynamically creates a feed that complies with the **XML Sitemap** protocol. There are no options to be set and the feed becomes instantly available on yourblogurl.tld/sitemap.xml (or yourblogurl.tld/?feed=sitemap), ready for indexing by search engines like Google, Yahoo, MSN, Ask.com and others.
14
 
15
  **Compatible with caching plugins** like Super Cache, W3 Total Cache and Quick Cache that cache feeds, allowing better performance to serve the hungry (impatient) spider.
16
 
17
  **qTranslate and xLanguage compatible!** Tested in Pre-Path Mode and Query Mode. Each language on your site will have its own XML Sitemap.
18
 
19
- A reference to it (or _them_, when using qTranslate or xLanguage) is added to the dynamically created **robots.txt** on yourblogurl.tld/robots.txt to tell search engines where to find your XML Sitemap(s).
20
 
21
  **NOTES:**
22
 
@@ -45,11 +45,11 @@ There is nothing to translate. The sitemap protocol is international, there is n
45
 
46
  = Plugin developers =
47
 
48
- Since 3.8.5, there is a FILTER hook `xml_sitemap_url` available that lets you filter the URL for the sitemap reference in the generated robots.txt and the home URL in the sitemap. It accepts both string (for single url) and array (for multiple urls) and should receive the same. See pre-packaged examples of it's use in xml-sitemap.php for the qTranslate and xLanguage plugins.
49
 
50
  = Credits =
51
 
52
- 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 rewritten.
53
 
54
  == Installation ==
55
 
@@ -83,10 +83,20 @@ Same as above but do a **Network Activate** to make a XML sitemap available for
83
 
84
  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/.
85
 
86
- Installed alongside [WordPress MU Sitewide Tags Pages](http://wordpress.org/extend/plugins/wordpress-mu-sitewide-tags/), XML Sitemap Feed will **not** create a sitemap.xml nor change robots.txt for any tag blogs. This is done deliberately because they would be full of links outside the tags blogs own domain and subsequently ignored (or worse: penalised) by Google.
87
 
88
  == Frequently Asked Questions ==
89
 
 
 
 
 
 
 
 
 
 
 
90
  = How are the values for priority and changefreq calculated? =
91
 
92
  The front page has a fixed priority of 100% (1.0). When your site has more posts than pages (you must be using WordPress for a blog), pages have a default priority of 40% (0.4) and posts have a default priority of 80% (0.8). If your site has more pages than posts (you must be using WordPress as CMS), pages have a default priority of 80% (0.8) and posts have a default priority of 40% (0.4).
@@ -116,15 +126,10 @@ No. In normal circumstances, your site will be indexed by the major search engin
116
 
117
  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:
118
 
119
- 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
120
- `
121
- http://rpc.pingomatic.com
122
- `
123
- Read more on [Ping-O-Matic](http://pingomatic.com) about what excellent service you are actually getting _for free with every WordPress blog_ installation!
124
 
125
- 2. 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 on the agenda of the major search engines, they will likely give no priority to your pings at all.
126
-
127
- 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, sitemap downloads, search terms and your visitors. Try it!
128
 
129
  = Do I need to change my robots.txt? =
130
 
@@ -154,7 +159,7 @@ Sitemap: http://yourblogurl.tld/?feed=sitemap
154
  User-agent: *
155
  Allow: /
156
  `
157
- 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/) and submit your sitemap for the first time from there to enable tracking of sitemap downloads by Google! or head over to [XML-Sitemaps.com](http://www.xml-sitemaps.com/validate-xml-sitemap.html) and enter your sites sitemap URL.
158
 
159
  = Can I change the sitemap name/URL? =
160
 
@@ -218,13 +223,9 @@ On some setups (usually using the WordPress MU Domain Mapping plugin) this error
218
 
219
  = Can I run this on a WPMU / WP3+ Multi-Site setup? =
220
 
221
- Yes. In fact, it has been designed for it. Tested on WPMU 2.9.2 and WPMS 3.0.1
222
-
223
- = Can I do a Network Activate on WP3.0 MS / Site Wide Activate on WPMU with this plugin ? =
224
-
225
- Yes.
226
 
227
- = Can I run this plugin from /mu-plugins/ on WP3.0 MS / WPMU ? =
228
 
229
  Yes. Upload the complete /xml-sitemap-feed/ directory to /wp-content/mu-plugins/ and move the file xml-sitemap.php one dir up.
230
 
@@ -235,16 +236,18 @@ Yes. Upload the complete /xml-sitemap-feed/ directory to /wp-content/mu-plugins/
235
 
236
  == Upgrade Notice ==
237
 
238
- = 3.8.8 =
239
- Bugfixes: PHP4 compatibility + mu-plugins URL stylesheet
240
 
241
  == Changelog ==
242
 
 
 
 
 
243
  = 3.8.8 =
244
  * Bugfix: PHP4 compatibility
245
  * Bugfix: stylesheet URL when installed in mu-plugins
246
-
247
- = 3.8.6 =
248
  * core change to class
249
  * minified sitemap output by default
250
 
1
+ === XML Sitemap & Google News Sitemap Feeds ===
2
  Contributors: RavanH
3
  Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=ravanhagen%40gmail%2ecom&item_name=XML%20Sitemap%20Feed&item_number=3%2e8&no_shipping=0&tax=0&bn=PP%2dDonationsBF&charset=UTF%2d8&lc=us
4
+ Tags: xml sitemap, news sitemap, sitemap.xml, Google, Google News, Yahoo, Bing, Live, MSN, seo, wpmu, feed, qtranslate, xlanguage
5
  Requires at least: 2.6
6
  Tested up to: 3.0.1
7
+ Stable tag: 3.9
8
 
9
+ Feeds that comply with the XML Sitemap and Google News protocol for fast indexing by Google, Yahoo, Bing, Ask and others. Multi-Site and Multi-Lingual compatible!
10
 
11
  == Description ==
12
 
13
+ This plugin dynamically creates feeds that comply with the **XML Sitemap** and the **Google News Sitemap** protocol. There are no options to be set nor file or dir access rights to be tampered with and the feeds become instantly available. One XML Sitemap on yourblogurl.tld/sitemap.xml (or yourblogurl.tld/?feed=sitemap), ready for indexing by search engines like Google, Yahoo, MSN, Ask.com and others. And one Google News Sitemap on yourblogurl.tld/sitemap-news.xml (or yourblogurl.tld/?feed=sitemap-news), ready for indexing by Google News. Please read the FAQ's for info on how to get your articles listed on Google News.
14
 
15
  **Compatible with caching plugins** like Super Cache, W3 Total Cache and Quick Cache that cache feeds, allowing better performance to serve the hungry (impatient) spider.
16
 
17
  **qTranslate and xLanguage compatible!** Tested in Pre-Path Mode and Query Mode. Each language on your site will have its own XML Sitemap.
18
 
19
+ References are automatically added to the dynamically created **robots.txt** on yourblogurl.tld/robots.txt to tell search engines where to find your XML Sitemaps.
20
 
21
  **NOTES:**
22
 
45
 
46
  = Plugin developers =
47
 
48
+ Since 3.8.5, there is a FILTER hook `xml_sitemap_url` available that lets you filter the URL for the sitemap reference in the generated robots.txt and the home URL in the sitemap. It sends both string (for single url) and array (for multiple urls) and should receive the same. See pre-packaged examples of it's use in xml-sitemap.php for the qTranslate and xLanguage plugins.
49
 
50
  = Credits =
51
 
52
+ 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 rewritten and extended in many ways.
53
 
54
  == Installation ==
55
 
83
 
84
  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/.
85
 
86
+ Installed alongside [WordPress MU Sitewide Tags Pages](http://wordpress.org/extend/plugins/wordpress-mu-sitewide-tags/), XML Sitemap Feed will **not** create a sitemap.xml nor change robots.txt for any **tag blogs**. This is done deliberately because they would be full of links outside the tags blogs own domain and subsequently ignored (or worse: penalised) by Google.
87
 
88
  == Frequently Asked Questions ==
89
 
90
+ = How do I get my latest articles listed on Google News? =
91
+
92
+ Go to [Suggest News Content for Google News](http://www.google.com/support/news_pub/bin/request.py?contact_type=suggest_content) and submit your website info as detailed as possible there. Give them the URL(s) of your fresh new Google News Sitemap in the text field 'Other' at the bottom.
93
+
94
+ You will also want to add the sitemap to your [Google Webmasters Tools account](https://www.google.com/webmasters/tools/) to check its validity and performance. Create an account if you don't have one yet.
95
+
96
+ = My Google News Sitemap is empty! =
97
+
98
+ The rules of the Google News game are that you do not feed the cookie monster any stale food. Older than 2 days is bad. You need to bake him some fresh bread ;)
99
+
100
  = How are the values for priority and changefreq calculated? =
101
 
102
  The front page has a fixed priority of 100% (1.0). When your site has more posts than pages (you must be using WordPress for a blog), pages have a default priority of 40% (0.4) and posts have a default priority of 80% (0.8). If your site has more pages than posts (you must be using WordPress as CMS), pages have a default priority of 80% (0.8) and posts have a default priority of 40% (0.4).
126
 
127
  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:
128
 
129
+ 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 `http://rpc.pingomatic.com`. Read more on [Ping-O-Matic](http://pingomatic.com) about what excellent service you are actually getting _for free with every WordPress blog_ installation!
130
+ 1. 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 on the agenda of the major search engines, they will likely give no priority to your pings at all.
 
 
 
131
 
132
+ You can always take a [Google Webmasters Tools account](https://www.google.com/webmasters/tools/) which will tell you many interesting things about your website, sitemap downloads, search terms and your visitors. Try it!
 
 
133
 
134
  = Do I need to change my robots.txt? =
135
 
159
  User-agent: *
160
  Allow: /
161
  `
162
+ You can also choose to notify major search engines of your new XML sitemap manually. Start with getting a [Google Webmasters Tools account](https://www.google.com/webmasters/tools/) and submit your sitemap for the first time from there to enable tracking of sitemap downloads by Google! or head over to [XML-Sitemaps.com](http://www.xml-sitemaps.com/validate-xml-sitemap.html) and enter your sites sitemap URL.
163
 
164
  = Can I change the sitemap name/URL? =
165
 
223
 
224
  = Can I run this on a WPMU / WP3+ Multi-Site setup? =
225
 
226
+ Yes. In fact, it has been designed for it. Tested on WPMU 2.9.2 and WPMS 3.0.1 both with normal activation and with Network Activate / Site Wide Activate.
 
 
 
 
227
 
228
+ = Can I run this plugin from /mu-plugins/ on WP3.0 MS or WPMU ? =
229
 
230
  Yes. Upload the complete /xml-sitemap-feed/ directory to /wp-content/mu-plugins/ and move the file xml-sitemap.php one dir up.
231
 
236
 
237
  == Upgrade Notice ==
238
 
239
+ = 3.9 =
240
+ Google News Sitemap! And a workaround for memory limit errors for most sites.
241
 
242
  == Changelog ==
243
 
244
+ = 3.9 =
245
+ * Google News Sitemap
246
+ * Memory limit error workaround (for most sites)
247
+
248
  = 3.8.8 =
249
  * Bugfix: PHP4 compatibility
250
  * Bugfix: stylesheet URL when installed in mu-plugins
 
 
251
  * core change to class
252
  * minified sitemap output by default
253
 
sitemap.xsl.php CHANGED
@@ -5,4 +5,4 @@
5
 
6
  header('Content-Type: text/xsl; charset=utf-8', true);
7
 
8
- echo '<?xml version="1.0" encoding="UTF-8"?>'; ?><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"><xsl:output method="html" version="1.0" encoding="UTF-8" indent="yes"/><xsl:template match="/"><html xmlns="http://www.w3.org/1999/xhtml"><head><title>XML Sitemap Feed</title><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><style type="text/css">body{font-family:"Lucida Grande","Lucida Sans Unicode",Tahoma,Verdana,sans-serif;font-size:13px}#header,#footer{padding:2px;margin:10px;font-size:8pt;color:gray}a{color:black}td{font-size:11px}th{text-align:left;padding-right:30px;font-size:11px}tr.high{background-color:whitesmoke}</style></head><body><h1>XML Sitemap Feed</h1><div id="header">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>.</div><div id="content"><table cellpadding="5"><tr style="border-bottom:1px black solid;"><th>#</th><th>URL</th><th>Priority</th><th>Change Frequency</th><th>Last Changed</th></tr><xsl:variable name="lower" select="'abcdefghijklmnopqrstuvwxyz'"/><xsl:variable name="upper" select="'ABCDEFGHIJKLMNOPQRSTUVWXYZ'"/><xsl:for-each select="sitemap:urlset/sitemap:url"><tr><xsl:if test="position() mod 2 != 1"><xsl:attribute name="class">high</xsl:attribute></xsl:if><td><xsl:value-of select="position()"/></td><td><xsl:variable name="itemURL"><xsl:value-of select="sitemap:loc"/></xsl:variable><a href="{$itemURL}"><xsl:value-of select="sitemap:loc"/></a></td><td><xsl:value-of select="concat(sitemap:priority*100,'%')"/></td><td><xsl:value-of select="concat(translate(substring(sitemap:changefreq, 1, 1),concat($lower, $upper),concat($upper, $lower)),substring(sitemap:changefreq, 2))"/></td><td><xsl:value-of select="concat(substring(sitemap:lastmod,0,11),concat(' ', substring(sitemap:lastmod,12,5)))"/></td></tr></xsl:for-each></table></div><div id="footer"><img src="<?php echo 'http://' . $_SERVER['HTTP_HOST'] . dirname($_SERVER['SCRIPT_NAME']); ?>/sitemapxml.gif" alt="XML Sitemap" title="XML Sitemap" /> generated by <a href="http://4visions.nl/en/wordpress-plugins/xml-sitemap-feed/" title="XML Sitemap Feed plugin for WordPress">XML Sitemap Feed <?php echo $_GET['v'] ?></a> running on <a href="http://wordpress.org/">WordPress</a>.</div></body></html></xsl:template></xsl:stylesheet>
5
 
6
  header('Content-Type: text/xsl; charset=utf-8', true);
7
 
8
+ echo '<?xml version="1.0" encoding="UTF-8"?>'; ?><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"><xsl:output method="html" version="1.0" encoding="UTF-8" indent="yes"/><xsl:template match="/"><html xmlns="http://www.w3.org/1999/xhtml"><head><title>XML Sitemap Feed</title><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><style type="text/css">body{font-family:"Lucida Grande","Lucida Sans Unicode",Tahoma,Verdana,sans-serif;font-size:13px}#header,#footer{padding:2px;margin:10px;font-size:8pt;color:gray}a{color:black}td{font-size:11px}th{text-align:left;padding-right:30px;font-size:11px}tr.high{background-color:whitesmoke}#footer img{vertical-align:text-bottom}</style></head><body><h1>XML Sitemap Feed</h1><div id="header">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>.</div><div id="content"><table cellpadding="5"><tr style="border-bottom:1px black solid;"><th>#</th><th>URL</th><th>Priority</th><th>Change Frequency</th><th>Last Changed</th></tr><xsl:variable name="lower" select="'abcdefghijklmnopqrstuvwxyz'"/><xsl:variable name="upper" select="'ABCDEFGHIJKLMNOPQRSTUVWXYZ'"/><xsl:for-each select="sitemap:urlset/sitemap:url"><tr><xsl:if test="position() mod 2 != 1"><xsl:attribute name="class">high</xsl:attribute></xsl:if><td><xsl:value-of select="position()"/></td><td><xsl:variable name="itemURL"><xsl:value-of select="sitemap:loc"/></xsl:variable><a href="{$itemURL}"><xsl:value-of select="sitemap:loc"/></a></td><td><xsl:value-of select="concat(sitemap:priority*100,'%')"/></td><td><xsl:value-of select="concat(translate(substring(sitemap:changefreq, 1, 1),concat($lower, $upper),concat($upper, $lower)),substring(sitemap:changefreq, 2))"/></td><td><xsl:value-of select="concat(substring(sitemap:lastmod,0,11),concat(' ', substring(sitemap:lastmod,12,5)))"/></td></tr></xsl:for-each></table></div><div id="footer"><img src="<?php echo 'http://' . $_SERVER['HTTP_HOST'] . dirname($_SERVER['SCRIPT_NAME']); ?>/sitemapxml.gif" alt="XML Sitemap" title="XML Sitemap" /> generated by <a href="http://4visions.nl/en/wordpress-plugins/xml-sitemap-feed/" title="XML Sitemap Feed plugin for WordPress">XML &amp; Google News Sitemap Feed <?php echo (is_numeric($_GET['v'])) ? $_GET['v'] : ''; ?></a> running on <a href="http://wordpress.org/">WordPress</a>.</div></body></html></xsl:template></xsl:stylesheet>
xml-sitemap.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: XML Sitemap Feed
4
  Plugin URI: http://4visions.nl/en/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. Happy with it? Please leave me a <strong><a href="https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=ravanhagen%40gmail%2ecom&item_name=XML%20Sitemap%20Feed&item_number=3%2e8&no_shipping=0&tax=0&bn=PP%2dDonationsBF&charset=UTF%2d8&lc=us">Tip</a></strong> for development and support time. Thanks :)
6
- Version: 3.8.8
7
  Author: RavanH
8
  Author URI: http://4visions.nl/
9
  */
@@ -45,7 +45,8 @@ Author URI: http://4visions.nl/
45
  /* --------------------
46
  * CONSTANTS
47
  * -------------------- */
48
- define('XMLSF_VERSION','3.8.8');
 
49
 
50
  if (file_exists(dirname(__FILE__).'/xml-sitemap-feed'))
51
  define('XMLSF_PLUGIN_DIR', dirname(__FILE__).'/xml-sitemap-feed');
3
  Plugin Name: XML Sitemap Feed
4
  Plugin URI: http://4visions.nl/en/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. Happy with it? Please leave me a <strong><a href="https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=ravanhagen%40gmail%2ecom&item_name=XML%20Sitemap%20Feed&item_number=3%2e8&no_shipping=0&tax=0&bn=PP%2dDonationsBF&charset=UTF%2d8&lc=us">Tip</a></strong> for development and support time. Thanks :)
6
+ Version: 3.9
7
  Author: RavanH
8
  Author URI: http://4visions.nl/
9
  */
45
  /* --------------------
46
  * CONSTANTS
47
  * -------------------- */
48
+ define('XMLSF_VERSION','3.9');
49
+ define('XMLSF_MEMORY_LIMIT','128M');
50
 
51
  if (file_exists(dirname(__FILE__).'/xml-sitemap-feed'))
52
  define('XMLSF_PLUGIN_DIR', dirname(__FILE__).'/xml-sitemap-feed');