Google XML Sitemaps - Version 3.2.9

Version Description

Download this release

Release Info

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

Code changes from version 3.2.8 to 3.2.9

Files changed (5) hide show
  1. documentation.txt +44 -43
  2. readme.txt +2 -6
  3. sitemap-core.php +398 -381
  4. sitemap-ui.php +159 -152
  5. sitemap.php +46 -46
documentation.txt CHANGED
@@ -1,27 +1,27 @@
1
   Google XML Sitemaps Generator for WordPress
2
  ==============================================================================
3
-
4
  This generator will create a sitemaps.org compliant sitemap of your WordPress blog.
5
  Currently homepage, posts, static pages, categories, archives and author pages are supported.
6
-
7
  The priority of a post depends on its comments. You can choose the way the priority
8
  is calculated in the options screen.
9
-
10
  Feel free to visit my website under www.arnebrachhold.de or contact me at
11
  himself [at] arnebrachhold [dot] de
12
-
13
- Have fun!
14
  Arne
15
-
16
  Installation:
17
  ==============================================================================
18
  1. Upload the full directory into your wp-content/plugins directory
19
- 2. Make your blog directory writeable OR create two files called sitemap.xml
20
  and sitemap.xml.gz and make them writeable via CHMOD In most cases, your blog directory is already writeable.
21
  2. Activate it in the Plugin options
22
  3. Edit or publish a post or click on Rebuild Sitemap on the Sitemap Administration Interface
23
-
24
-
25
  Additional contributors:
26
  ==============================================================================
27
  Inspiration Michael Nguyen http://www.socialpatterns.com/
@@ -33,16 +33,16 @@
33
  Simpl.Chinese File june6 http://www.june6.cn/
34
  Swedish Lang. File Tobias Bergius http://tobiasbergius.se/
35
  Czech Lang. File Peter Kahoun http://kahi.cz
36
- Finnish Lang. File Olli Jarva http://kuvat.blog.olli.jarva.fi/
37
  Belorussian Lang. File Marcis Gasuns
38
  Bulgarian Lang. File Alexander Dichev http://dichev.com
39
-
40
- Thanks to all contributors and bug reporters! There were much more people involved
41
  in testing this plugin and reporting bugs, either by email or in the WordPress forums.
42
-
43
  Unfortunately I can't maintain a whole list here, but thanks again to everybody not listed here!
44
-
45
-
46
  Release History:
47
  ==============================================================================
48
  2005-06-05 1.0 First release
@@ -57,7 +57,7 @@
57
  Fixed bug which ignored different post/page priorities
58
  Should support now different wordpress/admin directories
59
  2005-06-07 2.11 Fixed bug with hardcoded table table names instead of the $wpd vars
60
- 2005-06-07 2.12 Changed SQL Statement of the categories to get it work on MySQL 3
61
  2005-06-08 2.2 Added language file support:
62
  - Japanese Language Files and code modifications by hiromasa (http://hiromasa.zone.ne.jp/)
63
  - German Language File by Arne Brachhold (http://www.arnebrachhold.de)
@@ -212,7 +212,7 @@
212
  2009-11-13 3.1.9 Fixed MySQL Error if author pages were included
213
  2009-11-23 3.2 Added function to show the actual results of a ping instead of only linking to the url
214
  Added new hook (sm_rebuild) for third party plugins to start building the sitemap
215
- Fixed bug which showed the wrong URL for the latest Google ping result
216
  Added some missing phpdoc documentation
217
  Removed hardcoded php name for sitemap file for admin urls
218
  Uses KSES for showing ping test results
@@ -240,12 +240,13 @@
240
  2012-08-08 3.2.8 Fixed wrong custom taxonomy URLs, thanks to ramon fincken of the wordpress.org forum!
241
  Removed ASK ping since they shut down their service.
242
  Exclude post_format taxonomy from custom taxonomy list
 
243
 
244
  Maybe Todo:
245
  ==============================================================================
246
  - Your wishes :)
247
-
248
-
249
  License:
250
  ==============================================================================
251
  Copyright 2005 - 2012 ARNE BRACHHOLD (email : himself - arnebrachhold - de)
@@ -254,7 +255,7 @@
254
  it under the terms of the GNU General Public License as published by
255
  the Free Software Foundation; either version 2 of the License, or
256
  (at your option) any later version.
257
-
258
  This program is distributed in the hope that it will be useful,
259
  but WITHOUT ANY WARRANTY; without even the implied warranty of
260
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
@@ -263,33 +264,33 @@
263
  You should have received a copy of the GNU General Public License
264
  along with this program; if not, write to the Free Software
265
  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
266
-
267
-
268
  Developer Documentation
269
  ==============================================================================
270
-
271
  Adding other pages to the sitemap via other plugins
272
-
273
  This plugin uses the action system of WordPress to allow other plugins
274
  to add urls to the sitemap. Simply add your function with add_action to
275
  the list and the plugin will execute yours every time the sitemap is build.
276
- Use the static method "GetInstance" to get the generator and AddUrl method
277
  to add your content.
278
-
279
  Sample:
280
-
281
  function your_pages() {
282
  $generatorObject = &GoogleSitemapGenerator::GetInstance(); //Please note the "&" sign for PHP4!
283
  if($generatorObject!=null) $generatorObject->AddUrl("http://blog.uri/tags/hello/",time(),"daily",0.5);
284
  }
285
  add_action("sm_buildmap","your_pages");
286
-
287
  Parameters:
288
  - The URL to the page
289
  - The last modified data, as a UNIX timestamp (optional)
290
  - The Change Frequency (daily, hourly, weekly and so on) (optional)
291
  - The priority 0.0 to 1.0 (optional)
292
-
293
 
294
  Rebuilding the sitemap on request
295
 
@@ -298,38 +299,38 @@
298
  All other methods, like calling the Build method directly are highly unrecommended and might
299
  not work anymore with the next version of the plugin. Using this hook, the sitemap plugin will
300
  take care of everything like loading the required classes and so on.
301
-
302
  Sample:
303
-
304
  do_action("sm_rebuild");
305
-
306
  The sitemap might not be rebuild immediately, since newer versions use a background WP-Cron
307
  job by default to prevent that the user has to wait and avoid multiple rebuilds within a very short time.
308
  In case the sitemap plugin is not installed, nothing will happen and no errors will be thrown.
309
-
310
  ===============================================
311
-
312
  Adding additional PriorityProviders
313
-
314
  This plugin uses several classes to calculate the post priority.
315
  You can register your own provider and choose it at the options screen.
316
-
317
  Your class has to extend the GoogleSitemapGeneratorPrioProviderBase class
318
  which has a default constructor and a method called GetPostPriority
319
  which you can override.
320
-
321
  Look at the GoogleSitemapGeneratorPrioByPopularityContestProvider class
322
  for an example.
323
-
324
  To register your provider to the sitemap generator, use the following filter:
325
-
326
  add_filter("sm_add_prio_provider","AddMyProvider");
327
-
328
  Your function could look like this:
329
-
330
  function AddMyProvider($providers) {
331
  array_push($providers,"MyProviderClass");
332
  return $providers;
333
  }
334
-
335
- Note that you have to return the modified list!
1
   Google XML Sitemaps Generator for WordPress
2
  ==============================================================================
3
+
4
  This generator will create a sitemaps.org compliant sitemap of your WordPress blog.
5
  Currently homepage, posts, static pages, categories, archives and author pages are supported.
6
+
7
  The priority of a post depends on its comments. You can choose the way the priority
8
  is calculated in the options screen.
9
+
10
  Feel free to visit my website under www.arnebrachhold.de or contact me at
11
  himself [at] arnebrachhold [dot] de
12
+
13
+ Have fun!
14
  Arne
15
+
16
  Installation:
17
  ==============================================================================
18
  1. Upload the full directory into your wp-content/plugins directory
19
+ 2. Make your blog directory writeable OR create two files called sitemap.xml
20
  and sitemap.xml.gz and make them writeable via CHMOD In most cases, your blog directory is already writeable.
21
  2. Activate it in the Plugin options
22
  3. Edit or publish a post or click on Rebuild Sitemap on the Sitemap Administration Interface
23
+
24
+
25
  Additional contributors:
26
  ==============================================================================
27
  Inspiration Michael Nguyen http://www.socialpatterns.com/
33
  Simpl.Chinese File june6 http://www.june6.cn/
34
  Swedish Lang. File Tobias Bergius http://tobiasbergius.se/
35
  Czech Lang. File Peter Kahoun http://kahi.cz
36
+ Finnish Lang. File Olli Jarva http://kuvat.blog.olli.jarva.fi/
37
  Belorussian Lang. File Marcis Gasuns
38
  Bulgarian Lang. File Alexander Dichev http://dichev.com
39
+
40
+ Thanks to all contributors and bug reporters! There were much more people involved
41
  in testing this plugin and reporting bugs, either by email or in the WordPress forums.
42
+
43
  Unfortunately I can't maintain a whole list here, but thanks again to everybody not listed here!
44
+
45
+
46
  Release History:
47
  ==============================================================================
48
  2005-06-05 1.0 First release
57
  Fixed bug which ignored different post/page priorities
58
  Should support now different wordpress/admin directories
59
  2005-06-07 2.11 Fixed bug with hardcoded table table names instead of the $wpd vars
60
+ 2005-06-07 2.12 Changed SQL Statement of the categories to get it work on MySQL 3
61
  2005-06-08 2.2 Added language file support:
62
  - Japanese Language Files and code modifications by hiromasa (http://hiromasa.zone.ne.jp/)
63
  - German Language File by Arne Brachhold (http://www.arnebrachhold.de)
212
  2009-11-13 3.1.9 Fixed MySQL Error if author pages were included
213
  2009-11-23 3.2 Added function to show the actual results of a ping instead of only linking to the url
214
  Added new hook (sm_rebuild) for third party plugins to start building the sitemap
215
+ Fixed bug which showed the wrong URL for the latest Google ping result
216
  Added some missing phpdoc documentation
217
  Removed hardcoded php name for sitemap file for admin urls
218
  Uses KSES for showing ping test results
240
  2012-08-08 3.2.8 Fixed wrong custom taxonomy URLs, thanks to ramon fincken of the wordpress.org forum!
241
  Removed ASK ping since they shut down their service.
242
  Exclude post_format taxonomy from custom taxonomy list
243
+ 2013-01-11 3.2.9 Fixed security issue with change frequencies and filename of sitemap file. Exploit was only possible for admin accounts.
244
 
245
  Maybe Todo:
246
  ==============================================================================
247
  - Your wishes :)
248
+
249
+
250
  License:
251
  ==============================================================================
252
  Copyright 2005 - 2012 ARNE BRACHHOLD (email : himself - arnebrachhold - de)
255
  it under the terms of the GNU General Public License as published by
256
  the Free Software Foundation; either version 2 of the License, or
257
  (at your option) any later version.
258
+
259
  This program is distributed in the hope that it will be useful,
260
  but WITHOUT ANY WARRANTY; without even the implied warranty of
261
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
264
  You should have received a copy of the GNU General Public License
265
  along with this program; if not, write to the Free Software
266
  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
267
+
268
+
269
  Developer Documentation
270
  ==============================================================================
271
+
272
  Adding other pages to the sitemap via other plugins
273
+
274
  This plugin uses the action system of WordPress to allow other plugins
275
  to add urls to the sitemap. Simply add your function with add_action to
276
  the list and the plugin will execute yours every time the sitemap is build.
277
+ Use the static method "GetInstance" to get the generator and AddUrl method
278
  to add your content.
279
+
280
  Sample:
281
+
282
  function your_pages() {
283
  $generatorObject = &GoogleSitemapGenerator::GetInstance(); //Please note the "&" sign for PHP4!
284
  if($generatorObject!=null) $generatorObject->AddUrl("http://blog.uri/tags/hello/",time(),"daily",0.5);
285
  }
286
  add_action("sm_buildmap","your_pages");
287
+
288
  Parameters:
289
  - The URL to the page
290
  - The last modified data, as a UNIX timestamp (optional)
291
  - The Change Frequency (daily, hourly, weekly and so on) (optional)
292
  - The priority 0.0 to 1.0 (optional)
293
+
294
 
295
  Rebuilding the sitemap on request
296
 
299
  All other methods, like calling the Build method directly are highly unrecommended and might
300
  not work anymore with the next version of the plugin. Using this hook, the sitemap plugin will
301
  take care of everything like loading the required classes and so on.
302
+
303
  Sample:
304
+
305
  do_action("sm_rebuild");
306
+
307
  The sitemap might not be rebuild immediately, since newer versions use a background WP-Cron
308
  job by default to prevent that the user has to wait and avoid multiple rebuilds within a very short time.
309
  In case the sitemap plugin is not installed, nothing will happen and no errors will be thrown.
310
+
311
  ===============================================
312
+
313
  Adding additional PriorityProviders
314
+
315
  This plugin uses several classes to calculate the post priority.
316
  You can register your own provider and choose it at the options screen.
317
+
318
  Your class has to extend the GoogleSitemapGeneratorPrioProviderBase class
319
  which has a default constructor and a method called GetPostPriority
320
  which you can override.
321
+
322
  Look at the GoogleSitemapGeneratorPrioByPopularityContestProvider class
323
  for an example.
324
+
325
  To register your provider to the sitemap generator, use the following filter:
326
+
327
  add_filter("sm_add_prio_provider","AddMyProvider");
328
+
329
  Your function could look like this:
330
+
331
  function AddMyProvider($providers) {
332
  array_push($providers,"MyProviderClass");
333
  return $providers;
334
  }
335
+
336
+ Note that you have to return the modified list!
readme.txt CHANGED
@@ -3,8 +3,8 @@ Contributors: arnee
3
  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.5
7
- Stable tag: 3.2.7
8
 
9
  This plugin will generate a special XML sitemap which will help search engines to better index your blog.
10
 
@@ -12,10 +12,6 @@ This plugin will generate a special XML sitemap which will help search engines t
12
 
13
  This plugin will generate a special XML sitemap which will help search engines like Google, Bing, Yahoo and Ask.com to better index your blog. With such a sitemap, it's much easier for the crawlers to see the complete structure of your site and retrieve it more efficiently. The plugin supports all kinds of WordPress generated pages as well as custom URLs. Additionally it notifies all major search engines every time you create a post about the new content.
14
 
15
-
16
- > #### Try out the brand new Beta version!
17
- > Download the new beta version and try the new features like dynamic sitemap generation, full support for network activation, reduced memory usage and much more! <a href="http://www.arnebrachhold.de/redir/sitemap-dl-beta/">Download the beta version here!</a>
18
-
19
  Related Links:
20
 
21
  * <a href="http://www.arnebrachhold.de/projects/wordpress-plugins/google-xml-sitemaps-generator/" title="Google XML Sitemaps Plugin for WordPress">Plugin Homepage</a>
3
  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.6
7
+ Stable tag: 3.2.9
8
 
9
  This plugin will generate a special XML sitemap which will help search engines to better index your blog.
10
 
12
 
13
  This plugin will generate a special XML sitemap which will help search engines like Google, Bing, Yahoo and Ask.com to better index your blog. With such a sitemap, it's much easier for the crawlers to see the complete structure of your site and retrieve it more efficiently. The plugin supports all kinds of WordPress generated pages as well as custom URLs. Additionally it notifies all major search engines every time you create a post about the new content.
14
 
 
 
 
 
15
  Related Links:
16
 
17
  * <a href="http://www.arnebrachhold.de/projects/wordpress-plugins/google-xml-sitemaps-generator/" title="Google XML Sitemaps Plugin for WordPress">Plugin Homepage</a>
sitemap-core.php CHANGED
@@ -1,7 +1,7 @@
1
  <?php
2
  /*
3
-
4
- $Id: sitemap-core.php 583237 2012-08-08 21:06:12Z arnee $
5
 
6
  */
7
 
@@ -19,21 +19,21 @@ class GoogleSitemapGeneratorStatus {
19
 
20
  function GoogleSitemapGeneratorStatus() {
21
  $this->_startTime = $this->GetMicrotimeFloat();
22
-
23
  $exists = get_option("sm_status");
24
-
25
  if($exists === false) add_option("sm_status","",null,"no");
26
-
27
  $this->Save();
28
  }
29
-
30
  function Save() {
31
  update_option("sm_status",$this);
32
  }
33
-
34
  /**
35
  * Returns the last saved status object or null
36
- *
37
  * @return GoogleSitemapGeneratorStatus
38
  */
39
  function &Load() {
@@ -41,53 +41,53 @@ class GoogleSitemapGeneratorStatus {
41
  if(is_a($status,"GoogleSitemapGeneratorStatus")) return $status;
42
  else return null;
43
  }
44
-
45
  /**
46
  * @var float $_startTime The start time of the building process
47
  * @access private
48
  */
49
  var $_startTime = 0;
50
-
51
  /**
52
  * @var float $_endTime The end time of the building process
53
  * @access private
54
  */
55
  var $_endTime = 0;
56
-
57
  /**
58
  * @var bool $$_hasChanged Indicates if the sitemap content has changed
59
  * @access private
60
  */
61
  var $_hasChanged = true;
62
-
63
  /**
64
  * @var int $_memoryUsage The amount of memory used in bytes
65
  * @access private
66
  */
67
  var $_memoryUsage = 0;
68
-
69
  /**
70
  * @var int $_lastPost The number of posts processed. This value is updated every 50 posts.
71
  * @access private
72
  */
73
  var $_lastPost = 0;
74
-
75
  /**
76
  * @var int $_lastTime The time when the last step-update occured. This value is updated every 50 posts.
77
  * @access private
78
  */
79
  var $_lastTime = 0;
80
-
81
  function End($hasChanged = true) {
82
  $this->_endTime = $this->GetMicrotimeFloat();
83
-
84
  $this->SetMemoryUsage();
85
-
86
  $this->_hasChanged = $hasChanged;
87
-
88
  $this->Save();
89
  }
90
-
91
  function SetMemoryUsage() {
92
  if(function_exists("memory_get_peak_usage")) {
93
  $this->_memoryUsage = memory_get_peak_usage(true);
@@ -95,130 +95,130 @@ class GoogleSitemapGeneratorStatus {
95
  $this->_memoryUsage = memory_get_usage(true);
96
  }
97
  }
98
-
99
  function GetMemoryUsage() {
100
  return round($this->_memoryUsage / 1024 / 1024,2);
101
  }
102
-
103
  function SaveStep($postCount) {
104
  $this->SetMemoryUsage();
105
  $this->_lastPost = $postCount;
106
  $this->_lastTime = $this->GetMicrotimeFloat();
107
-
108
  $this->Save();
109
  }
110
-
111
  function GetTime() {
112
  return round($this->_endTime - $this->_startTime,2);
113
  }
114
-
115
  function GetStartTime() {
116
  return round($this->_startTime, 2);
117
  }
118
-
119
  function GetLastTime() {
120
  return round($this->_lastTime - $this->_startTime,2);
121
  }
122
-
123
  function GetLastPost() {
124
  return $this->_lastPost;
125
  }
126
-
127
  var $_usedXml = false;
128
  var $_xmlSuccess = false;
129
  var $_xmlPath = '';
130
  var $_xmlUrl = '';
131
-
132
  function StartXml($path,$url) {
133
  $this->_usedXml = true;
134
  $this->_xmlPath = $path;
135
  $this->_xmlUrl = $url;
136
-
137
  $this->Save();
138
  }
139
-
140
  function EndXml($success) {
141
  $this->_xmlSuccess = $success;
142
-
143
  $this->Save();
144
  }
145
-
146
-
147
  var $_usedZip = false;
148
  var $_zipSuccess = false;
149
  var $_zipPath = '';
150
  var $_zipUrl = '';
151
-
152
  function StartZip($path,$url) {
153
  $this->_usedZip = true;
154
  $this->_zipPath = $path;
155
  $this->_zipUrl = $url;
156
-
157
  $this->Save();
158
  }
159
-
160
  function EndZip($success) {
161
  $this->_zipSuccess = $success;
162
-
163
  $this->Save();
164
  }
165
-
166
  var $_usedGoogle = false;
167
  var $_googleUrl = '';
168
  var $_gooogleSuccess = false;
169
  var $_googleStartTime = 0;
170
  var $_googleEndTime = 0;
171
-
172
  function StartGooglePing($url) {
173
  $this->_googleUrl = $url;
174
  $this->_usedGoogle = true;
175
  $this->_googleStartTime = $this->GetMicrotimeFloat();
176
-
177
  $this->Save();
178
  }
179
-
180
  function EndGooglePing($success) {
181
  $this->_googleEndTime = $this->GetMicrotimeFloat();
182
  $this->_gooogleSuccess = $success;
183
-
184
  $this->Save();
185
  }
186
-
187
  function GetGoogleTime() {
188
  return round($this->_googleEndTime - $this->_googleStartTime,2);
189
  }
190
-
191
  var $_usedMsn = false;
192
  var $_msnUrl = '';
193
  var $_msnSuccess = false;
194
  var $_msnStartTime = 0;
195
  var $_msnEndTime = 0;
196
-
197
  function StartMsnPing($url) {
198
  $this->_usedMsn = true;
199
  $this->_msnUrl = $url;
200
  $this->_msnStartTime = $this->GetMicrotimeFloat();
201
-
202
  $this->Save();
203
  }
204
-
205
  function EndMsnPing($success) {
206
  $this->_msnEndTime = $this->GetMicrotimeFloat();
207
  $this->_msnSuccess = $success;
208
-
209
  $this->Save();
210
  }
211
-
212
  function GetMsnTime() {
213
  return round($this->_msnEndTime - $this->_msnStartTime,2);
214
  }
215
-
216
  function GetMicrotimeFloat() {
217
  list($usec, $sec) = explode(" ", microtime());
218
  return ((float)$usec + (float)$sec);
219
  }
220
  }
221
-
222
  /**
223
  * Represents an item in the page list
224
  * @author Arne Brachhold
@@ -226,31 +226,31 @@ class GoogleSitemapGeneratorStatus {
226
  * @since 3.0
227
  */
228
  class GoogleSitemapGeneratorPage {
229
-
230
  /**
231
  * @var string $_url Sets the URL or the relative path to the blog dir of the page
232
  * @access private
233
  */
234
  var $_url;
235
-
236
  /**
237
  * @var float $_priority Sets the priority of this page
238
  * @access private
239
  */
240
  var $_priority;
241
-
242
  /**
243
  * @var string $_changeFreq Sets the chanfe frequency of the page. I want Enums!
244
  * @access private
245
  */
246
  var $_changeFreq;
247
-
248
  /**
249
  * @var int $_lastMod Sets the lastMod date as a UNIX timestamp.
250
  * @access private
251
  */
252
  var $_lastMod;
253
-
254
  /**
255
  * Initialize a new page object
256
  *
@@ -269,7 +269,7 @@ class GoogleSitemapGeneratorPage {
269
  $this->SetChangeFreq($changeFreq);
270
  $this->SetLastMod($lastMod);
271
  }
272
-
273
  /**
274
  * Returns the URL of the page
275
  *
@@ -278,7 +278,7 @@ class GoogleSitemapGeneratorPage {
278
  function GetUrl() {
279
  return $this->_url;
280
  }
281
-
282
  /**
283
  * Sets the URL of the page
284
  *
@@ -287,7 +287,7 @@ class GoogleSitemapGeneratorPage {
287
  function SetUrl($url) {
288
  $this->_url=(string) $url;
289
  }
290
-
291
  /**
292
  * Returns the priority of this page
293
  *
@@ -296,7 +296,7 @@ class GoogleSitemapGeneratorPage {
296
  function GetPriority() {
297
  return $this->_priority;
298
  }
299
-
300
  /**
301
  * Sets the priority of the page
302
  *
@@ -305,7 +305,7 @@ class GoogleSitemapGeneratorPage {
305
  function SetProprity($priority) {
306
  $this->_priority=floatval($priority);
307
  }
308
-
309
  /**
310
  * Returns the change frequency of the page
311
  *
@@ -314,7 +314,7 @@ class GoogleSitemapGeneratorPage {
314
  function GetChangeFreq() {
315
  return $this->_changeFreq;
316
  }
317
-
318
  /**
319
  * Sets the change frequency of the page
320
  *
@@ -323,7 +323,7 @@ class GoogleSitemapGeneratorPage {
323
  function SetChangeFreq($changeFreq) {
324
  $this->_changeFreq=(string) $changeFreq;
325
  }
326
-
327
  /**
328
  * Returns the last mod of the page
329
  *
@@ -332,7 +332,7 @@ class GoogleSitemapGeneratorPage {
332
  function GetLastMod() {
333
  return $this->_lastMod;
334
  }
335
-
336
  /**
337
  * Sets the last mod of the page
338
  *
@@ -341,41 +341,41 @@ class GoogleSitemapGeneratorPage {
341
  function SetLastMod($lastMod) {
342
  $this->_lastMod=intval($lastMod);
343
  }
344
-
345
  function Render() {
346
-
347
  if($this->_url == "/" || empty($this->_url)) return '';
348
-
349
  $r="";
350
  $r.= "\t<url>\n";
351
  $r.= "\t\t<loc>" . $this->EscapeXML($this->_url) . "</loc>\n";
352
  if($this->_lastMod>0) $r.= "\t\t<lastmod>" . date('Y-m-d\TH:i:s+00:00',$this->_lastMod) . "</lastmod>\n";
353
- if(!empty($this->_changeFreq)) $r.= "\t\t<changefreq>" . $this->_changeFreq . "</changefreq>\n";
354
  if($this->_priority!==false && $this->_priority!=="") $r.= "\t\t<priority>" . number_format($this->_priority,1) . "</priority>\n";
355
  $r.= "\t</url>\n";
356
  return $r;
357
  }
358
-
359
  function EscapeXML($string) {
360
  return str_replace ( array ( '&', '"', "'", '<', '>'), array ( '&amp;' , '&quot;', '&apos;' , '&lt;' , '&gt;'), $string);
361
  }
362
  }
363
 
364
  class GoogleSitemapGeneratorXmlEntry {
365
-
366
  var $_xml;
367
-
368
  function GoogleSitemapGeneratorXmlEntry($xml) {
369
  $this->_xml = $xml;
370
  }
371
-
372
  function Render() {
373
  return $this->_xml;
374
  }
375
  }
376
 
377
  class GoogleSitemapGeneratorDebugEntry extends GoogleSitemapGeneratorXmlEntry {
378
-
379
  function Render() {
380
  return "<!-- " . $this->_xml . " -->\n";
381
  }
@@ -388,19 +388,19 @@ class GoogleSitemapGeneratorDebugEntry extends GoogleSitemapGeneratorXmlEntry {
388
  * @since 3.0
389
  */
390
  class GoogleSitemapGeneratorPrioProviderBase {
391
-
392
  /**
393
  * @var int $_totalComments The total number of comments of all posts
394
  * @access protected
395
  */
396
  var $_totalComments=0;
397
-
398
  /**
399
  * @var int $_totalComments The total number of posts
400
  * @access protected
401
  */
402
  var $_totalPosts=0;
403
-
404
  /**
405
  * Returns the (translated) name of this priority provider
406
  *
@@ -412,7 +412,7 @@ class GoogleSitemapGeneratorPrioProviderBase {
412
  function GetName() {
413
  return "";
414
  }
415
-
416
  /**
417
  * Returns the (translated) description of this priority provider
418
  *
@@ -424,7 +424,7 @@ class GoogleSitemapGeneratorPrioProviderBase {
424
  function GetDescription() {
425
  return "";
426
  }
427
-
428
  /**
429
  * Initializes a new priority provider
430
  *
@@ -437,9 +437,9 @@ class GoogleSitemapGeneratorPrioProviderBase {
437
  function GoogleSitemapGeneratorPrioProviderBase($totalComments,$totalPosts) {
438
  $this->_totalComments=$totalComments;
439
  $this->_totalPosts=$totalPosts;
440
-
441
  }
442
-
443
  /**
444
  * Returns the priority for a specified post
445
  *
@@ -462,7 +462,7 @@ class GoogleSitemapGeneratorPrioProviderBase {
462
  * @since 3.0
463
  */
464
  class GoogleSitemapGeneratorPrioByCountProvider extends GoogleSitemapGeneratorPrioProviderBase {
465
-
466
  /**
467
  * Returns the (translated) name of this priority provider
468
  *
@@ -474,7 +474,7 @@ class GoogleSitemapGeneratorPrioByCountProvider extends GoogleSitemapGeneratorPr
474
  function GetName() {
475
  return __("Comment Count",'sitemap');
476
  }
477
-
478
  /**
479
  * Returns the (translated) description of this priority provider
480
  *
@@ -486,7 +486,7 @@ class GoogleSitemapGeneratorPrioByCountProvider extends GoogleSitemapGeneratorPr
486
  function GetDescription() {
487
  return __("Uses the number of comments of the post to calculate the priority",'sitemap');
488
  }
489
-
490
  /**
491
  * Initializes a new priority provider which calculates the post priority based on the number of comments
492
  *
@@ -499,7 +499,7 @@ class GoogleSitemapGeneratorPrioByCountProvider extends GoogleSitemapGeneratorPr
499
  function GoogleSitemapGeneratorPrioByCountProvider($totalComments,$totalPosts) {
500
  parent::GoogleSitemapGeneratorPrioProviderBase($totalComments,$totalPosts);
501
  }
502
-
503
  /**
504
  * Returns the priority for a specified post
505
  *
@@ -528,13 +528,13 @@ class GoogleSitemapGeneratorPrioByCountProvider extends GoogleSitemapGeneratorPr
528
  * @since 3.0
529
  */
530
  class GoogleSitemapGeneratorPrioByAverageProvider extends GoogleSitemapGeneratorPrioProviderBase {
531
-
532
  /**
533
  * @var int $_average The average number of comments per post
534
  * @access protected
535
  */
536
  var $_average=0.0;
537
-
538
  /**
539
  * Returns the (translated) name of this priority provider
540
  *
@@ -546,7 +546,7 @@ class GoogleSitemapGeneratorPrioByAverageProvider extends GoogleSitemapGenerator
546
  function GetName() {
547
  return __("Comment Average",'sitemap');
548
  }
549
-
550
  /**
551
  * Returns the (translated) description of this priority provider
552
  *
@@ -558,7 +558,7 @@ class GoogleSitemapGeneratorPrioByAverageProvider extends GoogleSitemapGenerator
558
  function GetDescription() {
559
  return __("Uses the average comment count to calculate the priority",'sitemap');
560
  }
561
-
562
  /**
563
  * Initializes a new priority provider which calculates the post priority based on the average number of comments
564
  *
@@ -570,12 +570,12 @@ class GoogleSitemapGeneratorPrioByAverageProvider extends GoogleSitemapGenerator
570
  */
571
  function GoogleSitemapGeneratorPrioByAverageProvider($totalComments,$totalPosts) {
572
  parent::GoogleSitemapGeneratorPrioProviderBase($totalComments,$totalPosts);
573
-
574
  if($this->_totalComments>0 && $this->_totalPosts>0) {
575
  $this->_average= (double) $this->_totalComments / $this->_totalPosts;
576
  }
577
  }
578
-
579
  /**
580
  * Returns the priority for a specified post
581
  *
@@ -597,7 +597,7 @@ class GoogleSitemapGeneratorPrioByAverageProvider extends GoogleSitemapGenerator
597
  if($prio>1) $prio = 1;
598
  else if($prio<0) $prio = 0;
599
  }
600
-
601
  return round($prio,1);
602
  }
603
  }
@@ -609,7 +609,7 @@ class GoogleSitemapGeneratorPrioByAverageProvider extends GoogleSitemapGenerator
609
  * @since 3.0
610
  */
611
  class GoogleSitemapGeneratorPrioByPopularityContestProvider extends GoogleSitemapGeneratorPrioProviderBase {
612
-
613
  /**
614
  * Returns the (translated) name of this priority provider
615
  *
@@ -621,7 +621,7 @@ class GoogleSitemapGeneratorPrioByPopularityContestProvider extends GoogleSitema
621
  function GetName() {
622
  return __("Popularity Contest",'sitemap');
623
  }
624
-
625
  /**
626
  * Returns the (translated) description of this priority provider
627
  *
@@ -633,7 +633,7 @@ class GoogleSitemapGeneratorPrioByPopularityContestProvider extends GoogleSitema
633
  function GetDescription() {
634
  return str_replace("%4","index.php?page=popularity-contest.php",str_replace("%3","options-general.php?page=popularity-contest.php",str_replace("%2","http://www.alexking.org/",str_replace("%1","http://www.alexking.org/index.php?content=software/wordpress/content.php",__("Uses the activated <a href=\"%1\">Popularity Contest Plugin</a> from <a href=\"%2\">Alex King</a>. See <a href=\"%3\">Settings</a> and <a href=\"%4\">Most Popular Posts</a>",'sitemap')))));
635
  }
636
-
637
  /**
638
  * Initializes a new priority provider which calculates the post priority based on the popularity by the PopularityContest Plugin
639
  *
@@ -646,7 +646,7 @@ class GoogleSitemapGeneratorPrioByPopularityContestProvider extends GoogleSitema
646
  function GoogleSitemapGeneratorPrioByPopularityContestProvider($totalComments,$totalPosts) {
647
  parent::GoogleSitemapGeneratorPrioProviderBase($totalComments,$totalPosts);
648
  }
649
-
650
  /**
651
  * Returns the priority for a specified post
652
  *
@@ -660,7 +660,7 @@ class GoogleSitemapGeneratorPrioByPopularityContestProvider extends GoogleSitema
660
  function GetPostPriority($postID,$commentCount) {
661
  //$akpc is the global instance of the Popularity Contest Plugin
662
  global $akpc,$posts;
663
-
664
  $res=0;
665
  //Better check if its there
666
  if(!empty($akpc) && is_object($akpc)) {
@@ -696,13 +696,13 @@ class GoogleSitemapGenerator {
696
  /**
697
  * @var Version of the generator in SVN
698
  */
699
- var $_svnVersion = '$Id: sitemap-core.php 583237 2012-08-08 21:06:12Z arnee $';
700
-
701
  /**
702
  * @var array The unserialized array with the stored options
703
  */
704
  var $_options = array();
705
-
706
  /**
707
  * @var array The saved additional pages
708
  */
@@ -712,32 +712,32 @@ class GoogleSitemapGenerator {
712
  * @var array The values and names of the change frequencies
713
  */
714
  var $_freqNames = array();
715
-
716
  /**
717
  * @var array A list of class names which my be called for priority calculation
718
  */
719
  var $_prioProviders = array();
720
-
721
  /**
722
  * @var bool True if init complete (options loaded etc)
723
  */
724
  var $_initiated = false;
725
-
726
  /**
727
  * @var string Holds the last error if one occurs when writing the files
728
  */
729
  var $_lastError=null;
730
-
731
  /**
732
  * @var int The last handled post ID
733
  */
734
  var $_lastPostID = 0;
735
-
736
  /**
737
  * @var bool Defines if the sitemap building process is active at the moment
738
  */
739
  var $_isActive = false;
740
-
741
  /**
742
  * @var bool Defines if the sitemap building process has been scheduled via Wp cron
743
  */
@@ -747,20 +747,20 @@ class GoogleSitemapGenerator {
747
  * @var object The file handle which is used to write the sitemap file
748
  */
749
  var $_fileHandle = null;
750
-
751
  /**
752
  * @var object The file handle which is used to write the zipped sitemap file
753
  */
754
  var $_fileZipHandle = null;
755
-
756
  /**
757
  * Holds the user interface object
758
- *
759
  * @since 3.1.1
760
  * @var GoogleSitemapGeneratorUI
761
  */
762
  var $_ui = null;
763
-
764
  /**
765
  * Returns the path to the blog directory
766
  *
@@ -770,7 +770,7 @@ class GoogleSitemapGenerator {
770
  * @return string The full path to the blog directory
771
  */
772
  function GetHomePath() {
773
-
774
  $res="";
775
  //Check if we are in the admin area -> get_home_path() is avaiable
776
  if(function_exists("get_home_path")) {
@@ -794,7 +794,7 @@ class GoogleSitemapGenerator {
794
  }
795
  return $res;
796
  }
797
-
798
  /**
799
  * Returns the path to the directory where the plugin file is located
800
  * @since 3.0b5
@@ -806,7 +806,7 @@ class GoogleSitemapGenerator {
806
  $path = dirname(__FILE__);
807
  return trailingslashit(str_replace("\\","/",$path));
808
  }
809
-
810
  /**
811
  * Returns the URL to the directory where the plugin file is located
812
  * @since 3.0b5
@@ -815,17 +815,17 @@ class GoogleSitemapGenerator {
815
  * @return string The URL to the plugin directory
816
  */
817
  function GetPluginUrl() {
818
-
819
  //Try to use WP API if possible, introduced in WP 2.6
820
  if (function_exists('plugins_url')) return trailingslashit(plugins_url(basename(dirname(__FILE__))));
821
-
822
  //Try to find manually... can't work if wp-content was renamed or is redirected
823
  $path = dirname(__FILE__);
824
  $path = str_replace("\\","/",$path);
825
  $path = trailingslashit(get_bloginfo('wpurl')) . trailingslashit(substr($path,strpos($path,"wp-content/")));
826
  return $path;
827
  }
828
-
829
  /**
830
  * Returns the URL to default XSLT style if it exists
831
  * @since 3.0b5
@@ -843,7 +843,7 @@ class GoogleSitemapGenerator {
843
  }
844
  return '';
845
  }
846
-
847
  /**
848
  * Sets up the default configuration
849
  *
@@ -852,7 +852,7 @@ class GoogleSitemapGenerator {
852
  * @author Arne Brachhold
853
  */
854
  function InitOptions() {
855
-
856
  $this->_options=array();
857
  $this->_options["sm_b_prio_provider"]="GoogleSitemapGeneratorPrioByCountProvider"; //Provider for automatic priority calculation
858
  $this->_options["sm_b_filename"]="sitemap.xml"; //Name of the Sitemap file
@@ -907,7 +907,7 @@ class GoogleSitemapGenerator {
907
  $this->_options["sm_pr_arch"]=0.3; //Priority of archives
908
  $this->_options["sm_pr_auth"]=0.3; //Priority of author pages
909
  $this->_options["sm_pr_tags"]=0.3; //Priority of tags
910
-
911
  $this->_options["sm_i_donated"]=false; //Did you donate? Thank you! :)
912
  $this->_options["sm_i_hide_donated"]=false; //And hide the thank you..
913
  $this->_options["sm_i_install_date"]=time(); //The installation date
@@ -915,7 +915,7 @@ class GoogleSitemapGenerator {
915
  $this->_options["sm_i_hide_works"]=false; //Hide the "works?" message which appears after 15 days
916
  $this->_options["sm_i_hide_donors"]=false; //Hide the list of donations
917
  }
918
-
919
  /**
920
  * Loads the configuration from the database
921
  *
@@ -924,9 +924,9 @@ class GoogleSitemapGenerator {
924
  * @author Arne Brachhold
925
  */
926
  function LoadOptions() {
927
-
928
  $this->InitOptions();
929
-
930
  //First init default values, then overwrite it with stored values so we can add default
931
  //values with an update which get stored by the next edit.
932
  $storedoptions=get_option("sm_options");
@@ -936,7 +936,7 @@ class GoogleSitemapGenerator {
936
  }
937
  } else update_option("sm_options",$this->_options); //First time use, store default values
938
  }
939
-
940
  /**
941
  * Initializes a new Google Sitemap Generator
942
  *
@@ -947,10 +947,10 @@ class GoogleSitemapGenerator {
947
  function GoogleSitemapGenerator() {
948
 
949
 
950
-
951
-
952
  }
953
-
954
  /**
955
  * Returns the version of the generator
956
  *
@@ -962,7 +962,7 @@ class GoogleSitemapGenerator {
962
  function GetVersion() {
963
  return GoogleSitemapGeneratorLoader::GetVersion();
964
  }
965
-
966
  /**
967
  * Returns all parent classes of a class
968
  *
@@ -982,7 +982,7 @@ class GoogleSitemapGenerator {
982
  }
983
  return $parents;
984
  }
985
-
986
  /**
987
  * Returns if a class is a subclass of another class
988
  *
@@ -995,17 +995,17 @@ class GoogleSitemapGenerator {
995
  * @return bool true if the given class is a subclass of the other one
996
  */
997
  function IsSubclassOf($className, $parentName) {
998
-
999
  $className = strtolower($className);
1000
  $parentName = strtolower($parentName);
1001
-
1002
  if(empty($className) || empty($parentName) || !class_exists($className) || !class_exists($parentName)) return false;
1003
-
1004
  $parents=$this->GetParentClasses($className);
1005
-
1006
  return in_array($parentName,$parents);
1007
  }
1008
-
1009
  /**
1010
  * Loads up the configuration and validates the prioity providers
1011
  *
@@ -1017,7 +1017,7 @@ class GoogleSitemapGenerator {
1017
  */
1018
  function Initate() {
1019
  if(!$this->_initiated) {
1020
-
1021
  //Loading language file...
1022
  //load_plugin_textdomain('sitemap');
1023
  //Hmm, doesn't work if the plugin file has its own directory.
@@ -1027,7 +1027,7 @@ class GoogleSitemapGenerator {
1027
  $moFile = dirname(__FILE__) . "/lang/sitemap-" . $currentLocale . ".mo";
1028
  if(@file_exists($moFile) && is_readable($moFile)) load_textdomain('sitemap', $moFile);
1029
  }
1030
-
1031
  $this->_freqNames = array(
1032
  "always"=>__("Always","sitemap"),
1033
  "hourly"=>__("Hourly","sitemap"),
@@ -1037,26 +1037,26 @@ class GoogleSitemapGenerator {
1037
  "yearly"=>__("Yearly","sitemap"),
1038
  "never"=>__("Never","sitemap")
1039
  );
1040
-
1041
-
1042
  $this->LoadOptions();
1043
  $this->LoadPages();
1044
-
1045
  //Register our own priority providers
1046
  add_filter("sm_add_prio_provider",array(&$this, 'AddDefaultPrioProviders'));
1047
-
1048
  //Let other plugins register their providers
1049
  $r = apply_filters("sm_add_prio_provider",$this->_prioProviders);
1050
-
1051
  //Check if no plugin return null
1052
  if($r != null) $this->_prioProviders = $r;
1053
-
1054
  $this->ValidatePrioProviders();
1055
-
1056
  $this->_initiated = true;
1057
  }
1058
  }
1059
-
1060
  /**
1061
  * Returns the instance of the Sitemap Generator
1062
  *
@@ -1070,7 +1070,7 @@ class GoogleSitemapGenerator {
1070
  return $GLOBALS["sm_instance"];
1071
  } else return null;
1072
  }
1073
-
1074
  /**
1075
  * Returns if the sitemap building process is currently active
1076
  *
@@ -1083,7 +1083,7 @@ class GoogleSitemapGenerator {
1083
  $inst = &GoogleSitemapGenerator::GetInstance();
1084
  return ($inst != null && $inst->_isActive);
1085
  }
1086
-
1087
  /**
1088
  * Returns if the compressed sitemap was activated
1089
  *
@@ -1119,10 +1119,10 @@ class GoogleSitemapGenerator {
1119
  function IsCustomPostTypesSupported() {
1120
  return (function_exists("get_post_types") && function_exists("register_post_type"));
1121
  }
1122
-
1123
  /**
1124
  * Returns the list of custom taxonies. These are basically all taxonomies without categories and post tags
1125
- *
1126
  * @since 3.1.7
1127
  * @return array Array of names of user-defined taxonomies
1128
  */
@@ -1133,7 +1133,7 @@ class GoogleSitemapGenerator {
1133
 
1134
  /**
1135
  * Returns the list of custom post types. These are all custome post types except post, page and attachment
1136
- *
1137
  * @since 3.2.5
1138
  * @author Lee Willis
1139
  * @return array Array of custom post types as per get_post_types
@@ -1144,7 +1144,7 @@ class GoogleSitemapGenerator {
1144
  $post_types = array_diff($post_types,array("post","page","attachment"));
1145
  return $post_types;
1146
  }
1147
-
1148
  /**
1149
  * Enables the Google Sitemap Generator and registers the WordPress hooks
1150
  *
@@ -1157,7 +1157,7 @@ class GoogleSitemapGenerator {
1157
  $GLOBALS["sm_instance"]=new GoogleSitemapGenerator();
1158
  }
1159
  }
1160
-
1161
  /**
1162
  * Checks if sitemap building after content changed is enabled and rebuild the sitemap
1163
  *
@@ -1172,7 +1172,7 @@ class GoogleSitemapGenerator {
1172
  $this->Initate();
1173
  //Build one time per post and if not importing.
1174
  if((($this->GetOption("b_auto_enabled")===true && $this->_lastPostID != $postID) || $external) && (!defined('WP_IMPORTING') || WP_IMPORTING != true)) {
1175
-
1176
  //Build the sitemap directly or schedule it with WP cron
1177
  if($this->GetOption("b_auto_delay")==true && floatval($wp_version) >= 2.1) {
1178
  if(!$this->_isScheduled) {
@@ -1191,17 +1191,17 @@ class GoogleSitemapGenerator {
1191
  $this->_lastPostID = $postID;
1192
  }
1193
  }
1194
-
1195
  /**
1196
  * Builds the sitemap by external request, for example other plugins.
1197
- *
1198
  * @since 3.1.9
1199
  * @return null
1200
  */
1201
  function BuildNowRequest() {
1202
- $this->CheckForAutoBuild(null, true);
1203
  }
1204
-
1205
  /**
1206
  * Checks if the rebuild request was send and starts to rebuilt the sitemap
1207
  *
@@ -1229,7 +1229,7 @@ class GoogleSitemapGenerator {
1229
  */
1230
  function ValidatePrioProviders() {
1231
  $validProviders=array();
1232
-
1233
  for($i=0; $i<count($this->_prioProviders); $i++) {
1234
  if(class_exists($this->_prioProviders[$i])) {
1235
  if($this->IsSubclassOf($this->_prioProviders[$i],"GoogleSitemapGeneratorPrioProviderBase")) {
@@ -1238,7 +1238,7 @@ class GoogleSitemapGenerator {
1238
  }
1239
  }
1240
  $this->_prioProviders=$validProviders;
1241
-
1242
  if(!$this->GetOption("b_prio_provider")) {
1243
  if(!in_array($this->GetOption("b_prio_provider"),$this->_prioProviders,true)) {
1244
  $this->SetOption("b_prio_provider","");
@@ -1261,7 +1261,7 @@ class GoogleSitemapGenerator {
1261
  }
1262
  return $providers;
1263
  }
1264
-
1265
  /**
1266
  * Loads the stored pages from the database
1267
  *
@@ -1271,27 +1271,27 @@ class GoogleSitemapGenerator {
1271
  */
1272
  function LoadPages() {
1273
  global $wpdb;
1274
-
1275
  $needsUpdate=false;
1276
-
1277
  $pagesString=$wpdb->get_var("SELECT option_value FROM $wpdb->options WHERE option_name = 'sm_cpages'");
1278
-
1279
  //Class sm_page was renamed with 3.0 -> rename it in serialized value for compatibility
1280
  if(!empty($pagesString) && strpos($pagesString,"sm_page")!==false) {
1281
  $pagesString = str_replace("O:7:\"sm_page\"","O:26:\"GoogleSitemapGeneratorPage\"",$pagesString);
1282
  $needsUpdate=true;
1283
  }
1284
-
1285
  if(!empty($pagesString)) {
1286
  $storedpages=unserialize($pagesString);
1287
  $this->_pages=$storedpages;
1288
  } else {
1289
  $this->_pages=array();
1290
  }
1291
-
1292
  if($needsUpdate) $this->SavePages();
1293
  }
1294
-
1295
  /**
1296
  * Saved the additional pages back to the database
1297
  *
@@ -1311,8 +1311,8 @@ class GoogleSitemapGenerator {
1311
  return true;
1312
  }
1313
  }
1314
-
1315
-
1316
  /**
1317
  * Returns the URL for the sitemap file
1318
  *
@@ -1323,12 +1323,20 @@ class GoogleSitemapGenerator {
1323
  * @return The URL to the Sitemap file
1324
  */
1325
  function GetXmlUrl($forceAuto=false) {
1326
-
 
 
1327
  if(!$forceAuto && $this->GetOption("b_location_mode")=="manual") {
1328
- return $this->GetOption("b_fileurl_manual");
1329
  } else {
1330
- return trailingslashit(get_bloginfo('url')). $this->GetOption("b_filename");
 
 
 
 
1331
  }
 
 
1332
  }
1333
 
1334
  /**
@@ -1343,7 +1351,7 @@ class GoogleSitemapGenerator {
1343
  function GetZipUrl($forceAuto=false) {
1344
  return $this->GetXmlUrl($forceAuto) . ".gz";
1345
  }
1346
-
1347
  /**
1348
  * Returns the file system path to the sitemap file
1349
  *
@@ -1354,13 +1362,22 @@ class GoogleSitemapGenerator {
1354
  * @return The file system path;
1355
  */
1356
  function GetXmlPath($forceAuto=false) {
 
 
 
1357
  if(!$forceAuto && $this->GetOption("b_location_mode")=="manual") {
1358
- return $this->GetOption("b_filename_manual");
1359
  } else {
1360
- return $this->GetHomePath() . $this->GetOption("b_filename");
 
 
 
 
1361
  }
 
 
1362
  }
1363
-
1364
  /**
1365
  * Returns the file system path to the gzipped sitemap file
1366
  *
@@ -1373,7 +1390,7 @@ class GoogleSitemapGenerator {
1373
  function GetZipPath($forceAuto=false) {
1374
  return $this->GetXmlPath($forceAuto) . ".gz";
1375
  }
1376
-
1377
  /**
1378
  * Returns the option value for the given key
1379
  *
@@ -1389,7 +1406,7 @@ class GoogleSitemapGenerator {
1389
  return $this->_options[$key];
1390
  } else return null;
1391
  }
1392
-
1393
  /**
1394
  * Sets an option to a new value
1395
  *
@@ -1401,10 +1418,10 @@ class GoogleSitemapGenerator {
1401
  */
1402
  function SetOption($key,$value) {
1403
  if(strstr($key,"sm_")!==0) $key="sm_" . $key;
1404
-
1405
  $this->_options[$key]=$value;
1406
  }
1407
-
1408
  /**
1409
  * Saves the options back to the database
1410
  *
@@ -1419,7 +1436,7 @@ class GoogleSitemapGenerator {
1419
  return true;
1420
  } else return update_option("sm_options",$this->_options);
1421
  }
1422
-
1423
  /**
1424
  * Retrieves the number of comments of a post in a asso. array
1425
  * The key is the postID, the value the number of comments
@@ -1442,7 +1459,7 @@ class GoogleSitemapGenerator {
1442
  }
1443
  return $comments;
1444
  }
1445
-
1446
  /**
1447
  * Calculates the full number of comments from an sm_getComments() generated array
1448
  *
@@ -1460,7 +1477,7 @@ class GoogleSitemapGenerator {
1460
  }
1461
  return $commentCount;
1462
  }
1463
-
1464
  /**
1465
  * Adds a url to the sitemap. You can use this method or call AddElement directly.
1466
  *
@@ -1478,10 +1495,10 @@ class GoogleSitemapGenerator {
1478
  //Strip out the last modification time if activated
1479
  if($this->GetOption('in_lastmod')===false) $lastMod = 0;
1480
  $page = new GoogleSitemapGeneratorPage($loc, $priority, $changeFreq, $lastMod);
1481
-
1482
  $this->AddElement($page);
1483
  }
1484
-
1485
  /**
1486
  * Adds an element to the sitemap
1487
  *
@@ -1492,18 +1509,18 @@ class GoogleSitemapGenerator {
1492
  */
1493
  function AddElement(&$page) {
1494
  if(empty($page)) return;
1495
-
1496
  $s = $page->Render();
1497
-
1498
  if($this->_fileZipHandle && $this->IsGzipEnabled()) {
1499
  gzwrite($this->_fileZipHandle,$s);
1500
  }
1501
-
1502
  if($this->_fileHandle && $this->GetOption("b_xml")) {
1503
  fwrite($this->_fileHandle,$s);
1504
  }
1505
  }
1506
-
1507
  /**
1508
  * Checks if a file is writable and tries to make it if not.
1509
  *
@@ -1532,11 +1549,11 @@ class GoogleSitemapGenerator {
1532
  //we can write, return 1/true/happy dance.
1533
  return true;
1534
  }
1535
-
1536
  /**
1537
  * Adds the sitemap to the virtual robots.txt file
1538
  * This function is executed by WordPress with the do_robots hook
1539
- *
1540
  * @since 3.1.2
1541
  */
1542
  function DoRobots() {
@@ -1547,14 +1564,14 @@ class GoogleSitemapGenerator {
1547
  if($this->IsGzipEnabled()) {
1548
  $smUrl = $this->GetZipUrl();
1549
  }
1550
-
1551
  echo "\nSitemap: " . $smUrl . "\n";
1552
  }
1553
  }
1554
-
1555
  /**
1556
  * Builds the sitemap and writes it into a xml file.
1557
- *
1558
  * ATTENTION PLUGIN DEVELOPERS! DONT CALL THIS METHOD DIRECTLY!
1559
  * The method is probably not available, since it is only loaded when needed.
1560
  * Use do_action("sm_rebuild"); if you want to rebuild the sitemap.
@@ -1568,87 +1585,87 @@ class GoogleSitemapGenerator {
1568
  function BuildSitemap() {
1569
  global $wpdb, $posts, $wp_version;
1570
  $this->Initate();
1571
-
1572
  if($this->GetOption("b_memory")!='') {
1573
  @ini_set("memory_limit",$this->GetOption("b_memory"));
1574
  }
1575
-
1576
  if($this->GetOption("b_time")!=-1) {
1577
  @set_time_limit($this->GetOption("b_time"));
1578
  }
1579
-
1580
  //This object saves the status information of the script directly to the database
1581
  $status = new GoogleSitemapGeneratorStatus();
1582
-
1583
  //Other plugins can detect if the building process is active
1584
  $this->_isActive = true;
1585
-
1586
  //$this->AddElement(new GoogleSitemapGeneratorXmlEntry());
1587
-
1588
  //Debug mode?
1589
  $debug=$this->GetOption("b_debug");
1590
-
1591
  if($this->GetOption("b_xml")) {
1592
  $fileName = $this->GetXmlPath();
1593
  $status->StartXml($this->GetXmlPath(),$this->GetXmlUrl());
1594
-
1595
  if($this->IsFileWritable($fileName)) {
1596
-
1597
  $this->_fileHandle = fopen($fileName,"w");
1598
  if(!$this->_fileHandle) $status->EndXml(false,"Not openable");
1599
-
1600
  } else $status->EndXml(false,"not writable");
1601
  }
1602
-
1603
  //Write gzipped sitemap file
1604
  if($this->IsGzipEnabled()) {
1605
  $fileName = $this->GetZipPath();
1606
  $status->StartZip($this->GetZipPath(),$this->GetZipUrl());
1607
-
1608
  if($this->IsFileWritable($fileName)) {
1609
-
1610
  $this->_fileZipHandle = gzopen($fileName,"w1");
1611
  if(!$this->_fileZipHandle) $status->EndZip(false,"Not openable");
1612
-
1613
  } else $status->EndZip(false,"not writable");
1614
  }
1615
-
1616
  if(!$this->_fileHandle && !$this->_fileZipHandle) {
1617
  $status->End();
1618
  return;
1619
  }
1620
-
1621
-
1622
  //Content of the XML file
1623
  $this->AddElement(new GoogleSitemapGeneratorXmlEntry('<?xml version="1.0" encoding="UTF-8"' . '?' . '>'));
1624
-
1625
  $styleSheet = ($this->GetDefaultStyle() && $this->GetOption('b_style_default')===true?$this->GetDefaultStyle():$this->GetOption('b_style'));
1626
-
1627
  if(!empty($styleSheet)) {
1628
  $this->AddElement(new GoogleSitemapGeneratorXmlEntry('<' . '?xml-stylesheet type="text/xsl" href="' . $styleSheet . '"?' . '>'));
1629
  }
1630
-
1631
  $this->AddElement(new GoogleSitemapGeneratorDebugEntry("generator=\"wordpress/" . get_bloginfo('version') . "\""));
1632
  $this->AddElement(new GoogleSitemapGeneratorDebugEntry("sitemap-generator-url=\"http://www.arnebrachhold.de\" sitemap-generator-version=\"" . $this->GetVersion() . "\""));
1633
  $this->AddElement(new GoogleSitemapGeneratorDebugEntry("generated-on=\"" . date(get_option("date_format") . " " . get_option("time_format")) . "\""));
1634
-
1635
  //All comments as an asso. Array (postID=>commentCount)
1636
  $comments=($this->GetOption("b_prio_provider")!=""?$this->GetComments():array());
1637
-
1638
  //Full number of comments
1639
  $commentCount=(count($comments)>0?$this->GetCommentCount($comments):0);
1640
-
1641
  if($debug && $this->GetOption("b_prio_provider")!="") {
1642
  $this->AddElement(new GoogleSitemapGeneratorDebugEntry("Debug: Total comment count: " . $commentCount));
1643
  }
1644
-
1645
  //Go XML!
1646
  $this->AddElement(new GoogleSitemapGeneratorXmlEntry('<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">'));
1647
-
1648
  $home = get_bloginfo('url');
1649
-
1650
  $homePid = 0;
1651
-
1652
  //Add the home page (WITH a slash!)
1653
  if($this->GetOption("in_home")) {
1654
  if('page' == get_option('show_on_front') && get_option('page_on_front')) {
@@ -1662,58 +1679,58 @@ class GoogleSitemapGenerator {
1662
  $this->AddUrl(trailingslashit($home),$this->GetTimestampFromMySql(get_lastpostmodified('GMT')),$this->GetOption("cf_home"),$this->GetOption("pr_home"));
1663
  }
1664
  }
1665
-
1666
  //Add the posts
1667
  if($this->GetOption("in_posts") || $this->GetOption("in_pages")) {
1668
-
1669
  if($debug) $this->AddElement(new GoogleSitemapGeneratorDebugEntry("Debug: Start Postings"));
1670
-
1671
  //Pre 2.1 compatibility. 2.1 introduced 'future' as post_status so we don't need to check post_date
1672
  $wpCompat = (floatval($wp_version) < 2.1);
1673
-
1674
  $useQTransLate = false; //function_exists('qtrans_convertURL') && function_exists('qtrans_getEnabledLanguages'); Not really working yet
1675
-
1676
  $excludes = $this->GetOption('b_exclude'); //Excluded posts and pages (user enetered ID)
1677
-
1678
  $exclCats = $this->GetOption("b_exclude_cats"); // Excluded cats
1679
-
1680
  if($exclCats && count($exclCats)>0 && $this->IsTaxonomySupported()) {
1681
-
1682
  $excludedCatPosts = get_objects_in_term($exclCats,"category"); // Get all posts in excl. cats. Unforttunately this also gives us pages, revisions and so on...
1683
-
1684
  //Remove the pages, revisions etc from the exclude by category list, because they are always in the uncategorized one.
1685
  if(count($excludedCatPosts)>0) {
1686
  $exclPages = $wpdb->get_col("SELECT ID FROM `" . $wpdb->posts . "` WHERE post_type!='post' AND ID IN ('" . implode("','",$excludedCatPosts) . "')");
1687
-
1688
  $exclPages = array_map('intval', $exclPages);
1689
-
1690
  //Remove the pages from the exlusion list before
1691
  if(count($exclPages)>0) $excludedCatPosts = array_diff($excludedCatPosts, $exclPages);
1692
-
1693
  //Merge the category exclusion list with the users one
1694
  if(count($excludedCatPosts)>0) $excludes = array_merge($excludes, $excludedCatPosts);
1695
  }
1696
  }
1697
-
1698
-
1699
  $contentStmt = '';
1700
  if($useQTransLate) {
1701
  $contentStmt.=', post_content ';
1702
  }
1703
-
1704
  $postPageStmt = '';
1705
-
1706
  $inSubPages = ($this->GetOption('in_posts_sub')===true);
1707
-
1708
  if($inSubPages && $this->GetOption('in_posts')===true) {
1709
  $pageDivider='<!--nextpage-->';
1710
  $postPageStmt = ", (character_length(`post_content`) - character_length(REPLACE(`post_content`, '$pageDivider', ''))) / " . strlen($pageDivider) . " as postPages";
1711
  }
1712
-
1713
  $sql="SELECT `ID`, `post_author`, `post_date`, `post_date_gmt`, `post_status`, `post_name`, `post_modified`, `post_modified_gmt`, `post_parent`, `post_type` $postPageStmt $contentStmt FROM `" . $wpdb->posts . "` WHERE ";
1714
-
1715
  $where = '(';
1716
-
1717
  if($this->GetOption('in_posts')) {
1718
  //WP < 2.1: posts are post_status = publish
1719
  //WP >= 2.1: post_type must be 'post', no date check required because future posts are post_status='future'
@@ -1728,7 +1745,7 @@ class GoogleSitemapGenerator {
1728
  $where.=" (post_status = 'publish' AND (post_type = 'post' OR post_type = '')) ";
1729
  }
1730
  }
1731
-
1732
  if($this->GetOption('in_pages')) {
1733
  if($this->GetOption('in_posts')) {
1734
  $where.=" OR ";
@@ -1741,33 +1758,33 @@ class GoogleSitemapGenerator {
1741
  $where.=" (post_status = 'publish' AND post_type = 'page') ";
1742
  }
1743
  }
1744
-
1745
  $where.=") ";
1746
-
1747
-
1748
  if(is_array($excludes) && count($excludes)>0) {
1749
  $where.=" AND ID NOT IN ('" . implode("','",$excludes) . "')";
1750
  }
1751
-
1752
  $where.=" AND post_password='' ORDER BY post_modified DESC";
1753
-
1754
  $sql .= $where;
1755
-
1756
  if($this->GetOption("b_max_posts")>0) {
1757
  $sql.=" LIMIT 0," . $this->GetOption("b_max_posts");
1758
  }
1759
 
1760
  $postCount = intval($wpdb->get_var("SELECT COUNT(*) AS cnt FROM `" . $wpdb->posts . "` WHERE ". $where,0,0));
1761
-
1762
  //Create a new connection because we are using mysql_unbuffered_query and don't want to disturb the WP connection
1763
  //Safe Mode for other plugins which use mysql_query() without a connection handler and will destroy our resultset :(
1764
  $con = $postRes = null;
1765
-
1766
  //In 2.2, a bug which prevented additional DB connections was fixed
1767
  if(floatval($wp_version) < 2.2) {
1768
  $this->SetOption("b_safemode",true);
1769
  }
1770
-
1771
  if($this->GetOption("b_safemode")===true) {
1772
  $postRes = mysql_query($sql,$wpdb->dbh);
1773
  if(!$postRes) {
@@ -1785,66 +1802,66 @@ class GoogleSitemapGenerator {
1785
  return;
1786
  }
1787
  $postRes = mysql_unbuffered_query($sql,$con);
1788
-
1789
  if(!$postRes) {
1790
  trigger_error("MySQL unbuffered query failed: " . mysql_error(),E_USER_NOTICE);
1791
  return;
1792
  }
1793
  }
1794
-
1795
  if($postRes) {
1796
-
1797
  //#type $prioProvider GoogleSitemapGeneratorPrioProviderBase
1798
  $prioProvider=NULL;
1799
-
1800
  if($this->GetOption("b_prio_provider") != '') {
1801
  $providerClass=$this->GetOption('b_prio_provider');
1802
  $prioProvider = new $providerClass($commentCount,$postCount);
1803
  }
1804
-
1805
  //$posts is used by Alex King's Popularity Contest plugin
1806
  //if($posts == null || !is_array($posts)) {
1807
  // $posts = &$postRes;
1808
  //}
1809
-
1810
  $z = 1;
1811
  $zz = 1;
1812
-
1813
  //Default priorities
1814
  $default_prio_posts = $this->GetOption('pr_posts');
1815
  $default_prio_pages = $this->GetOption('pr_pages');
1816
-
1817
  //Change frequencies
1818
  $cf_pages = $this->GetOption('cf_pages');
1819
  $cf_posts = $this->GetOption('cf_posts');
1820
-
1821
  $minPrio=$this->GetOption('pr_posts_min');
1822
-
1823
-
1824
  //Cycle through all posts and add them
1825
  while($post = mysql_fetch_object($postRes)) {
1826
-
1827
  //Fill the cache with our DB result. Since it's incomplete (no text-content for example), we will clean it later.
1828
  $cache = array(&$post);
1829
  update_post_cache($cache);
1830
-
1831
  //Set the current working post for other plugins which depend on "the loop"
1832
  $GLOBALS['post'] = &$post;
1833
-
1834
  $permalink = get_permalink($post->ID);
1835
  if($permalink != $home && $post->ID != $homePid) {
1836
-
1837
  $isPage = false;
1838
  if($wpCompat) {
1839
  $isPage = ($post->post_status == 'static');
1840
  } else {
1841
  $isPage = ($post->post_type == 'page');
1842
  }
1843
-
1844
-
1845
  //Default Priority if auto calc is disabled
1846
  $prio = 0;
1847
-
1848
  if($isPage) {
1849
  //Priority for static pages
1850
  $prio = $default_prio_pages;
@@ -1852,7 +1869,7 @@ class GoogleSitemapGenerator {
1852
  //Priority for normal posts
1853
  $prio = $default_prio_posts;
1854
  }
1855
-
1856
  //If priority calc. is enabled, calculate (but only for posts, not pages)!
1857
  if($prioProvider !== null && !$isPage) {
1858
 
@@ -1862,14 +1879,14 @@ class GoogleSitemapGenerator {
1862
 
1863
  if($debug) $this->AddElement(new GoogleSitemapGeneratorDebugEntry('Debug: Priority report of postID ' . $post->ID . ': Comments: ' . $cmtcnt . ' of ' . $commentCount . ' = ' . $prio . ' points'));
1864
  }
1865
-
1866
  if(!$isPage && $minPrio>0 && $prio<$minPrio) {
1867
  $prio = $minPrio;
1868
  }
1869
-
1870
  //Add it
1871
  $this->AddUrl($permalink,$this->GetTimestampFromMySql(($post->post_modified_gmt && $post->post_modified_gmt!='0000-00-00 00:00:00'?$post->post_modified_gmt:$post->post_date_gmt)),($isPage?$cf_pages:$cf_posts),$prio);
1872
-
1873
  if($inSubPages) {
1874
  $subPage = '';
1875
  for($p = 1; $p <= $post->postPages; $p++) {
@@ -1882,7 +1899,7 @@ class GoogleSitemapGenerator {
1882
  $this->AddUrl($subPage,$this->GetTimestampFromMySql(($post->post_modified_gmt && $post->post_modified_gmt!='0000-00-00 00:00:00'?$post->post_modified_gmt:$post->post_date_gmt)),($isPage?$cf_pages:$cf_posts),$prio);
1883
  }
1884
  }
1885
-
1886
  // Multilingual Support with qTranslate, thanks to Qian Qin
1887
  if($useQTransLate) {
1888
  global $q_config;
@@ -1893,7 +1910,7 @@ class GoogleSitemapGenerator {
1893
  }
1894
  }
1895
  }
1896
-
1897
  //Update the status every 100 posts and at the end.
1898
  //If the script breaks because of memory or time limit,
1899
  //we have a "last reponded" value which can be compared to the server settings
@@ -1901,9 +1918,9 @@ class GoogleSitemapGenerator {
1901
  $status->SaveStep($z);
1902
  $zz=0;
1903
  } else $zz++;
1904
-
1905
  $z++;
1906
-
1907
  //Clean cache because it's incomplete
1908
  if(version_compare($wp_version,"2.5",">=")) {
1909
  //WP 2.5 makes a mysql query for every clean_post_cache to clear the child cache
@@ -1917,21 +1934,21 @@ class GoogleSitemapGenerator {
1917
  }
1918
  unset($postRes);
1919
  unset($prioProvider);
1920
-
1921
  if($this->GetOption("b_safemode")!==true && $con) mysql_close($con);
1922
  }
1923
  if($debug) $this->AddElement(new GoogleSitemapGeneratorDebugEntry("Debug: End Postings"));
1924
  }
1925
-
1926
  //Add the cats
1927
  if($this->GetOption("in_cats")) {
1928
  if($debug) $this->AddElement(new GoogleSitemapGeneratorDebugEntry("Debug: Start Cats"));
1929
-
1930
  $exclCats = $this->GetOption("b_exclude_cats"); // Excluded cats
1931
  if($exclCats == null) $exclCats=array();
1932
-
1933
  if(!$this->IsTaxonomySupported()) {
1934
-
1935
  $catsRes=$wpdb->get_results("
1936
  SELECT
1937
  c.cat_ID AS ID,
@@ -1966,7 +1983,7 @@ class GoogleSitemapGenerator {
1966
  }
1967
  if($debug) $this->AddElement(new GoogleSitemapGeneratorDebugEntry("Debug: End Cats"));
1968
  }
1969
-
1970
  //Add the archives
1971
  if($this->GetOption("in_arch")) {
1972
  if($debug) $this->AddElement(new GoogleSitemapGeneratorDebugEntry("Debug: Start Archive"));
@@ -1993,36 +2010,36 @@ class GoogleSitemapGenerator {
1993
  post_date_gmt DESC");
1994
  if ($arcresults) {
1995
  foreach ($arcresults as $arcresult) {
1996
-
1997
  $url = get_month_link($arcresult->year, $arcresult->month);
1998
  $changeFreq="";
1999
-
2000
  //Archive is the current one
2001
  if($arcresult->month==date("n") && $arcresult->year==date("Y")) {
2002
  $changeFreq=$this->GetOption("cf_arch_curr");
2003
  } else { // Archive is older
2004
  $changeFreq=$this->GetOption("cf_arch_old");
2005
  }
2006
-
2007
  $this->AddUrl($url,$this->GetTimestampFromMySql($arcresult->last_mod),$changeFreq,$this->GetOption("pr_arch"));
2008
  }
2009
  }
2010
  if($debug) $this->AddElement(new GoogleSitemapGeneratorDebugEntry("Debug: End Archive"));
2011
  }
2012
-
2013
  //Add the author pages
2014
  if($this->GetOption("in_auth")) {
2015
  if($debug) $this->AddElement(new GoogleSitemapGeneratorDebugEntry("Debug: Start Author pages"));
2016
-
2017
  $linkFunc = null;
2018
-
2019
  //get_author_link is deprecated in WP 2.1, try to use get_author_posts_url first.
2020
  if(function_exists('get_author_posts_url')) {
2021
  $linkFunc = 'get_author_posts_url';
2022
  } else if(function_exists('get_author_link')) {
2023
  $linkFunc = 'get_author_link';
2024
  }
2025
-
2026
  //Who knows what happens in later WP versions, so check again if it worked
2027
  if($linkFunc !== null) {
2028
  //Unfortunately there is no API function to get all authors, so we have to do it the dirty way...
@@ -2044,9 +2061,9 @@ class GoogleSitemapGenerator {
2044
  GROUP BY
2045
  u.ID,
2046
  u.user_nicename";
2047
-
2048
  $authors = $wpdb->get_results($sql);
2049
-
2050
  if($authors && is_array($authors)) {
2051
  foreach($authors as $author) {
2052
  if($debug) if($debug) $this->AddElement(new GoogleSitemapGeneratorDebugEntry("Author-ID:" . $author->ID));
@@ -2058,10 +2075,10 @@ class GoogleSitemapGenerator {
2058
  //Too bad, no author pages for you :(
2059
  if($debug) $this->AddElement(new GoogleSitemapGeneratorDebugEntry("Debug: No valid author link function found"));
2060
  }
2061
-
2062
  if($debug) $this->AddElement(new GoogleSitemapGeneratorDebugEntry("Debug: End Author pages"));
2063
  }
2064
-
2065
  //Add tag pages
2066
  if($this->GetOption("in_tags") && $this->IsTaxonomySupported()) {
2067
  if($debug) $this->AddElement(new GoogleSitemapGeneratorDebugEntry("Debug: Start Tags"));
@@ -2073,21 +2090,21 @@ class GoogleSitemapGenerator {
2073
  }
2074
  if($debug) $this->AddElement(new GoogleSitemapGeneratorDebugEntry("Debug: End Tags"));
2075
  }
2076
-
2077
  //Add custom taxonomy pages
2078
  if($this->GetOption("in_tax") && $this->IsTaxonomySupported()) {
2079
-
2080
  if($debug) $this->AddElement(new GoogleSitemapGeneratorDebugEntry("Debug: Start custom taxonomies"));
2081
-
2082
  $enabledTaxonomies = $this->GetOption("in_tax");
2083
-
2084
  $taxList = array();
2085
-
2086
  foreach ($enabledTaxonomies as $taxName) {
2087
  $taxonomy = get_taxonomy($taxName);
2088
  if($taxonomy) $taxList[] = $wpdb->escape($taxonomy->name);
2089
  }
2090
-
2091
  if(count($taxList)>0) {
2092
  //We're selecting all term information (t.*) plus some additional fields
2093
  //like the last mod date and the taxonomy name, so WP doesnt need to make
@@ -2115,9 +2132,9 @@ class GoogleSitemapGenerator {
2115
  AND tt.taxonomy IN ('" . implode("','",$taxList) . "')
2116
  GROUP BY
2117
  t.term_id";
2118
-
2119
  $termInfo = $wpdb->get_results($sql);
2120
-
2121
  foreach($termInfo AS $term) {
2122
  $this->AddUrl(get_term_link($term->slug,$term->_taxonomy),$term->_mod_date ,$this->GetOption("cf_tags"),$this->GetOption("pr_tags"));
2123
  }
@@ -2125,7 +2142,7 @@ class GoogleSitemapGenerator {
2125
 
2126
  if($debug) $this->AddElement(new GoogleSitemapGeneratorDebugEntry("Debug: End custom taxonomies"));
2127
  }
2128
-
2129
  //Add the custom pages
2130
  if($debug) $this->AddElement(new GoogleSitemapGeneratorDebugEntry("Debug: Start Custom Pages"));
2131
  if($this->_pages && is_array($this->_pages) && count($this->_pages)>0) {
@@ -2134,20 +2151,20 @@ class GoogleSitemapGenerator {
2134
  $this->AddUrl($page->GetUrl(),$page->getLastMod(),$page->getChangeFreq(),$page->getPriority());
2135
  }
2136
  }
2137
-
2138
  if($debug) $this->AddElement(new GoogleSitemapGeneratorDebugEntry("Debug: End Custom Pages"));
2139
-
2140
  if($debug) $this->AddElement(new GoogleSitemapGeneratorDebugEntry("Debug: Start additional URLs"));
2141
-
2142
  do_action('sm_buildmap');
2143
-
2144
  if($debug) $this->AddElement(new GoogleSitemapGeneratorDebugEntry("Debug: End additional URLs"));
2145
-
2146
  $this->AddElement(new GoogleSitemapGeneratorXmlEntry("</urlset>"));
2147
-
2148
 
2149
  $pingUrl='';
2150
-
2151
  if($this->GetOption("b_xml")) {
2152
  if($this->_fileHandle && fclose($this->_fileHandle)) {
2153
  $this->_fileHandle = null;
@@ -2155,7 +2172,7 @@ class GoogleSitemapGenerator {
2155
  $pingUrl=$this->GetXmlUrl();
2156
  } else $status->EndXml(false,"Could not close the sitemap file.");
2157
  }
2158
-
2159
  if($this->IsGzipEnabled()) {
2160
  if($this->_fileZipHandle && fclose($this->_fileZipHandle)) {
2161
  $this->_fileZipHandle = null;
@@ -2163,13 +2180,13 @@ class GoogleSitemapGenerator {
2163
  $pingUrl=$this->GetZipUrl();
2164
  } else $status->EndZip(false,"Could not close the zipped sitemap file");
2165
  }
2166
-
2167
  //Ping Google
2168
  if($this->GetOption("b_ping") && !empty($pingUrl)) {
2169
  $sPingUrl="http://www.google.com/webmasters/sitemaps/ping?sitemap=" . urlencode($pingUrl);
2170
  $status->StartGooglePing($sPingUrl);
2171
  $pingres=$this->RemoteOpen($sPingUrl);
2172
-
2173
  if($pingres==NULL || $pingres===false) {
2174
  $status->EndGooglePing(false,$this->_lastError);
2175
  trigger_error("Failed to ping Google: " . htmlspecialchars(strip_tags($pingres)),E_USER_NOTICE);
@@ -2177,8 +2194,8 @@ class GoogleSitemapGenerator {
2177
  $status->EndGooglePing(true);
2178
  }
2179
  }
2180
-
2181
-
2182
  //Ping Bing
2183
  if($this->GetOption("b_pingmsn") && !empty($pingUrl)) {
2184
  $sPingUrl="http://www.bing.com/webmaster/ping.aspx?siteMap=" . urlencode($pingUrl);
@@ -2192,36 +2209,36 @@ class GoogleSitemapGenerator {
2192
  $status->EndMsnPing(true);
2193
  }
2194
  }
2195
-
2196
  $status->End();
2197
-
2198
-
2199
  $this->_isActive = false;
2200
-
2201
  //done...
2202
  return $status;
2203
  }
2204
-
2205
  /**
2206
  * Tries to ping a specific service showing as much as debug output as possible
2207
  * @since 3.1.9
2208
  * @return null
2209
  */
2210
  function ShowPingResult() {
2211
-
2212
  check_admin_referer('sitemap');
2213
-
2214
  if(!current_user_can("administrator")) {
2215
  echo '<p>Please log in as admin</p>';
2216
  return;
2217
  }
2218
-
2219
  $service = !empty($_GET["sm_ping_service"])?$_GET["sm_ping_service"]:null;
2220
-
2221
  $status = &GoogleSitemapGeneratorStatus::Load();
2222
-
2223
  if(!$status) die("No build status yet. Build the sitemap first.");
2224
-
2225
  $url = null;
2226
 
2227
  switch($service) {
@@ -2230,35 +2247,35 @@ class GoogleSitemapGenerator {
2230
  break;
2231
  case "msn":
2232
  $url = $status->_msnUrl;
2233
- break;
2234
  }
2235
-
2236
  if(empty($url)) die("Invalid ping url");
2237
-
2238
  echo '<html><head><title>Ping Test</title>';
2239
  if(function_exists('wp_admin_css')) wp_admin_css('css/global',true);
2240
  echo '</head><body><h1>Ping Test</h1>';
2241
-
2242
  echo '<p>Trying to ping: <a href="' . $url . '">' . $url . '</a>. The sections below should give you an idea whats going on.</p>';
2243
-
2244
  //Try to get as much as debug / error output as possible
2245
  $errLevel = error_reporting(E_ALL);
2246
  $errDisplay = ini_set("display_errors",1);
2247
  if(!defined('WP_DEBUG')) define('WP_DEBUG',true);
2248
-
2249
  echo '<h2>Errors, Warnings, Notices:</h2>';
2250
-
2251
  if(WP_DEBUG == false) echo "<i>WP_DEBUG was set to false somewhere before. You might not see all debug information until you remove this declaration!</i><br />";
2252
  if(ini_get("display_errors")!=1) echo "<i>Your display_errors setting currently prevents the plugin from showing errors here. Please check your webserver logfile instead.</i><br />";
2253
-
2254
  $res = $this->RemoteOpen($url);
2255
-
2256
  echo '<h2>Result (text only):</h2>';
2257
 
2258
  echo wp_kses($res,array('a' => array('href' => array()),'p' => array(), 'ul' => array(), 'ol' => array(), 'li' => array()));
2259
-
2260
  echo '<h2>Result (HTML):</h2>';
2261
-
2262
  echo htmlspecialchars($res);
2263
 
2264
  //Revert back old values
@@ -2267,7 +2284,7 @@ class GoogleSitemapGenerator {
2267
  echo '</body></html>';
2268
  exit;
2269
  }
2270
-
2271
  /**
2272
  * Opens a remote file using the WordPress API or Snoopy
2273
  * @since 3.0
@@ -2279,56 +2296,56 @@ class GoogleSitemapGenerator {
2279
  */
2280
  function RemoteOpen($url,$method = 'get', $postData = null, $timeout = 10) {
2281
  global $wp_version;
2282
-
2283
  //Before WP 2.7, wp_remote_fopen was quite crappy so Snoopy was favoured.
2284
  if(floatval($wp_version) < 2.7) {
2285
  if(!file_exists(ABSPATH . 'wp-includes/class-snoopy.php')) {
2286
  trigger_error('Snoopy Web Request failed: Snoopy not found.',E_USER_NOTICE);
2287
  return false; //Hoah?
2288
  }
2289
-
2290
  require_once( ABSPATH . 'wp-includes/class-snoopy.php');
2291
-
2292
  $s = new Snoopy();
2293
-
2294
  $s->read_timeout = $timeout;
2295
-
2296
  if($method == 'get') {
2297
  $s->fetch($url);
2298
  } else {
2299
  $s->submit($url,$postData);
2300
  }
2301
-
2302
  if($s->status != "200") {
2303
  trigger_error('Snoopy Web Request failed: Status: ' . $s->status . "; Content: " . htmlspecialchars($s->results),E_USER_NOTICE);
2304
  }
2305
-
2306
  return $s->results;
2307
-
2308
  } else {
2309
-
2310
  $options = array();
2311
  $options['timeout'] = $timeout;
2312
-
2313
  if($method == 'get') {
2314
  $response = wp_remote_get( $url, $options );
2315
  } else {
2316
  $response = wp_remote_post($url, array_merge($options,array('body'=>$postData)));
2317
  }
2318
-
2319
  if ( is_wp_error( $response ) ) {
2320
  $errs = $response->get_error_messages();
2321
  $errs = htmlspecialchars(implode('; ', $errs));
2322
  trigger_error('WP HTTP API Web Request failed: ' . $errs,E_USER_NOTICE);
2323
  return false;
2324
  }
2325
-
2326
  return $response['body'];
2327
  }
2328
-
2329
  return false;
2330
  }
2331
-
2332
  /**
2333
  * Echos option fields for an select field containing the valid change frequencies
2334
  *
@@ -2339,12 +2356,12 @@ class GoogleSitemapGenerator {
2339
  * @return all valid change frequencies as html option fields
2340
  */
2341
  function HtmlGetFreqNames($currentVal) {
2342
-
2343
  foreach($this->_freqNames AS $k=>$v) {
2344
  echo "<option value=\"$k\" " . $this->HtmlGetSelected($k,$currentVal) .">" . $v . "</option>";
2345
  }
2346
  }
2347
-
2348
  /**
2349
  * Echos option fields for an select field containing the valid priorities (0- 1.0)
2350
  *
@@ -2365,7 +2382,7 @@ class GoogleSitemapGenerator {
2365
  echo "</option>";
2366
  }
2367
  }
2368
-
2369
  /**
2370
  * Returns the checked attribute if the given values match
2371
  *
@@ -2380,7 +2397,7 @@ class GoogleSitemapGenerator {
2380
  if($val==$equals) return $this->HtmlGetAttribute("checked");
2381
  else return "";
2382
  }
2383
-
2384
  /**
2385
  * Returns the selected attribute if the given values match
2386
  *
@@ -2395,7 +2412,7 @@ class GoogleSitemapGenerator {
2395
  if($val==$equals) return $this->HtmlGetAttribute("selected");
2396
  else return "";
2397
  }
2398
-
2399
  /**
2400
  * Returns an formatted attribute. If the value is NULL, the name will be used.
2401
  *
@@ -2410,7 +2427,7 @@ class GoogleSitemapGenerator {
2410
  if($value==NULL) $value=$attr;
2411
  return " " . $attr . "=\"" . $value . "\" ";
2412
  }
2413
-
2414
  /**
2415
  * Returns an array with GoogleSitemapGeneratorPage objects which is generated from POST values
2416
  *
@@ -2423,13 +2440,13 @@ class GoogleSitemapGenerator {
2423
  function HtmlApplyPages() {
2424
  // Array with all page URLs
2425
  $pages_ur=(!isset($_POST["sm_pages_ur"]) || !is_array($_POST["sm_pages_ur"])?array():$_POST["sm_pages_ur"]);
2426
-
2427
  //Array with all priorities
2428
  $pages_pr=(!isset($_POST["sm_pages_pr"]) || !is_array($_POST["sm_pages_pr"])?array():$_POST["sm_pages_pr"]);
2429
-
2430
  //Array with all change frequencies
2431
  $pages_cf=(!isset($_POST["sm_pages_cf"]) || !is_array($_POST["sm_pages_cf"])?array():$_POST["sm_pages_cf"]);
2432
-
2433
  //Array with all lastmods
2434
  $pages_lm=(!isset($_POST["sm_pages_lm"]) || !is_array($_POST["sm_pages_lm"])?array():$_POST["sm_pages_lm"]);
2435
 
@@ -2455,10 +2472,10 @@ class GoogleSitemapGenerator {
2455
 
2456
  return $pages;
2457
  }
2458
-
2459
  /**
2460
  * Converts a mysql datetime value into a unix timestamp
2461
- *
2462
  * @param The value in the mysql datetime format
2463
  * @return int The time in seconds
2464
  */
@@ -2468,10 +2485,10 @@ class GoogleSitemapGenerator {
2468
  list($hour,$min,$sec) = explode(':',$hours);
2469
  return mktime(intval($hour), intval($min), intval($sec), intval($month), intval($day), intval($year));
2470
  }
2471
-
2472
  /**
2473
  * Returns a link pointing to a spcific page of the authors website
2474
- *
2475
  * @since 3.0
2476
  * @param The page to link to
2477
  * @return string The full url
@@ -2479,10 +2496,10 @@ class GoogleSitemapGenerator {
2479
  function GetRedirectLink($redir) {
2480
  return trailingslashit("http://www.arnebrachhold.de/redir/" . $redir);
2481
  }
2482
-
2483
  /**
2484
  * Returns a link pointing back to the plugin page in WordPress
2485
- *
2486
  * @since 3.0
2487
  * @return string The full url
2488
  */
@@ -2492,34 +2509,34 @@ class GoogleSitemapGenerator {
2492
  //admin_url was added in WP 2.6.0
2493
  if(function_exists("admin_url")) $url = admin_url("options-general.php?page=" . GoogleSitemapGeneratorLoader::GetBaseName());
2494
  else $url = $_SERVER['PHP_SELF'] . "?page=" . GoogleSitemapGeneratorLoader::GetBaseName();
2495
-
2496
  //Some browser cache the page... great! So lets add some no caching params depending on the WP and plugin version
2497
  $url.='&sm_wpv=' . $wp_version . '&sm_pv=' . GoogleSitemapGeneratorLoader::GetVersion();
2498
-
2499
  return $url;
2500
  }
2501
-
2502
  /**
2503
  * Shows the option page of the plugin. Before 3.1.1, this function was basically the UI, afterwards the UI was outsourced to another class
2504
- *
2505
  * @see GoogleSitemapGeneratorUI
2506
  * @since 3.0
2507
  * @return bool
2508
  */
2509
  function HtmlShowOptionsPage() {
2510
-
2511
  $ui = $this->GetUI();
2512
  if($ui) {
2513
  $ui->HtmlShowOptionsPage();
2514
  return true;
2515
  }
2516
-
2517
  return false;
2518
  }
2519
-
2520
  /**
2521
  * Includes the user interface class and intializes it
2522
- *
2523
  * @since 3.1.1
2524
  * @see GoogleSitemapGeneratorUI
2525
  * @return GoogleSitemapGeneratorUI
@@ -2527,29 +2544,29 @@ class GoogleSitemapGenerator {
2527
  function GetUI() {
2528
 
2529
  global $wp_version;
2530
-
2531
  if($this->_ui === null) {
2532
-
2533
  $className='GoogleSitemapGeneratorUI';
2534
  $fileName='sitemap-ui.php';
2535
 
2536
  if(!class_exists($className)) {
2537
-
2538
  $path = trailingslashit(dirname(__FILE__));
2539
-
2540
  if(!file_exists( $path . $fileName)) return false;
2541
  require_once($path. $fileName);
2542
  }
2543
-
2544
  $this->_ui = new $className($this);
2545
-
2546
  }
2547
-
2548
  return $this->_ui;
2549
  }
2550
-
2551
  function HtmlShowHelp() {
2552
-
2553
-
2554
  }
2555
  }
1
  <?php
2
  /*
3
+
4
+ $Id: sitemap-core.php 651444 2013-01-11 19:54:39Z arnee $
5
 
6
  */
7
 
19
 
20
  function GoogleSitemapGeneratorStatus() {
21
  $this->_startTime = $this->GetMicrotimeFloat();
22
+
23
  $exists = get_option("sm_status");
24
+
25
  if($exists === false) add_option("sm_status","",null,"no");
26
+
27
  $this->Save();
28
  }
29
+
30
  function Save() {
31
  update_option("sm_status",$this);
32
  }
33
+
34
  /**
35
  * Returns the last saved status object or null
36
+ *
37
  * @return GoogleSitemapGeneratorStatus
38
  */
39
  function &Load() {
41
  if(is_a($status,"GoogleSitemapGeneratorStatus")) return $status;
42
  else return null;
43
  }
44
+
45
  /**
46
  * @var float $_startTime The start time of the building process
47
  * @access private
48
  */
49
  var $_startTime = 0;
50
+
51
  /**
52
  * @var float $_endTime The end time of the building process
53
  * @access private
54
  */
55
  var $_endTime = 0;
56
+
57
  /**
58
  * @var bool $$_hasChanged Indicates if the sitemap content has changed
59
  * @access private
60
  */
61
  var $_hasChanged = true;
62
+
63
  /**
64
  * @var int $_memoryUsage The amount of memory used in bytes
65
  * @access private
66
  */
67
  var $_memoryUsage = 0;
68
+
69
  /**
70
  * @var int $_lastPost The number of posts processed. This value is updated every 50 posts.
71
  * @access private
72
  */
73
  var $_lastPost = 0;
74
+
75
  /**
76
  * @var int $_lastTime The time when the last step-update occured. This value is updated every 50 posts.
77
  * @access private
78
  */
79
  var $_lastTime = 0;
80
+
81
  function End($hasChanged = true) {
82
  $this->_endTime = $this->GetMicrotimeFloat();
83
+
84
  $this->SetMemoryUsage();
85
+
86
  $this->_hasChanged = $hasChanged;
87
+
88
  $this->Save();
89
  }
90
+
91
  function SetMemoryUsage() {
92
  if(function_exists("memory_get_peak_usage")) {
93
  $this->_memoryUsage = memory_get_peak_usage(true);
95
  $this->_memoryUsage = memory_get_usage(true);
96
  }
97
  }
98
+
99
  function GetMemoryUsage() {
100
  return round($this->_memoryUsage / 1024 / 1024,2);
101
  }
102
+
103
  function SaveStep($postCount) {
104
  $this->SetMemoryUsage();
105
  $this->_lastPost = $postCount;
106
  $this->_lastTime = $this->GetMicrotimeFloat();
107
+
108
  $this->Save();
109
  }
110
+
111
  function GetTime() {
112
  return round($this->_endTime - $this->_startTime,2);
113
  }
114
+
115
  function GetStartTime() {
116
  return round($this->_startTime, 2);
117
  }
118
+
119
  function GetLastTime() {
120
  return round($this->_lastTime - $this->_startTime,2);
121
  }
122
+
123
  function GetLastPost() {
124
  return $this->_lastPost;
125
  }
126
+
127
  var $_usedXml = false;
128
  var $_xmlSuccess = false;
129
  var $_xmlPath = '';
130
  var $_xmlUrl = '';
131
+
132
  function StartXml($path,$url) {
133
  $this->_usedXml = true;
134
  $this->_xmlPath = $path;
135
  $this->_xmlUrl = $url;
136
+
137
  $this->Save();
138
  }
139
+
140
  function EndXml($success) {
141
  $this->_xmlSuccess = $success;
142
+
143
  $this->Save();
144
  }
145
+
146
+
147
  var $_usedZip = false;
148
  var $_zipSuccess = false;
149
  var $_zipPath = '';
150
  var $_zipUrl = '';
151
+
152
  function StartZip($path,$url) {
153
  $this->_usedZip = true;
154
  $this->_zipPath = $path;
155
  $this->_zipUrl = $url;
156
+
157
  $this->Save();
158
  }
159
+
160
  function EndZip($success) {
161
  $this->_zipSuccess = $success;
162
+
163
  $this->Save();
164
  }
165
+
166
  var $_usedGoogle = false;
167
  var $_googleUrl = '';
168
  var $_gooogleSuccess = false;
169
  var $_googleStartTime = 0;
170
  var $_googleEndTime = 0;
171
+
172
  function StartGooglePing($url) {
173
  $this->_googleUrl = $url;
174
  $this->_usedGoogle = true;
175
  $this->_googleStartTime = $this->GetMicrotimeFloat();
176
+
177
  $this->Save();
178
  }
179
+
180
  function EndGooglePing($success) {
181
  $this->_googleEndTime = $this->GetMicrotimeFloat();
182
  $this->_gooogleSuccess = $success;
183
+
184
  $this->Save();
185
  }
186
+
187
  function GetGoogleTime() {
188
  return round($this->_googleEndTime - $this->_googleStartTime,2);
189
  }
190
+
191
  var $_usedMsn = false;
192
  var $_msnUrl = '';
193
  var $_msnSuccess = false;
194
  var $_msnStartTime = 0;
195
  var $_msnEndTime = 0;
196
+
197
  function StartMsnPing($url) {
198
  $this->_usedMsn = true;
199
  $this->_msnUrl = $url;
200
  $this->_msnStartTime = $this->GetMicrotimeFloat();
201
+
202
  $this->Save();
203
  }
204
+
205
  function EndMsnPing($success) {
206
  $this->_msnEndTime = $this->GetMicrotimeFloat();
207
  $this->_msnSuccess = $success;
208
+
209
  $this->Save();
210
  }
211
+
212
  function GetMsnTime() {
213
  return round($this->_msnEndTime - $this->_msnStartTime,2);
214
  }
215
+
216
  function GetMicrotimeFloat() {
217
  list($usec, $sec) = explode(" ", microtime());
218
  return ((float)$usec + (float)$sec);
219
  }
220
  }
221
+
222
  /**
223
  * Represents an item in the page list
224
  * @author Arne Brachhold
226
  * @since 3.0
227
  */
228
  class GoogleSitemapGeneratorPage {
229
+
230
  /**
231
  * @var string $_url Sets the URL or the relative path to the blog dir of the page
232
  * @access private
233
  */
234
  var $_url;
235
+
236
  /**
237
  * @var float $_priority Sets the priority of this page
238
  * @access private
239
  */
240
  var $_priority;
241
+
242
  /**
243
  * @var string $_changeFreq Sets the chanfe frequency of the page. I want Enums!
244
  * @access private
245
  */
246
  var $_changeFreq;
247
+
248
  /**
249
  * @var int $_lastMod Sets the lastMod date as a UNIX timestamp.
250
  * @access private
251
  */
252
  var $_lastMod;
253
+
254
  /**
255
  * Initialize a new page object
256
  *
269
  $this->SetChangeFreq($changeFreq);
270
  $this->SetLastMod($lastMod);
271
  }
272
+
273
  /**
274
  * Returns the URL of the page
275
  *
278
  function GetUrl() {
279
  return $this->_url;
280
  }
281
+
282
  /**
283
  * Sets the URL of the page
284
  *
287
  function SetUrl($url) {
288
  $this->_url=(string) $url;
289
  }
290
+
291
  /**
292
  * Returns the priority of this page
293
  *
296
  function GetPriority() {
297
  return $this->_priority;
298
  }
299
+
300
  /**
301
  * Sets the priority of the page
302
  *
305
  function SetProprity($priority) {
306
  $this->_priority=floatval($priority);
307
  }
308
+
309
  /**
310
  * Returns the change frequency of the page
311
  *
314
  function GetChangeFreq() {
315
  return $this->_changeFreq;
316
  }
317
+
318
  /**
319
  * Sets the change frequency of the page
320
  *
323
  function SetChangeFreq($changeFreq) {
324
  $this->_changeFreq=(string) $changeFreq;
325
  }
326
+
327
  /**
328
  * Returns the last mod of the page
329
  *
332
  function GetLastMod() {
333
  return $this->_lastMod;
334
  }
335
+
336
  /**
337
  * Sets the last mod of the page
338
  *
341
  function SetLastMod($lastMod) {
342
  $this->_lastMod=intval($lastMod);
343
  }
344
+
345
  function Render() {
346
+
347
  if($this->_url == "/" || empty($this->_url)) return '';
348
+
349
  $r="";
350
  $r.= "\t<url>\n";
351
  $r.= "\t\t<loc>" . $this->EscapeXML($this->_url) . "</loc>\n";
352
  if($this->_lastMod>0) $r.= "\t\t<lastmod>" . date('Y-m-d\TH:i:s+00:00',$this->_lastMod) . "</lastmod>\n";
353
+ if(!empty($this->_changeFreq)) $r.= "\t\t<changefreq>" . $this->EscapeXML($this->_changeFreq) . "</changefreq>\n";
354
  if($this->_priority!==false && $this->_priority!=="") $r.= "\t\t<priority>" . number_format($this->_priority,1) . "</priority>\n";
355
  $r.= "\t</url>\n";
356
  return $r;
357
  }
358
+
359
  function EscapeXML($string) {
360
  return str_replace ( array ( '&', '"', "'", '<', '>'), array ( '&amp;' , '&quot;', '&apos;' , '&lt;' , '&gt;'), $string);
361
  }
362
  }
363
 
364
  class GoogleSitemapGeneratorXmlEntry {
365
+
366
  var $_xml;
367
+
368
  function GoogleSitemapGeneratorXmlEntry($xml) {
369
  $this->_xml = $xml;
370
  }
371
+
372
  function Render() {
373
  return $this->_xml;
374
  }
375
  }
376
 
377
  class GoogleSitemapGeneratorDebugEntry extends GoogleSitemapGeneratorXmlEntry {
378
+
379
  function Render() {
380
  return "<!-- " . $this->_xml . " -->\n";
381
  }
388
  * @since 3.0
389
  */
390
  class GoogleSitemapGeneratorPrioProviderBase {
391
+
392
  /**
393
  * @var int $_totalComments The total number of comments of all posts
394
  * @access protected
395
  */
396
  var $_totalComments=0;
397
+
398
  /**
399
  * @var int $_totalComments The total number of posts
400
  * @access protected
401
  */
402
  var $_totalPosts=0;
403
+
404
  /**
405
  * Returns the (translated) name of this priority provider
406
  *
412
  function GetName() {
413
  return "";
414
  }
415
+
416
  /**
417
  * Returns the (translated) description of this priority provider
418
  *
424
  function GetDescription() {
425
  return "";
426
  }
427
+
428
  /**
429
  * Initializes a new priority provider
430
  *
437
  function GoogleSitemapGeneratorPrioProviderBase($totalComments,$totalPosts) {
438
  $this->_totalComments=$totalComments;
439
  $this->_totalPosts=$totalPosts;
440
+
441
  }
442
+
443
  /**
444
  * Returns the priority for a specified post
445
  *
462
  * @since 3.0
463
  */
464
  class GoogleSitemapGeneratorPrioByCountProvider extends GoogleSitemapGeneratorPrioProviderBase {
465
+
466
  /**
467
  * Returns the (translated) name of this priority provider
468
  *
474
  function GetName() {
475
  return __("Comment Count",'sitemap');
476
  }
477
+
478
  /**
479
  * Returns the (translated) description of this priority provider
480
  *
486
  function GetDescription() {
487
  return __("Uses the number of comments of the post to calculate the priority",'sitemap');
488
  }
489
+
490
  /**
491
  * Initializes a new priority provider which calculates the post priority based on the number of comments
492
  *
499
  function GoogleSitemapGeneratorPrioByCountProvider($totalComments,$totalPosts) {
500
  parent::GoogleSitemapGeneratorPrioProviderBase($totalComments,$totalPosts);
501
  }
502
+
503
  /**
504
  * Returns the priority for a specified post
505
  *
528
  * @since 3.0
529
  */
530
  class GoogleSitemapGeneratorPrioByAverageProvider extends GoogleSitemapGeneratorPrioProviderBase {
531
+
532
  /**
533
  * @var int $_average The average number of comments per post
534
  * @access protected
535
  */
536
  var $_average=0.0;
537
+
538
  /**
539
  * Returns the (translated) name of this priority provider
540
  *
546
  function GetName() {
547
  return __("Comment Average",'sitemap');
548
  }
549
+
550
  /**
551
  * Returns the (translated) description of this priority provider
552
  *
558
  function GetDescription() {
559
  return __("Uses the average comment count to calculate the priority",'sitemap');
560
  }
561
+
562
  /**
563
  * Initializes a new priority provider which calculates the post priority based on the average number of comments
564
  *
570
  */
571
  function GoogleSitemapGeneratorPrioByAverageProvider($totalComments,$totalPosts) {
572
  parent::GoogleSitemapGeneratorPrioProviderBase($totalComments,$totalPosts);
573
+
574
  if($this->_totalComments>0 && $this->_totalPosts>0) {
575
  $this->_average= (double) $this->_totalComments / $this->_totalPosts;
576
  }
577
  }
578
+
579
  /**
580
  * Returns the priority for a specified post
581
  *
597
  if($prio>1) $prio = 1;
598
  else if($prio<0) $prio = 0;
599
  }
600
+
601
  return round($prio,1);
602
  }
603
  }
609
  * @since 3.0
610
  */
611
  class GoogleSitemapGeneratorPrioByPopularityContestProvider extends GoogleSitemapGeneratorPrioProviderBase {
612
+
613
  /**
614
  * Returns the (translated) name of this priority provider
615
  *
621
  function GetName() {
622
  return __("Popularity Contest",'sitemap');
623
  }
624
+
625
  /**
626
  * Returns the (translated) description of this priority provider
627
  *
633
  function GetDescription() {
634
  return str_replace("%4","index.php?page=popularity-contest.php",str_replace("%3","options-general.php?page=popularity-contest.php",str_replace("%2","http://www.alexking.org/",str_replace("%1","http://www.alexking.org/index.php?content=software/wordpress/content.php",__("Uses the activated <a href=\"%1\">Popularity Contest Plugin</a> from <a href=\"%2\">Alex King</a>. See <a href=\"%3\">Settings</a> and <a href=\"%4\">Most Popular Posts</a>",'sitemap')))));
635
  }
636
+
637
  /**
638
  * Initializes a new priority provider which calculates the post priority based on the popularity by the PopularityContest Plugin
639
  *
646
  function GoogleSitemapGeneratorPrioByPopularityContestProvider($totalComments,$totalPosts) {
647
  parent::GoogleSitemapGeneratorPrioProviderBase($totalComments,$totalPosts);
648
  }
649
+
650
  /**
651
  * Returns the priority for a specified post
652
  *
660
  function GetPostPriority($postID,$commentCount) {
661
  //$akpc is the global instance of the Popularity Contest Plugin
662
  global $akpc,$posts;
663
+
664
  $res=0;
665
  //Better check if its there
666
  if(!empty($akpc) && is_object($akpc)) {
696
  /**
697
  * @var Version of the generator in SVN
698
  */
699
+ var $_svnVersion = '$Id: sitemap-core.php 651444 2013-01-11 19:54:39Z arnee $';
700
+
701
  /**
702
  * @var array The unserialized array with the stored options
703
  */
704
  var $_options = array();
705
+
706
  /**
707
  * @var array The saved additional pages
708
  */
712
  * @var array The values and names of the change frequencies
713
  */
714
  var $_freqNames = array();
715
+
716
  /**
717
  * @var array A list of class names which my be called for priority calculation
718
  */
719
  var $_prioProviders = array();
720
+
721
  /**
722
  * @var bool True if init complete (options loaded etc)
723
  */
724
  var $_initiated = false;
725
+
726
  /**
727
  * @var string Holds the last error if one occurs when writing the files
728
  */
729
  var $_lastError=null;
730
+
731
  /**
732
  * @var int The last handled post ID
733
  */
734
  var $_lastPostID = 0;
735
+
736
  /**
737
  * @var bool Defines if the sitemap building process is active at the moment
738
  */
739
  var $_isActive = false;
740
+
741
  /**
742
  * @var bool Defines if the sitemap building process has been scheduled via Wp cron
743
  */
747
  * @var object The file handle which is used to write the sitemap file
748
  */
749
  var $_fileHandle = null;
750
+
751
  /**
752
  * @var object The file handle which is used to write the zipped sitemap file
753
  */
754
  var $_fileZipHandle = null;
755
+
756
  /**
757
  * Holds the user interface object
758
+ *
759
  * @since 3.1.1
760
  * @var GoogleSitemapGeneratorUI
761
  */
762
  var $_ui = null;
763
+
764
  /**
765
  * Returns the path to the blog directory
766
  *
770
  * @return string The full path to the blog directory
771
  */
772
  function GetHomePath() {
773
+
774
  $res="";
775
  //Check if we are in the admin area -> get_home_path() is avaiable
776
  if(function_exists("get_home_path")) {
794
  }
795
  return $res;
796
  }
797
+
798
  /**
799
  * Returns the path to the directory where the plugin file is located
800
  * @since 3.0b5
806
  $path = dirname(__FILE__);
807
  return trailingslashit(str_replace("\\","/",$path));
808
  }
809
+
810
  /**
811
  * Returns the URL to the directory where the plugin file is located
812
  * @since 3.0b5
815
  * @return string The URL to the plugin directory
816
  */
817
  function GetPluginUrl() {
818
+
819
  //Try to use WP API if possible, introduced in WP 2.6
820
  if (function_exists('plugins_url')) return trailingslashit(plugins_url(basename(dirname(__FILE__))));
821
+
822
  //Try to find manually... can't work if wp-content was renamed or is redirected
823
  $path = dirname(__FILE__);
824
  $path = str_replace("\\","/",$path);
825
  $path = trailingslashit(get_bloginfo('wpurl')) . trailingslashit(substr($path,strpos($path,"wp-content/")));
826
  return $path;
827
  }
828
+
829
  /**
830
  * Returns the URL to default XSLT style if it exists
831
  * @since 3.0b5
843
  }
844
  return '';
845
  }
846
+
847
  /**
848
  * Sets up the default configuration
849
  *
852
  * @author Arne Brachhold
853
  */
854
  function InitOptions() {
855
+
856
  $this->_options=array();
857
  $this->_options["sm_b_prio_provider"]="GoogleSitemapGeneratorPrioByCountProvider"; //Provider for automatic priority calculation
858
  $this->_options["sm_b_filename"]="sitemap.xml"; //Name of the Sitemap file
907
  $this->_options["sm_pr_arch"]=0.3; //Priority of archives
908
  $this->_options["sm_pr_auth"]=0.3; //Priority of author pages
909
  $this->_options["sm_pr_tags"]=0.3; //Priority of tags
910
+
911
  $this->_options["sm_i_donated"]=false; //Did you donate? Thank you! :)
912
  $this->_options["sm_i_hide_donated"]=false; //And hide the thank you..
913
  $this->_options["sm_i_install_date"]=time(); //The installation date
915
  $this->_options["sm_i_hide_works"]=false; //Hide the "works?" message which appears after 15 days
916
  $this->_options["sm_i_hide_donors"]=false; //Hide the list of donations
917
  }
918
+
919
  /**
920
  * Loads the configuration from the database
921
  *
924
  * @author Arne Brachhold
925
  */
926
  function LoadOptions() {
927
+
928
  $this->InitOptions();
929
+
930
  //First init default values, then overwrite it with stored values so we can add default
931
  //values with an update which get stored by the next edit.
932
  $storedoptions=get_option("sm_options");
936
  }
937
  } else update_option("sm_options",$this->_options); //First time use, store default values
938
  }
939
+
940
  /**
941
  * Initializes a new Google Sitemap Generator
942
  *
947
  function GoogleSitemapGenerator() {
948
 
949
 
950
+
951
+
952
  }
953
+
954
  /**
955
  * Returns the version of the generator
956
  *
962
  function GetVersion() {
963
  return GoogleSitemapGeneratorLoader::GetVersion();
964
  }
965
+
966
  /**
967
  * Returns all parent classes of a class
968
  *
982
  }
983
  return $parents;
984
  }
985
+
986
  /**
987
  * Returns if a class is a subclass of another class
988
  *
995
  * @return bool true if the given class is a subclass of the other one
996
  */
997
  function IsSubclassOf($className, $parentName) {
998
+
999
  $className = strtolower($className);
1000
  $parentName = strtolower($parentName);
1001
+
1002
  if(empty($className) || empty($parentName) || !class_exists($className) || !class_exists($parentName)) return false;
1003
+
1004
  $parents=$this->GetParentClasses($className);
1005
+
1006
  return in_array($parentName,$parents);
1007
  }
1008
+
1009
  /**
1010
  * Loads up the configuration and validates the prioity providers
1011
  *
1017
  */
1018
  function Initate() {
1019
  if(!$this->_initiated) {
1020
+
1021
  //Loading language file...
1022
  //load_plugin_textdomain('sitemap');
1023
  //Hmm, doesn't work if the plugin file has its own directory.
1027
  $moFile = dirname(__FILE__) . "/lang/sitemap-" . $currentLocale . ".mo";
1028
  if(@file_exists($moFile) && is_readable($moFile)) load_textdomain('sitemap', $moFile);
1029
  }
1030
+
1031
  $this->_freqNames = array(
1032
  "always"=>__("Always","sitemap"),
1033
  "hourly"=>__("Hourly","sitemap"),
1037
  "yearly"=>__("Yearly","sitemap"),
1038
  "never"=>__("Never","sitemap")
1039
  );
1040
+
1041
+
1042
  $this->LoadOptions();
1043
  $this->LoadPages();
1044
+
1045
  //Register our own priority providers
1046
  add_filter("sm_add_prio_provider",array(&$this, 'AddDefaultPrioProviders'));
1047
+
1048
  //Let other plugins register their providers
1049
  $r = apply_filters("sm_add_prio_provider",$this->_prioProviders);
1050
+
1051
  //Check if no plugin return null
1052
  if($r != null) $this->_prioProviders = $r;
1053
+
1054
  $this->ValidatePrioProviders();
1055
+
1056
  $this->_initiated = true;
1057
  }
1058
  }
1059
+
1060
  /**
1061
  * Returns the instance of the Sitemap Generator
1062
  *
1070
  return $GLOBALS["sm_instance"];
1071
  } else return null;
1072
  }
1073
+
1074
  /**
1075
  * Returns if the sitemap building process is currently active
1076
  *
1083
  $inst = &GoogleSitemapGenerator::GetInstance();
1084
  return ($inst != null && $inst->_isActive);
1085
  }
1086
+
1087
  /**
1088
  * Returns if the compressed sitemap was activated
1089
  *
1119
  function IsCustomPostTypesSupported() {
1120
  return (function_exists("get_post_types") && function_exists("register_post_type"));
1121
  }
1122
+
1123
  /**
1124
  * Returns the list of custom taxonies. These are basically all taxonomies without categories and post tags
1125
+ *
1126
  * @since 3.1.7
1127
  * @return array Array of names of user-defined taxonomies
1128
  */
1133
 
1134
  /**
1135
  * Returns the list of custom post types. These are all custome post types except post, page and attachment
1136
+ *
1137
  * @since 3.2.5
1138
  * @author Lee Willis
1139
  * @return array Array of custom post types as per get_post_types
1144
  $post_types = array_diff($post_types,array("post","page","attachment"));
1145
  return $post_types;
1146
  }
1147
+
1148
  /**
1149
  * Enables the Google Sitemap Generator and registers the WordPress hooks
1150
  *
1157
  $GLOBALS["sm_instance"]=new GoogleSitemapGenerator();
1158
  }
1159
  }
1160
+
1161
  /**
1162
  * Checks if sitemap building after content changed is enabled and rebuild the sitemap
1163
  *
1172
  $this->Initate();
1173
  //Build one time per post and if not importing.
1174
  if((($this->GetOption("b_auto_enabled")===true && $this->_lastPostID != $postID) || $external) && (!defined('WP_IMPORTING') || WP_IMPORTING != true)) {
1175
+
1176
  //Build the sitemap directly or schedule it with WP cron
1177
  if($this->GetOption("b_auto_delay")==true && floatval($wp_version) >= 2.1) {
1178
  if(!$this->_isScheduled) {
1191
  $this->_lastPostID = $postID;
1192
  }
1193
  }
1194
+
1195
  /**
1196
  * Builds the sitemap by external request, for example other plugins.
1197
+ *
1198
  * @since 3.1.9
1199
  * @return null
1200
  */
1201
  function BuildNowRequest() {
1202
+ $this->CheckForAutoBuild(null, true);
1203
  }
1204
+
1205
  /**
1206
  * Checks if the rebuild request was send and starts to rebuilt the sitemap
1207
  *
1229
  */
1230
  function ValidatePrioProviders() {
1231
  $validProviders=array();
1232
+
1233
  for($i=0; $i<count($this->_prioProviders); $i++) {
1234
  if(class_exists($this->_prioProviders[$i])) {
1235
  if($this->IsSubclassOf($this->_prioProviders[$i],"GoogleSitemapGeneratorPrioProviderBase")) {
1238
  }
1239
  }
1240
  $this->_prioProviders=$validProviders;
1241
+
1242
  if(!$this->GetOption("b_prio_provider")) {
1243
  if(!in_array($this->GetOption("b_prio_provider"),$this->_prioProviders,true)) {
1244
  $this->SetOption("b_prio_provider","");
1261
  }
1262
  return $providers;
1263
  }
1264
+
1265
  /**
1266
  * Loads the stored pages from the database
1267
  *
1271
  */
1272
  function LoadPages() {
1273
  global $wpdb;
1274
+
1275
  $needsUpdate=false;
1276
+
1277
  $pagesString=$wpdb->get_var("SELECT option_value FROM $wpdb->options WHERE option_name = 'sm_cpages'");
1278
+
1279
  //Class sm_page was renamed with 3.0 -> rename it in serialized value for compatibility
1280
  if(!empty($pagesString) && strpos($pagesString,"sm_page")!==false) {
1281
  $pagesString = str_replace("O:7:\"sm_page\"","O:26:\"GoogleSitemapGeneratorPage\"",$pagesString);
1282
  $needsUpdate=true;
1283
  }
1284
+
1285
  if(!empty($pagesString)) {
1286
  $storedpages=unserialize($pagesString);
1287
  $this->_pages=$storedpages;
1288
  } else {
1289
  $this->_pages=array();
1290
  }
1291
+
1292
  if($needsUpdate) $this->SavePages();
1293
  }
1294
+
1295
  /**
1296
  * Saved the additional pages back to the database
1297
  *
1311
  return true;
1312
  }
1313
  }
1314
+
1315
+
1316
  /**
1317
  * Returns the URL for the sitemap file
1318
  *
1323
  * @return The URL to the Sitemap file
1324
  */
1325
  function GetXmlUrl($forceAuto=false) {
1326
+
1327
+ $name ="";
1328
+
1329
  if(!$forceAuto && $this->GetOption("b_location_mode")=="manual") {
1330
+ $name = $this->GetOption("b_fileurl_manual");
1331
  } else {
1332
+ $name = trailingslashit(get_bloginfo('url')). $this->GetOption("b_filename");
1333
+ }
1334
+
1335
+ if(substr($name,-4)!=".xml") {
1336
+ $name.=".xml";
1337
  }
1338
+
1339
+ return $name;
1340
  }
1341
 
1342
  /**
1351
  function GetZipUrl($forceAuto=false) {
1352
  return $this->GetXmlUrl($forceAuto) . ".gz";
1353
  }
1354
+
1355
  /**
1356
  * Returns the file system path to the sitemap file
1357
  *
1362
  * @return The file system path;
1363
  */
1364
  function GetXmlPath($forceAuto=false) {
1365
+
1366
+ $name ="";
1367
+
1368
  if(!$forceAuto && $this->GetOption("b_location_mode")=="manual") {
1369
+ $name = $this->GetOption("b_filename_manual");
1370
  } else {
1371
+ $name = $this->GetHomePath() . $this->GetOption("b_filename");
1372
+ }
1373
+
1374
+ if(substr($name,-4)!=".xml") {
1375
+ $name.=".xml";
1376
  }
1377
+
1378
+ return $name;
1379
  }
1380
+
1381
  /**
1382
  * Returns the file system path to the gzipped sitemap file
1383
  *
1390
  function GetZipPath($forceAuto=false) {
1391
  return $this->GetXmlPath($forceAuto) . ".gz";
1392
  }
1393
+
1394
  /**
1395
  * Returns the option value for the given key
1396
  *
1406
  return $this->_options[$key];
1407
  } else return null;
1408
  }
1409
+
1410
  /**
1411
  * Sets an option to a new value
1412
  *
1418
  */
1419
  function SetOption($key,$value) {
1420
  if(strstr($key,"sm_")!==0) $key="sm_" . $key;
1421
+
1422
  $this->_options[$key]=$value;
1423
  }
1424
+
1425
  /**
1426
  * Saves the options back to the database
1427
  *
1436
  return true;
1437
  } else return update_option("sm_options",$this->_options);
1438
  }
1439
+
1440
  /**
1441
  * Retrieves the number of comments of a post in a asso. array
1442
  * The key is the postID, the value the number of comments
1459
  }
1460
  return $comments;
1461
  }
1462
+
1463
  /**
1464
  * Calculates the full number of comments from an sm_getComments() generated array
1465
  *
1477
  }
1478
  return $commentCount;
1479
  }
1480
+
1481
  /**
1482
  * Adds a url to the sitemap. You can use this method or call AddElement directly.
1483
  *
1495
  //Strip out the last modification time if activated
1496
  if($this->GetOption('in_lastmod')===false) $lastMod = 0;
1497
  $page = new GoogleSitemapGeneratorPage($loc, $priority, $changeFreq, $lastMod);
1498
+
1499
  $this->AddElement($page);
1500
  }
1501
+
1502
  /**
1503
  * Adds an element to the sitemap
1504
  *
1509
  */
1510
  function AddElement(&$page) {
1511
  if(empty($page)) return;
1512
+
1513
  $s = $page->Render();
1514
+
1515
  if($this->_fileZipHandle && $this->IsGzipEnabled()) {
1516
  gzwrite($this->_fileZipHandle,$s);
1517
  }
1518
+
1519
  if($this->_fileHandle && $this->GetOption("b_xml")) {
1520
  fwrite($this->_fileHandle,$s);
1521
  }
1522
  }
1523
+
1524
  /**
1525
  * Checks if a file is writable and tries to make it if not.
1526
  *
1549
  //we can write, return 1/true/happy dance.
1550
  return true;
1551
  }
1552
+
1553
  /**
1554
  * Adds the sitemap to the virtual robots.txt file
1555
  * This function is executed by WordPress with the do_robots hook
1556
+ *
1557
  * @since 3.1.2
1558
  */
1559
  function DoRobots() {
1564
  if($this->IsGzipEnabled()) {
1565
  $smUrl = $this->GetZipUrl();
1566
  }
1567
+
1568
  echo "\nSitemap: " . $smUrl . "\n";
1569
  }
1570
  }
1571
+
1572
  /**
1573
  * Builds the sitemap and writes it into a xml file.
1574
+ *
1575
  * ATTENTION PLUGIN DEVELOPERS! DONT CALL THIS METHOD DIRECTLY!
1576
  * The method is probably not available, since it is only loaded when needed.
1577
  * Use do_action("sm_rebuild"); if you want to rebuild the sitemap.
1585
  function BuildSitemap() {
1586
  global $wpdb, $posts, $wp_version;
1587
  $this->Initate();
1588
+
1589
  if($this->GetOption("b_memory")!='') {
1590
  @ini_set("memory_limit",$this->GetOption("b_memory"));
1591
  }
1592
+
1593
  if($this->GetOption("b_time")!=-1) {
1594
  @set_time_limit($this->GetOption("b_time"));
1595
  }
1596
+
1597
  //This object saves the status information of the script directly to the database
1598
  $status = new GoogleSitemapGeneratorStatus();
1599
+
1600
  //Other plugins can detect if the building process is active
1601
  $this->_isActive = true;
1602
+
1603
  //$this->AddElement(new GoogleSitemapGeneratorXmlEntry());
1604
+
1605
  //Debug mode?
1606
  $debug=$this->GetOption("b_debug");
1607
+
1608
  if($this->GetOption("b_xml")) {
1609
  $fileName = $this->GetXmlPath();
1610
  $status->StartXml($this->GetXmlPath(),$this->GetXmlUrl());
1611
+
1612
  if($this->IsFileWritable($fileName)) {
1613
+
1614
  $this->_fileHandle = fopen($fileName,"w");
1615
  if(!$this->_fileHandle) $status->EndXml(false,"Not openable");
1616
+
1617
  } else $status->EndXml(false,"not writable");
1618
  }
1619
+
1620
  //Write gzipped sitemap file
1621
  if($this->IsGzipEnabled()) {
1622
  $fileName = $this->GetZipPath();
1623
  $status->StartZip($this->GetZipPath(),$this->GetZipUrl());
1624
+
1625
  if($this->IsFileWritable($fileName)) {
1626
+
1627
  $this->_fileZipHandle = gzopen($fileName,"w1");
1628
  if(!$this->_fileZipHandle) $status->EndZip(false,"Not openable");
1629
+
1630
  } else $status->EndZip(false,"not writable");
1631
  }
1632
+
1633
  if(!$this->_fileHandle && !$this->_fileZipHandle) {
1634
  $status->End();
1635
  return;
1636
  }
1637
+
1638
+
1639
  //Content of the XML file
1640
  $this->AddElement(new GoogleSitemapGeneratorXmlEntry('<?xml version="1.0" encoding="UTF-8"' . '?' . '>'));
1641
+
1642
  $styleSheet = ($this->GetDefaultStyle() && $this->GetOption('b_style_default')===true?$this->GetDefaultStyle():$this->GetOption('b_style'));
1643
+
1644
  if(!empty($styleSheet)) {
1645
  $this->AddElement(new GoogleSitemapGeneratorXmlEntry('<' . '?xml-stylesheet type="text/xsl" href="' . $styleSheet . '"?' . '>'));
1646
  }
1647
+
1648
  $this->AddElement(new GoogleSitemapGeneratorDebugEntry("generator=\"wordpress/" . get_bloginfo('version') . "\""));
1649
  $this->AddElement(new GoogleSitemapGeneratorDebugEntry("sitemap-generator-url=\"http://www.arnebrachhold.de\" sitemap-generator-version=\"" . $this->GetVersion() . "\""));
1650
  $this->AddElement(new GoogleSitemapGeneratorDebugEntry("generated-on=\"" . date(get_option("date_format") . " " . get_option("time_format")) . "\""));
1651
+
1652
  //All comments as an asso. Array (postID=>commentCount)
1653
  $comments=($this->GetOption("b_prio_provider")!=""?$this->GetComments():array());
1654
+
1655
  //Full number of comments
1656
  $commentCount=(count($comments)>0?$this->GetCommentCount($comments):0);
1657
+
1658
  if($debug && $this->GetOption("b_prio_provider")!="") {
1659
  $this->AddElement(new GoogleSitemapGeneratorDebugEntry("Debug: Total comment count: " . $commentCount));
1660
  }
1661
+
1662
  //Go XML!
1663
  $this->AddElement(new GoogleSitemapGeneratorXmlEntry('<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">'));
1664
+
1665
  $home = get_bloginfo('url');
1666
+
1667
  $homePid = 0;
1668
+
1669
  //Add the home page (WITH a slash!)
1670
  if($this->GetOption("in_home")) {
1671
  if('page' == get_option('show_on_front') && get_option('page_on_front')) {
1679
  $this->AddUrl(trailingslashit($home),$this->GetTimestampFromMySql(get_lastpostmodified('GMT')),$this->GetOption("cf_home"),$this->GetOption("pr_home"));
1680
  }
1681
  }
1682
+
1683
  //Add the posts
1684
  if($this->GetOption("in_posts") || $this->GetOption("in_pages")) {
1685
+
1686
  if($debug) $this->AddElement(new GoogleSitemapGeneratorDebugEntry("Debug: Start Postings"));
1687
+
1688
  //Pre 2.1 compatibility. 2.1 introduced 'future' as post_status so we don't need to check post_date
1689
  $wpCompat = (floatval($wp_version) < 2.1);
1690
+
1691
  $useQTransLate = false; //function_exists('qtrans_convertURL') && function_exists('qtrans_getEnabledLanguages'); Not really working yet
1692
+
1693
  $excludes = $this->GetOption('b_exclude'); //Excluded posts and pages (user enetered ID)
1694
+
1695
  $exclCats = $this->GetOption("b_exclude_cats"); // Excluded cats
1696
+
1697
  if($exclCats && count($exclCats)>0 && $this->IsTaxonomySupported()) {
1698
+
1699
  $excludedCatPosts = get_objects_in_term($exclCats,"category"); // Get all posts in excl. cats. Unforttunately this also gives us pages, revisions and so on...
1700
+
1701
  //Remove the pages, revisions etc from the exclude by category list, because they are always in the uncategorized one.
1702
  if(count($excludedCatPosts)>0) {
1703
  $exclPages = $wpdb->get_col("SELECT ID FROM `" . $wpdb->posts . "` WHERE post_type!='post' AND ID IN ('" . implode("','",$excludedCatPosts) . "')");
1704
+
1705
  $exclPages = array_map('intval', $exclPages);
1706
+
1707
  //Remove the pages from the exlusion list before
1708
  if(count($exclPages)>0) $excludedCatPosts = array_diff($excludedCatPosts, $exclPages);
1709
+
1710
  //Merge the category exclusion list with the users one
1711
  if(count($excludedCatPosts)>0) $excludes = array_merge($excludes, $excludedCatPosts);
1712
  }
1713
  }
1714
+
1715
+
1716
  $contentStmt = '';
1717
  if($useQTransLate) {
1718
  $contentStmt.=', post_content ';
1719
  }
1720
+
1721
  $postPageStmt = '';
1722
+
1723
  $inSubPages = ($this->GetOption('in_posts_sub')===true);
1724
+
1725
  if($inSubPages && $this->GetOption('in_posts')===true) {
1726
  $pageDivider='<!--nextpage-->';
1727
  $postPageStmt = ", (character_length(`post_content`) - character_length(REPLACE(`post_content`, '$pageDivider', ''))) / " . strlen($pageDivider) . " as postPages";
1728
  }
1729
+
1730
  $sql="SELECT `ID`, `post_author`, `post_date`, `post_date_gmt`, `post_status`, `post_name`, `post_modified`, `post_modified_gmt`, `post_parent`, `post_type` $postPageStmt $contentStmt FROM `" . $wpdb->posts . "` WHERE ";
1731
+
1732
  $where = '(';
1733
+
1734
  if($this->GetOption('in_posts')) {
1735
  //WP < 2.1: posts are post_status = publish
1736
  //WP >= 2.1: post_type must be 'post', no date check required because future posts are post_status='future'
1745
  $where.=" (post_status = 'publish' AND (post_type = 'post' OR post_type = '')) ";
1746
  }
1747
  }
1748
+
1749
  if($this->GetOption('in_pages')) {
1750
  if($this->GetOption('in_posts')) {
1751
  $where.=" OR ";
1758
  $where.=" (post_status = 'publish' AND post_type = 'page') ";
1759
  }
1760
  }
1761
+
1762
  $where.=") ";
1763
+
1764
+
1765
  if(is_array($excludes) && count($excludes)>0) {
1766
  $where.=" AND ID NOT IN ('" . implode("','",$excludes) . "')";
1767
  }
1768
+
1769
  $where.=" AND post_password='' ORDER BY post_modified DESC";
1770
+
1771
  $sql .= $where;
1772
+
1773
  if($this->GetOption("b_max_posts")>0) {
1774
  $sql.=" LIMIT 0," . $this->GetOption("b_max_posts");
1775
  }
1776
 
1777
  $postCount = intval($wpdb->get_var("SELECT COUNT(*) AS cnt FROM `" . $wpdb->posts . "` WHERE ". $where,0,0));
1778
+
1779
  //Create a new connection because we are using mysql_unbuffered_query and don't want to disturb the WP connection
1780
  //Safe Mode for other plugins which use mysql_query() without a connection handler and will destroy our resultset :(
1781
  $con = $postRes = null;
1782
+
1783
  //In 2.2, a bug which prevented additional DB connections was fixed
1784
  if(floatval($wp_version) < 2.2) {
1785
  $this->SetOption("b_safemode",true);
1786
  }
1787
+
1788
  if($this->GetOption("b_safemode")===true) {
1789
  $postRes = mysql_query($sql,$wpdb->dbh);
1790
  if(!$postRes) {
1802
  return;
1803
  }
1804
  $postRes = mysql_unbuffered_query($sql,$con);
1805
+
1806
  if(!$postRes) {
1807
  trigger_error("MySQL unbuffered query failed: " . mysql_error(),E_USER_NOTICE);
1808
  return;
1809
  }
1810
  }
1811
+
1812
  if($postRes) {
1813
+
1814
  //#type $prioProvider GoogleSitemapGeneratorPrioProviderBase
1815
  $prioProvider=NULL;
1816
+
1817
  if($this->GetOption("b_prio_provider") != '') {
1818
  $providerClass=$this->GetOption('b_prio_provider');
1819
  $prioProvider = new $providerClass($commentCount,$postCount);
1820
  }
1821
+
1822
  //$posts is used by Alex King's Popularity Contest plugin
1823
  //if($posts == null || !is_array($posts)) {
1824
  // $posts = &$postRes;
1825
  //}
1826
+
1827
  $z = 1;
1828
  $zz = 1;
1829
+
1830
  //Default priorities
1831
  $default_prio_posts = $this->GetOption('pr_posts');
1832
  $default_prio_pages = $this->GetOption('pr_pages');
1833
+
1834
  //Change frequencies
1835
  $cf_pages = $this->GetOption('cf_pages');
1836
  $cf_posts = $this->GetOption('cf_posts');
1837
+
1838
  $minPrio=$this->GetOption('pr_posts_min');
1839
+
1840
+
1841
  //Cycle through all posts and add them
1842
  while($post = mysql_fetch_object($postRes)) {
1843
+
1844
  //Fill the cache with our DB result. Since it's incomplete (no text-content for example), we will clean it later.
1845
  $cache = array(&$post);
1846
  update_post_cache($cache);
1847
+
1848
  //Set the current working post for other plugins which depend on "the loop"
1849
  $GLOBALS['post'] = &$post;
1850
+
1851
  $permalink = get_permalink($post->ID);
1852
  if($permalink != $home && $post->ID != $homePid) {
1853
+
1854
  $isPage = false;
1855
  if($wpCompat) {
1856
  $isPage = ($post->post_status == 'static');
1857
  } else {
1858
  $isPage = ($post->post_type == 'page');
1859
  }
1860
+
1861
+
1862
  //Default Priority if auto calc is disabled
1863
  $prio = 0;
1864
+
1865
  if($isPage) {
1866
  //Priority for static pages
1867
  $prio = $default_prio_pages;
1869
  //Priority for normal posts
1870
  $prio = $default_prio_posts;
1871
  }
1872
+
1873
  //If priority calc. is enabled, calculate (but only for posts, not pages)!
1874
  if($prioProvider !== null && !$isPage) {
1875
 
1879
 
1880
  if($debug) $this->AddElement(new GoogleSitemapGeneratorDebugEntry('Debug: Priority report of postID ' . $post->ID . ': Comments: ' . $cmtcnt . ' of ' . $commentCount . ' = ' . $prio . ' points'));
1881
  }
1882
+
1883
  if(!$isPage && $minPrio>0 && $prio<$minPrio) {
1884
  $prio = $minPrio;
1885
  }
1886
+
1887
  //Add it
1888
  $this->AddUrl($permalink,$this->GetTimestampFromMySql(($post->post_modified_gmt && $post->post_modified_gmt!='0000-00-00 00:00:00'?$post->post_modified_gmt:$post->post_date_gmt)),($isPage?$cf_pages:$cf_posts),$prio);
1889
+
1890
  if($inSubPages) {
1891
  $subPage = '';
1892
  for($p = 1; $p <= $post->postPages; $p++) {
1899
  $this->AddUrl($subPage,$this->GetTimestampFromMySql(($post->post_modified_gmt && $post->post_modified_gmt!='0000-00-00 00:00:00'?$post->post_modified_gmt:$post->post_date_gmt)),($isPage?$cf_pages:$cf_posts),$prio);
1900
  }
1901
  }
1902
+
1903
  // Multilingual Support with qTranslate, thanks to Qian Qin
1904
  if($useQTransLate) {
1905
  global $q_config;
1910
  }
1911
  }
1912
  }
1913
+
1914
  //Update the status every 100 posts and at the end.
1915
  //If the script breaks because of memory or time limit,
1916
  //we have a "last reponded" value which can be compared to the server settings
1918
  $status->SaveStep($z);
1919
  $zz=0;
1920
  } else $zz++;
1921
+
1922
  $z++;
1923
+
1924
  //Clean cache because it's incomplete
1925
  if(version_compare($wp_version,"2.5",">=")) {
1926
  //WP 2.5 makes a mysql query for every clean_post_cache to clear the child cache
1934
  }
1935
  unset($postRes);
1936
  unset($prioProvider);
1937
+
1938
  if($this->GetOption("b_safemode")!==true && $con) mysql_close($con);
1939
  }
1940
  if($debug) $this->AddElement(new GoogleSitemapGeneratorDebugEntry("Debug: End Postings"));
1941
  }
1942
+
1943
  //Add the cats
1944
  if($this->GetOption("in_cats")) {
1945
  if($debug) $this->AddElement(new GoogleSitemapGeneratorDebugEntry("Debug: Start Cats"));
1946
+
1947
  $exclCats = $this->GetOption("b_exclude_cats"); // Excluded cats
1948
  if($exclCats == null) $exclCats=array();
1949
+
1950
  if(!$this->IsTaxonomySupported()) {
1951
+
1952
  $catsRes=$wpdb->get_results("
1953
  SELECT
1954
  c.cat_ID AS ID,
1983
  }
1984
  if($debug) $this->AddElement(new GoogleSitemapGeneratorDebugEntry("Debug: End Cats"));
1985
  }
1986
+
1987
  //Add the archives
1988
  if($this->GetOption("in_arch")) {
1989
  if($debug) $this->AddElement(new GoogleSitemapGeneratorDebugEntry("Debug: Start Archive"));
2010
  post_date_gmt DESC");
2011
  if ($arcresults) {
2012
  foreach ($arcresults as $arcresult) {
2013
+
2014
  $url = get_month_link($arcresult->year, $arcresult->month);
2015
  $changeFreq="";
2016
+
2017
  //Archive is the current one
2018
  if($arcresult->month==date("n") && $arcresult->year==date("Y")) {
2019
  $changeFreq=$this->GetOption("cf_arch_curr");
2020
  } else { // Archive is older
2021
  $changeFreq=$this->GetOption("cf_arch_old");
2022
  }
2023
+
2024
  $this->AddUrl($url,$this->GetTimestampFromMySql($arcresult->last_mod),$changeFreq,$this->GetOption("pr_arch"));
2025
  }
2026
  }
2027
  if($debug) $this->AddElement(new GoogleSitemapGeneratorDebugEntry("Debug: End Archive"));
2028
  }
2029
+
2030
  //Add the author pages
2031
  if($this->GetOption("in_auth")) {
2032
  if($debug) $this->AddElement(new GoogleSitemapGeneratorDebugEntry("Debug: Start Author pages"));
2033
+
2034
  $linkFunc = null;
2035
+
2036
  //get_author_link is deprecated in WP 2.1, try to use get_author_posts_url first.
2037
  if(function_exists('get_author_posts_url')) {
2038
  $linkFunc = 'get_author_posts_url';
2039
  } else if(function_exists('get_author_link')) {
2040
  $linkFunc = 'get_author_link';
2041
  }
2042
+
2043
  //Who knows what happens in later WP versions, so check again if it worked
2044
  if($linkFunc !== null) {
2045
  //Unfortunately there is no API function to get all authors, so we have to do it the dirty way...
2061
  GROUP BY
2062
  u.ID,
2063
  u.user_nicename";
2064
+
2065
  $authors = $wpdb->get_results($sql);
2066
+
2067
  if($authors && is_array($authors)) {
2068
  foreach($authors as $author) {
2069
  if($debug) if($debug) $this->AddElement(new GoogleSitemapGeneratorDebugEntry("Author-ID:" . $author->ID));
2075
  //Too bad, no author pages for you :(
2076
  if($debug) $this->AddElement(new GoogleSitemapGeneratorDebugEntry("Debug: No valid author link function found"));
2077
  }
2078
+
2079
  if($debug) $this->AddElement(new GoogleSitemapGeneratorDebugEntry("Debug: End Author pages"));
2080
  }
2081
+
2082
  //Add tag pages
2083
  if($this->GetOption("in_tags") && $this->IsTaxonomySupported()) {
2084
  if($debug) $this->AddElement(new GoogleSitemapGeneratorDebugEntry("Debug: Start Tags"));
2090
  }
2091
  if($debug) $this->AddElement(new GoogleSitemapGeneratorDebugEntry("Debug: End Tags"));
2092
  }
2093
+
2094
  //Add custom taxonomy pages
2095
  if($this->GetOption("in_tax") && $this->IsTaxonomySupported()) {
2096
+
2097
  if($debug) $this->AddElement(new GoogleSitemapGeneratorDebugEntry("Debug: Start custom taxonomies"));
2098
+
2099
  $enabledTaxonomies = $this->GetOption("in_tax");
2100
+
2101
  $taxList = array();
2102
+
2103
  foreach ($enabledTaxonomies as $taxName) {
2104
  $taxonomy = get_taxonomy($taxName);
2105
  if($taxonomy) $taxList[] = $wpdb->escape($taxonomy->name);
2106
  }
2107
+
2108
  if(count($taxList)>0) {
2109
  //We're selecting all term information (t.*) plus some additional fields
2110
  //like the last mod date and the taxonomy name, so WP doesnt need to make
2132
  AND tt.taxonomy IN ('" . implode("','",$taxList) . "')
2133
  GROUP BY
2134
  t.term_id";
2135
+
2136
  $termInfo = $wpdb->get_results($sql);
2137
+
2138
  foreach($termInfo AS $term) {
2139
  $this->AddUrl(get_term_link($term->slug,$term->_taxonomy),$term->_mod_date ,$this->GetOption("cf_tags"),$this->GetOption("pr_tags"));
2140
  }
2142
 
2143
  if($debug) $this->AddElement(new GoogleSitemapGeneratorDebugEntry("Debug: End custom taxonomies"));
2144
  }
2145
+
2146
  //Add the custom pages
2147
  if($debug) $this->AddElement(new GoogleSitemapGeneratorDebugEntry("Debug: Start Custom Pages"));
2148
  if($this->_pages && is_array($this->_pages) && count($this->_pages)>0) {
2151
  $this->AddUrl($page->GetUrl(),$page->getLastMod(),$page->getChangeFreq(),$page->getPriority());
2152
  }
2153
  }
2154
+
2155
  if($debug) $this->AddElement(new GoogleSitemapGeneratorDebugEntry("Debug: End Custom Pages"));
2156
+
2157
  if($debug) $this->AddElement(new GoogleSitemapGeneratorDebugEntry("Debug: Start additional URLs"));
2158
+
2159
  do_action('sm_buildmap');
2160
+
2161
  if($debug) $this->AddElement(new GoogleSitemapGeneratorDebugEntry("Debug: End additional URLs"));
2162
+
2163
  $this->AddElement(new GoogleSitemapGeneratorXmlEntry("</urlset>"));
2164
+
2165
 
2166
  $pingUrl='';
2167
+
2168
  if($this->GetOption("b_xml")) {
2169
  if($this->_fileHandle && fclose($this->_fileHandle)) {
2170
  $this->_fileHandle = null;
2172
  $pingUrl=$this->GetXmlUrl();
2173
  } else $status->EndXml(false,"Could not close the sitemap file.");
2174
  }
2175
+
2176
  if($this->IsGzipEnabled()) {
2177
  if($this->_fileZipHandle && fclose($this->_fileZipHandle)) {
2178
  $this->_fileZipHandle = null;
2180
  $pingUrl=$this->GetZipUrl();
2181
  } else $status->EndZip(false,"Could not close the zipped sitemap file");
2182
  }
2183
+
2184
  //Ping Google
2185
  if($this->GetOption("b_ping") && !empty($pingUrl)) {
2186
  $sPingUrl="http://www.google.com/webmasters/sitemaps/ping?sitemap=" . urlencode($pingUrl);
2187
  $status->StartGooglePing($sPingUrl);
2188
  $pingres=$this->RemoteOpen($sPingUrl);
2189
+
2190
  if($pingres==NULL || $pingres===false) {
2191
  $status->EndGooglePing(false,$this->_lastError);
2192
  trigger_error("Failed to ping Google: " . htmlspecialchars(strip_tags($pingres)),E_USER_NOTICE);
2194
  $status->EndGooglePing(true);
2195
  }
2196
  }
2197
+
2198
+
2199
  //Ping Bing
2200
  if($this->GetOption("b_pingmsn") && !empty($pingUrl)) {
2201
  $sPingUrl="http://www.bing.com/webmaster/ping.aspx?siteMap=" . urlencode($pingUrl);
2209
  $status->EndMsnPing(true);
2210
  }
2211
  }
2212
+
2213
  $status->End();
2214
+
2215
+
2216
  $this->_isActive = false;
2217
+
2218
  //done...
2219
  return $status;
2220
  }
2221
+
2222
  /**
2223
  * Tries to ping a specific service showing as much as debug output as possible
2224
  * @since 3.1.9
2225
  * @return null
2226
  */
2227
  function ShowPingResult() {
2228
+
2229
  check_admin_referer('sitemap');
2230
+
2231
  if(!current_user_can("administrator")) {
2232
  echo '<p>Please log in as admin</p>';
2233
  return;
2234
  }
2235
+
2236
  $service = !empty($_GET["sm_ping_service"])?$_GET["sm_ping_service"]:null;
2237
+
2238
  $status = &GoogleSitemapGeneratorStatus::Load();
2239
+
2240
  if(!$status) die("No build status yet. Build the sitemap first.");
2241
+
2242
  $url = null;
2243
 
2244
  switch($service) {
2247
  break;
2248
  case "msn":
2249
  $url = $status->_msnUrl;
2250
+ break;
2251
  }
2252
+
2253
  if(empty($url)) die("Invalid ping url");
2254
+
2255
  echo '<html><head><title>Ping Test</title>';
2256
  if(function_exists('wp_admin_css')) wp_admin_css('css/global',true);
2257
  echo '</head><body><h1>Ping Test</h1>';
2258
+
2259
  echo '<p>Trying to ping: <a href="' . $url . '">' . $url . '</a>. The sections below should give you an idea whats going on.</p>';
2260
+
2261
  //Try to get as much as debug / error output as possible
2262
  $errLevel = error_reporting(E_ALL);
2263
  $errDisplay = ini_set("display_errors",1);
2264
  if(!defined('WP_DEBUG')) define('WP_DEBUG',true);
2265
+
2266
  echo '<h2>Errors, Warnings, Notices:</h2>';
2267
+
2268
  if(WP_DEBUG == false) echo "<i>WP_DEBUG was set to false somewhere before. You might not see all debug information until you remove this declaration!</i><br />";
2269
  if(ini_get("display_errors")!=1) echo "<i>Your display_errors setting currently prevents the plugin from showing errors here. Please check your webserver logfile instead.</i><br />";
2270
+
2271
  $res = $this->RemoteOpen($url);
2272
+
2273
  echo '<h2>Result (text only):</h2>';
2274
 
2275
  echo wp_kses($res,array('a' => array('href' => array()),'p' => array(), 'ul' => array(), 'ol' => array(), 'li' => array()));
2276
+
2277
  echo '<h2>Result (HTML):</h2>';
2278
+
2279
  echo htmlspecialchars($res);
2280
 
2281
  //Revert back old values
2284
  echo '</body></html>';
2285
  exit;
2286
  }
2287
+
2288
  /**
2289
  * Opens a remote file using the WordPress API or Snoopy
2290
  * @since 3.0
2296
  */
2297
  function RemoteOpen($url,$method = 'get', $postData = null, $timeout = 10) {
2298
  global $wp_version;
2299
+
2300
  //Before WP 2.7, wp_remote_fopen was quite crappy so Snoopy was favoured.
2301
  if(floatval($wp_version) < 2.7) {
2302
  if(!file_exists(ABSPATH . 'wp-includes/class-snoopy.php')) {
2303
  trigger_error('Snoopy Web Request failed: Snoopy not found.',E_USER_NOTICE);
2304
  return false; //Hoah?
2305
  }
2306
+
2307
  require_once( ABSPATH . 'wp-includes/class-snoopy.php');
2308
+
2309
  $s = new Snoopy();
2310
+
2311
  $s->read_timeout = $timeout;
2312
+
2313
  if($method == 'get') {
2314
  $s->fetch($url);
2315
  } else {
2316
  $s->submit($url,$postData);
2317
  }
2318
+
2319
  if($s->status != "200") {
2320
  trigger_error('Snoopy Web Request failed: Status: ' . $s->status . "; Content: " . htmlspecialchars($s->results),E_USER_NOTICE);
2321
  }
2322
+
2323
  return $s->results;
2324
+
2325
  } else {
2326
+
2327
  $options = array();
2328
  $options['timeout'] = $timeout;
2329
+
2330
  if($method == 'get') {
2331
  $response = wp_remote_get( $url, $options );
2332
  } else {
2333
  $response = wp_remote_post($url, array_merge($options,array('body'=>$postData)));
2334
  }
2335
+
2336
  if ( is_wp_error( $response ) ) {
2337
  $errs = $response->get_error_messages();
2338
  $errs = htmlspecialchars(implode('; ', $errs));
2339
  trigger_error('WP HTTP API Web Request failed: ' . $errs,E_USER_NOTICE);
2340
  return false;
2341
  }
2342
+
2343
  return $response['body'];
2344
  }
2345
+
2346
  return false;
2347
  }
2348
+
2349
  /**
2350
  * Echos option fields for an select field containing the valid change frequencies
2351
  *
2356
  * @return all valid change frequencies as html option fields
2357
  */
2358
  function HtmlGetFreqNames($currentVal) {
2359
+
2360
  foreach($this->_freqNames AS $k=>$v) {
2361
  echo "<option value=\"$k\" " . $this->HtmlGetSelected($k,$currentVal) .">" . $v . "</option>";
2362
  }
2363
  }
2364
+
2365
  /**
2366
  * Echos option fields for an select field containing the valid priorities (0- 1.0)
2367
  *
2382
  echo "</option>";
2383
  }
2384
  }
2385
+
2386
  /**
2387
  * Returns the checked attribute if the given values match
2388
  *
2397
  if($val==$equals) return $this->HtmlGetAttribute("checked");
2398
  else return "";
2399
  }
2400
+
2401
  /**
2402
  * Returns the selected attribute if the given values match
2403
  *
2412
  if($val==$equals) return $this->HtmlGetAttribute("selected");
2413
  else return "";
2414
  }
2415
+
2416
  /**
2417
  * Returns an formatted attribute. If the value is NULL, the name will be used.
2418
  *
2427
  if($value==NULL) $value=$attr;
2428
  return " " . $attr . "=\"" . $value . "\" ";
2429
  }
2430
+
2431
  /**
2432
  * Returns an array with GoogleSitemapGeneratorPage objects which is generated from POST values
2433
  *
2440
  function HtmlApplyPages() {
2441
  // Array with all page URLs
2442
  $pages_ur=(!isset($_POST["sm_pages_ur"]) || !is_array($_POST["sm_pages_ur"])?array():$_POST["sm_pages_ur"]);
2443
+
2444
  //Array with all priorities
2445
  $pages_pr=(!isset($_POST["sm_pages_pr"]) || !is_array($_POST["sm_pages_pr"])?array():$_POST["sm_pages_pr"]);
2446
+
2447
  //Array with all change frequencies
2448
  $pages_cf=(!isset($_POST["sm_pages_cf"]) || !is_array($_POST["sm_pages_cf"])?array():$_POST["sm_pages_cf"]);
2449
+
2450
  //Array with all lastmods
2451
  $pages_lm=(!isset($_POST["sm_pages_lm"]) || !is_array($_POST["sm_pages_lm"])?array():$_POST["sm_pages_lm"]);
2452
 
2472
 
2473
  return $pages;
2474
  }
2475
+
2476
  /**
2477
  * Converts a mysql datetime value into a unix timestamp
2478
+ *
2479
  * @param The value in the mysql datetime format
2480
  * @return int The time in seconds
2481
  */
2485
  list($hour,$min,$sec) = explode(':',$hours);
2486
  return mktime(intval($hour), intval($min), intval($sec), intval($month), intval($day), intval($year));
2487
  }
2488
+
2489
  /**
2490
  * Returns a link pointing to a spcific page of the authors website
2491
+ *
2492
  * @since 3.0
2493
  * @param The page to link to
2494
  * @return string The full url
2496
  function GetRedirectLink($redir) {
2497
  return trailingslashit("http://www.arnebrachhold.de/redir/" . $redir);
2498
  }
2499
+
2500
  /**
2501
  * Returns a link pointing back to the plugin page in WordPress
2502
+ *
2503
  * @since 3.0
2504
  * @return string The full url
2505
  */
2509
  //admin_url was added in WP 2.6.0
2510
  if(function_exists("admin_url")) $url = admin_url("options-general.php?page=" . GoogleSitemapGeneratorLoader::GetBaseName());
2511
  else $url = $_SERVER['PHP_SELF'] . "?page=" . GoogleSitemapGeneratorLoader::GetBaseName();
2512
+
2513
  //Some browser cache the page... great! So lets add some no caching params depending on the WP and plugin version
2514
  $url.='&sm_wpv=' . $wp_version . '&sm_pv=' . GoogleSitemapGeneratorLoader::GetVersion();
2515
+
2516
  return $url;
2517
  }
2518
+
2519
  /**
2520
  * Shows the option page of the plugin. Before 3.1.1, this function was basically the UI, afterwards the UI was outsourced to another class
2521
+ *
2522
  * @see GoogleSitemapGeneratorUI
2523
  * @since 3.0
2524
  * @return bool
2525
  */
2526
  function HtmlShowOptionsPage() {
2527
+
2528
  $ui = $this->GetUI();
2529
  if($ui) {
2530
  $ui->HtmlShowOptionsPage();
2531
  return true;
2532
  }
2533
+
2534
  return false;
2535
  }
2536
+
2537
  /**
2538
  * Includes the user interface class and intializes it
2539
+ *
2540
  * @since 3.1.1
2541
  * @see GoogleSitemapGeneratorUI
2542
  * @return GoogleSitemapGeneratorUI
2544
  function GetUI() {
2545
 
2546
  global $wp_version;
2547
+
2548
  if($this->_ui === null) {
2549
+
2550
  $className='GoogleSitemapGeneratorUI';
2551
  $fileName='sitemap-ui.php';
2552
 
2553
  if(!class_exists($className)) {
2554
+
2555
  $path = trailingslashit(dirname(__FILE__));
2556
+
2557
  if(!file_exists( $path . $fileName)) return false;
2558
  require_once($path. $fileName);
2559
  }
2560
+
2561
  $this->_ui = new $className($this);
2562
+
2563
  }
2564
+
2565
  return $this->_ui;
2566
  }
2567
+
2568
  function HtmlShowHelp() {
2569
+
2570
+
2571
  }
2572
  }
sitemap-ui.php CHANGED
@@ -1,7 +1,7 @@
1
  <?php
2
  /*
3
-
4
- $Id: sitemap-ui.php 583237 2012-08-08 21:06:12Z arnee $
5
 
6
  */
7
 
@@ -13,18 +13,18 @@ class GoogleSitemapGeneratorUI {
13
  * @var GoogleSitemapGenerator
14
  */
15
  var $sg = null;
16
-
17
  var $mode = 21;
18
 
19
  function GoogleSitemapGeneratorUI(&$sitemapBuilder) {
20
  global $wp_version;
21
  $this->sg = &$sitemapBuilder;
22
-
23
  if(floatval($wp_version) >= 2.7) {
24
  $this->mode = 27;
25
  }
26
  }
27
-
28
  function HtmlPrintBoxHeader($id, $title, $right = false) {
29
  if($this->mode == 27) {
30
  ?>
@@ -38,13 +38,13 @@ class GoogleSitemapGeneratorUI {
38
  <?php if(!$right): ?><div class="dbx-h-andle-wrapper"><?php endif; ?>
39
  <h3 class="dbx-handle"><?php echo $title ?></h3>
40
  <?php if(!$right): ?></div><?php endif; ?>
41
-
42
  <?php if(!$right): ?><div class="dbx-c-ontent-wrapper"><?php endif; ?>
43
  <div class="dbx-content">
44
  <?php
45
  }
46
  }
47
-
48
  function HtmlPrintBoxFooter( $right = false) {
49
  if($this->mode == 27) {
50
  ?>
@@ -59,7 +59,7 @@ class GoogleSitemapGeneratorUI {
59
  <?php
60
  }
61
  }
62
-
63
  /**
64
  * Displays the option page
65
  *
@@ -69,27 +69,27 @@ class GoogleSitemapGeneratorUI {
69
  */
70
  function HtmlShowOptionsPage() {
71
  global $wp_version;
72
-
73
  $snl = false; //SNL
74
-
75
  $this->sg->Initate();
76
-
77
  $message="";
78
-
79
  if(!empty($_REQUEST["sm_rebuild"])) { //Pressed Button: Rebuild Sitemap
80
  check_admin_referer('sitemap');
81
-
82
  //Clear any outstanding build cron jobs
83
  if(function_exists('wp_clear_scheduled_hook')) wp_clear_scheduled_hook('sm_build_cron');
84
-
85
  if(isset($_GET["sm_do_debug"]) && $_GET["sm_do_debug"]=="true") {
86
-
87
  //Check again, just for the case that something went wrong before
88
  if(!current_user_can("administrator")) {
89
  echo '<p>Please log in as admin</p>';
90
  return;
91
  }
92
-
93
  $oldErr = error_reporting(E_ALL);
94
  $oldIni = ini_set("display_errors",1);
95
 
@@ -116,7 +116,7 @@ class GoogleSitemapGeneratorUI {
116
  $os = $wpdb->get_results( "SELECT option_name, option_value FROM $wpdb->options");
117
  foreach ( (array) $os as $o ) $opts[$o->option_name] = $o->option_value;
118
  }
119
-
120
  $popts = array();
121
  foreach($opts as $k=>$v) {
122
  //Try to filter out passwords etc...
@@ -138,7 +138,7 @@ class GoogleSitemapGeneratorUI {
138
  echo '<pre>';
139
  var_dump($GLOBALS['wpdb']->queries);
140
  echo '</pre>';
141
-
142
  $total = 0;
143
  foreach($GLOBALS['wpdb']->queries as $q) {
144
  $total+=$q[1];
@@ -161,7 +161,7 @@ class GoogleSitemapGeneratorUI {
161
  } else {
162
  $this->sg->BuildSitemap();
163
  $redirURL = $this->sg->GetBackLink() . '&sm_fromrb=true';
164
-
165
  //Redirect so the sm_rebuild GET parameter no longer exists.
166
  @header("location: " . $redirURL);
167
  //If there was already any other output, the header redirect will fail
@@ -171,23 +171,28 @@ class GoogleSitemapGeneratorUI {
171
  }
172
  } else if (!empty($_POST['sm_update'])) { //Pressed Button: Update Config
173
  check_admin_referer('sitemap');
174
-
175
  if(isset($_POST['sm_b_style']) && $_POST['sm_b_style'] == $this->sg->getDefaultStyle()) {
176
  $_POST['sm_b_style_default'] = true;
177
  $_POST['sm_b_style'] = '';
178
  }
179
-
180
  foreach($this->sg->_options as $k=>$v) {
181
  //Check vor values and convert them into their types, based on the category they are in
182
  if(!isset($_POST[$k])) $_POST[$k]=""; // Empty string will get false on 2bool and 0 on 2float
183
-
184
  //Options of the category "Basic Settings" are boolean, except the filename and the autoprio provider
185
  if(substr($k,0,5)=="sm_b_") {
186
  if($k=="sm_b_filename" || $k=="sm_b_fileurl_manual" || $k=="sm_b_filename_manual" || $k=="sm_b_prio_provider" || $k=="sm_b_manual_key" || $k == "sm_b_style" || $k == "sm_b_memory") {
 
 
 
 
 
187
  if($k=="sm_b_filename_manual" && strpos($_POST[$k],"\\")!==false){
188
  $_POST[$k]=stripslashes($_POST[$k]);
189
  }
190
-
191
  $this->sg->_options[$k]=(string) $_POST[$k];
192
  } else if($k=="sm_b_location_mode") {
193
  $tmp=(string) $_POST[$k];
@@ -222,7 +227,7 @@ class GoogleSitemapGeneratorUI {
222
  if($k=='sm_in_tax') {
223
 
224
  $enabledTaxonomies = array();
225
-
226
  foreach(array_keys((array) $_POST[$k]) AS $taxName) {
227
  if(empty($taxName) || !is_taxonomy($taxName)) continue;
228
 
@@ -230,11 +235,11 @@ class GoogleSitemapGeneratorUI {
230
  }
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
 
@@ -242,44 +247,46 @@ class GoogleSitemapGeneratorUI {
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_") {
249
- $this->sg->_options[$k]=(string) $_POST[$k];
 
 
250
  //Options of the category "Priorities" are float
251
  } else if(substr($k,0,6)=="sm_pr_") {
252
  $this->sg->_options[$k]=(float) $_POST[$k];
253
  }
254
  }
255
-
256
  //No Mysql unbuffered query for WP < 2.2
257
  if(floatval($wp_version) < 2.2) {
258
  $this->sg->SetOption('b_safemode',true);
259
  }
260
-
261
  //No Wp-Cron for WP < 2.1
262
  if(floatval($wp_version) < 2.1) {
263
  $this->sg->SetOption('b_auto_delay',false);
264
  }
265
-
266
  //Apply page changes from POST
267
  $this->sg->_pages=$this->sg->HtmlApplyPages();
268
-
269
  if($this->sg->SaveOptions()) $message.=__('Configuration updated', 'sitemap') . "<br />";
270
  else $message.=__('Error while saving options', 'sitemap') . "<br />";
271
-
272
  if($this->sg->SavePages()) $message.=__("Pages saved",'sitemap') . "<br />";
273
  else $message.=__('Error while saving pages', 'sitemap'). "<br />";
274
-
275
  } else if(!empty($_POST["sm_reset_config"])) { //Pressed Button: Reset Config
276
  check_admin_referer('sitemap');
277
  $this->sg->InitOptions();
278
  $this->sg->SaveOptions();
279
-
280
  $message.=__('The default configuration was restored.','sitemap');
281
  }
282
-
283
  //Print out the message to the user, if any
284
  if($message!="") {
285
  ?>
@@ -287,10 +294,10 @@ class GoogleSitemapGeneratorUI {
287
  echo $message;
288
  ?></p></strong></div><?php
289
  }
290
-
291
-
292
  if(!$snl) {
293
-
294
  if(isset($_GET['sm_hidedonate'])) {
295
  $this->sg->SetOption('i_hide_donated',true);
296
  $this->sg->SaveOptions();
@@ -311,8 +318,8 @@ class GoogleSitemapGeneratorUI {
311
  $this->sg->SetOption('i_hide_works',true);
312
  $this->sg->SaveOptions();
313
  }
314
-
315
-
316
  if(isset($_GET['sm_donated']) || ($this->sg->GetOption('i_donated')===true && $this->sg->GetOption('i_hide_donated')!==true)) {
317
  ?>
318
  <div class="updated">
@@ -335,7 +342,7 @@ class GoogleSitemapGeneratorUI {
335
  <?php
336
  }
337
  }
338
-
339
  if(function_exists("wp_next_scheduled")) {
340
  $next = wp_next_scheduled('sm_build_cron');
341
  if($next) {
@@ -353,29 +360,29 @@ class GoogleSitemapGeneratorUI {
353
  <?php
354
  }
355
  }
356
-
357
-
358
  ?>
359
-
360
  <style type="text/css">
361
-
362
  li.sm_hint {
363
  color:green;
364
  }
365
-
366
  li.sm_optimize {
367
  color:orange;
368
  }
369
-
370
  li.sm_error {
371
  color:red;
372
  }
373
-
374
  input.sm_warning:hover {
375
  background: #ce0000;
376
  color: #fff;
377
  }
378
-
379
  a.sm_button {
380
  padding:4px;
381
  display:block;
@@ -385,7 +392,7 @@ class GoogleSitemapGeneratorUI {
385
  text-decoration:none;
386
  border:none;
387
  }
388
-
389
  a.sm_button:hover {
390
  border-bottom-width:1px;
391
  }
@@ -393,52 +400,52 @@ class GoogleSitemapGeneratorUI {
393
  a.sm_donatePayPal {
394
  background-image:url(<?php echo $this->sg->GetPluginUrl(); ?>img/icon-paypal.gif);
395
  }
396
-
397
  a.sm_donateAmazon {
398
  background-image:url(<?php echo $this->sg->GetPluginUrl(); ?>img/icon-amazon.gif);
399
  }
400
-
401
  a.sm_pluginHome {
402
  background-image:url(<?php echo $this->sg->GetPluginUrl(); ?>img/icon-arne.gif);
403
  }
404
-
405
  a.sm_pluginList {
406
  background-image:url(<?php echo $this->sg->GetPluginUrl(); ?>img/icon-email.gif);
407
  }
408
-
409
  a.sm_pluginSupport {
410
  background-image:url(<?php echo $this->sg->GetPluginUrl(); ?>img/icon-wordpress.gif);
411
  }
412
-
413
  a.sm_pluginBugs {
414
  background-image:url(<?php echo $this->sg->GetPluginUrl(); ?>img/icon-trac.gif);
415
  }
416
-
417
  a.sm_resGoogle {
418
  background-image:url(<?php echo $this->sg->GetPluginUrl(); ?>img/icon-google.gif);
419
  }
420
-
421
  a.sm_resBing {
422
  background-image:url(<?php echo $this->sg->GetPluginUrl(); ?>img/icon-bing.gif);
423
  }
424
-
425
  div.sm-update-nag p {
426
  margin:5px;
427
  }
428
-
429
  </style>
430
-
431
  <?php
432
  if($this->mode == 27): ?>
433
  <style type="text/css">
434
-
435
  .sm-padded .inside {
436
  margin:12px!important;
437
  }
438
  .sm-padded .inside ul {
439
  margin:6px 0 12px 0;
440
  }
441
-
442
  .sm-padded .inside input {
443
  padding:1px;
444
  margin:0;
@@ -477,7 +484,7 @@ class GoogleSitemapGeneratorUI {
477
 
478
 
479
  </style>
480
-
481
  <?php elseif(version_compare($wp_version,"2.5",">=")): ?>
482
  <style type="text/css">
483
  div#moremeta {
@@ -496,7 +503,7 @@ class GoogleSitemapGeneratorUI {
496
  fieldset.dbx-box {
497
  margin-bottom:5px;
498
  }
499
-
500
  div.sm-update-nag {
501
  margin-top:10px!important;
502
  }
@@ -508,7 +515,7 @@ class GoogleSitemapGeneratorUI {
508
  }
509
  </style>
510
  <![endif]-->
511
-
512
  <?php else: ?>
513
  <style type="text/css">
514
  div.updated-message {
@@ -517,21 +524,21 @@ class GoogleSitemapGeneratorUI {
517
  </style>
518
  <?php endif;
519
  ?>
520
-
521
  <div class="wrap" id="sm_div">
522
  <form method="post" action="<?php echo $this->sg->GetBackLink() ?>">
523
  <h2><?php _e('XML Sitemap Generator for WordPress', 'sitemap'); echo " " . $this->sg->GetVersion() ?> </h2>
524
  <?php
525
  if(function_exists("wp_update_plugins") && (!defined('SM_NO_UPDATE') || SM_NO_UPDATE == false)) {
526
-
527
  wp_update_plugins();
528
-
529
  $file = GoogleSitemapGeneratorLoader::GetBaseName();
530
-
531
  $plugin_data = get_plugin_data(GoogleSitemapGeneratorLoader::GetPluginFile());
532
-
533
  $current = function_exists('get_transient')?get_transient('update_plugins'):get_option('update_plugins');
534
-
535
  if(isset($current->response[$file])) {
536
  $r = $current->response[$file];
537
  ?><div id="update-nag" class="sm-update-nag"><?php
@@ -541,16 +548,16 @@ class GoogleSitemapGeneratorUI {
541
  printf( __('There is a new version of %1$s available. <a href="%2$s">Download version %3$s here</a> <em>automatic upgrade unavailable for this plugin</em>.','default'), $plugin_data['Name'], $r->url, $r->new_version);
542
  else
543
  printf( __('There is a new version of %1$s available. <a href="%2$s">Download version %3$s here</a> or <a href="%4$s">upgrade automatically</a>.','default'), $plugin_data['Name'], $r->url, $r->new_version, wp_nonce_url("update.php?action=upgrade-plugin&amp;plugin=$file", 'upgrade-plugin_' . $file) );
544
-
545
  ?></div><?php
546
  }
547
  }
548
-
549
-
550
  if(get_option('blog_public')!=1) {
551
  ?><div class="error"><p><?php echo str_replace("%s","options-privacy.php",__('Your blog is currently blocking search engines! Visit the <a href="%s">privacy settings</a> to change this.','sitemap')); ?></p></div><?php
552
  }
553
-
554
  ?>
555
 
556
  <?php if(version_compare($wp_version,"2.5","<")): ?>
@@ -559,7 +566,7 @@ class GoogleSitemapGeneratorUI {
559
  //<![CDATA[
560
  addLoadEvent( function() {
561
  var manager = new dbxManager('sm_sitemap_meta_33');
562
-
563
  //create new docking boxes group
564
  var meta = new dbxGroup(
565
  'grabit', // container ID [/-_a-zA-Z0-9/]
@@ -600,7 +607,7 @@ class GoogleSitemapGeneratorUI {
600
  <?php endif; ?>
601
 
602
  <?php if($this->mode == 27): ?>
603
-
604
  <?php if(!$snl): ?>
605
  <div id="poststuff" class="metabox-holder has-right-sidebar">
606
  <div class="inner-sidebar">
@@ -617,22 +624,22 @@ class GoogleSitemapGeneratorUI {
617
  <div>
618
  <?php endif; ?>
619
  <?php endif; ?>
620
-
621
  <?php if(!$snl): ?>
622
-
623
  <?php $this->HtmlPrintBoxHeader('sm_pnres',__('About this Plugin:','sitemap'),true); ?>
624
  <a class="sm_button sm_pluginHome" href="<?php echo $this->sg->GetRedirectLink('sitemap-home'); ?>"><?php _e('Plugin Homepage','sitemap'); ?></a>
625
  <a class="sm_button sm_pluginHome" href="<?php echo $this->sg->GetRedirectLink('sitemap-feedback'); ?>"><?php _e('Suggest a Feature','sitemap'); ?></a>
626
  <a class="sm_button sm_pluginList" href="<?php echo $this->sg->GetRedirectLink('sitemap-list'); ?>"><?php _e('Notify List','sitemap'); ?></a>
627
  <a class="sm_button sm_pluginSupport" href="<?php echo $this->sg->GetRedirectLink('sitemap-support'); ?>"><?php _e('Support Forum','sitemap'); ?></a>
628
  <a class="sm_button sm_pluginBugs" href="<?php echo $this->sg->GetRedirectLink('sitemap-bugs'); ?>"><?php _e('Report a Bug','sitemap'); ?></a>
629
-
630
  <a class="sm_button sm_donatePayPal" href="<?php echo $this->sg->GetRedirectLink('sitemap-paypal'); ?>"><?php _e('Donate with PayPal','sitemap'); ?></a>
631
  <a class="sm_button sm_donateAmazon" href="<?php echo $this->sg->GetRedirectLink('sitemap-amazon'); ?>"><?php _e('My Amazon Wish List','sitemap'); ?></a>
632
  <?php if(__('translator_name','sitemap')!='translator_name') {?><a class="sm_button sm_pluginSupport" href="<?php _e('translator_url','sitemap'); ?>"><?php _e('translator_name','sitemap'); ?></a><?php } ?>
633
  <?php $this->HtmlPrintBoxFooter(true); ?>
634
-
635
-
636
  <?php $this->HtmlPrintBoxHeader('sm_smres',__('Sitemap Resources:','sitemap'),true); ?>
637
  <a class="sm_button sm_resGoogle" href="<?php echo $this->sg->GetRedirectLink('sitemap-gwt'); ?>"><?php _e('Webmaster Tools','sitemap'); ?></a>
638
  <a class="sm_button sm_resGoogle" href="<?php echo $this->sg->GetRedirectLink('sitemap-gwb'); ?>"><?php _e('Webmaster Blog','sitemap'); ?></a>
@@ -644,7 +651,7 @@ class GoogleSitemapGeneratorUI {
644
  <a class="sm_button sm_resGoogle" href="<?php echo $this->sg->GetRedirectLink('sitemap-ofaq'); ?>"><?php _e('Official Sitemaps FAQ','sitemap'); ?></a>
645
  <a class="sm_button sm_pluginHome" href="<?php echo $this->sg->GetRedirectLink('sitemap-afaq'); ?>"><?php _e('My Sitemaps FAQ','sitemap'); ?></a>
646
  <?php $this->HtmlPrintBoxFooter(true); ?>
647
-
648
  <?php $this->HtmlPrintBoxHeader('dm_donations',__('Recent Donations:','sitemap'),true); ?>
649
  <?php if($this->sg->GetOption('i_hide_donors')!==true) { ?>
650
  <iframe border="0" frameborder="0" scrolling="no" allowtransparency="yes" style="width:100%; height:80px;" src="<?php echo $this->sg->GetRedirectLink('sitemap-donorlist'); ?>">
@@ -656,22 +663,22 @@ class GoogleSitemapGeneratorUI {
656
  <span><small><?php _e('Thanks for your support!','sitemap'); ?></small></span>
657
  <div style="clear:left; height:1px;"></div>
658
  <?php $this->HtmlPrintBoxFooter(true); ?>
659
-
660
-
661
  </div>
662
  </div>
663
  <?php endif; ?>
664
-
665
  <?php if($this->mode == 27): ?>
666
  <div class="has-sidebar sm-padded" >
667
-
668
  <div id="post-body-content" class="<?php if(!$snl): ?>has-sidebar-content<?php endif; ?>">
669
-
670
  <div class="meta-box-sortabless">
671
  <?php else: ?>
672
  <div id="advancedstuff" class="dbx-group" >
673
  <?php endif; ?>
674
-
675
  <!-- Rebuild Area -->
676
  <?php
677
  $status = &GoogleSitemapGeneratorStatus::Load();
@@ -680,11 +687,11 @@ class GoogleSitemapGeneratorUI {
680
  $st=$status->GetStartTime();
681
  $head=str_replace("%date%",date(get_option('date_format'),$st) . " " . date(get_option('time_format'),$st),__("Result of the last build process, started on %date%.",'sitemap'));
682
  }
683
-
684
  $this->HtmlPrintBoxHeader('sm_rebuild',$head); ?>
685
  <ul>
686
  <?php
687
-
688
 
689
  if($status == null) {
690
  echo "<li>" . str_replace("%s",wp_nonce_url($this->sg->GetBackLink() . "&sm_rebuild=true&noheader=true",'sitemap'),__('The sitemap wasn\'t built yet. <a href="%s">Click here</a> to build it the first time.','sitemap')) . "</li>";
@@ -699,7 +706,7 @@ class GoogleSitemapGeneratorUI {
699
  echo "<li class=\"sm_error\">" . str_replace("%url%",$this->sg->GetRedirectLink('sitemap-help-files'),__("There was a problem writing your sitemap file. Make sure the file exists and is writable. <a href=\"%url%\">Learn more</a>",'sitemap')) . "</li>";
700
  }
701
  }
702
-
703
  if($status->_usedZip) {
704
  if($status->_zipSuccess) {
705
  $ft = is_readable($status->_zipPath)?filemtime($status->_zipPath):false;
@@ -709,7 +716,7 @@ class GoogleSitemapGeneratorUI {
709
  echo "<li class=\"sm_error\">" . str_replace("%url%",$this->sg->GetRedirectLink('sitemap-help-files'),__("There was a problem writing your zipped sitemap file. Make sure the file exists and is writable. <a href=\"%url%\">Learn more</a>",'sitemap')) . "</li>";
710
  }
711
  }
712
-
713
  if($status->_usedGoogle) {
714
  if($status->_gooogleSuccess) {
715
  echo "<li>" .__("Google was <b>successfully notified</b> about changes.",'sitemap'). "</li>";
@@ -733,20 +740,20 @@ class GoogleSitemapGeneratorUI {
733
  echo "<li class=\"sm_error\">" . str_replace("%s",wp_nonce_url($this->sg->GetBackLink() . "&sm_ping_service=msn&noheader=true",'sitemap'),__('There was a problem while notifying Bing. <a href="%s">View result</a>','sitemap')) . "</li>";
734
  }
735
  }
736
-
737
  $et = $status->GetTime();
738
  $mem = $status->GetMemoryUsage();
739
-
740
  if($mem > 0) {
741
  echo "<li>" .str_replace(array("%time%","%memory%"),array($et,$mem),__("The building process took about <b>%time% seconds</b> to complete and used %memory% MB of memory.",'sitemap')). "</li>";
742
  } else {
743
  echo "<li>" .str_replace("%time%",$et,__("The building process took about <b>%time% seconds</b> to complete.",'sitemap')). "</li>";
744
  }
745
-
746
  if(!$status->_hasChanged) {
747
  echo "<li>" . __("The content of your sitemap <strong>didn't change</strong> since the last time so the files were not written and no search engine was pinged.",'sitemap'). "</li>";
748
  }
749
-
750
  } else {
751
  if($this->sg->GetOption("b_auto_delay")) {
752
  $st = ($status->GetStartTime() - time()) * -1;
@@ -759,11 +766,11 @@ class GoogleSitemapGeneratorUI {
759
  if($status->_memoryUsage > 0) {
760
  echo '<li class="sm_error">'. str_replace(array("%memused%","%memlimit%"),array($status->GetMemoryUsage(),ini_get('memory_limit')),__("The last known memory usage of the script was %memused%MB, the limit of your server is %memlimit%.",'sitemap')) . '</li>';
761
  }
762
-
763
  if($status->_lastTime > 0) {
764
  echo '<li class="sm_error">'. str_replace(array("%timeused%","%timelimit%"),array($status->GetLastTime(),ini_get('max_execution_time')),__("The last known execution time of the script was %timeused% seconds, the limit of your server is %timelimit% seconds.",'sitemap')) . '</li>';
765
  }
766
-
767
  if($status->GetLastPost() > 0) {
768
  echo '<li class="sm_optimize">'. str_replace("%lastpost%",$status->GetLastPost(),__("The script stopped around post number %lastpost% (+/- 100)",'sitemap')) . '</li>';
769
  }
@@ -779,10 +786,10 @@ class GoogleSitemapGeneratorUI {
779
 
780
  </ul>
781
  <?php $this->HtmlPrintBoxFooter(); ?>
782
-
783
  <!-- Basic Options -->
784
  <?php $this->HtmlPrintBoxHeader('sm_basic_options',__('Basic Options', 'sitemap')); ?>
785
-
786
  <b><?php _e('Sitemap files:','sitemap'); ?></b> <a href="<?php echo $this->sg->GetRedirectLink('sitemap-help-options-files'); ?>"><?php _e('Learn more','sitemap'); ?></a>
787
  <ul>
788
  <li>
@@ -873,11 +880,11 @@ class GoogleSitemapGeneratorUI {
873
  </label>
874
  </li>
875
  </ul>
876
-
877
  <?php $this->HtmlPrintBoxFooter(); ?>
878
-
879
  <?php $this->HtmlPrintBoxHeader('sm_pages',__('Additional pages', 'sitemap')); ?>
880
-
881
  <?php
882
  _e('Here you can specify files or URLs which should be included in the sitemap, but do not belong to your Blog/WordPress.<br />For example, if your domain is www.foo.com and your blog is located on www.foo.com/blog you might want to include your homepage at www.foo.com','sitemap');
883
  echo "<ul><li>";
@@ -892,10 +899,10 @@ class GoogleSitemapGeneratorUI {
892
  echo "</li><li>";
893
  echo "<strong>" . __('Last Changed','sitemap'). "</strong>: ";
894
  _e("Enter the date of the last change as YYYY-MM-DD (2005-12-31 for example) (optional).",'sitemap');
895
-
896
  echo "</li></ul>";
897
-
898
-
899
  ?>
900
  <script type="text/javascript">
901
  //<![CDATA[
@@ -906,9 +913,9 @@ class GoogleSitemapGeneratorUI {
906
 
907
  var changeFreqVals = new Array( <?php echo $freqVals; ?> );
908
  var changeFreqNames= new Array( <?php echo $freqNames; ?> );
909
-
910
  var priorities= new Array(0 <?php for($i=0.1; $i<1; $i+=0.1) { echo "," . number_format($i,1,".",""); } ?>);
911
-
912
  var pages = [ <?php
913
  if(count($this->sg->_pages)>0) {
914
  for($i=0; $i<count($this->sg->_pages); $i++) {
@@ -939,11 +946,11 @@ class GoogleSitemapGeneratorUI {
939
  </table>
940
  <a href="javascript:void(0);" onclick="sm_addPage();"><?php _e("Add new page",'sitemap'); ?></a>
941
  <?php $this->HtmlPrintBoxFooter(); ?>
942
-
943
-
944
  <!-- AutoPrio Options -->
945
  <?php $this->HtmlPrintBoxHeader('sm_postprio',__('Post Priority', 'sitemap')); ?>
946
-
947
  <p><?php _e('Please select how the priority of each post should be calculated:', 'sitemap') ?></p>
948
  <ul>
949
  <li><p><input type="radio" name="sm_b_prio_provider" id="sm_b_prio_provider__0" value="" <?php echo $this->sg->HtmlGetChecked($this->sg->GetOption("b_prio_provider"),"") ?> /> <label for="sm_b_prio_provider__0"><?php _e('Do not use automatic priority calculation', 'sitemap') ?></label><br /><?php _e('All posts will have the same priority which is defined in &quot;Priorities&quot;', 'sitemap') ?></p></li>
@@ -954,11 +961,11 @@ class GoogleSitemapGeneratorUI {
954
  ?>
955
  </ul>
956
  <?php $this->HtmlPrintBoxFooter(); ?>
957
-
958
-
959
  <!-- Location Options -->
960
  <?php $this->HtmlPrintBoxHeader('sm_location',__('Location of your sitemap file', 'sitemap')); ?>
961
-
962
  <div>
963
  <b><label for="sm_location_useauto"><input type="radio" id="sm_location_useauto" name="sm_b_location_mode" value="auto" <?php echo ($this->sg->GetOption("b_location_mode")=="auto"?"checked=\"checked\"":"") ?> /> <?php _e('Automatic detection','sitemap') ?></label></b>
964
  <ul>
@@ -994,9 +1001,9 @@ class GoogleSitemapGeneratorUI {
994
  </li>
995
  </ul>
996
  </div>
997
-
998
  <?php $this->HtmlPrintBoxFooter(); ?>
999
-
1000
  <!-- Includes -->
1001
  <?php $this->HtmlPrintBoxHeader('sm_includes',__('Sitemap Content', 'sitemap')); ?>
1002
  <b><?php _e('WordPress standard content', 'sitemap') ?>:</b>
@@ -1052,20 +1059,20 @@ class GoogleSitemapGeneratorUI {
1052
  </li>
1053
  <?php endif; ?>
1054
  </ul>
1055
-
1056
- <?php
1057
-
1058
  if($this->sg->IsTaxonomySupported()) {
1059
  $taxonomies = $this->sg->GetCustomTaxonomies();
1060
-
1061
  $enabledTaxonomies = $this->sg->GetOption('in_tax');
1062
-
1063
  if(count($taxonomies)>0) {
1064
- ?><b><?php _e('Custom taxonomies', 'sitemap') ?>:</b><ul><?php
1065
-
1066
-
1067
  foreach ($taxonomies as $taxName) {
1068
-
1069
  $taxonomy = get_taxonomy($taxName);
1070
  $selected = in_array($taxonomy->name, $enabledTaxonomies);
1071
  ?>
@@ -1077,24 +1084,24 @@ class GoogleSitemapGeneratorUI {
1077
  </li>
1078
  <?php
1079
  }
1080
-
1081
- ?></ul><?php
1082
-
1083
  }
1084
  }
1085
-
1086
-
1087
  if($this->sg->IsCustomPostTypesSupported()) {
1088
  $custom_post_types = $this->sg->GetCustomPostTypes();
1089
-
1090
  $enabledPostTypes = $this->sg->GetOption('in_customtypes');
1091
-
1092
  if(count($custom_post_types)>0) {
1093
- ?><b><?php _e('Custom post types', 'sitemap') ?>:</b><ul><?php
1094
-
1095
  foreach ($custom_post_types as $post_type) {
1096
  $post_type_object = get_post_type_object($post_type);
1097
-
1098
  if (is_array($enabledPostTypes)) $selected = in_array($post_type_object->name, $enabledPostTypes);
1099
 
1100
  ?>
@@ -1106,13 +1113,13 @@ class GoogleSitemapGeneratorUI {
1106
  </li>
1107
  <?php
1108
  }
1109
-
1110
- ?></ul><?php
1111
  }
1112
  }
1113
-
1114
  ?>
1115
-
1116
  <b><?php _e('Further options', 'sitemap') ?>:</b>
1117
  <ul>
1118
  <li>
@@ -1123,12 +1130,12 @@ class GoogleSitemapGeneratorUI {
1123
  <small><?php _e('This is highly recommended and helps the search engines to know when your content has changed. This option affects <i>all</i> sitemap entries.', 'sitemap') ?></small>
1124
  </li>
1125
  </ul>
1126
-
1127
  <?php $this->HtmlPrintBoxFooter(); ?>
1128
-
1129
  <!-- Excluded Items -->
1130
  <?php $this->HtmlPrintBoxHeader('sm_excludes',__('Excluded items', 'sitemap')); ?>
1131
-
1132
  <b><?php _e('Excluded categories', 'sitemap') ?>:</b>
1133
  <?php if(version_compare($wp_version,"2.5.1",">=")): ?>
1134
  <cite style="display:block; margin-left:40px;"><?php _e("Note","sitemap") ?>: <?php _e("Using this feature will increase build time and memory usage!","sitemap"); ?></cite>
@@ -1140,16 +1147,16 @@ class GoogleSitemapGeneratorUI {
1140
  <?php else: ?>
1141
  <ul><li><?php echo sprintf(__("This feature requires at least WordPress 2.5.1, you are using %s","sitemap"),$wp_version); ?></li></ul>
1142
  <?php endif; ?>
1143
-
1144
  <b><?php _e("Exclude posts","sitemap"); ?>:</b>
1145
  <div style="margin:5px 0 13px 40px;">
1146
  <label for="sm_b_exclude"><?php _e('Exclude the following posts or pages:', 'sitemap') ?> <small><?php _e('List of IDs, separated by comma', 'sitemap') ?></small><br />
1147
  <input name="sm_b_exclude" id="sm_b_exclude" type="text" style="width:400px;" value="<?php echo implode(",",$this->sg->GetOption("b_exclude")); ?>" /></label><br />
1148
  <cite><?php _e("Note","sitemap") ?>: <?php _e("Child posts won't be excluded automatically!","sitemap"); ?></cite>
1149
  </div>
1150
-
1151
  <?php $this->HtmlPrintBoxFooter(); ?>
1152
-
1153
  <!-- Change frequencies -->
1154
  <?php $this->HtmlPrintBoxHeader('sm_change_frequencies',__('Change frequencies', 'sitemap')); ?>
1155
 
@@ -1209,9 +1216,9 @@ class GoogleSitemapGeneratorUI {
1209
  </label>
1210
  </li>
1211
  </ul>
1212
-
1213
  <?php $this->HtmlPrintBoxFooter(); ?>
1214
-
1215
  <!-- Priorities -->
1216
  <?php $this->HtmlPrintBoxHeader('sm_priorities',__('Priorities', 'sitemap')); ?>
1217
  <ul>
@@ -1266,9 +1273,9 @@ class GoogleSitemapGeneratorUI {
1266
  </label>
1267
  </li>
1268
  </ul>
1269
-
1270
  <?php $this->HtmlPrintBoxFooter(); ?>
1271
-
1272
  </div>
1273
  <div>
1274
  <p class="submit">
@@ -1277,7 +1284,7 @@ class GoogleSitemapGeneratorUI {
1277
  <input type="submit" onclick='return confirm("Do you really want to reset your configuration?");' class="sm_warning" name="sm_reset_config" value="<?php _e('Reset options', 'sitemap'); ?>" />
1278
  </p>
1279
  </div>
1280
-
1281
  <?php if($this->mode == 27): ?>
1282
  </div>
1283
  </div>
1
  <?php
2
  /*
3
+
4
+ $Id: sitemap-ui.php 651444 2013-01-11 19:54:39Z arnee $
5
 
6
  */
7
 
13
  * @var GoogleSitemapGenerator
14
  */
15
  var $sg = null;
16
+
17
  var $mode = 21;
18
 
19
  function GoogleSitemapGeneratorUI(&$sitemapBuilder) {
20
  global $wp_version;
21
  $this->sg = &$sitemapBuilder;
22
+
23
  if(floatval($wp_version) >= 2.7) {
24
  $this->mode = 27;
25
  }
26
  }
27
+
28
  function HtmlPrintBoxHeader($id, $title, $right = false) {
29
  if($this->mode == 27) {
30
  ?>
38
  <?php if(!$right): ?><div class="dbx-h-andle-wrapper"><?php endif; ?>
39
  <h3 class="dbx-handle"><?php echo $title ?></h3>
40
  <?php if(!$right): ?></div><?php endif; ?>
41
+
42
  <?php if(!$right): ?><div class="dbx-c-ontent-wrapper"><?php endif; ?>
43
  <div class="dbx-content">
44
  <?php
45
  }
46
  }
47
+
48
  function HtmlPrintBoxFooter( $right = false) {
49
  if($this->mode == 27) {
50
  ?>
59
  <?php
60
  }
61
  }
62
+
63
  /**
64
  * Displays the option page
65
  *
69
  */
70
  function HtmlShowOptionsPage() {
71
  global $wp_version;
72
+
73
  $snl = false; //SNL
74
+
75
  $this->sg->Initate();
76
+
77
  $message="";
78
+
79
  if(!empty($_REQUEST["sm_rebuild"])) { //Pressed Button: Rebuild Sitemap
80
  check_admin_referer('sitemap');
81
+
82
  //Clear any outstanding build cron jobs
83
  if(function_exists('wp_clear_scheduled_hook')) wp_clear_scheduled_hook('sm_build_cron');
84
+
85
  if(isset($_GET["sm_do_debug"]) && $_GET["sm_do_debug"]=="true") {
86
+
87
  //Check again, just for the case that something went wrong before
88
  if(!current_user_can("administrator")) {
89
  echo '<p>Please log in as admin</p>';
90
  return;
91
  }
92
+
93
  $oldErr = error_reporting(E_ALL);
94
  $oldIni = ini_set("display_errors",1);
95
 
116
  $os = $wpdb->get_results( "SELECT option_name, option_value FROM $wpdb->options");
117
  foreach ( (array) $os as $o ) $opts[$o->option_name] = $o->option_value;
118
  }
119
+
120
  $popts = array();
121
  foreach($opts as $k=>$v) {
122
  //Try to filter out passwords etc...
138
  echo '<pre>';
139
  var_dump($GLOBALS['wpdb']->queries);
140
  echo '</pre>';
141
+
142
  $total = 0;
143
  foreach($GLOBALS['wpdb']->queries as $q) {
144
  $total+=$q[1];
161
  } else {
162
  $this->sg->BuildSitemap();
163
  $redirURL = $this->sg->GetBackLink() . '&sm_fromrb=true';
164
+
165
  //Redirect so the sm_rebuild GET parameter no longer exists.
166
  @header("location: " . $redirURL);
167
  //If there was already any other output, the header redirect will fail
171
  }
172
  } else if (!empty($_POST['sm_update'])) { //Pressed Button: Update Config
173
  check_admin_referer('sitemap');
174
+
175
  if(isset($_POST['sm_b_style']) && $_POST['sm_b_style'] == $this->sg->getDefaultStyle()) {
176
  $_POST['sm_b_style_default'] = true;
177
  $_POST['sm_b_style'] = '';
178
  }
179
+
180
  foreach($this->sg->_options as $k=>$v) {
181
  //Check vor values and convert them into their types, based on the category they are in
182
  if(!isset($_POST[$k])) $_POST[$k]=""; // Empty string will get false on 2bool and 0 on 2float
183
+
184
  //Options of the category "Basic Settings" are boolean, except the filename and the autoprio provider
185
  if(substr($k,0,5)=="sm_b_") {
186
  if($k=="sm_b_filename" || $k=="sm_b_fileurl_manual" || $k=="sm_b_filename_manual" || $k=="sm_b_prio_provider" || $k=="sm_b_manual_key" || $k == "sm_b_style" || $k == "sm_b_memory") {
187
+
188
+ if($k=="sm_b_filename" || $k=="sm_b_filename_manual") {
189
+ if(substr($_POST[$k],-4)!=".xml") $_POST[$k].=".xml";
190
+ }
191
+
192
  if($k=="sm_b_filename_manual" && strpos($_POST[$k],"\\")!==false){
193
  $_POST[$k]=stripslashes($_POST[$k]);
194
  }
195
+
196
  $this->sg->_options[$k]=(string) $_POST[$k];
197
  } else if($k=="sm_b_location_mode") {
198
  $tmp=(string) $_POST[$k];
227
  if($k=='sm_in_tax') {
228
 
229
  $enabledTaxonomies = array();
230
+
231
  foreach(array_keys((array) $_POST[$k]) AS $taxName) {
232
  if(empty($taxName) || !is_taxonomy($taxName)) continue;
233
 
235
  }
236
 
237
  $this->sg->_options[$k] = $enabledTaxonomies;
238
+
239
  } else if($k=='sm_in_customtypes') {
240
 
241
  $enabledPostTypes = array();
242
+
243
  foreach(array_keys((array) $_POST[$k]) AS $postTypeName) {
244
  if(empty($postTypeName) || !post_type_exists($postTypeName)) continue;
245
 
247
  }
248
 
249
  $this->sg->_options[$k] = $enabledPostTypes;
250
+
251
  } else $this->sg->_options[$k]=(bool) $_POST[$k];
252
  //Options of the category "Change frequencies" are string
253
  } else if(substr($k,0,6)=="sm_cf_") {
254
+ if(array_key_exists($_POST[$k],$this->sg->_freqNames)) {
255
+ $this->sg->_options[$k]=(string) $_POST[$k];
256
+ }
257
  //Options of the category "Priorities" are float
258
  } else if(substr($k,0,6)=="sm_pr_") {
259
  $this->sg->_options[$k]=(float) $_POST[$k];
260
  }
261
  }
262
+
263
  //No Mysql unbuffered query for WP < 2.2
264
  if(floatval($wp_version) < 2.2) {
265
  $this->sg->SetOption('b_safemode',true);
266
  }
267
+
268
  //No Wp-Cron for WP < 2.1
269
  if(floatval($wp_version) < 2.1) {
270
  $this->sg->SetOption('b_auto_delay',false);
271
  }
272
+
273
  //Apply page changes from POST
274
  $this->sg->_pages=$this->sg->HtmlApplyPages();
275
+
276
  if($this->sg->SaveOptions()) $message.=__('Configuration updated', 'sitemap') . "<br />";
277
  else $message.=__('Error while saving options', 'sitemap') . "<br />";
278
+
279
  if($this->sg->SavePages()) $message.=__("Pages saved",'sitemap') . "<br />";
280
  else $message.=__('Error while saving pages', 'sitemap'). "<br />";
281
+
282
  } else if(!empty($_POST["sm_reset_config"])) { //Pressed Button: Reset Config
283
  check_admin_referer('sitemap');
284
  $this->sg->InitOptions();
285
  $this->sg->SaveOptions();
286
+
287
  $message.=__('The default configuration was restored.','sitemap');
288
  }
289
+
290
  //Print out the message to the user, if any
291
  if($message!="") {
292
  ?>
294
  echo $message;
295
  ?></p></strong></div><?php
296
  }
297
+
298
+
299
  if(!$snl) {
300
+
301
  if(isset($_GET['sm_hidedonate'])) {
302
  $this->sg->SetOption('i_hide_donated',true);
303
  $this->sg->SaveOptions();
318
  $this->sg->SetOption('i_hide_works',true);
319
  $this->sg->SaveOptions();
320
  }
321
+
322
+
323
  if(isset($_GET['sm_donated']) || ($this->sg->GetOption('i_donated')===true && $this->sg->GetOption('i_hide_donated')!==true)) {
324
  ?>
325
  <div class="updated">
342
  <?php
343
  }
344
  }
345
+
346
  if(function_exists("wp_next_scheduled")) {
347
  $next = wp_next_scheduled('sm_build_cron');
348
  if($next) {
360
  <?php
361
  }
362
  }
363
+
364
+
365
  ?>
366
+
367
  <style type="text/css">
368
+
369
  li.sm_hint {
370
  color:green;
371
  }
372
+
373
  li.sm_optimize {
374
  color:orange;
375
  }
376
+
377
  li.sm_error {
378
  color:red;
379
  }
380
+
381
  input.sm_warning:hover {
382
  background: #ce0000;
383
  color: #fff;
384
  }
385
+
386
  a.sm_button {
387
  padding:4px;
388
  display:block;
392
  text-decoration:none;
393
  border:none;
394
  }
395
+
396
  a.sm_button:hover {
397
  border-bottom-width:1px;
398
  }
400
  a.sm_donatePayPal {
401
  background-image:url(<?php echo $this->sg->GetPluginUrl(); ?>img/icon-paypal.gif);
402
  }
403
+
404
  a.sm_donateAmazon {
405
  background-image:url(<?php echo $this->sg->GetPluginUrl(); ?>img/icon-amazon.gif);
406
  }
407
+
408
  a.sm_pluginHome {
409
  background-image:url(<?php echo $this->sg->GetPluginUrl(); ?>img/icon-arne.gif);
410
  }
411
+
412
  a.sm_pluginList {
413
  background-image:url(<?php echo $this->sg->GetPluginUrl(); ?>img/icon-email.gif);
414
  }
415
+
416
  a.sm_pluginSupport {
417
  background-image:url(<?php echo $this->sg->GetPluginUrl(); ?>img/icon-wordpress.gif);
418
  }
419
+
420
  a.sm_pluginBugs {
421
  background-image:url(<?php echo $this->sg->GetPluginUrl(); ?>img/icon-trac.gif);
422
  }
423
+
424
  a.sm_resGoogle {
425
  background-image:url(<?php echo $this->sg->GetPluginUrl(); ?>img/icon-google.gif);
426
  }
427
+
428
  a.sm_resBing {
429
  background-image:url(<?php echo $this->sg->GetPluginUrl(); ?>img/icon-bing.gif);
430
  }
431
+
432
  div.sm-update-nag p {
433
  margin:5px;
434
  }
435
+
436
  </style>
437
+
438
  <?php
439
  if($this->mode == 27): ?>
440
  <style type="text/css">
441
+
442
  .sm-padded .inside {
443
  margin:12px!important;
444
  }
445
  .sm-padded .inside ul {
446
  margin:6px 0 12px 0;
447
  }
448
+
449
  .sm-padded .inside input {
450
  padding:1px;
451
  margin:0;
484
 
485
 
486
  </style>
487
+
488
  <?php elseif(version_compare($wp_version,"2.5",">=")): ?>
489
  <style type="text/css">
490
  div#moremeta {
503
  fieldset.dbx-box {
504
  margin-bottom:5px;
505
  }
506
+
507
  div.sm-update-nag {
508
  margin-top:10px!important;
509
  }
515
  }
516
  </style>
517
  <![endif]-->
518
+
519
  <?php else: ?>
520
  <style type="text/css">
521
  div.updated-message {
524
  </style>
525
  <?php endif;
526
  ?>
527
+
528
  <div class="wrap" id="sm_div">
529
  <form method="post" action="<?php echo $this->sg->GetBackLink() ?>">
530
  <h2><?php _e('XML Sitemap Generator for WordPress', 'sitemap'); echo " " . $this->sg->GetVersion() ?> </h2>
531
  <?php
532
  if(function_exists("wp_update_plugins") && (!defined('SM_NO_UPDATE') || SM_NO_UPDATE == false)) {
533
+
534
  wp_update_plugins();
535
+
536
  $file = GoogleSitemapGeneratorLoader::GetBaseName();
537
+
538
  $plugin_data = get_plugin_data(GoogleSitemapGeneratorLoader::GetPluginFile());
539
+
540
  $current = function_exists('get_transient')?get_transient('update_plugins'):get_option('update_plugins');
541
+
542
  if(isset($current->response[$file])) {
543
  $r = $current->response[$file];
544
  ?><div id="update-nag" class="sm-update-nag"><?php
548
  printf( __('There is a new version of %1$s available. <a href="%2$s">Download version %3$s here</a> <em>automatic upgrade unavailable for this plugin</em>.','default'), $plugin_data['Name'], $r->url, $r->new_version);
549
  else
550
  printf( __('There is a new version of %1$s available. <a href="%2$s">Download version %3$s here</a> or <a href="%4$s">upgrade automatically</a>.','default'), $plugin_data['Name'], $r->url, $r->new_version, wp_nonce_url("update.php?action=upgrade-plugin&amp;plugin=$file", 'upgrade-plugin_' . $file) );
551
+
552
  ?></div><?php
553
  }
554
  }
555
+
556
+
557
  if(get_option('blog_public')!=1) {
558
  ?><div class="error"><p><?php echo str_replace("%s","options-privacy.php",__('Your blog is currently blocking search engines! Visit the <a href="%s">privacy settings</a> to change this.','sitemap')); ?></p></div><?php
559
  }
560
+
561
  ?>
562
 
563
  <?php if(version_compare($wp_version,"2.5","<")): ?>
566
  //<![CDATA[
567
  addLoadEvent( function() {
568
  var manager = new dbxManager('sm_sitemap_meta_33');
569
+
570
  //create new docking boxes group
571
  var meta = new dbxGroup(
572
  'grabit', // container ID [/-_a-zA-Z0-9/]
607
  <?php endif; ?>
608
 
609
  <?php if($this->mode == 27): ?>
610
+
611
  <?php if(!$snl): ?>
612
  <div id="poststuff" class="metabox-holder has-right-sidebar">
613
  <div class="inner-sidebar">
624
  <div>
625
  <?php endif; ?>
626
  <?php endif; ?>
627
+
628
  <?php if(!$snl): ?>
629
+
630
  <?php $this->HtmlPrintBoxHeader('sm_pnres',__('About this Plugin:','sitemap'),true); ?>
631
  <a class="sm_button sm_pluginHome" href="<?php echo $this->sg->GetRedirectLink('sitemap-home'); ?>"><?php _e('Plugin Homepage','sitemap'); ?></a>
632
  <a class="sm_button sm_pluginHome" href="<?php echo $this->sg->GetRedirectLink('sitemap-feedback'); ?>"><?php _e('Suggest a Feature','sitemap'); ?></a>
633
  <a class="sm_button sm_pluginList" href="<?php echo $this->sg->GetRedirectLink('sitemap-list'); ?>"><?php _e('Notify List','sitemap'); ?></a>
634
  <a class="sm_button sm_pluginSupport" href="<?php echo $this->sg->GetRedirectLink('sitemap-support'); ?>"><?php _e('Support Forum','sitemap'); ?></a>
635
  <a class="sm_button sm_pluginBugs" href="<?php echo $this->sg->GetRedirectLink('sitemap-bugs'); ?>"><?php _e('Report a Bug','sitemap'); ?></a>
636
+
637
  <a class="sm_button sm_donatePayPal" href="<?php echo $this->sg->GetRedirectLink('sitemap-paypal'); ?>"><?php _e('Donate with PayPal','sitemap'); ?></a>
638
  <a class="sm_button sm_donateAmazon" href="<?php echo $this->sg->GetRedirectLink('sitemap-amazon'); ?>"><?php _e('My Amazon Wish List','sitemap'); ?></a>
639
  <?php if(__('translator_name','sitemap')!='translator_name') {?><a class="sm_button sm_pluginSupport" href="<?php _e('translator_url','sitemap'); ?>"><?php _e('translator_name','sitemap'); ?></a><?php } ?>
640
  <?php $this->HtmlPrintBoxFooter(true); ?>
641
+
642
+
643
  <?php $this->HtmlPrintBoxHeader('sm_smres',__('Sitemap Resources:','sitemap'),true); ?>
644
  <a class="sm_button sm_resGoogle" href="<?php echo $this->sg->GetRedirectLink('sitemap-gwt'); ?>"><?php _e('Webmaster Tools','sitemap'); ?></a>
645
  <a class="sm_button sm_resGoogle" href="<?php echo $this->sg->GetRedirectLink('sitemap-gwb'); ?>"><?php _e('Webmaster Blog','sitemap'); ?></a>
651
  <a class="sm_button sm_resGoogle" href="<?php echo $this->sg->GetRedirectLink('sitemap-ofaq'); ?>"><?php _e('Official Sitemaps FAQ','sitemap'); ?></a>
652
  <a class="sm_button sm_pluginHome" href="<?php echo $this->sg->GetRedirectLink('sitemap-afaq'); ?>"><?php _e('My Sitemaps FAQ','sitemap'); ?></a>
653
  <?php $this->HtmlPrintBoxFooter(true); ?>
654
+
655
  <?php $this->HtmlPrintBoxHeader('dm_donations',__('Recent Donations:','sitemap'),true); ?>
656
  <?php if($this->sg->GetOption('i_hide_donors')!==true) { ?>
657
  <iframe border="0" frameborder="0" scrolling="no" allowtransparency="yes" style="width:100%; height:80px;" src="<?php echo $this->sg->GetRedirectLink('sitemap-donorlist'); ?>">
663
  <span><small><?php _e('Thanks for your support!','sitemap'); ?></small></span>
664
  <div style="clear:left; height:1px;"></div>
665
  <?php $this->HtmlPrintBoxFooter(true); ?>
666
+
667
+
668
  </div>
669
  </div>
670
  <?php endif; ?>
671
+
672
  <?php if($this->mode == 27): ?>
673
  <div class="has-sidebar sm-padded" >
674
+
675
  <div id="post-body-content" class="<?php if(!$snl): ?>has-sidebar-content<?php endif; ?>">
676
+
677
  <div class="meta-box-sortabless">
678
  <?php else: ?>
679
  <div id="advancedstuff" class="dbx-group" >
680
  <?php endif; ?>
681
+
682
  <!-- Rebuild Area -->
683
  <?php
684
  $status = &GoogleSitemapGeneratorStatus::Load();
687
  $st=$status->GetStartTime();
688
  $head=str_replace("%date%",date(get_option('date_format'),$st) . " " . date(get_option('time_format'),$st),__("Result of the last build process, started on %date%.",'sitemap'));
689
  }
690
+
691
  $this->HtmlPrintBoxHeader('sm_rebuild',$head); ?>
692
  <ul>
693
  <?php
694
+
695
 
696
  if($status == null) {
697
  echo "<li>" . str_replace("%s",wp_nonce_url($this->sg->GetBackLink() . "&sm_rebuild=true&noheader=true",'sitemap'),__('The sitemap wasn\'t built yet. <a href="%s">Click here</a> to build it the first time.','sitemap')) . "</li>";
706
  echo "<li class=\"sm_error\">" . str_replace("%url%",$this->sg->GetRedirectLink('sitemap-help-files'),__("There was a problem writing your sitemap file. Make sure the file exists and is writable. <a href=\"%url%\">Learn more</a>",'sitemap')) . "</li>";
707
  }
708
  }
709
+
710
  if($status->_usedZip) {
711
  if($status->_zipSuccess) {
712
  $ft = is_readable($status->_zipPath)?filemtime($status->_zipPath):false;
716
  echo "<li class=\"sm_error\">" . str_replace("%url%",$this->sg->GetRedirectLink('sitemap-help-files'),__("There was a problem writing your zipped sitemap file. Make sure the file exists and is writable. <a href=\"%url%\">Learn more</a>",'sitemap')) . "</li>";
717
  }
718
  }
719
+
720
  if($status->_usedGoogle) {
721
  if($status->_gooogleSuccess) {
722
  echo "<li>" .__("Google was <b>successfully notified</b> about changes.",'sitemap'). "</li>";
740
  echo "<li class=\"sm_error\">" . str_replace("%s",wp_nonce_url($this->sg->GetBackLink() . "&sm_ping_service=msn&noheader=true",'sitemap'),__('There was a problem while notifying Bing. <a href="%s">View result</a>','sitemap')) . "</li>";
741
  }
742
  }
743
+
744
  $et = $status->GetTime();
745
  $mem = $status->GetMemoryUsage();
746
+
747
  if($mem > 0) {
748
  echo "<li>" .str_replace(array("%time%","%memory%"),array($et,$mem),__("The building process took about <b>%time% seconds</b> to complete and used %memory% MB of memory.",'sitemap')). "</li>";
749
  } else {
750
  echo "<li>" .str_replace("%time%",$et,__("The building process took about <b>%time% seconds</b> to complete.",'sitemap')). "</li>";
751
  }
752
+
753
  if(!$status->_hasChanged) {
754
  echo "<li>" . __("The content of your sitemap <strong>didn't change</strong> since the last time so the files were not written and no search engine was pinged.",'sitemap'). "</li>";
755
  }
756
+
757
  } else {
758
  if($this->sg->GetOption("b_auto_delay")) {
759
  $st = ($status->GetStartTime() - time()) * -1;
766
  if($status->_memoryUsage > 0) {
767
  echo '<li class="sm_error">'. str_replace(array("%memused%","%memlimit%"),array($status->GetMemoryUsage(),ini_get('memory_limit')),__("The last known memory usage of the script was %memused%MB, the limit of your server is %memlimit%.",'sitemap')) . '</li>';
768
  }
769
+
770
  if($status->_lastTime > 0) {
771
  echo '<li class="sm_error">'. str_replace(array("%timeused%","%timelimit%"),array($status->GetLastTime(),ini_get('max_execution_time')),__("The last known execution time of the script was %timeused% seconds, the limit of your server is %timelimit% seconds.",'sitemap')) . '</li>';
772
  }
773
+
774
  if($status->GetLastPost() > 0) {
775
  echo '<li class="sm_optimize">'. str_replace("%lastpost%",$status->GetLastPost(),__("The script stopped around post number %lastpost% (+/- 100)",'sitemap')) . '</li>';
776
  }
786
 
787
  </ul>
788
  <?php $this->HtmlPrintBoxFooter(); ?>
789
+
790
  <!-- Basic Options -->
791
  <?php $this->HtmlPrintBoxHeader('sm_basic_options',__('Basic Options', 'sitemap')); ?>
792
+
793
  <b><?php _e('Sitemap files:','sitemap'); ?></b> <a href="<?php echo $this->sg->GetRedirectLink('sitemap-help-options-files'); ?>"><?php _e('Learn more','sitemap'); ?></a>
794
  <ul>
795
  <li>
880
  </label>
881
  </li>
882
  </ul>
883
+
884
  <?php $this->HtmlPrintBoxFooter(); ?>
885
+
886
  <?php $this->HtmlPrintBoxHeader('sm_pages',__('Additional pages', 'sitemap')); ?>
887
+
888
  <?php
889
  _e('Here you can specify files or URLs which should be included in the sitemap, but do not belong to your Blog/WordPress.<br />For example, if your domain is www.foo.com and your blog is located on www.foo.com/blog you might want to include your homepage at www.foo.com','sitemap');
890
  echo "<ul><li>";
899
  echo "</li><li>";
900
  echo "<strong>" . __('Last Changed','sitemap'). "</strong>: ";
901
  _e("Enter the date of the last change as YYYY-MM-DD (2005-12-31 for example) (optional).",'sitemap');
902
+
903
  echo "</li></ul>";
904
+
905
+
906
  ?>
907
  <script type="text/javascript">
908
  //<![CDATA[
913
 
914
  var changeFreqVals = new Array( <?php echo $freqVals; ?> );
915
  var changeFreqNames= new Array( <?php echo $freqNames; ?> );
916
+
917
  var priorities= new Array(0 <?php for($i=0.1; $i<1; $i+=0.1) { echo "," . number_format($i,1,".",""); } ?>);
918
+
919
  var pages = [ <?php
920
  if(count($this->sg->_pages)>0) {
921
  for($i=0; $i<count($this->sg->_pages); $i++) {
946
  </table>
947
  <a href="javascript:void(0);" onclick="sm_addPage();"><?php _e("Add new page",'sitemap'); ?></a>
948
  <?php $this->HtmlPrintBoxFooter(); ?>
949
+
950
+
951
  <!-- AutoPrio Options -->
952
  <?php $this->HtmlPrintBoxHeader('sm_postprio',__('Post Priority', 'sitemap')); ?>
953
+
954
  <p><?php _e('Please select how the priority of each post should be calculated:', 'sitemap') ?></p>
955
  <ul>
956
  <li><p><input type="radio" name="sm_b_prio_provider" id="sm_b_prio_provider__0" value="" <?php echo $this->sg->HtmlGetChecked($this->sg->GetOption("b_prio_provider"),"") ?> /> <label for="sm_b_prio_provider__0"><?php _e('Do not use automatic priority calculation', 'sitemap') ?></label><br /><?php _e('All posts will have the same priority which is defined in &quot;Priorities&quot;', 'sitemap') ?></p></li>
961
  ?>
962
  </ul>
963
  <?php $this->HtmlPrintBoxFooter(); ?>
964
+
965
+
966
  <!-- Location Options -->
967
  <?php $this->HtmlPrintBoxHeader('sm_location',__('Location of your sitemap file', 'sitemap')); ?>
968
+
969
  <div>
970
  <b><label for="sm_location_useauto"><input type="radio" id="sm_location_useauto" name="sm_b_location_mode" value="auto" <?php echo ($this->sg->GetOption("b_location_mode")=="auto"?"checked=\"checked\"":"") ?> /> <?php _e('Automatic detection','sitemap') ?></label></b>
971
  <ul>
1001
  </li>
1002
  </ul>
1003
  </div>
1004
+
1005
  <?php $this->HtmlPrintBoxFooter(); ?>
1006
+
1007
  <!-- Includes -->
1008
  <?php $this->HtmlPrintBoxHeader('sm_includes',__('Sitemap Content', 'sitemap')); ?>
1009
  <b><?php _e('WordPress standard content', 'sitemap') ?>:</b>
1059
  </li>
1060
  <?php endif; ?>
1061
  </ul>
1062
+
1063
+ <?php
1064
+
1065
  if($this->sg->IsTaxonomySupported()) {
1066
  $taxonomies = $this->sg->GetCustomTaxonomies();
1067
+
1068
  $enabledTaxonomies = $this->sg->GetOption('in_tax');
1069
+
1070
  if(count($taxonomies)>0) {
1071
+ ?><b><?php _e('Custom taxonomies', 'sitemap') ?>:</b><ul><?php
1072
+
1073
+
1074
  foreach ($taxonomies as $taxName) {
1075
+
1076
  $taxonomy = get_taxonomy($taxName);
1077
  $selected = in_array($taxonomy->name, $enabledTaxonomies);
1078
  ?>
1084
  </li>
1085
  <?php
1086
  }
1087
+
1088
+ ?></ul><?php
1089
+
1090
  }
1091
  }
1092
+
1093
+
1094
  if($this->sg->IsCustomPostTypesSupported()) {
1095
  $custom_post_types = $this->sg->GetCustomPostTypes();
1096
+
1097
  $enabledPostTypes = $this->sg->GetOption('in_customtypes');
1098
+
1099
  if(count($custom_post_types)>0) {
1100
+ ?><b><?php _e('Custom post types', 'sitemap') ?>:</b><ul><?php
1101
+
1102
  foreach ($custom_post_types as $post_type) {
1103
  $post_type_object = get_post_type_object($post_type);
1104
+
1105
  if (is_array($enabledPostTypes)) $selected = in_array($post_type_object->name, $enabledPostTypes);
1106
 
1107
  ?>
1113
  </li>
1114
  <?php
1115
  }
1116
+
1117
+ ?></ul><?php
1118
  }
1119
  }
1120
+
1121
  ?>
1122
+
1123
  <b><?php _e('Further options', 'sitemap') ?>:</b>
1124
  <ul>
1125
  <li>
1130
  <small><?php _e('This is highly recommended and helps the search engines to know when your content has changed. This option affects <i>all</i> sitemap entries.', 'sitemap') ?></small>
1131
  </li>
1132
  </ul>
1133
+
1134
  <?php $this->HtmlPrintBoxFooter(); ?>
1135
+
1136
  <!-- Excluded Items -->
1137
  <?php $this->HtmlPrintBoxHeader('sm_excludes',__('Excluded items', 'sitemap')); ?>
1138
+
1139
  <b><?php _e('Excluded categories', 'sitemap') ?>:</b>
1140
  <?php if(version_compare($wp_version,"2.5.1",">=")): ?>
1141
  <cite style="display:block; margin-left:40px;"><?php _e("Note","sitemap") ?>: <?php _e("Using this feature will increase build time and memory usage!","sitemap"); ?></cite>
1147
  <?php else: ?>
1148
  <ul><li><?php echo sprintf(__("This feature requires at least WordPress 2.5.1, you are using %s","sitemap"),$wp_version); ?></li></ul>
1149
  <?php endif; ?>
1150
+
1151
  <b><?php _e("Exclude posts","sitemap"); ?>:</b>
1152
  <div style="margin:5px 0 13px 40px;">
1153
  <label for="sm_b_exclude"><?php _e('Exclude the following posts or pages:', 'sitemap') ?> <small><?php _e('List of IDs, separated by comma', 'sitemap') ?></small><br />
1154
  <input name="sm_b_exclude" id="sm_b_exclude" type="text" style="width:400px;" value="<?php echo implode(",",$this->sg->GetOption("b_exclude")); ?>" /></label><br />
1155
  <cite><?php _e("Note","sitemap") ?>: <?php _e("Child posts won't be excluded automatically!","sitemap"); ?></cite>
1156
  </div>
1157
+
1158
  <?php $this->HtmlPrintBoxFooter(); ?>
1159
+
1160
  <!-- Change frequencies -->
1161
  <?php $this->HtmlPrintBoxHeader('sm_change_frequencies',__('Change frequencies', 'sitemap')); ?>
1162
 
1216
  </label>
1217
  </li>
1218
  </ul>
1219
+
1220
  <?php $this->HtmlPrintBoxFooter(); ?>
1221
+
1222
  <!-- Priorities -->
1223
  <?php $this->HtmlPrintBoxHeader('sm_priorities',__('Priorities', 'sitemap')); ?>
1224
  <ul>
1273
  </label>
1274
  </li>
1275
  </ul>
1276
+
1277
  <?php $this->HtmlPrintBoxFooter(); ?>
1278
+
1279
  </div>
1280
  <div>
1281
  <p class="submit">
1284
  <input type="submit" onclick='return confirm("Do you really want to reset your configuration?");' class="sm_warning" name="sm_reset_config" value="<?php _e('Reset options', 'sitemap'); ?>" />
1285
  </p>
1286
  </div>
1287
+
1288
  <?php if($this->mode == 27): ?>
1289
  </div>
1290
  </div>
sitemap.php CHANGED
@@ -1,21 +1,21 @@
1
  <?php
2
 
3
  /*
4
- $Id: sitemap.php 583238 2012-08-08 21:10:26Z arnee $
5
 
6
  Google XML Sitemaps Generator for WordPress
7
  ==============================================================================
8
-
9
  This generator will create a sitemaps.org compliant sitemap of your WordPress blog.
10
  Currently homepage, posts, static pages, categories, archives and author pages are supported.
11
-
12
  The priority of a post depends on its comments. You can choose the way the priority
13
  is calculated in the options screen.
14
-
15
  Feel free to visit my website under www.arnebrachhold.de!
16
 
17
  For aditional details like installation instructions, please check the readme.txt and documentation.txt files.
18
-
19
  Have fun!
20
  Arne
21
 
@@ -25,12 +25,12 @@
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.8
29
  Author: Arne Brachhold
30
  Author URI: http://www.arnebrachhold.de/
31
  Text Domain: sitemap
32
  Domain Path: /lang/
33
-
34
  */
35
 
36
  /**
@@ -52,52 +52,52 @@ class GoogleSitemapGeneratorLoader {
52
  if((defined('WP_ALLOW_MULTISITE') && WP_ALLOW_MULTISITE) || (function_exists('is_multisite') && is_multisite())) {
53
  if(function_exists('is_super_admin') && is_super_admin()) {
54
  add_action('admin_notices', array('GoogleSitemapGeneratorLoader', 'AddMultisiteWarning'));
55
- }
56
-
57
  return;
58
  }
59
-
60
  //Register the sitemap creator to wordpress...
61
  add_action('admin_menu', array('GoogleSitemapGeneratorLoader', 'RegisterAdminPage'));
62
-
63
  //Nice icon for Admin Menu (requires Ozh Admin Drop Down Plugin)
64
  add_filter('ozh_adminmenu_icon', array('GoogleSitemapGeneratorLoader', 'RegisterAdminIcon'));
65
-
66
  //Additional links on the plugin page
67
  add_filter('plugin_row_meta', array('GoogleSitemapGeneratorLoader', 'RegisterPluginLinks'),10,2);
68
 
69
  //Existing posts was deleted
70
  add_action('delete_post', array('GoogleSitemapGeneratorLoader', 'CallCheckForAutoBuild'),9999,1);
71
-
72
  //Existing post was published
73
  add_action('publish_post', array('GoogleSitemapGeneratorLoader', 'CallCheckForAutoBuild'),9999,1);
74
-
75
  //Existing page was published
76
  add_action('publish_page', array('GoogleSitemapGeneratorLoader', 'CallCheckForAutoBuild'),9999,1);
77
-
78
  //WP Cron hook
79
  add_action('sm_build_cron', array('GoogleSitemapGeneratorLoader', 'CallBuildSitemap'),1,0);
80
-
81
  //External build hook
82
  add_action('sm_rebuild', array('GoogleSitemapGeneratorLoader', 'CallBuildNowRequest'),1,0);
83
-
84
  //Robots.txt request
85
  add_action('do_robots', array('GoogleSitemapGeneratorLoader', 'CallDoRobots'),100,0);
86
-
87
  //Help topics for context sensitive help
88
  add_filter('contextual_help_list', array('GoogleSitemapGeneratorLoader', 'CallHtmlShowHelpList'),9999,2);
89
-
90
  //Check if this is a BUILD-NOW request (key will be checked later)
91
  if(!empty($_GET["sm_command"]) && !empty($_GET["sm_key"])) {
92
  GoogleSitemapGeneratorLoader::CallCheckForManualBuild();
93
  }
94
-
95
  //Check if the result of a ping request should be shown
96
  if(!empty($_GET["sm_ping_service"])) {
97
  GoogleSitemapGeneratorLoader::CallShowPingResult();
98
  }
99
  }
100
-
101
  /**
102
  * Outputs the warning bar if multisite mode is activated
103
  */
@@ -109,19 +109,19 @@ class GoogleSitemapGeneratorLoader {
109
  * Registers the plugin in the admin menu system
110
  */
111
  function RegisterAdminPage() {
112
-
113
  if (function_exists('add_options_page')) {
114
  add_options_page(__('XML-Sitemap Generator','sitemap'), __('XML-Sitemap','sitemap'), 'level_10', GoogleSitemapGeneratorLoader::GetBaseName(), array('GoogleSitemapGeneratorLoader','CallHtmlShowOptionsPage'));
115
  }
116
  }
117
-
118
  function RegisterAdminIcon($hook) {
119
  if ( $hook == GoogleSitemapGeneratorLoader::GetBaseName() && function_exists('plugins_url')) {
120
  return plugins_url('img/icon-arne.gif',GoogleSitemapGeneratorLoader::GetBaseName());
121
  }
122
  return $hook;
123
  }
124
-
125
  function RegisterPluginLinks($links, $file) {
126
  $base = GoogleSitemapGeneratorLoader::GetBaseName();
127
  if ($file == $base) {
@@ -132,7 +132,7 @@ class GoogleSitemapGeneratorLoader {
132
  }
133
  return $links;
134
  }
135
-
136
  /**
137
  * Invokes the HtmlShowOptionsPage method of the generator
138
  */
@@ -142,7 +142,7 @@ class GoogleSitemapGeneratorLoader {
142
  $gs->HtmlShowOptionsPage();
143
  }
144
  }
145
-
146
  /**
147
  * Invokes the CheckForAutoBuild method of the generator
148
  */
@@ -152,7 +152,7 @@ class GoogleSitemapGeneratorLoader {
152
  $gs->CheckForAutoBuild($args);
153
  }
154
  }
155
-
156
  /**
157
  * Invokes the CheckForAutoBuild method of the generator
158
  */
@@ -162,7 +162,7 @@ class GoogleSitemapGeneratorLoader {
162
  $gs->BuildNowRequest();
163
  }
164
  }
165
-
166
  /**
167
  * Invokes the BuildSitemap method of the generator
168
  */
@@ -172,7 +172,7 @@ class GoogleSitemapGeneratorLoader {
172
  $gs->BuildSitemap();
173
  }
174
  }
175
-
176
  /**
177
  * Invokes the CheckForManualBuild method of the generator
178
  */
@@ -182,7 +182,7 @@ class GoogleSitemapGeneratorLoader {
182
  $gs->CheckForManualBuild();
183
  }
184
  }
185
-
186
  /**
187
  * Invokes the ShowPingResult method of the generator
188
  */
@@ -192,20 +192,20 @@ class GoogleSitemapGeneratorLoader {
192
  $gs->ShowPingResult();
193
  }
194
  }
195
-
196
 
197
  function CallHtmlShowHelpList($filterVal,$screen) {
198
-
199
- $id = get_plugin_page_hookname(GoogleSitemapGeneratorLoader::GetBaseName(),'options-general.php');
200
-
201
  if($screen == $id) {
202
  $links = array(
203
  __('Plugin Homepage','sitemap')=>'http://www.arnebrachhold.de/redir/sitemap-help-home/',
204
  __('My Sitemaps FAQ','sitemap')=>'http://www.arnebrachhold.de/redir/sitemap-help-faq/'
205
  );
206
-
207
  $filterVal[$id] = '';
208
-
209
  $i=0;
210
  foreach($links AS $text=>$url) {
211
  $filterVal[$id].='<a href="' . $url . '">' . $text . '</a>' . ($i < (count($links)-1)?'<br />':'') ;
@@ -214,35 +214,35 @@ class GoogleSitemapGeneratorLoader {
214
  }
215
  return $filterVal;
216
  }
217
-
218
  function CallDoRobots() {
219
  if(GoogleSitemapGeneratorLoader::LoadPlugin()) {
220
  $gs = &GoogleSitemapGenerator::GetInstance();
221
  $gs->DoRobots();
222
  }
223
  }
224
-
225
  /**
226
  * Loads the actual generator class and tries to raise the memory and time limits if not already done by WP
227
  *
228
  * @return boolean true if run successfully
229
  */
230
  function LoadPlugin() {
231
-
232
  $mem = abs(intval(@ini_get('memory_limit')));
233
  if($mem && $mem < 64) {
234
  @ini_set('memory_limit', '64M');
235
  }
236
-
237
  $time = abs(intval(@ini_get("max_execution_time")));
238
  if($time != 0 && $time < 120) {
239
  @set_time_limit(120);
240
  }
241
-
242
  if(!class_exists("GoogleSitemapGenerator")) {
243
-
244
  $path = trailingslashit(dirname(__FILE__));
245
-
246
  if(!file_exists( $path . 'sitemap-core.php')) return false;
247
  require_once($path. 'sitemap-core.php');
248
  }
@@ -250,7 +250,7 @@ class GoogleSitemapGeneratorLoader {
250
  GoogleSitemapGenerator::Enable();
251
  return true;
252
  }
253
-
254
  /**
255
  * Returns the plugin basename of the plugin (using __FILE__)
256
  *
@@ -259,7 +259,7 @@ class GoogleSitemapGeneratorLoader {
259
  function GetBaseName() {
260
  return plugin_basename(__FILE__);
261
  }
262
-
263
  /**
264
  * Returns the name of this loader script, using __FILE__
265
  *
@@ -268,7 +268,7 @@ class GoogleSitemapGeneratorLoader {
268
  function GetPluginFile() {
269
  return __FILE__;
270
  }
271
-
272
  /**
273
  * Returns the plugin version
274
  *
1
  <?php
2
 
3
  /*
4
+ $Id: sitemap.php 651444 2013-01-11 19:54:39Z arnee $
5
 
6
  Google XML Sitemaps Generator for WordPress
7
  ==============================================================================
8
+
9
  This generator will create a sitemaps.org compliant sitemap of your WordPress blog.
10
  Currently homepage, posts, static pages, categories, archives and author pages are supported.
11
+
12
  The priority of a post depends on its comments. You can choose the way the priority
13
  is calculated in the options screen.
14
+
15
  Feel free to visit my website under www.arnebrachhold.de!
16
 
17
  For aditional details like installation instructions, please check the readme.txt and documentation.txt files.
18
+
19
  Have fun!
20
  Arne
21
 
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.9
29
  Author: Arne Brachhold
30
  Author URI: http://www.arnebrachhold.de/
31
  Text Domain: sitemap
32
  Domain Path: /lang/
33
+
34
  */
35
 
36
  /**
52
  if((defined('WP_ALLOW_MULTISITE') && WP_ALLOW_MULTISITE) || (function_exists('is_multisite') && is_multisite())) {
53
  if(function_exists('is_super_admin') && is_super_admin()) {
54
  add_action('admin_notices', array('GoogleSitemapGeneratorLoader', 'AddMultisiteWarning'));
55
+ }
56
+
57
  return;
58
  }
59
+
60
  //Register the sitemap creator to wordpress...
61
  add_action('admin_menu', array('GoogleSitemapGeneratorLoader', 'RegisterAdminPage'));
62
+
63
  //Nice icon for Admin Menu (requires Ozh Admin Drop Down Plugin)
64
  add_filter('ozh_adminmenu_icon', array('GoogleSitemapGeneratorLoader', 'RegisterAdminIcon'));
65
+
66
  //Additional links on the plugin page
67
  add_filter('plugin_row_meta', array('GoogleSitemapGeneratorLoader', 'RegisterPluginLinks'),10,2);
68
 
69
  //Existing posts was deleted
70
  add_action('delete_post', array('GoogleSitemapGeneratorLoader', 'CallCheckForAutoBuild'),9999,1);
71
+
72
  //Existing post was published
73
  add_action('publish_post', array('GoogleSitemapGeneratorLoader', 'CallCheckForAutoBuild'),9999,1);
74
+
75
  //Existing page was published
76
  add_action('publish_page', array('GoogleSitemapGeneratorLoader', 'CallCheckForAutoBuild'),9999,1);
77
+
78
  //WP Cron hook
79
  add_action('sm_build_cron', array('GoogleSitemapGeneratorLoader', 'CallBuildSitemap'),1,0);
80
+
81
  //External build hook
82
  add_action('sm_rebuild', array('GoogleSitemapGeneratorLoader', 'CallBuildNowRequest'),1,0);
83
+
84
  //Robots.txt request
85
  add_action('do_robots', array('GoogleSitemapGeneratorLoader', 'CallDoRobots'),100,0);
86
+
87
  //Help topics for context sensitive help
88
  add_filter('contextual_help_list', array('GoogleSitemapGeneratorLoader', 'CallHtmlShowHelpList'),9999,2);
89
+
90
  //Check if this is a BUILD-NOW request (key will be checked later)
91
  if(!empty($_GET["sm_command"]) && !empty($_GET["sm_key"])) {
92
  GoogleSitemapGeneratorLoader::CallCheckForManualBuild();
93
  }
94
+
95
  //Check if the result of a ping request should be shown
96
  if(!empty($_GET["sm_ping_service"])) {
97
  GoogleSitemapGeneratorLoader::CallShowPingResult();
98
  }
99
  }
100
+
101
  /**
102
  * Outputs the warning bar if multisite mode is activated
103
  */
109
  * Registers the plugin in the admin menu system
110
  */
111
  function RegisterAdminPage() {
112
+
113
  if (function_exists('add_options_page')) {
114
  add_options_page(__('XML-Sitemap Generator','sitemap'), __('XML-Sitemap','sitemap'), 'level_10', GoogleSitemapGeneratorLoader::GetBaseName(), array('GoogleSitemapGeneratorLoader','CallHtmlShowOptionsPage'));
115
  }
116
  }
117
+
118
  function RegisterAdminIcon($hook) {
119
  if ( $hook == GoogleSitemapGeneratorLoader::GetBaseName() && function_exists('plugins_url')) {
120
  return plugins_url('img/icon-arne.gif',GoogleSitemapGeneratorLoader::GetBaseName());
121
  }
122
  return $hook;
123
  }
124
+
125
  function RegisterPluginLinks($links, $file) {
126
  $base = GoogleSitemapGeneratorLoader::GetBaseName();
127
  if ($file == $base) {
132
  }
133
  return $links;
134
  }
135
+
136
  /**
137
  * Invokes the HtmlShowOptionsPage method of the generator
138
  */
142
  $gs->HtmlShowOptionsPage();
143
  }
144
  }
145
+
146
  /**
147
  * Invokes the CheckForAutoBuild method of the generator
148
  */
152
  $gs->CheckForAutoBuild($args);
153
  }
154
  }
155
+
156
  /**
157
  * Invokes the CheckForAutoBuild method of the generator
158
  */
162
  $gs->BuildNowRequest();
163
  }
164
  }
165
+
166
  /**
167
  * Invokes the BuildSitemap method of the generator
168
  */
172
  $gs->BuildSitemap();
173
  }
174
  }
175
+
176
  /**
177
  * Invokes the CheckForManualBuild method of the generator
178
  */
182
  $gs->CheckForManualBuild();
183
  }
184
  }
185
+
186
  /**
187
  * Invokes the ShowPingResult method of the generator
188
  */
192
  $gs->ShowPingResult();
193
  }
194
  }
195
+
196
 
197
  function CallHtmlShowHelpList($filterVal,$screen) {
198
+
199
+ $id = get_plugin_page_hookname(GoogleSitemapGeneratorLoader::GetBaseName(),'options-general.php');
200
+
201
  if($screen == $id) {
202
  $links = array(
203
  __('Plugin Homepage','sitemap')=>'http://www.arnebrachhold.de/redir/sitemap-help-home/',
204
  __('My Sitemaps FAQ','sitemap')=>'http://www.arnebrachhold.de/redir/sitemap-help-faq/'
205
  );
206
+
207
  $filterVal[$id] = '';
208
+
209
  $i=0;
210
  foreach($links AS $text=>$url) {
211
  $filterVal[$id].='<a href="' . $url . '">' . $text . '</a>' . ($i < (count($links)-1)?'<br />':'') ;
214
  }
215
  return $filterVal;
216
  }
217
+
218
  function CallDoRobots() {
219
  if(GoogleSitemapGeneratorLoader::LoadPlugin()) {
220
  $gs = &GoogleSitemapGenerator::GetInstance();
221
  $gs->DoRobots();
222
  }
223
  }
224
+
225
  /**
226
  * Loads the actual generator class and tries to raise the memory and time limits if not already done by WP
227
  *
228
  * @return boolean true if run successfully
229
  */
230
  function LoadPlugin() {
231
+
232
  $mem = abs(intval(@ini_get('memory_limit')));
233
  if($mem && $mem < 64) {
234
  @ini_set('memory_limit', '64M');
235
  }
236
+
237
  $time = abs(intval(@ini_get("max_execution_time")));
238
  if($time != 0 && $time < 120) {
239
  @set_time_limit(120);
240
  }
241
+
242
  if(!class_exists("GoogleSitemapGenerator")) {
243
+
244
  $path = trailingslashit(dirname(__FILE__));
245
+
246
  if(!file_exists( $path . 'sitemap-core.php')) return false;
247
  require_once($path. 'sitemap-core.php');
248
  }
250
  GoogleSitemapGenerator::Enable();
251
  return true;
252
  }
253
+
254
  /**
255
  * Returns the plugin basename of the plugin (using __FILE__)
256
  *
259
  function GetBaseName() {
260
  return plugin_basename(__FILE__);
261
  }
262
+
263
  /**
264
  * Returns the name of this loader script, using __FILE__
265
  *
268
  function GetPluginFile() {
269
  return __FILE__;
270
  }
271
+
272
  /**
273
  * Returns the plugin version
274
  *