Google XML Sitemaps - Version 3.2.5

Version Description

Download this release

Release Info

Developer arnee
Plugin Icon 128x128 Google XML Sitemaps
Version 3.2.5
Comparing to
See all releases

Code changes from version 3.2.4 to 3.2.5

Files changed (4) hide show
  1. readme.txt +1 -1
  2. sitemap-core.php +43 -8
  3. sitemap-ui.php +73 -15
  4. sitemap.php +3 -3
readme.txt CHANGED
@@ -4,7 +4,7 @@ Donate link: http://www.arnebrachhold.de/redir/sitemap-paypal
4
  Tags: seo, google, sitemaps, google sitemaps, yahoo, msn, ask, live, xml sitemap, xml
5
  Requires at least: 2.1
6
  Tested up to: 3.3
7
- Stable tag: 3.2.3
8
 
9
  This plugin will generate a special XML sitemap which will help search engines to better index your blog.
10
 
4
  Tags: seo, google, sitemaps, google sitemaps, yahoo, msn, ask, live, xml sitemap, xml
5
  Requires at least: 2.1
6
  Tested up to: 3.3
7
+ Stable tag: 3.2.4
8
 
9
  This plugin will generate a special XML sitemap which will help search engines to better index your blog.
10
 
sitemap-core.php CHANGED
@@ -1,7 +1,7 @@
1
  <?php
2
  /*
3
 
4
- $Id: sitemap-core.php 246875 2010-05-29 07:22:02Z arnee $
5
 
6
  */
7
 
@@ -746,7 +746,7 @@ class GoogleSitemapGenerator {
746
  /**
747
  * @var Version of the generator in SVN
748
  */
749
- var $_svnVersion = '$Id: sitemap-core.php 246875 2010-05-29 07:22:02Z arnee $';
750
 
751
  /**
752
  * @var array The unserialized array with the stored options
@@ -940,6 +940,7 @@ class GoogleSitemapGenerator {
940
  $this->_options["sm_in_auth"]=false; //Include author pages
941
  $this->_options["sm_in_tags"]=false; //Include tag pages
942
  $this->_options["sm_in_tax"]=array(); //Include additional taxonomies
 
943
  $this->_options["sm_in_lastmod"]=true; //Include the last modification date
944
 
945
  $this->_options["sm_cf_home"]="daily"; //Change frequency of the homepage
@@ -1159,6 +1160,18 @@ class GoogleSitemapGenerator {
1159
  function IsTaxonomySupported() {
1160
  return (function_exists("get_taxonomy") && function_exists("get_terms"));
1161
  }
 
 
 
 
 
 
 
 
 
 
 
 
1162
 
1163
  /**
1164
  * Returns the list of custom taxonies. These are basically all taxonomies without categories and post tags
@@ -1170,6 +1183,20 @@ class GoogleSitemapGenerator {
1170
  $taxonomies = get_object_taxonomies('post');
1171
  return array_diff($taxonomies,array("category","post_tag"));
1172
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1173
 
1174
  /**
1175
  * Enables the Google Sitemap Generator and registers the WordPress hooks
@@ -1744,7 +1771,15 @@ class GoogleSitemapGenerator {
1744
  //WP < 2.1: posts are post_status = publish
1745
  //WP >= 2.1: post_type must be 'post', no date check required because future posts are post_status='future'
1746
  if($wpCompat) $where.="(post_status = 'publish' AND post_date_gmt <= '" . gmdate('Y-m-d H:i:59') . "')";
1747
- else $where.=" (post_status = 'publish' AND (post_type = 'post' OR post_type = '')) ";
 
 
 
 
 
 
 
 
1748
  }
1749
 
1750
  if($this->GetOption('in_pages')) {
@@ -2229,8 +2264,8 @@ class GoogleSitemapGenerator {
2229
  $sPingUrl="http://www.bing.com/webmaster/ping.aspx?siteMap=" . urlencode($pingUrl);
2230
  $status->StartMsnPing($sPingUrl);
2231
  $pingres=$this->RemoteOpen($sPingUrl);
2232
-
2233
- if($pingres==NULL || $pingres===false || strpos($pingres,"Thanks for submitting your sitemap")===false) {
2234
  trigger_error("Failed to ping Bing: " . htmlspecialchars(strip_tags($pingres)),E_USER_NOTICE);
2235
  $status->EndMsnPing(false,$this->_lastError);
2236
  } else {
@@ -2514,9 +2549,9 @@ class GoogleSitemapGenerator {
2514
  * @return int The time in seconds
2515
  */
2516
  function GetTimestampFromMySql($mysqlDateTime) {
2517
- list($date, $hours) = split(' ', $mysqlDateTime);
2518
- list($year,$month,$day) = split('-',$date);
2519
- list($hour,$min,$sec) = split(':',$hours);
2520
  return mktime(intval($hour), intval($min), intval($sec), intval($month), intval($day), intval($year));
2521
  }
2522
 
1
  <?php
2
  /*
3
 
4
+ $Id: sitemap-core.php 412231 2011-07-19 21:35:16Z arnee $
5
 
6
  */
7
 
746
  /**
747
  * @var Version of the generator in SVN
748
  */
749
+ var $_svnVersion = '$Id: sitemap-core.php 412231 2011-07-19 21:35:16Z arnee $';
750
 
751
  /**
752
  * @var array The unserialized array with the stored options
940
  $this->_options["sm_in_auth"]=false; //Include author pages
941
  $this->_options["sm_in_tags"]=false; //Include tag pages
942
  $this->_options["sm_in_tax"]=array(); //Include additional taxonomies
943
+ $this->_options["sm_in_customtypes"]=array(); //Include custom post types
944
  $this->_options["sm_in_lastmod"]=true; //Include the last modification date
945
 
946
  $this->_options["sm_cf_home"]="daily"; //Change frequency of the homepage
1160
  function IsTaxonomySupported() {
1161
  return (function_exists("get_taxonomy") && function_exists("get_terms"));
1162
  }
1163
+
1164
+ /**
1165
+ * Returns if this version of WordPress supports custom post types
1166
+ *
1167
+ * @since 3.2.5
1168
+ * @access private
1169
+ * @author Lee Willis
1170
+ * @return true if supported
1171
+ */
1172
+ function IsCustomPostTypesSupported() {
1173
+ return (function_exists("get_post_types") && function_exists("register_post_type"));
1174
+ }
1175
 
1176
  /**
1177
  * Returns the list of custom taxonies. These are basically all taxonomies without categories and post tags
1183
  $taxonomies = get_object_taxonomies('post');
1184
  return array_diff($taxonomies,array("category","post_tag"));
1185
  }
1186
+
1187
+ /**
1188
+ * Returns the list of custom post types. These are all custome post types except post, page and attachment
1189
+ *
1190
+ * @since 3.2.5
1191
+ * @author Lee Willis
1192
+ * @return array Array of custom post types as per get_post_types
1193
+ */
1194
+ function GetCustomPostTypes() {
1195
+ $post_types = get_post_types(array("public"=>1));
1196
+
1197
+ $post_types = array_diff($post_types,array("post","page","attachment"));
1198
+ return $post_types;
1199
+ }
1200
 
1201
  /**
1202
  * Enables the Google Sitemap Generator and registers the WordPress hooks
1771
  //WP < 2.1: posts are post_status = publish
1772
  //WP >= 2.1: post_type must be 'post', no date check required because future posts are post_status='future'
1773
  if($wpCompat) $where.="(post_status = 'publish' AND post_date_gmt <= '" . gmdate('Y-m-d H:i:59') . "')";
1774
+ else if ($this->IsCustomPostTypesSupported() && count($this->GetOption('in_customtypes'))>0) {
1775
+ $where.=" (post_status = 'publish' AND (post_type in ('','post'";
1776
+ foreach ($this->GetOption('in_customtypes') as $customType) {
1777
+ $where.= ",'$customType'";
1778
+ }
1779
+ $where .= "))) ";
1780
+ } else {
1781
+ $where.=" (post_status = 'publish' AND (post_type = 'post' OR post_type = '')) ";
1782
+ }
1783
  }
1784
 
1785
  if($this->GetOption('in_pages')) {
2264
  $sPingUrl="http://www.bing.com/webmaster/ping.aspx?siteMap=" . urlencode($pingUrl);
2265
  $status->StartMsnPing($sPingUrl);
2266
  $pingres=$this->RemoteOpen($sPingUrl);
2267
+ //Bing returns ip/country-based success messages, so there is no way to check the content. Rely on HTTP 500 only then...
2268
+ if($pingres==NULL || $pingres===false || strpos($pingres," ")===false) {
2269
  trigger_error("Failed to ping Bing: " . htmlspecialchars(strip_tags($pingres)),E_USER_NOTICE);
2270
  $status->EndMsnPing(false,$this->_lastError);
2271
  } else {
2549
  * @return int The time in seconds
2550
  */
2551
  function GetTimestampFromMySql($mysqlDateTime) {
2552
+ list($date, $hours) = explode(' ', $mysqlDateTime);
2553
+ list($year,$month,$day) = explode('-',$date);
2554
+ list($hour,$min,$sec) = explode(':',$hours);
2555
  return mktime(intval($hour), intval($min), intval($sec), intval($month), intval($day), intval($year));
2556
  }
2557
 
sitemap-ui.php CHANGED
@@ -1,7 +1,7 @@
1
  <?php
2
  /*
3
 
4
- $Id: sitemap-ui.php 241392 2010-05-15 09:51:44Z arnee $
5
 
6
  */
7
 
@@ -231,6 +231,18 @@ class GoogleSitemapGeneratorUI {
231
 
232
  $this->sg->_options[$k] = $enabledTaxonomies;
233
 
 
 
 
 
 
 
 
 
 
 
 
 
234
  } else $this->sg->_options[$k]=(bool) $_POST[$k];
235
  //Options of the category "Change frequencies" are string
236
  } else if(substr($k,0,6)=="sm_cf_") {
@@ -757,6 +769,10 @@ class GoogleSitemapGeneratorUI {
757
  echo "<li>" . str_replace("%s",wp_nonce_url($this->sg->GetBackLink() . "&sm_rebuild=true&noheader=true",'sitemap'),__('If you changed something on your server or blog, you should <a href="%s">rebuild the sitemap</a> manually.','sitemap')) . "</li>";
758
  }
759
  echo "<li>" . str_replace("%d",wp_nonce_url($this->sg->GetBackLink() . "&sm_rebuild=true&sm_do_debug=true",'sitemap'),__('If you encounter any problems with the build process you can use the <a href="%d">debug function</a> to get more information.','sitemap')) . "</li>";
 
 
 
 
760
  ?>
761
 
762
  </ul>
@@ -992,7 +1008,7 @@ class GoogleSitemapGeneratorUI {
992
 
993
  <!-- Includes -->
994
  <?php $this->HtmlPrintBoxHeader('sm_includes',__('Sitemap Content', 'sitemap')); ?>
995
-
996
  <ul>
997
  <li>
998
  <label for="sm_in_home">
@@ -1030,6 +1046,12 @@ class GoogleSitemapGeneratorUI {
1030
  <?php _e('Include archives', 'sitemap') ?>
1031
  </label>
1032
  </li>
 
 
 
 
 
 
1033
  <?php if($this->sg->IsTaxonomySupported()): ?>
1034
  <li>
1035
  <label for="sm_in_tags">
@@ -1037,11 +1059,20 @@ class GoogleSitemapGeneratorUI {
1037
  <?php _e('Include tag pages', 'sitemap') ?>
1038
  </label>
1039
  </li>
1040
- <?php
1041
- $taxonomies = $this->sg->GetCustomTaxonomies();
1042
-
1043
- $enabledTaxonomies = $this->sg->GetOption('in_tax');
 
 
 
 
 
 
 
 
1044
 
 
1045
  foreach ($taxonomies as $taxName) {
1046
 
1047
  $taxonomy = get_taxonomy($taxName);
@@ -1052,18 +1083,45 @@ class GoogleSitemapGeneratorUI {
1052
  <input type="checkbox" id="sm_in_tax[<?php echo $taxonomy->name; ?>]" name="sm_in_tax[<?php echo $taxonomy->name; ?>]" <?php echo $selected?"checked=\"checked\"":""; ?> />
1053
  <?php echo str_replace('%s',$taxonomy->label,__('Include taxonomy pages for %s', 'sitemap')); ?>
1054
  </label>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1055
  <li>
 
 
 
 
 
1056
  <?php
1057
  }
1058
- ?>
1059
- <?php endif; ?>
1060
- <li>
1061
- <label for="sm_in_auth">
1062
- <input type="checkbox" id="sm_in_auth" name="sm_in_auth" <?php echo ($this->sg->GetOption("in_auth")==true?"checked=\"checked\"":"") ?> />
1063
- <?php _e('Include author pages', 'sitemap') ?>
1064
- </label>
1065
- </li>
1066
- </ul>
1067
  <b><?php _e('Further options', 'sitemap') ?>:</b>
1068
  <ul>
1069
  <li>
1
  <?php
2
  /*
3
 
4
+ $Id: sitemap-ui.php 412231 2011-07-19 21:35:16Z arnee $
5
 
6
  */
7
 
231
 
232
  $this->sg->_options[$k] = $enabledTaxonomies;
233
 
234
+ } else if($k=='sm_in_customtypes') {
235
+
236
+ $enabledPostTypes = array();
237
+
238
+ foreach(array_keys((array) $_POST[$k]) AS $postTypeName) {
239
+ if(empty($postTypeName) || !post_type_exists($postTypeName)) continue;
240
+
241
+ $enabledPostTypes[] = $postTypeName;
242
+ }
243
+
244
+ $this->sg->_options[$k] = $enabledPostTypes;
245
+
246
  } else $this->sg->_options[$k]=(bool) $_POST[$k];
247
  //Options of the category "Change frequencies" are string
248
  } else if(substr($k,0,6)=="sm_cf_") {
769
  echo "<li>" . str_replace("%s",wp_nonce_url($this->sg->GetBackLink() . "&sm_rebuild=true&noheader=true",'sitemap'),__('If you changed something on your server or blog, you should <a href="%s">rebuild the sitemap</a> manually.','sitemap')) . "</li>";
770
  }
771
  echo "<li>" . str_replace("%d",wp_nonce_url($this->sg->GetBackLink() . "&sm_rebuild=true&sm_do_debug=true",'sitemap'),__('If you encounter any problems with the build process you can use the <a href="%d">debug function</a> to get more information.','sitemap')) . "</li>";
772
+
773
+ if(version_compare($wp_version,"2.9",">=") && version_compare(PHP_VERSION,"5.1",">=")) {
774
+ echo "<li class='sm_hint'>" . str_replace("%s",$this->sg->GetRedirectLink('sitemap-info-beta'), __('There is a new beta version of this plugin available which supports the new multi-site feature of WordPress as well as many other new functions! <a href="%s">More information and download</a>','sitemap')) . "</li>";
775
+ }
776
  ?>
777
 
778
  </ul>
1008
 
1009
  <!-- Includes -->
1010
  <?php $this->HtmlPrintBoxHeader('sm_includes',__('Sitemap Content', 'sitemap')); ?>
1011
+ <b><?php _e('WordPress standard content', 'sitemap') ?>:</b>
1012
  <ul>
1013
  <li>
1014
  <label for="sm_in_home">
1046
  <?php _e('Include archives', 'sitemap') ?>
1047
  </label>
1048
  </li>
1049
+ <li>
1050
+ <label for="sm_in_auth">
1051
+ <input type="checkbox" id="sm_in_auth" name="sm_in_auth" <?php echo ($this->sg->GetOption("in_auth")==true?"checked=\"checked\"":"") ?> />
1052
+ <?php _e('Include author pages', 'sitemap') ?>
1053
+ </label>
1054
+ </li>
1055
  <?php if($this->sg->IsTaxonomySupported()): ?>
1056
  <li>
1057
  <label for="sm_in_tags">
1059
  <?php _e('Include tag pages', 'sitemap') ?>
1060
  </label>
1061
  </li>
1062
+ <?php endif; ?>
1063
+ </ul>
1064
+
1065
+ <?php
1066
+
1067
+ if($this->sg->IsTaxonomySupported()) {
1068
+ $taxonomies = $this->sg->GetCustomTaxonomies();
1069
+
1070
+ $enabledTaxonomies = $this->sg->GetOption('in_tax');
1071
+
1072
+ if(count($taxonomies)>0) {
1073
+ ?><b><?php _e('Custom taxonomies', 'sitemap') ?>:</b><ul><?php
1074
 
1075
+
1076
  foreach ($taxonomies as $taxName) {
1077
 
1078
  $taxonomy = get_taxonomy($taxName);
1083
  <input type="checkbox" id="sm_in_tax[<?php echo $taxonomy->name; ?>]" name="sm_in_tax[<?php echo $taxonomy->name; ?>]" <?php echo $selected?"checked=\"checked\"":""; ?> />
1084
  <?php echo str_replace('%s',$taxonomy->label,__('Include taxonomy pages for %s', 'sitemap')); ?>
1085
  </label>
1086
+ </li>
1087
+ <?php
1088
+ }
1089
+
1090
+ ?></ul><?php
1091
+
1092
+ }
1093
+ }
1094
+
1095
+
1096
+ if($this->sg->IsCustomPostTypesSupported()) {
1097
+ $custom_post_types = $this->sg->GetCustomPostTypes();
1098
+
1099
+ $enabledPostTypes = $this->sg->GetOption('in_customtypes');
1100
+
1101
+ if(count($taxonomies)>0) {
1102
+ ?><b><?php _e('Custom post types', 'sitemap') ?>:</b><ul><?php
1103
+
1104
+ foreach ($custom_post_types as $post_type) {
1105
+ $post_type_object = get_post_type_object($post_type);
1106
+
1107
+ if (is_array($enabledPostTypes)) $selected = in_array($post_type_object->name, $enabledPostTypes);
1108
+
1109
+ ?>
1110
  <li>
1111
+ <label for="sm_in_customtypes[<?php echo $post_type_object->name; ?>]">
1112
+ <input type="checkbox" id="sm_in_customtypes[<?php echo $post_type_object->name; ?>]" name="sm_in_customtypes[<?php echo $post_type_object->name; ?>]" <?php echo $selected?"checked=\"checked\"":""; ?> />
1113
+ <?php echo str_replace('%s',$post_type_object->label,__('Include custom post type %s', 'sitemap')); ?>
1114
+ </label>
1115
+ </li>
1116
  <?php
1117
  }
1118
+
1119
+ ?></ul><?php
1120
+ }
1121
+ }
1122
+
1123
+ ?>
1124
+
 
 
1125
  <b><?php _e('Further options', 'sitemap') ?>:</b>
1126
  <ul>
1127
  <li>
sitemap.php CHANGED
@@ -1,7 +1,7 @@
1
  <?php
2
 
3
  /*
4
- $Id: sitemap.php 246883 2010-05-29 07:28:03Z arnee $
5
 
6
  Google XML Sitemaps Generator for WordPress
7
  ==============================================================================
@@ -25,7 +25,7 @@
25
  Plugin Name: Google XML Sitemaps
26
  Plugin URI: http://www.arnebrachhold.de/redir/sitemap-home/
27
  Description: This plugin will generate a special XML sitemap which will help search engines like Google, Yahoo, Bing and Ask.com to better index your blog.
28
- Version: 3.2.4
29
  Author: Arne Brachhold
30
  Author URI: http://www.arnebrachhold.de/
31
  Text Domain: sitemap
@@ -102,7 +102,7 @@ class GoogleSitemapGeneratorLoader {
102
  * Outputs the warning bar if multisite mode is activated
103
  */
104
  function AddMultisiteWarning() {
105
- echo "<div id='sm-multisite-warning' class='error fade'><p><strong>".__('Google XML Sitemaps is not multisite compatible.','sitemap')."</strong><br /> ".sprintf(__('Unfortunately the Google XML Sitemaps plugin was not tested with the multisite feature of WordPress 3.0 yet. The plugin will not be active until you disable the multisite mode. Otherwise go to <a href="%1$s">active plugins</a> and deactivate the Google XML Sitemaps plugin to make this message disappear.','sitemap'), "plugins.php?plugin_status=active")."</p></div>";
106
  }
107
 
108
  /**
1
  <?php
2
 
3
  /*
4
+ $Id: sitemap.php 412231 2011-07-19 21:35:16Z arnee $
5
 
6
  Google XML Sitemaps Generator for WordPress
7
  ==============================================================================
25
  Plugin Name: Google XML Sitemaps
26
  Plugin URI: http://www.arnebrachhold.de/redir/sitemap-home/
27
  Description: This plugin will generate a special XML sitemap which will help search engines like Google, Yahoo, Bing and Ask.com to better index your blog.
28
+ Version: 3.2.5
29
  Author: Arne Brachhold
30
  Author URI: http://www.arnebrachhold.de/
31
  Text Domain: sitemap
102
  * Outputs the warning bar if multisite mode is activated
103
  */
104
  function AddMultisiteWarning() {
105
+ echo "<div id='sm-multisite-warning' class='error fade'><p><strong>".__('This version of Google XML Sitemaps is not multisite compatible.','sitemap')."</strong><br /> ".sprintf(__('Unfortunately this version of the Google XML Sitemaps plugin was not tested with the multisite feature of WordPress 3.0 yet. <br />The plugin will not be active until you disable the multisite mode. <br />Or you can <a href="%1$s">try the new beta</a> which supports all the new WordPress features!','sitemap'), "http://www.arnebrachhold.de/redir/sitemap-info-beta/")."</p></div>";
106
  }
107
 
108
  /**