Simple Wp Sitemap - Version 1.0.4

Version Description

(March 18, 2015) = * Added options to include category, tag and author pages * Changed layout a bit and made it more responsive * Changed font to a more readable one

Download this release

Release Info

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

Code changes from version 1.0.3 to 1.0.4

css/html.css CHANGED
@@ -3,6 +3,10 @@
3
  padding: 0;
4
  }
5
  body{
 
 
 
 
6
  font-family: "Palatino Linotype", "Book Antiqua", Palatino, serif;
7
  }
8
  a{
@@ -10,6 +14,9 @@ a{
10
  color: black;
11
  word-break: break-all;
12
  transition: all 0.3s;
 
 
 
13
  }
14
  a:hover{
15
  background: whitesmoke;
@@ -21,7 +28,7 @@ h1{
21
  margin: 20px 0;
22
  }
23
  #wrapper{
24
- max-width: 960px;
25
  padding: 0 2% 40px 2%;
26
  margin: 0 auto;
27
  }
@@ -45,6 +52,19 @@ h1{
45
  margin-top: 25px;
46
  }
47
  @media screen and (max-width: 960px){
 
 
 
 
 
 
 
 
 
 
 
 
 
48
  .date{
49
  float: none;
50
  display: block;
3
  padding: 0;
4
  }
5
  body{
6
+ font-family: "Lucida Sans Unicode", "Lucida Grande", sans-serif;
7
+ font-size: 14px;
8
+ }
9
+ h1{
10
  font-family: "Palatino Linotype", "Book Antiqua", Palatino, serif;
11
  }
12
  a{
14
  color: black;
15
  word-break: break-all;
16
  transition: all 0.3s;
17
+ display: inline-block;
18
+ vertical-align: top;
19
+ max-width: 75%;
20
  }
21
  a:hover{
22
  background: whitesmoke;
28
  margin: 20px 0;
29
  }
30
  #wrapper{
31
+ max-width: 1080px;
32
  padding: 0 2% 40px 2%;
33
  margin: 0 auto;
34
  }
52
  margin-top: 25px;
53
  }
54
  @media screen and (max-width: 960px){
55
+ a{
56
+ max-width: 100%;
57
+ }
58
+ ul{
59
+ list-style-type: none;
60
+ padding: 0;
61
+ }
62
+ li{
63
+ border-bottom: 1px solid lightgray;
64
+ }
65
+ li:nth-child(2n){
66
+ background: whitesmoke;
67
+ }
68
  .date{
69
  float: none;
70
  display: block;
css/xml.css CHANGED
@@ -1,14 +1,14 @@
1
  urlset{
2
  display: block;
3
- max-width: 960px;
4
  margin: 10px auto;
5
- font-family: "Palatino Linotype", "Book Antiqua", Palatino, serif;
6
  }
7
  url{
8
  display: block;
9
  overflow: auto;
10
  padding: 5px;
11
- font-size: 0.9em;
12
  word-break: break-all;
13
  }
14
  url:nth-child(2n+1){
@@ -16,12 +16,14 @@ url:nth-child(2n+1){
16
  }
17
  loc{
18
  float: left;
 
19
  }
20
  lastmod{
21
  float: right;
22
  }
23
  @media screen and (max-width: 960px){
24
  loc, lastmod{
 
25
  width: 100%;
26
  float: left;
27
  }
1
  urlset{
2
  display: block;
3
+ max-width: 1080px;
4
  margin: 10px auto;
5
+ font-family: "Lucida Sans Unicode", "Lucida Grande", sans-serif;
6
  }
7
  url{
8
  display: block;
9
  overflow: auto;
10
  padding: 5px;
11
+ font-size: 0.8em;
12
  word-break: break-all;
13
  }
14
  url:nth-child(2n+1){
16
  }
17
  loc{
18
  float: left;
19
+ max-width: 75%;
20
  }
21
  lastmod{
22
  float: right;
23
  }
24
  @media screen and (max-width: 960px){
25
  loc, lastmod{
26
+ max-width: 100%;
27
  width: 100%;
28
  float: left;
29
  }
readme.txt CHANGED
@@ -5,7 +5,7 @@ License URI: http://www.gnu.org/licenses/gpl.html
5
  Tags: sitemap, google sitemap, xml, simple sitemap, html, xml sitemap, html sitemap, seo, seo sitemap
6
  Requires at least: 4.0
7
  Tested up to: 4.1.1
8
- Stable tag: 1.0.3
9
 
10
  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!
11
 
@@ -17,7 +17,7 @@ Reason the sitemaps are created as static files and aren't generated everytime s
17
 
18
  Also supports the option to add pages to the sitemaps that aren't part of your original wordpress site. For instance if you create a little html file and upload to your server and want it to be included in the sitemaps, it's easily done. You can also block pages that you don't want to be included in them.
19
 
20
- So why use this instead of the other hundreds(?) of sitemap plugins that's out are and which has thousands(?) of downloads? Well for one thing it's just an easy, fast and secure plugin that will just work for you, and it also makes the life pretty easy for search engines that wants to index your site!
21
 
22
  And yes, of course the sitemaps are mobile friendly :)
23
 
@@ -43,6 +43,11 @@ None so far :)
43
 
44
  == Changelog ==
45
 
 
 
 
 
 
46
  = 1.0.3 (March 16, 2015) =
47
  * New layout for both html and xml sitemaps
48
  * Created a logo for the plugin
5
  Tags: sitemap, google sitemap, xml, simple sitemap, html, xml sitemap, html sitemap, seo, seo sitemap
6
  Requires at least: 4.0
7
  Tested up to: 4.1.1
8
+ Stable tag: 1.0.4
9
 
10
  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!
11
 
17
 
18
  Also supports the option to add pages to the sitemaps that aren't part of your original wordpress site. For instance if you create a little html file and upload to your server and want it to be included in the sitemaps, it's easily done. You can also block pages that you don't want to be included in them.
19
 
20
+ So why use this instead of the other hundreds(?) of sitemap plugins that's out there and which has thousands(?) of downloads? Well for one thing it's just an easy, fast and secure plugin that will just work for you, and it also makes the life pretty easy for search engines that wants to index your site!
21
 
22
  And yes, of course the sitemaps are mobile friendly :)
23
 
43
 
44
  == Changelog ==
45
 
46
+ = 1.0.4 (March 18, 2015) =
47
+ * Added options to include category, tag and author pages
48
+ * Changed layout a bit and made it more responsive
49
+ * Changed font to a more readable one
50
+
51
  = 1.0.3 (March 16, 2015) =
52
  * New layout for both html and xml sitemaps
53
  * Created a logo for the plugin
simple-wp-sitemap.php CHANGED
@@ -2,9 +2,9 @@
2
 
3
  /*
4
  * Plugin Name: Simple Wp Sitemap
5
- * Plugin URI: https://wordpress.org/plugins/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.3
8
  * Author: Webbjocke
9
  * Author URI: http://www.webbjocke.com/
10
  * License: GPLv3
@@ -43,6 +43,9 @@ class SimpleWpSitemap {
43
  register_setting('simple_wp-sitemap-group', 'simple_wp_other_urls');
44
  register_setting('simple_wp-sitemap-group', 'simple_wp_block_urls');
45
  register_setting('simple_wp-sitemap-group', 'simple_wp_attr_link');
 
 
 
46
  }
47
 
48
  // Interface for settings page, also handles initial post request when settings are changed
@@ -51,11 +54,12 @@ class SimpleWpSitemap {
51
  $options = new SimpleWpMapOptions();
52
 
53
  if (isset($_POST['simple_wp_other_urls'], $_POST['simple_wp_block_urls'])){
54
- $options->setOptions($_POST['simple_wp_other_urls'], $_POST['simple_wp_block_urls'], isset($_POST['simple_wp_attr_link']) ? 1 : 0);
55
  self::updateSitemaps();
56
  } ?>
57
 
58
  <div class="wrap">
 
59
  <h1>Simple Wp Sitemap settings</h1>
60
 
61
  <p>Change and customize the sitemap</p>
@@ -66,17 +70,23 @@ class SimpleWpSitemap {
66
 
67
  <table class="widefat form-table">
68
 
69
- <tr><td><b>Add pages</b></td></tr>
70
  <tr><td>Add pages to the sitemaps in addition to the original wordpress ones. Just paste "absolute" links in the textarea like: <b>http://www.example.com/</b>, each link on a new row.</td></tr>
71
  <tr><td><textarea rows="7" name="simple_wp_other_urls" class="large-text code"><?php echo $options->getOptions('simple_wp_other_urls'); ?></textarea></td></tr>
72
 
73
- <tr><td><b>Block pages</b></td></tr>
74
  <tr><td>Add pages you dont't want to show up in the sitemaps. Same as above and just paste every link on a new row. (Hint: Copy paste the whole url from the address bar on the actual pages).</td></tr>
75
  <tr><td><textarea rows="7" name="simple_wp_block_urls" class="large-text code"><?php echo $options->getOptions('simple_wp_block_urls'); ?></textarea></td></tr>
76
 
77
- <tr><td><b>Like the plugin?</b></td></tr>
78
- <tr><td>Show your support by rating the plugin at wordpress.org, or atleast by adding an attribution link to the sitemap.html file :)</td></tr>
79
- <tr><td><input type="checkbox" name="simple_wp_attr_link" id="simple_wp_check" <?php echo $options->getOptions('simple_wp_attr_link'); ?>></input> <label for="simple_wp_check">Add "Generated by Simple Wp Sitemap" link to bottom of sitemap.html.</label></td></tr>
 
 
 
 
 
 
80
 
81
  </table>
82
 
2
 
3
  /*
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.4
8
  * Author: Webbjocke
9
  * Author URI: http://www.webbjocke.com/
10
  * License: GPLv3
43
  register_setting('simple_wp-sitemap-group', 'simple_wp_other_urls');
44
  register_setting('simple_wp-sitemap-group', 'simple_wp_block_urls');
45
  register_setting('simple_wp-sitemap-group', 'simple_wp_attr_link');
46
+ register_setting('simple_wp-sitemap-group', 'simple_wp_disp_categories');
47
+ register_setting('simple_wp-sitemap-group', 'simple_wp_disp_tags');
48
+ register_setting('simple_wp-sitemap-group', 'simple_wp_disp_authors');
49
  }
50
 
51
  // Interface for settings page, also handles initial post request when settings are changed
54
  $options = new SimpleWpMapOptions();
55
 
56
  if (isset($_POST['simple_wp_other_urls'], $_POST['simple_wp_block_urls'])){
57
+ $options->setOptions($_POST['simple_wp_other_urls'], $_POST['simple_wp_block_urls'], (isset($_POST['simple_wp_attr_link']) ? 1 : 0), (isset($_POST['simple_wp_disp_categories']) ? 1 : 0), (isset($_POST['simple_wp_disp_tags']) ? 1 : 0), (isset($_POST['simple_wp_disp_authors']) ? 1 : 0));
58
  self::updateSitemaps();
59
  } ?>
60
 
61
  <div class="wrap">
62
+
63
  <h1>Simple Wp Sitemap settings</h1>
64
 
65
  <p>Change and customize the sitemap</p>
70
 
71
  <table class="widefat form-table">
72
 
73
+ <tr><td><strong>Add pages</strong></td></tr>
74
  <tr><td>Add pages to the sitemaps in addition to the original wordpress ones. Just paste "absolute" links in the textarea like: <b>http://www.example.com/</b>, each link on a new row.</td></tr>
75
  <tr><td><textarea rows="7" name="simple_wp_other_urls" class="large-text code"><?php echo $options->getOptions('simple_wp_other_urls'); ?></textarea></td></tr>
76
 
77
+ <tr><td><strong>Block pages</strong></td></tr>
78
  <tr><td>Add pages you dont't want to show up in the sitemaps. Same as above and just paste every link on a new row. (Hint: Copy paste the whole url from the address bar on the actual pages).</td></tr>
79
  <tr><td><textarea rows="7" name="simple_wp_block_urls" class="large-text code"><?php echo $options->getOptions('simple_wp_block_urls'); ?></textarea></td></tr>
80
 
81
+ <tr><td><strong>Extra sitemap includes</strong></td></tr>
82
+ <tr><td>Check if you want to include categories, tags and/or author pages in the sitemaps.</td></tr>
83
+ <tr><td><input type="checkbox" name="simple_wp_disp_categories" id="simple_wp_cat" <?php echo $options->getOptions('simple_wp_disp_categories'); ?>></input><label for="simple_wp_cat"> Include categories</label></td></tr>
84
+ <tr><td><input type="checkbox" name="simple_wp_disp_tags" id="simple_wp_tags" <?php echo $options->getOptions('simple_wp_disp_tags'); ?>></input><label for="simple_wp_tags"> Include tags</label></td></tr>
85
+ <tr><td><input type="checkbox" name="simple_wp_disp_authors" id="simple_wp_authors" <?php echo $options->getOptions('simple_wp_disp_authors'); ?>></input><label for="simple_wp_authors"> Include authors</label></td></tr>
86
+
87
+ <tr><td><strong>Like the plugin?</strong></td></tr>
88
+ <tr><td>Show your support by rating the plugin at wordpress.org, or atleast by adding an attribution link on the sitemap.html file :)</td></tr>
89
+ <tr><td><input type="checkbox" name="simple_wp_attr_link" id="simple_wp_check" <?php echo $options->getOptions('simple_wp_attr_link'); ?>></input><label for="simple_wp_check"> Add "Generated by Simple Wp Sitemap" link at bottom of sitemap.html.</label></td></tr>
90
 
91
  </table>
92
 
simpleWpMapBuilder.php CHANGED
@@ -10,6 +10,9 @@ class SimpleWpMapBuilder {
10
  private $url;
11
  private $homeUrl;
12
  private $blockedUrls;
 
 
 
13
 
14
  // Constructor, the only public function this class has
15
  public function __construct($command){
@@ -22,12 +25,15 @@ class SimpleWpMapBuilder {
22
  break;
23
  case 'delete':
24
  $this->deleteSitemaps();
25
- break;
26
  }
27
  }
28
 
29
  // Generates the maps
30
- private function generateSitemaps(){
 
 
 
 
31
  $this->setUpBlockedUrls();
32
  $this->getContent();
33
 
@@ -43,11 +49,10 @@ class SimpleWpMapBuilder {
43
 
44
  // Returns other urls (not standard wordpress) user has submitted
45
  private function getOtherPages(){
46
- $options = get_option('simple_wp_other_urls');
47
  $html = '';
48
  $xml = '';
49
 
50
- if ($options){
51
  foreach($options as $option){
52
  if ($option && is_array($option)){
53
  $url = esc_url($option['url']);
@@ -67,7 +72,7 @@ class SimpleWpMapBuilder {
67
  $this->blockedUrls = array();
68
 
69
  foreach($blocked as $block){
70
- $this->blockedUrls[] = $block['url'];
71
  }
72
  }
73
  else{
@@ -75,9 +80,9 @@ class SimpleWpMapBuilder {
75
  }
76
  }
77
 
78
- // Matches url against all blocked ones that shouldn't be displayed
79
  private function isBlockedUrl($url){
80
- return $this->blockedUrls && in_array($url, $this->blockedUrls);
81
  }
82
 
83
  // Returns an html string
@@ -106,13 +111,15 @@ class SimpleWpMapBuilder {
106
  $homePage = false;
107
 
108
  if ($q->have_posts()) {
109
- while ($q->have_posts()) {
110
  $q->the_post();
111
 
112
  $link = esc_url(get_permalink());
113
  $date = esc_html(get_the_modified_date('Y-m-d\TH:i:sP'));
114
 
115
- if (!$this->isBlockedUrl($link)) {
 
 
116
  if ($link === $this->homeUrl) {
117
  $xml .= $this->getXml($link, $date);
118
  $html .= $this->getHtml($link, $date);
@@ -137,15 +144,46 @@ class SimpleWpMapBuilder {
137
  wp_reset_postdata();
138
  }
139
 
140
- // Displays attribution link. Not default, user has to check a checkbox for this to be displayed (returns an empty string as default)
141
  private function attributionLink(){
142
  if (get_option('simple_wp_attr_link')){
143
- return "\t<p id=\"attr\">Generated by: <a href=\"http://www.webbjocke.com/\">Simple Wp Sitemap</a></p>\n"; // will be changed to like webbjocke.com/simple-wp-sitemap or plugin page on wordpress.org if the plugin gets accepted
144
  }
145
  return '';
146
  }
147
 
148
- // Merges the arrays with post data into strings and gets user submitted pages
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
149
  private function mergeArraysAndGetOtherPages($posts, $pages, $homePage){
150
  $xml = '';
151
  $html = '';
@@ -155,7 +193,7 @@ class SimpleWpMapBuilder {
155
  $xml .= $this->getXml($this->homeUrl, $date);
156
  $html .= sprintf("%s\t</ul>\n", $this->getHtml($this->homeUrl, $date));
157
  }
158
- else{ // just a formatting rule for html
159
  $html .= "\t</ul>\n";
160
  }
161
 
@@ -174,15 +212,71 @@ class SimpleWpMapBuilder {
174
  $html .= sprintf("%s\t<ul>\n%s\t</ul>\n", $this->htmlTableH('Other'), $otherPages['html']);
175
  }
176
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
177
  return array('xml' => $xml, 'html' => $html);
178
  }
179
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
180
  // Sets up file paths to home directory
181
  private function setFile($fileType){
182
  $this->file = sprintf("%s%ssitemap.%s", get_home_path(), (substr(get_home_path(), -1) === '/' ? '' : '/'), $fileType);
183
  }
184
 
185
- // Creates sitemap files and overrides old ones if there are any
186
  private function writeToFile($data, $fileType){
187
  $this->setFile($fileType);
188
  try{
10
  private $url;
11
  private $homeUrl;
12
  private $blockedUrls;
13
+ private $categories;
14
+ private $tags;
15
+ private $authors;
16
 
17
  // Constructor, the only public function this class has
18
  public function __construct($command){
25
  break;
26
  case 'delete':
27
  $this->deleteSitemaps();
 
28
  }
29
  }
30
 
31
  // Generates the maps
32
+ private function generateSitemaps(){
33
+ $this->categories = (get_option('simple_wp_disp_categories') ? array(0 => 0) : null);
34
+ $this->tags = (get_option('simple_wp_disp_tags') ? array(0 => 0) : null);
35
+ $this->authors = (get_option('simple_wp_disp_authors') ? array(0 => 0) : null);
36
+
37
  $this->setUpBlockedUrls();
38
  $this->getContent();
39
 
49
 
50
  // Returns other urls (not standard wordpress) user has submitted
51
  private function getOtherPages(){
 
52
  $html = '';
53
  $xml = '';
54
 
55
+ if ($options = get_option('simple_wp_other_urls')){
56
  foreach($options as $option){
57
  if ($option && is_array($option)){
58
  $url = esc_url($option['url']);
72
  $this->blockedUrls = array();
73
 
74
  foreach($blocked as $block){
75
+ $this->blockedUrls[$block['url']] = 'blocked';
76
  }
77
  }
78
  else{
80
  }
81
  }
82
 
83
+ // Matches url against blocked ones that shouldn't be displayed
84
  private function isBlockedUrl($url){
85
+ return $this->blockedUrls && isset($this->blockedUrls[$url]);
86
  }
87
 
88
  // Returns an html string
111
  $homePage = false;
112
 
113
  if ($q->have_posts()) {
114
+ while ($q->have_posts()) {
115
  $q->the_post();
116
 
117
  $link = esc_url(get_permalink());
118
  $date = esc_html(get_the_modified_date('Y-m-d\TH:i:sP'));
119
 
120
+ $this->getCategoriesTagsAndAuthor($date);
121
+
122
+ if (!$this->isBlockedUrl($link)) {
123
  if ($link === $this->homeUrl) {
124
  $xml .= $this->getXml($link, $date);
125
  $html .= $this->getHtml($link, $date);
144
  wp_reset_postdata();
145
  }
146
 
147
+ // Displays attribution link if admin has checked the checkbox
148
  private function attributionLink(){
149
  if (get_option('simple_wp_attr_link')){
150
+ return "\t<p id=\"attr\">Generated by: <a href=\"http://www.webbjocke.com/simple-wp-sitemap/\">Simple Wp Sitemap</a></p>\n";
151
  }
152
  return '';
153
  }
154
 
155
+ // Gets a posts categories, tags and author, and compares for last modified date
156
+ private function getCategoriesTagsAndAuthor($date){
157
+ if ($this->categories){
158
+ if ($postCats = get_the_category()){
159
+ foreach($postCats as $category){
160
+ $id = $category->term_id;
161
+ if (!isset($this->categories[$id]) || $this->categories[$id] < $date){
162
+ $this->categories[$id] = $date;
163
+ }
164
+ }
165
+ }
166
+ }
167
+ if ($this->tags){
168
+ if ($postTags = get_the_tags()){
169
+ foreach($postTags as $tag){
170
+ $id = $tag->term_id;
171
+ if (!isset($this->tags[$id]) || $this->tags[$id] < $date){
172
+ $this->tags[$id] = $date;
173
+ }
174
+ }
175
+ }
176
+ }
177
+ if ($this->authors){
178
+ if ($id = get_the_author_meta('ID')){
179
+ if (is_int($id) && (!isset($this->authors[$id]) || $this->authors[$id] < $date)){
180
+ $this->authors[$id] = $date;
181
+ }
182
+ }
183
+ }
184
+ }
185
+
186
+ // Merges the arrays with post data into strings and gets user submitted pages, categories, tags and author pages
187
  private function mergeArraysAndGetOtherPages($posts, $pages, $homePage){
188
  $xml = '';
189
  $html = '';
193
  $xml .= $this->getXml($this->homeUrl, $date);
194
  $html .= sprintf("%s\t</ul>\n", $this->getHtml($this->homeUrl, $date));
195
  }
196
+ else{
197
  $html .= "\t</ul>\n";
198
  }
199
 
212
  $html .= sprintf("%s\t<ul>\n%s\t</ul>\n", $this->htmlTableH('Other'), $otherPages['html']);
213
  }
214
 
215
+ if ($this->categories){
216
+ $locArr = $this->stringifyCatsTagsAuths('Categories');
217
+ $xml .= $locArr['xml'];
218
+ $html .= $locArr['html'];
219
+ }
220
+ if ($this->tags){
221
+ $locArr = $this->stringifyCatsTagsAuths('Tags');
222
+ $xml .= $locArr['xml'];
223
+ $html .= $locArr['html'];
224
+ }
225
+ if ($this->authors){
226
+ $locArr = $this->stringifyCatsTagsAuths(count($this->authors) > 2 ? 'Authors' : 'Author');
227
+ $xml .= $locArr['xml'];
228
+ $html .= $locArr['html'];
229
+ }
230
+
231
  return array('xml' => $xml, 'html' => $html);
232
  }
233
 
234
+ // Returns category, tag and author links as ready xml and html strings
235
+ private function stringifyCatsTagsAuths($type){
236
+ $html = sprintf("%s\t<ul>\n", $this->htmlTableH($type));
237
+ $xml = '';
238
+
239
+ switch($type){
240
+ case 'Tags':
241
+ $arr = $this->tags;
242
+ break;
243
+ case 'Categories':
244
+ $arr = $this->categories;
245
+ break;
246
+ default: // 'Author'
247
+ $arr = $this->authors;
248
+ }
249
+
250
+ foreach($arr as $id => $date){
251
+ if ($date){
252
+ $link = esc_url($this->getLink($id, $type));
253
+ if (!$this->isBlockedUrl($link)){
254
+ $xml .= $this->getXml($link, $date);
255
+ $html .= $this->getHtml($link, $date);
256
+ }
257
+ }
258
+ }
259
+ return array('xml' => $xml, 'html' => $html . "\t</ul>\n");
260
+ }
261
+
262
+ // Returns either a category, tag or an author link
263
+ private function getLink($id, $type){
264
+ switch($type){
265
+ case 'Tags':
266
+ return get_tag_link($id);
267
+ case 'Categories':
268
+ return get_category_link($id);
269
+ default: // 'Author'
270
+ return get_author_posts_url($id);
271
+ }
272
+ }
273
+
274
  // Sets up file paths to home directory
275
  private function setFile($fileType){
276
  $this->file = sprintf("%s%ssitemap.%s", get_home_path(), (substr(get_home_path(), -1) === '/' ? '' : '/'), $fileType);
277
  }
278
 
279
+ // Creates sitemap files and overrides old ones if there's any
280
  private function writeToFile($data, $fileType){
281
  $this->setFile($fileType);
282
  try{
simpleWpMapOptions.php CHANGED
@@ -6,27 +6,26 @@
6
  class SimpleWpMapOptions {
7
 
8
  // Updates the settings/options
9
- public function setOptions($otherUrls, $blockUrls, $attrLink){
10
  update_option('simple_wp_other_urls', $this->addUrls($otherUrls, get_option('simple_wp_other_urls')));
11
  update_option('simple_wp_block_urls', $this->addUrls($blockUrls));
12
  update_option('simple_wp_attr_link', $attrLink);
 
 
 
13
  }
14
 
15
  // Returns the options as strings to be displayed in textareas, and checkbox values
16
  public function getOptions($val){
17
- switch($val){
18
- case 'simple_wp_other_urls':
19
- $val = get_option('simple_wp_other_urls');
20
- break;
21
- case 'simple_wp_block_urls':
22
- $val = get_option('simple_wp_block_urls');
23
- break;
24
- case 'simple_wp_attr_link':
25
- $val = get_option('simple_wp_attr_link');
26
- return $val ? 'checked' : ''; // return checkbox checked value right here and dont bother with the loop below
27
- default:
28
- $val = null;
29
  }
 
 
 
 
 
 
30
 
31
  if (!$this->isNullOrWhiteSpace($val)){
32
  $str = '';
6
  class SimpleWpMapOptions {
7
 
8
  // Updates the settings/options
9
+ public function setOptions($otherUrls, $blockUrls, $attrLink, $categories, $tags, $authors){
10
  update_option('simple_wp_other_urls', $this->addUrls($otherUrls, get_option('simple_wp_other_urls')));
11
  update_option('simple_wp_block_urls', $this->addUrls($blockUrls));
12
  update_option('simple_wp_attr_link', $attrLink);
13
+ update_option('simple_wp_disp_categories', $categories);
14
+ update_option('simple_wp_disp_tags', $tags);
15
+ update_option('simple_wp_disp_authors', $authors);
16
  }
17
 
18
  // Returns the options as strings to be displayed in textareas, and checkbox values
19
  public function getOptions($val){
20
+ if ($val === 'simple_wp_other_urls' || $val === 'simple_wp_block_urls'){
21
+ $val = get_option($val);
 
 
 
 
 
 
 
 
 
 
22
  }
23
+ elseif ($val === 'simple_wp_attr_link' || $val === 'simple_wp_disp_categories' || $val === 'simple_wp_disp_tags' || $val === 'simple_wp_disp_authors'){
24
+ return get_option($val) ? 'checked' : ''; // return checkbox checked values right here and dont bother with the loop below
25
+ }
26
+ else{
27
+ $val = null;
28
+ }
29
 
30
  if (!$this->isNullOrWhiteSpace($val)){
31
  $str = '';