XML Sitemap & Google News feeds - Version 3.8.5

Version Description

  • xLanguage support based on code and testing by Daniele Pelagatti
  • new FILTER HOOK robotstxt_sitemap_url for any translate and url changing plugins.
  • BUGFIX: Decimal separator cannot be a comma!
Download this release

Release Info

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

Code changes from version 3.8.3 to 3.8.5

Files changed (3) hide show
  1. feed-sitemap.php +5 -6
  2. readme.txt +21 -16
  3. xml-sitemap.php +79 -25
feed-sitemap.php CHANGED
@@ -79,11 +79,10 @@ $counter = 1;
79
// start with the main URL
80
?>
81
<urlset 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" xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"><url><loc><?php
82
- if (function_exists('qtrans_convertURL')) {
83
- echo esc_url( qtrans_convertURL(trailingslashit(get_bloginfo('url'))) );
84
- } else {
85
- echo esc_url( trailingslashit(get_bloginfo('url')) );
86
- } ?></loc><lastmod><?php echo mysql2date('Y-m-d\TH:i:s+00:00', $lastmodified_gmt, false); ?></lastmod><changefreq>daily</changefreq><priority>1.0</priority></url><?php
87
// and loop away!
88
if ( have_posts() ) : while ( have_posts() && $counter < $maxURLS ) : the_post();
89
@@ -139,7 +138,7 @@ if ( have_posts() ) : while ( have_posts() && $counter < $maxURLS ) : the_post()
139
} else if(($lastactivityage/604800) < 52) { // last activity between 12 and 52 weeks old
140
?><changefreq>monthly</changefreq><?php
141
} else { ?><changefreq>yearly</changefreq><?php
142
- } ?><priority><?php echo round($priority,1) ?></priority></url><?php
143
$counter++;
144
145
endwhile; endif;
79
// start with the main URL
80
?>
81
<urlset 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" xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"><url><loc><?php
82
+ // hook for filter 'xml_sitemap_url' provides a string here and MUST get a string returned
83
+ $url = apply_filters( 'xml_sitemap_url', trailingslashit(get_bloginfo('url')) );
84
+ if ( is_string($url) ) echo esc_url( $url ); else echo esc_url( trailingslashit(get_bloginfo('url')) );
85
+ ?></loc><lastmod><?php echo mysql2date('Y-m-d\TH:i:s+00:00', $lastmodified_gmt, false); ?></lastmod><changefreq>daily</changefreq><priority>1.0</priority></url><?php
86
// and loop away!
87
if ( have_posts() ) : while ( have_posts() && $counter < $maxURLS ) : the_post();
88
138
} else if(($lastactivityage/604800) < 52) { // last activity between 12 and 52 weeks old
139
?><changefreq>monthly</changefreq><?php
140
} else { ?><changefreq>yearly</changefreq><?php
141
+ } ?><priority><?php echo number_format($priority,1) ?></priority></url><?php
142
$counter++;
143
144
endwhile; endif;
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&amp;business=ravanhagen%40gmail%2ecom&amp;item_name=XML%20Sitemap%20Feed&amp;item_number=3%2e8&amp;no_shipping=0&amp;tax=0&amp;bn=PP%2dDonationsBF&amp;charset=UTF%2d8
4
- Tags: xml, sitemap, xml sitemap, sitemap.xml, Google, Yahoo, Bing, Live, MSN, wpmu, feed
5
Requires at least: 2.6
6
Tested up to: 3.0.1
7
- Stable tag: 3.8.3
8
9
- Creates a feed (or more when using qTranlate) that complies with the XML Sitemap protocol for indexing by Google, Yahoo, Bing, Ask and others.
10
11
== Description ==
12
13
This plugin dynamically creates an 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
- **Now qTranslate compatible!** Tested in Pre-Path Mode and Query Mode. Each language on your site will have its own XML Sitemap.
16
17
- A reference to it (or _them_, when using qTranslate) is added to the dynamically created **robots.txt** on yourblogurl.tld/robots.txt to tell search engines where to find your XML Sitemap(s).
18
19
**NOTES:**
20
@@ -25,10 +25,10 @@ A reference to it (or _them_, when using qTranslate) is added to the dynamically
25
= Advantages =
26
27
* 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!
28
- * Completely **automatic** post URL _priority_ and _change frequency_ calculation based on post age and comment/trackback activity.
29
* Works out-of-the-box, even on **multi-site / shared codebase / multi-blog setups** like WordPress MU, WP 3.0 in MultiSite (WPMS) mode and others.
30
* Also works upon **Network Activate** or placed in **/mu-plugins/** on WP 3.0 in MS mode and WPMU and even takes care to exclude any tags blogs to avoid malus points for link spamming.
31
- * Compatible with multi-lingual sites using **qTranslate** to allow all languages to be indexed equally.
32
33
= Limitations =
34
@@ -41,6 +41,10 @@ A reference to it (or _them_, when using qTranslate) is added to the dynamically
41
42
There is nothing to translate. The sitemap protocol is international, there is no options page nor any front-end or widget output. Nothing to see here, please move along ;)
43
44
= Credits =
45
46
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.
@@ -215,14 +219,18 @@ Yes. Upload the complete /xml-sitemap-feed/ directory to /wp-content/mu-plugins/
215
216
== Changelog ==
217
218
- = 3.8.3 =
219
- * filter external URLs inserted by plugins like Page Links To (thanks, Francois)
220
- * minified sitemap and stylesheet output
221
222
* BUGFIX: qTranslate non-default language home URL
223
224
= 3.8 =
225
- * qTranslate support !
226
* no more Sitemap reference in robots.txt on non-public blogs
227
228
= 3.7.4 =
@@ -278,9 +286,6 @@ Yes. Upload the complete /xml-sitemap-feed/ directory to /wp-content/mu-plugins/
278
279
== Upgrade Notice ==
280
281
- = 3.8.3 =
282
- BUGFIX RELEASE. Filter external links (thanks to Francois Deschenes) plus improved qTranslate support.
283
-
284
- = 3.8 =
285
- Now support for qTranslate: one XML Sitemap for each language! Plus no more sitemap when site is set to block spidering.
286
1
=== XML Sitemap Feed ===
2
Contributors: RavanH
3
Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_donations&amp;business=ravanhagen%40gmail%2ecom&amp;item_name=XML%20Sitemap%20Feed&amp;item_number=3%2e8&amp;no_shipping=0&amp;tax=0&amp;bn=PP%2dDonationsBF&amp;charset=UTF%2d8
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.5
8
9
+ Creates one or more (when using qTranlate or xLanguage) feeds that comply with the XML Sitemap protocol for fast indexing by Google, Yahoo, Bing, Ask and others.
10
11
== Description ==
12
13
This plugin dynamically creates an 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
+ **Now qTranslate and xLanguage compatible!** Tested in Pre-Path Mode and Query Mode. Each language on your site will have its own XML Sitemap.
16
17
+ 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).
18
19
**NOTES:**
20
25
= Advantages =
26
27
* 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!
28
+ * Completely **automatic** post URL _priority_ and _change frequency_ calculation based on post age and comment and trackback activity.
29
* Works out-of-the-box, even on **multi-site / shared codebase / multi-blog setups** like WordPress MU, WP 3.0 in MultiSite (WPMS) mode and others.
30
* Also works upon **Network Activate** or placed in **/mu-plugins/** on WP 3.0 in MS mode and WPMU and even takes care to exclude any tags blogs to avoid malus points for link spamming.
31
+ * Compatible with multi-lingual sites using **qTranslate** or **xLanguage** to allow all languages to be indexed equally.
32
33
= Limitations =
34
41
42
There is nothing to translate. The sitemap protocol is international, there is no options page nor any front-end or widget output. Nothing to see here, please move along ;)
43
44
+ = Plugin developers =
45
+
46
+ 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.
47
+
48
= Credits =
49
50
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.
219
220
== Changelog ==
221
222
+ = 3.8.5 =
223
+ * **xLanguage support** based on code and testing by **Daniele Pelagatti**
224
+ * new FILTER HOOK `robotstxt_sitemap_url` for any translate and url changing plugins.
225
+ * BUGFIX: Decimal separator cannot be a comma!
226
227
+ = 3.8.3 =
228
+ * filter out external URLs inserted by plugins like Page Links To (thanks, Francois)
229
+ * minify sitemap and stylesheet output
230
* BUGFIX: qTranslate non-default language home URL
231
232
= 3.8 =
233
+ * **qTranslate support**
234
* no more Sitemap reference in robots.txt on non-public blogs
235
236
= 3.7.4 =
286
287
== Upgrade Notice ==
288
289
+ = 3.8.5 =
290
+ Automatic xLanguage support thanks to Daniele Pelagatti + new FILTER HOOK for other translate and url changing plugins. BUGFIX: Decimal separator cannot be a comma!
291
xml-sitemap.php CHANGED
@@ -1,9 +1,9 @@
1
<?php
2
/*
3
Plugin Name: XML Sitemap Feed
4
- Plugin URI: http://4visions.nl/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&amp;business=ravanhagen%40gmail%2ecom&amp;item_name=XML%20Sitemap%20Feed&amp;item_number=3%2e8&no_shipping=0&amp;tax=0&bn=PP%2dDonationsBF&amp;charset=UTF%2d8">Tip</a></strong> for development and support time. Thanks :)
6
- Version: 3.8.3
7
Author: RavanH
8
Author URI: http://4visions.nl/
9
*/
@@ -25,18 +25,28 @@ Author URI: http://4visions.nl/
25
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
26
*/
27
28
- // ALTERNATIVE to investigate 3.5:
29
- // Use "template_redirect" just like do_robots does and make sitemap.xml available via /?sitemapxml=1
30
- // and make a rewrite to sitemap.xml for it... Nearly works but :( ...
31
- // PROBLEMS so far:
32
- // * Redirect rules no longer working ?!?
33
-
34
/* --------------------
35
- CONSTANTS
36
- -------------------- */
37
38
// set version
39
- define('XMLSF_VERSION','3.8.3');
40
41
// dir
42
$xmlsf_dir = dirname(__FILE__);
@@ -52,8 +62,8 @@ if (file_exists($xmlsf_dir.'/xml-sitemap-feed')) {
52
}
53
54
/* --------------------
55
- FUNCTIONS
56
- -------------------- */
57
58
// FEEDS //
59
// set up the feed template
@@ -77,25 +87,29 @@ function xml_sitemap_flush_rewrite_rules() {
77
78
// ROBOTSTXT //
79
// add sitemap location in robots.txt generated by WP
80
function xml_sitemap_robots() {
81
82
- if (function_exists('qtrans_convertURL')) {
83
- global $q_config;
84
- foreach($q_config['enabled_languages'] as $language)
85
- echo "\nSitemap: ".qtrans_convertURL(trailingslashit(get_bloginfo('url'))."sitemap.xml",$language);
86
- } else {
87
- echo "\nSitemap: ".trailingslashit(get_bloginfo('url'))."sitemap.xml";
88
- }
89
echo "\n\n";
90
}
91
92
- // DE/ACTIVATION
93
function xml_sitemap_activate() {
94
update_option('xml-sitemap-feed-version', XMLSF_VERSION);
95
xml_sitemap_flush_rewrite_rules();
96
}
97
function xml_sitemap_deactivate() {
98
- //remove_filter('query_vars', 'xml_sitemap_vars');
99
remove_filter('generate_rewrite_rules', 'xml_sitemap_rewrite');
100
delete_option('xml-sitemap-feed-version');
101
xml_sitemap_flush_rewrite_rules();
@@ -114,6 +128,7 @@ if( !function_exists('get_firstmodified') ) {
114
return $firstpagemodified;
115
}
116
}
117
if( !function_exists('get_lastmodified') ) {
118
function get_lastmodified($timezone = 'server') {
119
$lastpostmodified = get_lastpostmodified($timezone);
@@ -398,9 +413,39 @@ if( !function_exists('get_firstpagedate') ) {
398
}
399
}
400
401
/* --------------------
402
- HOOKS
403
- -------------------- */
404
405
// FLUSH RULES check
406
// limited to after (site wide) plugin upgrade
@@ -428,6 +473,15 @@ if ( '0' == get_option( 'blog_public' ) || ( $wpdb->blogid && function_exists('g
428
add_action('do_robotstxt', 'xml_sitemap_robots');
429
}
430
431
// DE/ACTIVATION
432
register_activation_hook( __FILE__, 'xml_sitemap_activate' );
433
register_deactivation_hook( __FILE__, 'xml_sitemap_deactivate' );
1
<?php
2
/*
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.5
7
Author: RavanH
8
Author URI: http://4visions.nl/
9
*/
25
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
26
*/
27
28
/* --------------------
29
+ * AVAILABLE HOOKS
30
+ * --------------------
31
+ *
32
+ * FILTERS
33
+ * xml_sitemap_url -> Filters the URL used in the sitemap reference in robots.txt
34
+ * (receives an ARRAY and MUST return one; can be multiple urls)
35
+ * and for the home URL in the sitemap (receives a STRING and MUST)
36
+ * return one) itself. Useful for multi language plugins or other
37
+ * plugins that affect the blogs main URL... See pre-defined filter
38
+ * xml_sitemap_qtranslate() in this file as an example.
39
+ * ACTIONS
40
+ * [ none at this point, but feel free to request one :) ]
41
+ *
42
+ */
43
+
44
+ /* --------------------
45
+ * CONSTANTS
46
+ * -------------------- */
47
48
// set version
49
+ define('XMLSF_VERSION','3.8.5');
50
51
// dir
52
$xmlsf_dir = dirname(__FILE__);
62
}
63
64
/* --------------------
65
+ * FUNCTIONS
66
+ * -------------------- */
67
68
// FEEDS //
69
// set up the feed template
87
88
// ROBOTSTXT //
89
// add sitemap location in robots.txt generated by WP
90
+ // available filter : robotstxt_sitemap_url
91
function xml_sitemap_robots() {
92
+
93
+ // hook for filter 'xml_sitemap_url' provides an array here and MUST get an array returned
94
+ $sitemap_array = apply_filters('xml_sitemap_url',array(trailingslashit(get_bloginfo('url'))."sitemap.xml"));
95
+
96
+ echo "\n# XML Sitemap Feed ".XMLSF_VERSION." (http://4visions.nl/en/wordpress-plugins/xml-sitemap-feed/)";
97
+
98
+ if ( is_array($sitemap_array) && !empty($sitemap_array) )
99
+ foreach ( $sitemap_array as $url )
100
+ echo "\nSitemap: " . $url;
101
+ else
102
+ echo "\n# Warning: xml sitemap url is missing, filtered out or filter did not return an array.";
103
104
echo "\n\n";
105
}
106
107
+ // DE/ACTIVATION //
108
function xml_sitemap_activate() {
109
update_option('xml-sitemap-feed-version', XMLSF_VERSION);
110
xml_sitemap_flush_rewrite_rules();
111
}
112
function xml_sitemap_deactivate() {
113
remove_filter('generate_rewrite_rules', 'xml_sitemap_rewrite');
114
delete_option('xml-sitemap-feed-version');
115
xml_sitemap_flush_rewrite_rules();
128
return $firstpagemodified;
129
}
130
}
131
+
132
if( !function_exists('get_lastmodified') ) {
133
function get_lastmodified($timezone = 'server') {
134
$lastpostmodified = get_lastpostmodified($timezone);
413
}
414
}
415
416
+ // MULTI-LANGUAGE PLUGIN FILTERS
417
+
418
+ // qTranslate
419
+ function xml_sitemap_qtranslate($input) {
420
+ global $q_config;
421
+
422
+ if (is_array($input)) // got an array? return one!
423
+ foreach ( $input as $url )
424
+ foreach($q_config['enabled_languages'] as $language)
425
+ $return[] = qtrans_convertURL($url,$language);
426
+ else // not an array? just convert the string.
427
+ $return = qtrans_convertURL($input);
428
+
429
+ return $return;
430
+ }
431
+
432
+ // xLanguage
433
+ function xml_sitemap_xlanguage($input) {
434
+ global $xlanguage;
435
+
436
+ if (is_array($input)) // got an array? return one!
437
+ foreach ( $input as $url )
438
+ foreach($xlanguage->options['language'] as $language)
439
+ $return[] = $xlanguage->filter_link_in_lang($url,$language['code']);
440
+ else // not an array? just convert the string.
441
+ $return = $xlanguage->filter_link($input);
442
+
443
+ return $return;
444
+ }
445
+
446
/* --------------------
447
+ * HOOKS ++
448
+ * -------------------- */
449
450
// FLUSH RULES check
451
// limited to after (site wide) plugin upgrade
473
add_action('do_robotstxt', 'xml_sitemap_robots');
474
}
475
476
+ // check for qTranslate and activate filter
477
+ if (function_exists('qtrans_convertURL'))
478
+ add_filter('xml_sitemap_url','xml_sitemap_qtranslate',99);
479
+
480
+ // check for xLanguage and activate filter
481
+ global $xlanguage;
482
+ if (isset($xlanguage))
483
+ add_filter('xml_sitemap_url','xml_sitemap_xlanguage',99);
484
+
485
// DE/ACTIVATION
486
register_activation_hook( __FILE__, 'xml_sitemap_activate' );
487
register_deactivation_hook( __FILE__, 'xml_sitemap_deactivate' );