Simple Wp Sitemap - Version 1.1.1

Version Description

(Nov 11, 2015) = * Messed up the update, new try

Download this release

Release Info

Developer Webbjocke
Plugin Icon 128x128 Simple Wp Sitemap
Version 1.1.1
Comparing to
See all releases

Code changes from version 1.0.9 to 1.1.1

readme.txt CHANGED
@@ -3,10 +3,10 @@ Contributors: Webbjocke
3
  Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=UH6ANJA7M8DNS
4
  License: GPLv3
5
  License URI: http://www.gnu.org/licenses/gpl.html
6
- Tags: sitemap, google sitemap, xml, simple sitemap, html, xml sitemap, html sitemap, seo, seo sitemap
7
  Requires at least: 4.0
8
- Tested up to: 4.3
9
- Stable tag: 1.0.9
10
 
11
  An easy, fast and secure plugin that adds both an xml and an html sitemap to your site, which updates and maintains themselves so you dont have to!
12
 
@@ -22,6 +22,12 @@ So what the plugin actually does is making one sitemap.xml and one sitemap.html
22
 
23
  And yes, of course the sitemaps are mobile friendly. They also work well with caching plugins :)
24
 
 
 
 
 
 
 
25
  == Installation ==
26
 
27
  1. 1. Go to the plugins page in your wordpress admin area and hit "add new".
@@ -74,6 +80,17 @@ When you deactivate the plugin they get removed automatically.
74
 
75
  == Changelog ==
76
 
 
 
 
 
 
 
 
 
 
 
 
77
  = 1.0.9 (Jun 23, 2015) =
78
  * Added donation link
79
  * Made the sitemaps compatible down to ie7
3
  Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=UH6ANJA7M8DNS
4
  License: GPLv3
5
  License URI: http://www.gnu.org/licenses/gpl.html
6
+ Tags: sitemap, google sitemap, xml, simple sitemap, html, xml sitemap, html sitemap, seo, seo sitemap, sitemaps, site map, sitemap html, sitemap xml
7
  Requires at least: 4.0
8
+ Tested up to: 4.4
9
+ Stable tag: 1.1.1
10
 
11
  An easy, fast and secure plugin that adds both an xml and an html sitemap to your site, which updates and maintains themselves so you dont have to!
12
 
22
 
23
  And yes, of course the sitemaps are mobile friendly. They also work well with caching plugins :)
24
 
25
+ I would like to add a review here someone gave after installing this plugin:
26
+
27
+ Q: So what do you like about this sitemap plugin?
28
+
29
+ A: That the sitemaps are always updated automatically! Every time I add a new, update or delete a post or page my sitemap is also always updated. It means a lot to know that whenever a user or google visits my site the sitemaps are always up to date and shows what I want them to show, and blocks what I do not want them to.
30
+
31
  == Installation ==
32
 
33
  1. 1. Go to the plugins page in your wordpress admin area and hit "add new".
80
 
81
  == Changelog ==
82
 
83
+ = 1.1.1 (Nov 11, 2015) =
84
+ * Messed up the update, new try
85
+
86
+ = 1.1.0 (Nov 11, 2015) =
87
+ * Changed date format in html sitemap to (Y-m-d H:i:s)
88
+ * Added lang attribute and to be automatically set
89
+ * Added some tags and updated the plugin page
90
+ * Removed unnecessary fixes for old versions of the plugin
91
+ * Changes done "under the hood" in php for performance etc
92
+ * Also tested with wordpress 4.4
93
+
94
  = 1.0.9 (Jun 23, 2015) =
95
  * Added donation link
96
  * Made the sitemaps compatible down to ie7
simple-wp-sitemap.php CHANGED
@@ -4,7 +4,7 @@
4
  * Plugin Name: Simple Wp Sitemap
5
  * Plugin URI: http://www.webbjocke.com/simple-wp-sitemap/
6
  * Description: An easy, fast and secure plugin that adds both an xml and an html sitemap to your site, which updates and maintains themselves so you dont have to!
7
- * Version: 1.0.9
8
  * Author: Webbjocke
9
  * Author URI: http://www.webbjocke.com/
10
  * License: GPLv3
@@ -18,8 +18,7 @@ class SimpleWpSitemap {
18
  // Runs on plugin activation
19
  public static function activateSitemaps () {
20
  self::rewriteRules();
21
- flush_rewrite_rules();
22
-
23
  update_option('simple_wp_sitemap_version', self::$version);
24
 
25
  // deletes files sitemap.xml and .html from old versions of the plugin
@@ -34,8 +33,7 @@ class SimpleWpSitemap {
34
 
35
  // Updates the plugin if needed (calls activateSitemaps)
36
  public static function updateCheck () {
37
- $current = get_option('simple_wp_sitemap_version');
38
-
39
  if (!$current || $current < self::$version) {
40
  self::activateSitemaps();
41
  }
@@ -92,11 +90,9 @@ class SimpleWpSitemap {
92
 
93
  // Generates the content
94
  public static function generateSitemapContent () {
95
- global $wp_query;
96
-
97
  if (isset($wp_query->query_vars['thesimplewpsitemap'])) {
98
- $q = $wp_query->query_vars['thesimplewpsitemap'];
99
-
100
  if (!empty($q) && ($q === 'xml' || $q === 'html')) {
101
  $wp_query->is_404 = false;
102
 
@@ -107,7 +103,7 @@ class SimpleWpSitemap {
107
  header('Content-type: application/xml; charset=utf-8');
108
  }
109
  $sitemap->getContent($q);
110
- exit;
111
  }
112
  }
113
  }
@@ -188,8 +184,7 @@ class SimpleWpSitemap {
188
 
189
  <ul id="sitemap-display-order">
190
 
191
- <?php
192
-
193
  if (!($orderArray = $options->getOptions('simple_wp_disp_sitemap_order'))) {
194
  $orderArray = array('Home' => null, 'Posts' => null, 'Pages' => null, 'Other' => null, 'Categories' => null, 'Tags' => null, 'Authors' => null);
195
  }
@@ -197,8 +192,7 @@ class SimpleWpSitemap {
197
 
198
  foreach ($orderArray as $title => $val) {
199
  printf('<li>%s<span class="sitemap-down" title="move down"></span><span class="sitemap-up" title="move up"></span><input type="hidden" name="simple_wp_%s_n" value="%d"></li>', $title, lcfirst($title), ($count++));
200
- }
201
-
202
  ?>
203
 
204
  </ul>
4
  * Plugin Name: Simple Wp Sitemap
5
  * Plugin URI: http://www.webbjocke.com/simple-wp-sitemap/
6
  * Description: An easy, fast and secure plugin that adds both an xml and an html sitemap to your site, which updates and maintains themselves so you dont have to!
7
+ * Version: 1.1.1
8
  * Author: Webbjocke
9
  * Author URI: http://www.webbjocke.com/
10
  * License: GPLv3
18
  // Runs on plugin activation
19
  public static function activateSitemaps () {
20
  self::rewriteRules();
21
+ flush_rewrite_rules();
 
22
  update_option('simple_wp_sitemap_version', self::$version);
23
 
24
  // deletes files sitemap.xml and .html from old versions of the plugin
33
 
34
  // Updates the plugin if needed (calls activateSitemaps)
35
  public static function updateCheck () {
36
+ $current = get_option('simple_wp_sitemap_version');
 
37
  if (!$current || $current < self::$version) {
38
  self::activateSitemaps();
39
  }
90
 
91
  // Generates the content
92
  public static function generateSitemapContent () {
93
+ global $wp_query;
 
94
  if (isset($wp_query->query_vars['thesimplewpsitemap'])) {
95
+ $q = $wp_query->query_vars['thesimplewpsitemap'];
 
96
  if (!empty($q) && ($q === 'xml' || $q === 'html')) {
97
  $wp_query->is_404 = false;
98
 
103
  header('Content-type: application/xml; charset=utf-8');
104
  }
105
  $sitemap->getContent($q);
106
+ exit;
107
  }
108
  }
109
  }
184
 
185
  <ul id="sitemap-display-order">
186
 
187
+ <?php
 
188
  if (!($orderArray = $options->getOptions('simple_wp_disp_sitemap_order'))) {
189
  $orderArray = array('Home' => null, 'Posts' => null, 'Pages' => null, 'Other' => null, 'Categories' => null, 'Tags' => null, 'Authors' => null);
190
  }
192
 
193
  foreach ($orderArray as $title => $val) {
194
  printf('<li>%s<span class="sitemap-down" title="move down"></span><span class="sitemap-up" title="move up"></span><input type="hidden" name="simple_wp_%s_n" value="%d"></li>', $title, lcfirst($title), ($count++));
195
+ }
 
196
  ?>
197
 
198
  </ul>
simpleWpMapBuilder.php CHANGED
@@ -9,12 +9,13 @@ class SimpleWpMapBuilder {
9
  private $html = false;
10
  private $posts = '';
11
  private $pages = '';
 
12
  private $url;
13
  private $tags;
 
14
  private $homeUrl;
15
  private $authors;
16
  private $categories;
17
- private $blockedUrls;
18
 
19
  // Constructor
20
  public function __construct () {
@@ -23,12 +24,15 @@ class SimpleWpMapBuilder {
23
  $this->categories = get_option('simple_wp_disp_categories') ? array(0 => 0) : false;
24
  $this->tags = get_option('simple_wp_disp_tags') ? array(0 => 0) : false;
25
  $this->authors = get_option('simple_wp_disp_authors') ? array(0 => 0) : false;
 
 
26
  }
27
 
28
  // Generates the sitemaps and returns the content
29
  public function getContent ($type) {
30
  if ($type === 'xml' || $type === 'html') {
31
  $this->$type = true;
 
32
  $this->setUpBlockedUrls();
33
  $this->generateContent();
34
  $this->mergeAndPrint();
@@ -37,12 +41,14 @@ class SimpleWpMapBuilder {
37
 
38
  // Returns other urls user has submitted
39
  private function getOtherPages () {
40
- $xml = '';
41
-
42
  if ($options = get_option('simple_wp_other_urls')) {
43
  foreach ($options as $option) {
44
  if ($option && is_array($option)) {
45
- $xml .= $this->getXml(esc_url($option['url']), esc_html($option['date']));
 
 
 
46
  }
47
  }
48
  }
@@ -51,71 +57,50 @@ class SimpleWpMapBuilder {
51
 
52
  // Sets up blocked urls into an array
53
  private function setUpBlockedUrls () {
54
- $blocked = get_option('simple_wp_block_urls');
55
-
56
- if ($blocked && is_array($blocked)) {
57
- $this->blockedUrls = array();
58
  foreach ($blocked as $block) {
59
  $this->blockedUrls[$block['url']] = 'blocked';
60
  }
61
  }
62
- else {
63
- $this->blockedUrls = null;
64
- }
65
  }
66
 
67
  // Matches url against blocked ones that shouldn't be displayed
68
  private function isBlockedUrl($url) {
69
  return $this->blockedUrls && isset($this->blockedUrls[$url]);
70
- }
71
-
72
 
73
  // Returns an xml or html string
74
  private function getXml ($link, $date) {
75
- if ($this->xml) {
76
- return "<url>\n\t<loc>$link</loc>\n\t<lastmod>$date</lastmod>\n</url>\n";
77
- }
78
- else { // html
79
- return "<li><a title=\"$link\" href=\"$link\"><span class=\"link\">$link</span><span class=\"date\">$date</span></a></li>";
80
- }
81
  }
82
 
83
- // Returns table headers with specific names (has been changed to div)
84
- private function htmlTableH($name) {
85
- return '<div class="header"><p class="header-txt">' . $name . ':</p><p class="header-date">Last modified:</p></div>';
86
- }
87
-
88
- // Querys the database and gets the actual sitemaps content
89
  private function generateContent () {
90
- $q = new WP_Query(array('post_type' => 'any', 'post_status' => 'publish', 'posts_per_page' => 50000, 'has_password' => false));
91
-
92
- global $post;
93
- $localPost = $post;
94
 
95
  if ($q->have_posts()) {
96
  while ($q->have_posts()) {
97
  $q->the_post();
98
-
99
  $link = esc_url(get_permalink());
100
- $date = esc_html(get_the_modified_date('Y-m-d\TH:i:sP'));
101
-
102
  $this->getCategoriesTagsAndAuthor($date);
103
 
104
  if (!$this->isBlockedUrl($link)) {
105
  if (!$this->home && $link === $this->homeUrl) {
106
  $this->home = $this->getXml($link, $date);
107
- }
108
- elseif ('page' === get_post_type()) {
109
  $this->pages .= $this->getXml($link, $date);
110
- }
111
- else { // posts (also all custom post types are added here)
112
  $this->posts .= $this->getXml($link, $date);
113
  }
114
  }
115
  }
116
- }
117
  wp_reset_postdata();
118
- $post = $localPost; // reset global post to its value before the loop
119
  }
120
 
121
  // Gets a posts categories, tags and author, and compares for last modified date
@@ -145,30 +130,9 @@ class SimpleWpMapBuilder {
145
 
146
  // Merges the arrays with post data into strings and gets user submitted pages, categories, tags and author pages
147
  private function mergeAndPrint () {
148
- $xml = '';
149
- $name = get_bloginfo('name');
150
- $sections = $this->getSortedArray();
151
-
152
- foreach ($sections as $title => $content) {
153
- if ($content) {
154
- if (preg_match("/^(Categories|Tags|Authors)$/", $title)) {
155
- $content = $this->stringifyCatsTagsAuths($title, $content);
156
- if ($title === 'Authors' && count($this->authors) <= 2) { // only one author
157
- $title = 'Author';
158
- }
159
- }
160
-
161
- if ($content) {
162
- $xml .= $this->xml ? $content : $this->htmlTableH($title) . "<ul>$content</ul>";
163
- }
164
- }
165
- }
166
- if ($this->xml) {
167
- echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<?xml-stylesheet type=\"text/css\" href=\"{$this->url}/css/xml.css\"?>\n<urlset xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://www.sitemaps.org/schemas/sitemap/0.9\n\thttp://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd\" xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\">\n$xml</urlset>\n<!-- Sitemap content by Simple Wp Sitemap -->";
168
- }
169
- else {
170
- echo '<!doctype html><html><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><title>' . $name . ' Html Sitemap</title><link rel="stylesheet" href="' . $this->url . '/css/html.css"></head><body><div id="wrapper"><h1>' . $name . ' Html Sitemap</h1>' . $xml . $this->attributionLink() . "</div></body></html>\n<!-- Sitemap content by Simple Wp Sitemap -->";
171
- }
172
  }
173
 
174
  // Displays attribution link if admin has checked the checkbox
@@ -178,54 +142,55 @@ class SimpleWpMapBuilder {
178
  }
179
  return '';
180
  }
181
-
182
- // Gets sorted array according to specified order
183
- private function getSortedArray () {
184
- if (!($arr = get_option('simple_wp_disp_sitemap_order'))) {
185
- $arr = array('Home' => null, 'Posts' => null, 'Pages' => null, 'Other' => null, 'Categories' => null, 'Tags' => null, 'Authors' => null);
186
- }
187
-
188
- if (!$this->home) { // if homepage isn't found in the query (for instance if it's not a real "page" it wont be found)
189
- @date_default_timezone_set(get_option('timezone_string'));
190
- $this->home = $this->getXml($this->homeUrl, date('Y-m-d\TH:i:sP'));
191
- }
192
-
193
- // copy to array and also clear some memory (some sites have a huge amount of posts)
194
- $arr['Home'] = $this->home; $this->home = null;
195
- $arr['Posts'] = $this->posts; $this->posts = null;
196
- $arr['Pages'] = $this->pages; $this->pages = null;
197
- $arr['Categories'] = $this->categories; $this->categories = null;
198
- $arr['Tags'] = $this->tags; $this->tags = null;
199
- $arr['Authors'] = $this->authors; $this->authors = null;
200
- $arr['Other'] = $this->getOtherPages();
201
-
202
- return $arr;
203
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
204
 
205
  // Returns category, tag and author links as ready xml and html strings
206
  private function stringifyCatsTagsAuths ($type, $content) {
207
- $xml = '';
208
-
209
- foreach ($content as $id => $date) {
210
- if ($date) {
211
- $link = esc_url($this->getLink($id, $type));
212
- if (!$this->isBlockedUrl($link)) {
213
- $xml .= $this->getXml($link, $date);
214
- }
215
- }
216
- }
 
 
 
 
 
217
  return $xml;
218
  }
219
 
220
- // Returns either a category, tag or an author link
221
- private function getLink ($id, $type) {
222
- switch ($type) {
223
- case 'Tags': return get_tag_link($id);
224
- case 'Categories': return get_category_link($id);
225
- default: return get_author_posts_url($id); // Authors
226
- }
227
- }
228
-
229
  // Deletes the sitemap files from old versions of the plugin
230
  public static function deleteFiles () {
231
  if (function_exists('get_home_path')) {
9
  private $html = false;
10
  private $posts = '';
11
  private $pages = '';
12
+ private $blockedUrls = null;
13
  private $url;
14
  private $tags;
15
+ private $other;
16
  private $homeUrl;
17
  private $authors;
18
  private $categories;
 
19
 
20
  // Constructor
21
  public function __construct () {
24
  $this->categories = get_option('simple_wp_disp_categories') ? array(0 => 0) : false;
25
  $this->tags = get_option('simple_wp_disp_tags') ? array(0 => 0) : false;
26
  $this->authors = get_option('simple_wp_disp_authors') ? array(0 => 0) : false;
27
+ $this->blockedUrls = get_option('simple_wp_block_urls');
28
+ @date_default_timezone_set(get_option('timezone_string'));
29
  }
30
 
31
  // Generates the sitemaps and returns the content
32
  public function getContent ($type) {
33
  if ($type === 'xml' || $type === 'html') {
34
  $this->$type = true;
35
+ $this->other = $this->getOtherPages();
36
  $this->setUpBlockedUrls();
37
  $this->generateContent();
38
  $this->mergeAndPrint();
41
 
42
  // Returns other urls user has submitted
43
  private function getOtherPages () {
44
+ $xml = '';
 
45
  if ($options = get_option('simple_wp_other_urls')) {
46
  foreach ($options as $option) {
47
  if ($option && is_array($option)) {
48
+ if (!is_int($option['date'])) { // fix for old versions of the plugin when date was stored in clear text
49
+ $option['date'] = strtotime($option['date']);
50
+ }
51
+ $xml .= $this->getXml(esc_url($option['url']), esc_html(date($this->xml ? 'Y-m-d\TH:i:sP' : 'Y-m-d H:i', $option['date'])));
52
  }
53
  }
54
  }
57
 
58
  // Sets up blocked urls into an array
59
  private function setUpBlockedUrls () {
60
+ if (($blocked = get_option('simple_wp_block_urls')) && is_array($blocked)) {
61
+ $this->blockedUrls = array();
 
 
62
  foreach ($blocked as $block) {
63
  $this->blockedUrls[$block['url']] = 'blocked';
64
  }
65
  }
 
 
 
66
  }
67
 
68
  // Matches url against blocked ones that shouldn't be displayed
69
  private function isBlockedUrl($url) {
70
  return $this->blockedUrls && isset($this->blockedUrls[$url]);
71
+ }
 
72
 
73
  // Returns an xml or html string
74
  private function getXml ($link, $date) {
75
+ return $this->xml ?
76
+ "<url>\n\t<loc>$link</loc>\n\t<lastmod>$date</lastmod>\n</url>\n" :
77
+ "<li><a title=\"$link\" href=\"$link\"><span class=\"link\">$link</span><span class=\"date\">$date</span></a></li>";
 
 
 
78
  }
79
 
80
+ // Querys the database and gets the actual sitemaps content
 
 
 
 
 
81
  private function generateContent () {
82
+ $q = new WP_Query(array('post_type' => 'any', 'post_status' => 'publish', 'posts_per_page' => 50000, 'has_password' => false));
 
 
 
83
 
84
  if ($q->have_posts()) {
85
  while ($q->have_posts()) {
86
  $q->the_post();
87
+
88
  $link = esc_url(get_permalink());
89
+ $date = get_the_modified_date($this->xml ? 'Y-m-d\TH:i:sP' : 'Y-m-d H:i');
 
90
  $this->getCategoriesTagsAndAuthor($date);
91
 
92
  if (!$this->isBlockedUrl($link)) {
93
  if (!$this->home && $link === $this->homeUrl) {
94
  $this->home = $this->getXml($link, $date);
95
+ } elseif (get_post_type() === 'page') {
 
96
  $this->pages .= $this->getXml($link, $date);
97
+ } else { // posts (also all custom post types are added here)
 
98
  $this->posts .= $this->getXml($link, $date);
99
  }
100
  }
101
  }
102
+ }
103
  wp_reset_postdata();
 
104
  }
105
 
106
  // Gets a posts categories, tags and author, and compares for last modified date
130
 
131
  // Merges the arrays with post data into strings and gets user submitted pages, categories, tags and author pages
132
  private function mergeAndPrint () {
133
+ echo $this->xml ?
134
+ "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<?xml-stylesheet type=\"text/css\" href=\"" . $this->url . "/css/xml.css\"?>\n<urlset xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://www.sitemaps.org/schemas/sitemap/0.9\n\thttp://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd\" xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\">\n" . $this->sortAndGetString() . "</urlset>\n<!-- Sitemap content by Simple Wp Sitemap -->":
135
+ '<!doctype html><html lang="' . get_locale() . '"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><title>' . get_bloginfo('name') . ' Html Sitemap</title><link rel="stylesheet" href="' . $this->url . '/css/html.css"></head><body><div id="wrapper"><h1>' . get_bloginfo('name') . ' Html Sitemap</h1>' . $this->sortAndGetString() . $this->attributionLink() . "</div></body></html>\n<!-- Sitemap content by Simple Wp Sitemap -->";
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
136
  }
137
 
138
  // Displays attribution link if admin has checked the checkbox
142
  }
143
  return '';
144
  }
145
+
146
+ // Returns sorted array as string according to specified order
147
+ private function sortAndGetString () {
148
+ if (!($arr = get_option('simple_wp_disp_sitemap_order'))) { $arr = array('Home' => null, 'Posts' => null, 'Pages' => null, 'Other' => null, 'Categories' => null, 'Tags' => null, 'Authors' => null); }
149
+ if (!$this->home) { $this->home = $this->getXml($this->homeUrl, date($this->xml ? 'Y-m-d\TH:i:sP' : 'Y-m-d H:i')); }
150
+
151
+ $str = '';
152
+ foreach ($arr as $title => $val) {
153
+ $str .= $this->getTitleStr(lcfirst($title));
154
+ }
155
+ return $str;
 
 
 
 
 
 
 
 
 
 
 
156
  }
157
+
158
+ // Returns a title as string
159
+ private function getTitleStr ($title) {
160
+ $xml = $this->$title ? $this->$title : '';
161
+ if ($xml) {
162
+ if (in_array($title, array('categories', 'tags', 'authors'))) {
163
+ $xml = $this->stringifyCatsTagsAuths($title, $xml);
164
+ if ($title === 'authors' && count($this->authors) <= 2) { $title = 'author'; } // if one or more authors
165
+ }
166
+ if ($xml) {
167
+ $xml = $this->xml ? $xml : '<div class="header"><p class="header-txt">' . ucfirst($title) . ':</p><p class="header-date">Last updated:</p></div><ul>' . $xml . '</ul>';
168
+ $this->$title = null; // clear some memory (sites with huge amount of posts will be happy)
169
+ }
170
+ }
171
+ return $xml;
172
+ }
173
 
174
  // Returns category, tag and author links as ready xml and html strings
175
  private function stringifyCatsTagsAuths ($type, $content) {
176
+ $xml = '';
177
+ if ($content) {
178
+ foreach ($content as $id => $date) {
179
+ if ($date) {
180
+ switch ($type) {
181
+ case 'tags': $link = esc_url(get_tag_link($id)); break;
182
+ case 'categories': $link = esc_url(get_category_link($id)); break;
183
+ default: $link = esc_url(get_author_posts_url($id)); // Authors
184
+ }
185
+ if (!$this->isBlockedUrl($link)) {
186
+ $xml .= $this->getXml($link, $date);
187
+ }
188
+ }
189
+ }
190
+ }
191
  return $xml;
192
  }
193
 
 
 
 
 
 
 
 
 
 
194
  // Deletes the sitemap files from old versions of the plugin
195
  public static function deleteFiles () {
196
  if (function_exists('get_home_path')) {
simpleWpMapOptions.php CHANGED
@@ -36,14 +36,11 @@ class SimpleWpMapOptions {
36
  public function getOptions ($val) {
37
  if (preg_match("/^simple_wp_(other_urls|block_urls)$/", $val)) {
38
  $val = get_option($val);
39
- }
40
- elseif (preg_match("/^simple_wp_(attr_link|disp_categories|disp_tags|disp_authors)$/", $val)) {
41
  return get_option($val) ? 'checked' : ''; // return checkbox checked values right here and dont bother with the loop below
42
- }
43
- elseif ($val === 'simple_wp_disp_sitemap_order' && ($orderArray = get_option($val))) {
44
  return $this->checkOrder($orderArray);
45
- }
46
- else {
47
  $val = null;
48
  }
49
 
@@ -51,7 +48,7 @@ class SimpleWpMapOptions {
51
  if (!$this->isNullOrWhiteSpace($val)) {
52
  foreach ($val as $sArr) {
53
  $str .= $this->sanitizeUrl($sArr['url']) . "\n";
54
- }
55
  }
56
  return trim($str);
57
  }
@@ -102,7 +99,7 @@ class SimpleWpMapOptions {
102
  }
103
  }
104
  if (!$b && strlen($u) < 500) {
105
- $arr[] = array('url' => $u, 'date' => date('Y-m-d\TH:i:sP'));
106
  }
107
  }
108
  }
36
  public function getOptions ($val) {
37
  if (preg_match("/^simple_wp_(other_urls|block_urls)$/", $val)) {
38
  $val = get_option($val);
39
+ } elseif (preg_match("/^simple_wp_(attr_link|disp_categories|disp_tags|disp_authors)$/", $val)) {
 
40
  return get_option($val) ? 'checked' : ''; // return checkbox checked values right here and dont bother with the loop below
41
+ } elseif ($val === 'simple_wp_disp_sitemap_order' && ($orderArray = get_option($val))) {
 
42
  return $this->checkOrder($orderArray);
43
+ } else {
 
44
  $val = null;
45
  }
46
 
48
  if (!$this->isNullOrWhiteSpace($val)) {
49
  foreach ($val as $sArr) {
50
  $str .= $this->sanitizeUrl($sArr['url']) . "\n";
51
+ }
52
  }
53
  return trim($str);
54
  }
99
  }
100
  }
101
  if (!$b && strlen($u) < 500) {
102
+ $arr[] = array('url' => $u, 'date' => time());
103
  }
104
  }
105
  }