Simple Wp Sitemap - Version 1.1.9

Version Description

(Jun 9, 2017) = * Added more sort options * New screenshots * Fixes in admin area

Download this release

Release Info

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

Code changes from version 1.1.7 to 1.1.9

css/html.css CHANGED
@@ -1,3 +1,7 @@
 
 
 
 
1
  *{
2
  margin: 0;
3
  padding: 0;
@@ -104,7 +108,7 @@ h1 a:hover{
104
  padding: 4px 7px 2px 7px;
105
  box-sizing: border-box;
106
  float: none;
107
- }
108
  .date{
109
  float: none;
110
  padding: 0 7px 4px 7px;
@@ -125,4 +129,4 @@ h1 a:hover{
125
  body{
126
  font-size: 11px;
127
  }
128
- }
1
+ /*
2
+ * Simple Wp Sitemap html css
3
+ */
4
+
5
  *{
6
  margin: 0;
7
  padding: 0;
108
  padding: 4px 7px 2px 7px;
109
  box-sizing: border-box;
110
  float: none;
111
+ }
112
  .date{
113
  float: none;
114
  padding: 0 7px 4px 7px;
129
  body{
130
  font-size: 11px;
131
  }
132
+ }
css/simple-wp-sitemap-admin.css CHANGED
@@ -1,44 +1,35 @@
 
 
 
 
1
  #sitemap-settings{
2
  background: #fff;
3
  margin: 0;
4
  float: left;
5
  }
6
  #sitemap-settings li{
 
 
 
7
  float: left;
8
  padding: 10px 0;
9
  width: 100px;
10
  margin: 0;
 
 
11
  text-align: center;
12
  border: 1px solid #f1f1f1;
13
  transition: all 0.3s;
14
  }
15
- #sitemap-settings li:hover{
16
  cursor: pointer;
17
  background: #ffffe0;
18
- border-color: #c0c0c0 !important;
19
- }
20
- #sitemap-settings li:active, #sitemap-settings li:focus{
21
- border-color: #000 !important;
22
- }
23
- .sitemap-active{
24
- border-color: #c0c0c0 !important;
25
- }
26
- #sitemap-table-hide, .sitemap-hidden{
27
- display: none;
28
- }
29
- #sitemap-table-show, .sitemap-shown{
30
- display: block !important;
31
  }
32
- #simple-wp-sitemap-donate{
33
- position: relative,
34
- }
35
- #simple-wp-sitemap-donate img{
36
- position: absolute;
37
- margin: -1px 0 0 7px;
38
- transition: all 0.3s;
39
- }
40
- #simple-wp-sitemap-donate img:hover{
41
- opacity: 0.8;
42
  }
43
  #simple-wp-sitemap-h2{
44
  float: left;
@@ -76,34 +67,27 @@
76
  #sitemap-display-order li:last-child{
77
  border-bottom: 1px solid #c0c0c0;
78
  }
79
- #sitemap-display-order span.swp-name{
80
- display: inline-block;
81
- min-height: 16px;
82
- padding-bottom: 1px;
83
- }
84
  #sitemap-display-order input.swp-name{
85
  max-width: 160px;
86
  }
87
- .sitemap-down{
88
  position: absolute;
 
 
 
 
 
 
 
 
 
 
89
  right: 45px;
90
- top: 6px;
91
- border-left: 18px solid transparent;
92
- border-right: 18px solid transparent;
93
  border-top: 25px solid #d3d3d3;
94
- transition: border-color 0.3s;
95
- }
96
- .sitemap-down:last-child{
97
- border-color: blue;
98
  }
99
  .sitemap-up{
100
- position: absolute;
101
  right: 5px;
102
- top: 5px;
103
- border-left: 18px solid transparent;
104
- border-right: 18px solid transparent;
105
  border-bottom: 25px solid #d3d3d3;
106
- transition: border-color 0.3s;
107
  }
108
  .sitemap-down:hover{
109
  cursor: pointer;
@@ -113,36 +97,19 @@
113
  cursor: pointer;
114
  border-bottom-color: #008000;
115
  }
116
- .sitemap-change-btn{
117
- position: absolute;
118
- left: 275px;
119
- top: 4px;
120
- }
121
  .simple-wp-sitemap-includes{
122
  padding: 0 20px;
123
  margin: 0;
124
  list-style-type: disc;
125
  }
126
- #swpErrorText{
127
- color: red;
128
- }
129
- #swpErrorText:hover{
130
- cursor: pointer;
131
- }
132
- @media screen and (max-width: 500px){
133
- #simple-wp-sitemap-donate img{
134
- position: static;
135
- display: block;
136
- margin: 10px 0 0 0;
137
  }
138
- #sitemap-settings{
139
- width: 100%;
140
- margin-bottom: 10px;
141
- }
142
- #sitemap-settings li{
143
- width: 100%;
144
- }
145
- #simple-wp-sitemap-form table{
146
- padding: 2% 0 2% 2%;
147
  }
148
  }
1
+ /*
2
+ * Simple Wp Sitemap admin css
3
+ */
4
+
5
  #sitemap-settings{
6
  background: #fff;
7
  margin: 0;
8
  float: left;
9
  }
10
  #sitemap-settings li{
11
+ display: inline;
12
+ }
13
+ #sitemap-settings a{
14
  float: left;
15
  padding: 10px 0;
16
  width: 100px;
17
  margin: 0;
18
+ color: inherit;
19
+ text-decoration: none;
20
  text-align: center;
21
  border: 1px solid #f1f1f1;
22
  transition: all 0.3s;
23
  }
24
+ #sitemap-settings a:hover, #sitemap-settings a:focus, #sitemap-settings .ui-state-active a{
25
  cursor: pointer;
26
  background: #ffffe0;
27
+ border-color: #c0c0c0;
28
+ outline: none;
29
+ box-shadow: none;
 
 
 
 
 
 
 
 
 
 
30
  }
31
+ #simple-wp-sitemap-donate, #simple_wp_order_by{
32
+ vertical-align: baseline;
 
 
 
 
 
 
 
 
33
  }
34
  #simple-wp-sitemap-h2{
35
  float: left;
67
  #sitemap-display-order li:last-child{
68
  border-bottom: 1px solid #c0c0c0;
69
  }
 
 
 
 
 
70
  #sitemap-display-order input.swp-name{
71
  max-width: 160px;
72
  }
73
+ #sitemap-display-order span{
74
  position: absolute;
75
+ top: 10px;
76
+ transition: border-color 0.3s;
77
+ border-left: 18px solid transparent;
78
+ border-right: 18px solid transparent;
79
+ top: 50%;
80
+ -ms-transform: translateY(-50%);
81
+ -webkit-transform: translateY(-50%);
82
+ transform: translateY(-50%);
83
+ }
84
+ .sitemap-down{
85
  right: 45px;
 
 
 
86
  border-top: 25px solid #d3d3d3;
 
 
 
 
87
  }
88
  .sitemap-up{
 
89
  right: 5px;
 
 
 
90
  border-bottom: 25px solid #d3d3d3;
 
91
  }
92
  .sitemap-down:hover{
93
  cursor: pointer;
97
  cursor: pointer;
98
  border-bottom-color: #008000;
99
  }
 
 
 
 
 
100
  .simple-wp-sitemap-includes{
101
  padding: 0 20px;
102
  margin: 0;
103
  list-style-type: disc;
104
  }
105
+ @media screen and (max-width: 782px) {
106
+ #simple-wp-sitemap-form tr{
107
+ margin: 10px;
108
+ display: block;
 
 
 
 
 
 
 
109
  }
110
+ }
111
+ @media screen and (max-width: 440px){
112
+ #sitemap-settings, #sitemap-settings a{
113
+ width: 100%;
 
 
 
 
 
114
  }
115
  }
css/xml.css CHANGED
@@ -1,3 +1,7 @@
 
 
 
 
1
  urlset{
2
  display: block;
3
  max-width: 1080px;
@@ -40,4 +44,4 @@ lastmod{
40
  width: 100%;
41
  float: left;
42
  }
43
- }
1
+ /*
2
+ * Simple Wp Sitemap xml css
3
+ */
4
+
5
  urlset{
6
  display: block;
7
  max-width: 1080px;
44
  width: 100%;
45
  float: left;
46
  }
47
+ }
js/simple-wp-sitemap-admin.js CHANGED
@@ -1,153 +1,60 @@
1
- (function ($) {
2
- var Sitemap = {
 
3
 
4
- // Constructor function
5
- run: function (config) {
6
- var self = this;
7
- this.c = config;
8
 
9
- this.c.menuBtns.each(function (i, btn) {
10
- btn = $(btn);
 
11
 
12
- if (self.c.activePage.val() === btn.attr('id')) {
13
- self.changeMenuState(btn);
14
- }
15
- });
16
 
17
- this.bindEvents();
18
- },
 
19
 
20
- // Binds all events
21
- bindEvents: function () {
22
- var self = this;
23
 
24
- this.c.menuBtns.on('click', function () {
25
- self.changeMenuState($(this));
26
- });
27
-
28
- this.c.orderList.on('click', function (e) {
29
- self.changeOrderItem($(e.target));
30
- });
31
-
32
- this.c.defaultBtn.on('click', function () {
33
- self.restoreDefaultOrder();
34
- });
35
-
36
- this.c.form.on('submit', function (e) {
37
- e.preventDefault();
38
- self.submitForm();
39
- });
40
-
41
- this.c.premiumBtn.on('click', function () {
42
- self.upgrade();
43
- });
44
-
45
- this.c.premiumInput.on('keypress', function (e) {
46
- if (e.which === 13) {
47
- e.preventDefault();
48
- self.upgrade();
49
- }
50
- });
51
-
52
- this.c.error.on('click', function (e) {
53
- if (!$(e.target).is('a')) {
54
- $(this).text('');
55
- }
56
- });
57
- },
58
-
59
- // Changes menu state and active page
60
- changeMenuState: function (btn) {
61
- this.c.menuBtns.attr('class', '');
62
- btn.attr('class', 'sitemap-active');
63
-
64
- this.c.tables.attr('id', '')
65
- .parent()
66
- .find('table[data-id="' + btn.attr('id') + '"]')
67
- .attr('id', 'sitemap-table-show');
68
-
69
- this.c.activePage.val(btn.attr('id'));
70
- },
71
-
72
- // Changes an item in order menu
73
- changeOrderItem: function (node) {
74
- var li = node.parent(), elem;
75
-
76
- if (node.attr('class') === 'sitemap-up' && li.prev()[0]) {
77
- li.prev().before(li);
78
-
79
- } else if (node.attr('class') === 'sitemap-down' && li.next()[0]) {
80
- li.next().after(li);
81
-
82
- } else if (node.hasClass('sitemap-change-btn')) {
83
- elem = li.find('.swp-name');
84
-
85
- if (node.val() === 'Change') {
86
- elem.replaceWith('<input type="text" class="swp-name" value="' + this.esc(elem.text()) + '" data-name="' + elem.attr('data-name') + '">');
87
- node.val('Ok');
88
- } else {
89
- elem.replaceWith('<span class="swp-name" data-name="' + elem.attr('data-name') + '">' + this.esc(elem.val()) + '</span>');
90
- node.val('Change');
91
- }
92
- }
93
- },
94
-
95
- // Sets hidden fields values and submits the form to save changes
96
- submitForm: function () {
97
- var inputs = this.c.orderList.find('input[type=hidden]'),
98
- titles = this.c.orderList.find('[data-name]'),
99
- self = this;
100
 
101
- $.each(inputs, function (i, node) {
102
- inputs.eq(i).val(self.esc((i + 1) + '-|-' + (titles.eq(i).text() || titles.eq(i).val())));
103
- });
104
- this.c.form[0].submit();
105
- },
106
 
107
- // Submits form to upgrade plugin to premium
108
- upgrade: function () {
109
- this.c.premiumForm.find('input[type=hidden]').attr({
110
- name: 'upgrade_to_premium',
111
- value: this.esc(this.c.premiumInput.val())
112
- });
113
- this.c.premiumForm.submit();
114
- },
115
 
116
- // Restores default order options
117
- restoreDefaultOrder: function () {
118
- var sections = ['Home', 'Posts', 'Pages', 'Other', 'Categories', 'Tags', 'Authors'],
119
- html = '';
120
 
121
- $.each(sections, function (i) {
122
- html += '<li><span class="swp-name" data-name="' + sections[i].toLowerCase() + '">' + sections[i] + '</span>' +
123
- '<span class="sitemap-down" title="move down"></span><span class="sitemap-up" title="move up"></span>' +
124
- '<input type="hidden" name="simple_wp_' + sections[i].toLowerCase() + '_n" value="' + (i + 1) + '">' +
125
- '<input type="button" value="Change" class="button-secondary sitemap-change-btn"></li>';
126
- });
127
- this.c.orderList.html(html);
128
- this.c.updatedText.val('');
129
- },
130
 
131
- // Escapes some special chars
132
- esc: function (str) {
133
- return str.replace(/[<"'>]/g, function (ch) {
134
- return {'<': "&lt;", '>': "&gt;", '"': '&quot;', '\'': '&#39;'}[ch];
135
- });
136
- }
 
 
 
 
 
137
  };
138
 
139
- Sitemap.run({
140
- tables: $('#simple-wp-sitemap-form table'),
141
- updatedText: $('#simple_wp_last_updated'),
142
- textarea: $('#swsp-add-pages-textarea'),
143
- activePage: $('#simple_wp_active-page'),
144
- orderList: $('#sitemap-display-order'),
145
- premiumForm: $('#simpleWpHiddenForm'),
146
- menuBtns: $('#sitemap-settings li'),
147
- form: $('#simple-wp-sitemap-form'),
148
- premiumBtn: $('#upgradeToPremium'),
149
- defaultBtn: $('#sitemap-defaults'),
150
- premiumInput: $('#upgradeField'),
151
- error: $('#swpErrorText'),
152
  });
153
- })(jQuery);
 
 
 
 
1
+ /*
2
+ * Simple Wp Sitemap admin js
3
+ */
4
 
5
+ jQuery(function ($) {
6
+ 'use strict';
 
 
7
 
8
+ var form = $('#simple-wp-sitemap-form'),
9
+ orderList = $('#sitemap-display-order'),
10
+ tab = location.search[location.search.length - 1];
11
 
 
 
 
 
12
 
13
+ // Changes an item in order menu
14
+ function changeOrderItem (e) {
15
+ var arrow = $(e.target), li = arrow.parent();
16
 
17
+ if (arrow.hasClass('sitemap-up') && li.prev().length) {
18
+ li.prev().before(li);
 
19
 
20
+ } else if (arrow.hasClass('sitemap-down') && li.next().length) {
21
+ li.next().after(li);
22
+ }
23
+ };
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
24
 
25
+ // Sets hidden fields values and submits the form to save changes
26
+ function submitForm (e) {
27
+ e.preventDefault();
 
 
28
 
29
+ var inputs = orderList.find('input[data-name]');
 
 
 
 
 
 
 
30
 
31
+ orderList.find('input[type=hidden]').each(function (i) {
32
+ $(this).val((i + 1) + '-|-' + inputs.eq(i).val());
33
+ });
 
34
 
35
+ form.attr('action', form.attr('action') + '&tab=' + (parseInt(form.tabs('option', 'active')) + 1));
36
+ form.get(0).submit();
37
+ };
 
 
 
 
 
 
38
 
39
+ // Restores default order options
40
+ function restoreDefaultOrder () {
41
+ var sections = ['Home', 'Posts', 'Pages', 'Other', 'Categories', 'Tags', 'Authors'],
42
+ html = '';
43
+
44
+ $.each(sections, function (i, section) {
45
+ html += '<li><input type="text" class="swp-name" data-name="' + section.toLowerCase() + '" value="' + section + '">' +
46
+ '<span class="sitemap-down" title="move down"></span><span class="sitemap-up" title="move up"></span>' +
47
+ '<input type="hidden" name="simple_wp_' + section.toLowerCase() + '_n" value="' + (i + 1) + '"></li>';
48
+ });
49
+ orderList.html(html);
50
  };
51
 
52
+
53
+ form.tabs({
54
+ active: /\d/.test(tab) ? parseInt(tab) - 1 : 0
 
 
 
 
 
 
 
 
 
 
55
  });
56
+
57
+ form.on('submit', submitForm);
58
+ orderList.on('click', changeOrderItem);
59
+ $('#sitemap-defaults').on('click', restoreDefaultOrder);
60
+ });
languages/simple-wp-sitemap.pot ADDED
@@ -0,0 +1,269 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Copyright (C) 2017 Simple Wp Sitemap
2
+ # This file is distributed under the same license as the Simple Wp Sitemap package.
3
+ #, fuzzy
4
+ msgid ""
5
+ msgstr ""
6
+ "Project-Id-Version: Simple Wp Sitemap\n"
7
+ "POT-Creation-Date: 2017-06-09 08:02+0200\n"
8
+ "PO-Revision-Date: \n"
9
+ "Last-Translator: Webbjocke <mail@webbjocke.com>\n"
10
+ "Language-Team: Webbjocke <mail@webbjocke.com>\n"
11
+ "Report-Msgid-Bugs-To: Webbjocke <mail@webbjocke.com>\n"
12
+ "MIME-Version: 1.0\n"
13
+ "Content-Type: text/plain; charset=UTF-8\n"
14
+ "Content-Transfer-Encoding: 8bit\n"
15
+ "Plural-Forms: nplurals=2; plural=n != 1;\n"
16
+ "X-Generator: Poedit 1.8.11\n"
17
+ "X-Poedit-SourceCharset: UTF-8\n"
18
+ "X-Poedit-KeywordsList: _e;__;esc_attr_e;_n;_n:1,2\n"
19
+ "X-Poedit-Basepath: ..\n"
20
+ "X-Poedit-SearchPath-0: .\n"
21
+
22
+ #: simple-wp-sitemap.php:83
23
+ msgid "Settings"
24
+ msgstr ""
25
+
26
+ #: simpleWpMapAdmin.php:11
27
+ msgid "Simple Wp Sitemap logo"
28
+ msgstr ""
29
+
30
+ #: simpleWpMapAdmin.php:12
31
+ msgid "Simple Wp Sitemap settings"
32
+ msgstr ""
33
+
34
+ #: simpleWpMapAdmin.php:15
35
+ msgid "Your two sitemaps are active! Here you can change and customize them."
36
+ msgstr ""
37
+
38
+ #: simpleWpMapAdmin.php:16
39
+ msgid "Links to your xml and html sitemap:"
40
+ msgstr ""
41
+
42
+ #: simpleWpMapAdmin.php:19
43
+ msgid "Xml sitemap:"
44
+ msgstr ""
45
+
46
+ #: simpleWpMapAdmin.php:21
47
+ msgid "Html sitemap:"
48
+ msgstr ""
49
+
50
+ #: simpleWpMapAdmin.php:22
51
+ msgid "(disabled)"
52
+ msgstr ""
53
+
54
+ #: simpleWpMapAdmin.php:26
55
+ msgid "(Please enable javascript to edit options)"
56
+ msgstr ""
57
+
58
+ #: simpleWpMapAdmin.php:31
59
+ msgid "General"
60
+ msgstr ""
61
+
62
+ #: simpleWpMapAdmin.php:32
63
+ msgid "Order"
64
+ msgstr ""
65
+
66
+ #: simpleWpMapAdmin.php:33
67
+ msgid "Premium"
68
+ msgstr ""
69
+
70
+ #: simpleWpMapAdmin.php:39
71
+ msgid "Add pages"
72
+ msgstr ""
73
+
74
+ #: simpleWpMapAdmin.php:44
75
+ msgid "Add pages to the sitemaps in addition to your normal WordPress ones. Just paste \"full\" urls in the textarea like: <b>http://www.example.com/a-page/</b>. Each link on a new row (this will affect both your xml and html sitemap)."
76
+ msgstr ""
77
+
78
+ #: simpleWpMapAdmin.php:57
79
+ msgid "Block pages"
80
+ msgstr ""
81
+
82
+ #: simpleWpMapAdmin.php:62
83
+ msgid "Add pages you want to block from showing up in the sitemaps. Same as above, just paste every link on a new row. (Tip: copy paste links from one of your sitemaps to get correct urls)."
84
+ msgstr ""
85
+
86
+ #: simpleWpMapAdmin.php:75
87
+ msgid "Extra sitemap includes"
88
+ msgstr ""
89
+
90
+ #: simpleWpMapAdmin.php:80
91
+ msgid "Check if you want to include categories, tags and/or author pages in the sitemaps."
92
+ msgstr ""
93
+
94
+ #: simpleWpMapAdmin.php:85
95
+ msgid "Include categories"
96
+ msgstr ""
97
+
98
+ #: simpleWpMapAdmin.php:86
99
+ msgid "Include tags"
100
+ msgstr ""
101
+
102
+ #: simpleWpMapAdmin.php:87
103
+ msgid "Include authors"
104
+ msgstr ""
105
+
106
+ #: simpleWpMapAdmin.php:95
107
+ msgid "Html sitemap"
108
+ msgstr ""
109
+
110
+ #: simpleWpMapAdmin.php:100
111
+ msgid "Enable or disable your html sitemap. This will not effect your xml sitemap."
112
+ msgstr ""
113
+
114
+ #: simpleWpMapAdmin.php:106
115
+ msgid "Enable"
116
+ msgstr ""
117
+
118
+ #: simpleWpMapAdmin.php:106
119
+ msgid "Disable"
120
+ msgstr ""
121
+
122
+ #: simpleWpMapAdmin.php:106
123
+ msgid "Disable and set to 404"
124
+ msgstr ""
125
+
126
+ #: simpleWpMapAdmin.php:117
127
+ msgid "Like the plugin?"
128
+ msgstr ""
129
+
130
+ #: simpleWpMapAdmin.php:122
131
+ msgid "Show your support by rating the plugin at wordpress.org, and/or by adding an attribution link to the sitemap.html file :)"
132
+ msgstr ""
133
+
134
+ #: simpleWpMapAdmin.php:127
135
+ msgid "Add \"Generated by Simple Wp Sitemap\" link at bottom of sitemap.html"
136
+ msgstr ""
137
+
138
+ #: simpleWpMapAdmin.php:132
139
+ msgid "A donation is also always welcome!"
140
+ msgstr ""
141
+
142
+ #: simpleWpMapAdmin.php:133
143
+ msgid "Donate"
144
+ msgstr ""
145
+
146
+ #: simpleWpMapAdmin.php:141
147
+ msgid "Display order and titles"
148
+ msgstr ""
149
+
150
+ #: simpleWpMapAdmin.php:146
151
+ msgid "If you want to change the display order in your sitemaps, click the arrows to move sections up or down. They will be displayed as ordered below (highest up is displayed first and lowest down last)"
152
+ msgstr ""
153
+
154
+ #: simpleWpMapAdmin.php:167
155
+ msgid "Last updated text:"
156
+ msgstr ""
157
+
158
+ #: simpleWpMapAdmin.php:168 simpleWpMapBuilder.php:76
159
+ msgid "Last updated"
160
+ msgstr ""
161
+
162
+ #: simpleWpMapAdmin.php:173
163
+ msgid "Sort posts and pages:"
164
+ msgstr ""
165
+
166
+ #: simpleWpMapAdmin.php:175
167
+ msgid "Posted date"
168
+ msgstr ""
169
+
170
+ #: simpleWpMapAdmin.php:175
171
+ msgid "Last updated date"
172
+ msgstr ""
173
+
174
+ #: simpleWpMapAdmin.php:175
175
+ msgid "Alphabetical"
176
+ msgstr ""
177
+
178
+ #: simpleWpMapAdmin.php:175
179
+ msgid "Random"
180
+ msgstr ""
181
+
182
+ #: simpleWpMapAdmin.php:175
183
+ msgid "Comments"
184
+ msgstr ""
185
+
186
+ #: simpleWpMapAdmin.php:175
187
+ msgid "Parents"
188
+ msgstr ""
189
+
190
+ #: simpleWpMapAdmin.php:183
191
+ msgid "Restore default order"
192
+ msgstr ""
193
+
194
+ #: simpleWpMapAdmin.php:191
195
+ msgid "Simple Wp Sitemap Premium"
196
+ msgstr ""
197
+
198
+ #: simpleWpMapAdmin.php:196
199
+ msgid "There's a premium version of Simple Wp Sitemap available which includes:"
200
+ msgstr ""
201
+
202
+ #: simpleWpMapAdmin.php:202
203
+ msgid "Split sitemaps"
204
+ msgstr ""
205
+
206
+ #: simpleWpMapAdmin.php:203
207
+ msgid "Image sitemaps"
208
+ msgstr ""
209
+
210
+ #: simpleWpMapAdmin.php:204
211
+ msgid "Display with shortcode"
212
+ msgstr ""
213
+
214
+ #: simpleWpMapAdmin.php:205
215
+ msgid "Exclude directories"
216
+ msgstr ""
217
+
218
+ #: simpleWpMapAdmin.php:206
219
+ msgid "And much more!"
220
+ msgstr ""
221
+
222
+ #: simpleWpMapAdmin.php:212
223
+ #, php-format
224
+ msgid "Available at: <a target=\"_blank\" href=\"%s\">webbjocke.com/downloads/simple-wp-sitemap-premium</a>"
225
+ msgstr ""
226
+
227
+ #: simpleWpMapAdmin.php:217
228
+ msgid "Save Changes"
229
+ msgstr ""
230
+
231
+ #: simpleWpMapAdmin.php:219
232
+ msgid "(If you have a caching plugin, you might have to clear cache before changes will be shown in the sitemaps)"
233
+ msgstr ""
234
+
235
+ #: simpleWpMapBuilder.php:156
236
+ msgid "Html Sitemap"
237
+ msgstr ""
238
+
239
+ #: simpleWpMapBuilder.php:214
240
+ msgid "Generated by: Simple Wp Sitemap"
241
+ msgstr ""
242
+
243
+ #: simpleWpMapOptions.php:16
244
+ msgid "Home"
245
+ msgstr ""
246
+
247
+ #: simpleWpMapOptions.php:16
248
+ msgid "Posts"
249
+ msgstr ""
250
+
251
+ #: simpleWpMapOptions.php:16
252
+ msgid "Pages"
253
+ msgstr ""
254
+
255
+ #: simpleWpMapOptions.php:16
256
+ msgid "Other"
257
+ msgstr ""
258
+
259
+ #: simpleWpMapOptions.php:16
260
+ msgid "Categories"
261
+ msgstr ""
262
+
263
+ #: simpleWpMapOptions.php:16
264
+ msgid "Tags"
265
+ msgstr ""
266
+
267
+ #: simpleWpMapOptions.php:16
268
+ msgid "Authors"
269
+ msgstr ""
readme.txt CHANGED
@@ -5,20 +5,20 @@ License: GPLv3
5
  License URI: http://www.gnu.org/licenses/gpl.html
6
  Tags: sitemap, site map, sitemap.xml, xml sitemap, html sitemap, simple sitemap, seo sitemap, google sitemap, sitemap.html, sitemap plugin, wordpress sitemap
7
  Requires at least: 4.0
8
- Tested up to: 4.7
9
- Stable tag: 1.1.7
10
 
11
  An easy sitemap plugin that adds both an xml and an html sitemap to your site, which updates and maintains themselves so you don't have to!
12
 
13
  == Description ==
14
 
15
- = A Wordpress sitemap plugin =
16
 
17
  Simple Wp Sitemap is a sitemap plugin that generates both an xml and an html sitemap to your site dynamically. These two are updated automatically everytime someone's visiting them. Which means they're always up to date and that you only have to install and activate the plugin once, and it will just work for you without you ever having to worry.
18
 
19
  Reason the sitemaps are generated dynamically instead of being created as actual files as they were in the beginning, is because it's much faster and more solid. No problems with having to access, create and delete files, instead they're just presented when needed to. It's now suddenly as lightweight, simple and fast as one can expect!
20
 
21
- 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 them, it's easily done. You can also block pages that you don't want to be included, and much more.
22
 
23
  = What it does =
24
 
@@ -32,7 +32,7 @@ The sitemaps are multisite and multilanguage compatible. Every site gets their o
32
 
33
  == Installation ==
34
 
35
- 1. 1. Go to the plugins page in your wordpress admin area and hit "add new".
36
  2. Either search for "simple wp sitemap" and click install, or hit "upload plugin" and upload the zip file.
37
  3. Another way is by just uploading the "simple-wp-sitemap" folder via ftp to the /wp-content/plugins/ directory.
38
 
@@ -82,6 +82,16 @@ When you deactivate the plugin they get removed automatically.
82
 
83
  == Changelog ==
84
 
 
 
 
 
 
 
 
 
 
 
85
  = 1.1.7 (Dec 3, 2016) =
86
  * Now escapes urls
87
 
@@ -120,7 +130,7 @@ When you deactivate the plugin they get removed automatically.
120
  * Added some tags and updated the plugin page
121
  * Removed unnecessary fixes for old versions of the plugin
122
  * Changes done "under the hood" in php for performance etc
123
- * Also tested with wordpress 4.4
124
 
125
  = 1.0.9 (Jun 23, 2015) =
126
  * Added donation link
5
  License URI: http://www.gnu.org/licenses/gpl.html
6
  Tags: sitemap, site map, sitemap.xml, xml sitemap, html sitemap, simple sitemap, seo sitemap, google sitemap, sitemap.html, sitemap plugin, wordpress sitemap
7
  Requires at least: 4.0
8
+ Tested up to: 4.8
9
+ Stable tag: 1.1.9
10
 
11
  An easy sitemap plugin that adds both an xml and an html sitemap to your site, which updates and maintains themselves so you don't have to!
12
 
13
  == Description ==
14
 
15
+ = A WordPress sitemap plugin =
16
 
17
  Simple Wp Sitemap is a sitemap plugin that generates both an xml and an html sitemap to your site dynamically. These two are updated automatically everytime someone's visiting them. Which means they're always up to date and that you only have to install and activate the plugin once, and it will just work for you without you ever having to worry.
18
 
19
  Reason the sitemaps are generated dynamically instead of being created as actual files as they were in the beginning, is because it's much faster and more solid. No problems with having to access, create and delete files, instead they're just presented when needed to. It's now suddenly as lightweight, simple and fast as one can expect!
20
 
21
+ 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 them, it's easily done. You can also block pages that you don't want to be included, and much more.
22
 
23
  = What it does =
24
 
32
 
33
  == Installation ==
34
 
35
+ 1. 1. Go to the plugins page in your WordPress admin area and hit "add new".
36
  2. Either search for "simple wp sitemap" and click install, or hit "upload plugin" and upload the zip file.
37
  3. Another way is by just uploading the "simple-wp-sitemap" folder via ftp to the /wp-content/plugins/ directory.
38
 
82
 
83
  == Changelog ==
84
 
85
+ = 1.1.9 (Jun 9, 2017) =
86
+ * Added more sort options
87
+ * New screenshots
88
+ * Fixes in admin area
89
+
90
+ = 1.1.8 (Apr 12, 2017) =
91
+ * Plugin is now translation ready
92
+ * Added option to order posts after updated date
93
+ * Bugfixes
94
+
95
  = 1.1.7 (Dec 3, 2016) =
96
  * Now escapes urls
97
 
130
  * Added some tags and updated the plugin page
131
  * Removed unnecessary fixes for old versions of the plugin
132
  * Changes done "under the hood" in php for performance etc
133
+ * Also tested with WordPress 4.4
134
 
135
  = 1.0.9 (Jun 23, 2015) =
136
  * Added donation link
screenshot-1.png CHANGED
Binary file
screenshot-2.png CHANGED
Binary file
screenshot-3.png CHANGED
Binary file
simple-wp-sitemap.php CHANGED
@@ -1,18 +1,20 @@
1
- <?php defined('ABSPATH') || exit;
2
 
3
  /*
4
  * Plugin Name: Simple Wp Sitemap
5
- * Plugin URI: http://www.webbjocke.com/simple-wp-sitemap/
6
  * Description: An easy sitemap plugin that adds both an xml and an html sitemap to your site, which updates and maintains themselves so you don't have to!
7
- * Version: 1.1.7
8
  * Author: Webbjocke
9
- * Author URI: http://www.webbjocke.com/
10
  * License: GPLv3
 
 
11
  */
12
 
13
  /*
14
- Simple Wp Sitemap - Wordpress plugin
15
- Copyright (C) 2016 Webbjocke
16
 
17
  This program is free software: you can redistribute it and/or modify
18
  it under the terms of the GNU General Public License as published by
@@ -28,10 +30,12 @@ You should have received a copy of the GNU General Public License
28
  along with this program. If not, see http://www.gnu.org/licenses/.
29
  */
30
 
31
- // Main class
 
 
32
 
33
  class SimpleWpSitemap {
34
- private static $version = 16; // only changes when needed
35
 
36
  // Runs on plugin activation
37
  public static function activateSitemaps () {
@@ -61,6 +65,7 @@ class SimpleWpSitemap {
61
  public static function registerHooks () {
62
  register_activation_hook(__FILE__, array(__CLASS__, 'activateSitemaps'));
63
  register_deactivation_hook(__FILE__, array(__CLASS__, 'deactivateSitemaps'));
 
64
  add_action('admin_menu', array(__CLASS__, 'sitemapAdminSetup'));
65
  add_action('init', array(__CLASS__, 'rewriteRules'), 1);
66
  add_filter('query_vars', array(__CLASS__, 'addSitemapQuery'), 1);
@@ -68,24 +73,21 @@ class SimpleWpSitemap {
68
  add_filter("plugin_action_links_" . plugin_basename(__FILE__), array(__CLASS__, 'pluginSettingsLink'));
69
  }
70
 
 
 
 
 
 
71
  // Adds a link to settings from the plugins page
72
  public static function pluginSettingsLink ($links) {
73
- return array_merge($links, array(sprintf('<a href="%s">%s</a>', esc_url(admin_url('options-general.php?page=simpleWpSitemapSettings')), __('Settings'))));
74
  }
75
 
76
  // Sets the option menu for admins and enqueues scripts n styles
77
  public static function sitemapAdminSetup () {
78
- add_options_page('Simple Wp Sitemap', 'Simple Wp Sitemap', 'administrator', 'simpleWpSitemapSettings', array(__CLASS__, 'sitemapAdminArea'));
79
  add_action('admin_enqueue_scripts', array(__CLASS__, 'sitemapScriptsAndStyles'));
80
- add_action('admin_init', array(__CLASS__, 'sitemapAdminInit'));
81
- }
82
-
83
- // Registers settings on admin_init and checks for updates
84
- public static function sitemapAdminInit () {
85
- foreach (array('other_urls', 'block_urls', 'attr_link', 'disp_categories', 'disp_tags', 'disp_authors', 'disp_sitemap_order', 'sitemap_version', 'last_updated', 'block_html') as $setting) {
86
- register_setting('simple_wp-sitemap-group', 'simple_wp_' . $setting);
87
- }
88
- self::updateCheck();
89
  }
90
 
91
  // Rewrite rules for sitemaps
@@ -130,29 +132,29 @@ class SimpleWpSitemap {
130
  // Add custom scripts and styles to the plugins customization page in admin area
131
  public static function sitemapScriptsAndStyles ($page) {
132
  if ($page === 'settings_page_simpleWpSitemapSettings') {
133
- wp_enqueue_style('simple-wp-sitemap-admin-css', plugin_dir_url( __FILE__ ) . 'css/simple-wp-sitemap-admin.css', array(), self::$version);
134
- wp_enqueue_script('simple-wp-sitemap-admin-js', plugin_dir_url( __FILE__ ) . 'js/simple-wp-sitemap-admin.js', array('jquery'), self::$version, true);
 
135
  }
136
  }
137
 
138
- // Interface for settings page, also handles initial post request when settings are changed
139
  public static function sitemapAdminArea () {
140
- require_once 'simpleWpMapOptions.php';
141
- $ops = new SimpleWpMapOptions();
 
142
 
143
- if (isset($_POST['simple_wp_other_urls'], $_POST['simple_wp_block_urls'], $_POST['simple_wp_home_n'], $_POST['simple_wp_posts_n'], $_POST['simple_wp_pages_n'], $_POST['simple_wp_other_n'], $_POST['simple_wp_categories_n'], $_POST['simple_wp_tags_n'], $_POST['simple_wp_authors_n'], $_POST['simple_wp_active_page'], $_POST['simple_wp_last_updated'], $_POST['simple_wp_block_html'])) {
144
- $order = $ops->getDefaultOrder();
145
 
146
- foreach ($order as $key => $val) {
147
- $arr = explode('-|-', $_POST['simple_wp_' . $key . '_n']);
148
- $order[$key] = array('i' => $arr[0], 'title' => isset($arr[1]) ? $arr[1] : $key);
 
 
149
  }
150
- $ops->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), $order, $_POST['simple_wp_active_page'], $_POST['simple_wp_last_updated'], $_POST['simple_wp_block_html']);
151
- }
152
- elseif (isset($_POST['upgrade_to_premium'])) {
153
- $ops->upgradePlugin($_POST['upgrade_to_premium']);
154
  }
155
- require_once 'simpleWpMapAdmin.php';
156
  }
157
  }
158
  SimpleWpSitemap::registerHooks();
1
+ <?php defined('ABSPATH') or die;
2
 
3
  /*
4
  * Plugin Name: Simple Wp Sitemap
5
+ * Plugin URI: https://www.webbjocke.com/simple-wp-sitemap/
6
  * Description: An easy sitemap plugin that adds both an xml and an html sitemap to your site, which updates and maintains themselves so you don't have to!
7
+ * Version: 1.1.9
8
  * Author: Webbjocke
9
+ * Author URI: https://www.webbjocke.com/
10
  * License: GPLv3
11
+ * Text Domain: simple-wp-sitemap
12
+ * Domain Path: /languages
13
  */
14
 
15
  /*
16
+ Simple Wp Sitemap - WordPress sitemap plugin
17
+ Copyright (C) 2017 Webbjocke
18
 
19
  This program is free software: you can redistribute it and/or modify
20
  it under the terms of the GNU General Public License as published by
30
  along with this program. If not, see http://www.gnu.org/licenses/.
31
  */
32
 
33
+ /*
34
+ * Simple Wp Sitemap main class
35
+ */
36
 
37
  class SimpleWpSitemap {
38
+ private static $version = 18; // only changes when needed
39
 
40
  // Runs on plugin activation
41
  public static function activateSitemaps () {
65
  public static function registerHooks () {
66
  register_activation_hook(__FILE__, array(__CLASS__, 'activateSitemaps'));
67
  register_deactivation_hook(__FILE__, array(__CLASS__, 'deactivateSitemaps'));
68
+ add_action('plugins_loaded', array(__CLASS__, 'loadTextDomain'));
69
  add_action('admin_menu', array(__CLASS__, 'sitemapAdminSetup'));
70
  add_action('init', array(__CLASS__, 'rewriteRules'), 1);
71
  add_filter('query_vars', array(__CLASS__, 'addSitemapQuery'), 1);
73
  add_filter("plugin_action_links_" . plugin_basename(__FILE__), array(__CLASS__, 'pluginSettingsLink'));
74
  }
75
 
76
+ // Loads plugins text domain
77
+ public static function loadTextDomain () {
78
+ load_plugin_textdomain('simple-wp-sitemap', false, basename(dirname( __FILE__ )) . '/languages/');
79
+ }
80
+
81
  // Adds a link to settings from the plugins page
82
  public static function pluginSettingsLink ($links) {
83
+ return array_merge(array(sprintf('<a href="%s">%s</a>', esc_url(admin_url('options-general.php?page=simpleWpSitemapSettings')), __('Settings', 'simple-wp-sitemap'))), $links);
84
  }
85
 
86
  // Sets the option menu for admins and enqueues scripts n styles
87
  public static function sitemapAdminSetup () {
88
+ add_options_page('Simple Wp Sitemap', 'Simple Wp Sitemap', 'manage_options', 'simpleWpSitemapSettings', array(__CLASS__, 'sitemapAdminArea'));
89
  add_action('admin_enqueue_scripts', array(__CLASS__, 'sitemapScriptsAndStyles'));
90
+ add_action('admin_init', array(__CLASS__, 'updateCheck'));
 
 
 
 
 
 
 
 
91
  }
92
 
93
  // Rewrite rules for sitemaps
132
  // Add custom scripts and styles to the plugins customization page in admin area
133
  public static function sitemapScriptsAndStyles ($page) {
134
  if ($page === 'settings_page_simpleWpSitemapSettings') {
135
+ wp_enqueue_script('jquery-ui-tabs');
136
+ wp_enqueue_style('simple-wp-sitemap-admin-css', esc_url(plugin_dir_url( __FILE__ ) . 'css/simple-wp-sitemap-admin.css'), array(), self::$version);
137
+ wp_enqueue_script('simple-wp-sitemap-admin-js', esc_url(plugin_dir_url( __FILE__ ) . 'js/simple-wp-sitemap-admin.js'), array('jquery'), self::$version, true);
138
  }
139
  }
140
 
141
+ // Loads admin page and handles post request when settings are changed
142
  public static function sitemapAdminArea () {
143
+ if (is_admin() && current_user_can('manage_options')) {
144
+ require_once 'simpleWpMapOptions.php';
145
+ $ops = new SimpleWpMapOptions();
146
 
147
+ if (isset($_POST['simple_wp_other_urls'], $_POST['simple_wp_block_urls'], $_POST['simple_wp_home_n'], $_POST['simple_wp_posts_n'], $_POST['simple_wp_pages_n'], $_POST['simple_wp_other_n'], $_POST['simple_wp_categories_n'], $_POST['simple_wp_tags_n'], $_POST['simple_wp_authors_n'], $_POST['simple_wp_last_updated'], $_POST['simple_wp_block_html'], $_POST['simple_wp_order_by'])) {
148
+ $order = $ops->getDefaultOrder();
149
 
150
+ foreach ($order as $key => $val) {
151
+ $arr = explode('-|-', $_POST['simple_wp_' . $key . '_n']);
152
+ $order[$key] = array('i' => $arr[0], 'title' => isset($arr[1]) ? $arr[1] : $key);
153
+ }
154
+ $ops->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), $order, $_POST['simple_wp_last_updated'], $_POST['simple_wp_block_html'], $_POST['simple_wp_order_by']);
155
  }
156
+ require_once 'simpleWpMapAdmin.php';
 
 
 
157
  }
 
158
  }
159
  }
160
  SimpleWpSitemap::registerHooks();
simpleWpMapAdmin.php CHANGED
@@ -1,58 +1,52 @@
1
- <?php defined('ABSPATH') || exit;
 
2
  /*
3
- * Simple Wp Sitemap Admin interface
4
  */
 
5
  ?>
6
  <div class="wrap">
7
 
8
  <h2 id="simple-wp-sitemap-h2">
9
- <img src="<?php printf('%ssign.png', $ops->pluginUrl()); ?>" alt="logo" width="40" height="40">
10
- <span>Simple Wp Sitemap settings</span>
11
  </h2>
12
 
13
- <p>Your two sitemaps are active! Here you can change and customize them.</p>
14
- <p><strong>Links to your xml and html sitemap:</strong></p>
15
 
16
  <ul>
17
- <li>Xml sitemap: <?php printf('<a href="%1$s">%1$s</a>', $ops->sitemapUrl('xml')); ?></li>
18
- <li>Html sitemap:
19
- <?php if ($ops->getOption('simple_wp_block_html')) {
20
- echo '(disabled)';
21
- } else {
22
- printf('<a href="%1$s">%1$s</a>', $ops->sitemapUrl('html'));
23
- } ?>
24
  </li>
25
  </ul>
26
 
27
- <noscript>(Please enable javascript to edit options)</noscript>
28
 
29
- <form method="post" action="<?php echo $ops->getSubmitUrl(); ?>" id="simple-wp-sitemap-form">
30
-
31
- <?php settings_fields('simple_wp-sitemap-group'); ?>
32
 
33
  <ul id="sitemap-settings">
34
- <li id="sitemap-normal" class="sitemap-active">General</li>
35
- <li id="sitemap-advanced">Order</li>
36
- <li id="sitemap-premium">Premium</li>
37
  </ul>
38
 
39
- <input type="hidden" id="simple_wp_active-page" name="simple_wp_active_page" value="<?php echo $ops->getPage(); ?>">
40
-
41
- <table id="sitemap-table-show" class="widefat form-table table-hidden" data-id="sitemap-normal">
42
  <tr>
43
  <td>
44
- <strong>Add pages</strong>
45
  </td>
46
  </tr>
47
  <tr>
48
  <td>
49
- Add pages to the sitemaps in addition to your normal wordpress ones. Just paste "full" urls in the textarea like:
50
- <strong>http://www.example.com/a-page/</strong>. Each link on a new row <em>(this will affect both your xml and html sitemap)</em>.
51
  </td>
52
  </tr>
53
  <tr>
54
  <td>
55
- <textarea rows="7" name="simple_wp_other_urls" placeholder="http://www.example.com/a-page/" class="large-text code" id="swsp-add-pages-textarea"><?php echo $ops->getOption('simple_wp_other_urls'); ?></textarea>
56
  </td>
57
  </tr>
58
 
@@ -60,18 +54,17 @@
60
 
61
  <tr>
62
  <td>
63
- <strong>Block pages</strong>
64
  </td>
65
  </tr>
66
  <tr>
67
  <td>
68
- Add pages you want to block from showing up in the sitemaps. Same as above, just paste every link on a new row.
69
- <em>(Hint: copy paste links from one of the sitemaps to get correct urls)</em>.
70
  </td>
71
  </tr>
72
  <tr>
73
  <td>
74
- <textarea rows="7" name="simple_wp_block_urls" placeholder="http://www.example.com/block-this-page/" class="large-text code"><?php echo $ops->getOption('simple_wp_block_urls'); ?></textarea>
75
  </td>
76
  </tr>
77
 
@@ -79,27 +72,19 @@
79
 
80
  <tr>
81
  <td>
82
- <strong>Extra sitemap includes</strong>
83
- </td>
84
- </tr>
85
- <tr>
86
- <td>
87
- Check if you want to include categories, tags and/or author pages in the sitemaps.
88
  </td>
89
  </tr>
90
  <tr>
91
  <td>
92
- <input type="checkbox" name="simple_wp_disp_categories" id="simple_wp_cat" <?php echo $ops->getOption('simple_wp_disp_categories'); ?>><label for="simple_wp_cat"> Include categories</label>
93
  </td>
94
  </tr>
95
  <tr>
96
  <td>
97
- <input type="checkbox" name="simple_wp_disp_tags" id="simple_wp_tags" <?php echo $ops->getOption('simple_wp_disp_tags'); ?>><label for="simple_wp_tags"> Include tags</label>
98
- </td>
99
- </tr>
100
- <tr>
101
- <td>
102
- <input type="checkbox" name="simple_wp_disp_authors" id="simple_wp_authors" <?php echo $ops->getOption('simple_wp_disp_authors'); ?>><label for="simple_wp_authors"> Include authors</label>
103
  </td>
104
  </tr>
105
 
@@ -107,20 +92,20 @@
107
 
108
  <tr>
109
  <td>
110
- <strong>Html sitemap</strong>
111
  </td>
112
  </tr>
113
  <tr>
114
  <td>
115
- Enable or disable your html sitemap. This will not effect your xml sitemap.
116
  </td>
117
  </tr>
118
  <tr>
119
  <td>
120
  <select name="simple_wp_block_html" id="simple_wp_block_html">
121
- <?php foreach (array('Enable' => '', 'Disable' => '1', 'Disable and set to 404' => '404') as $key => $val) {
122
- printf('<option value="%s"%s>%s</option>', $val, $val == $ops->getOption('simple_wp_block_html') ? ' selected' : '', $key);
123
- } ?>
124
  </select>
125
  </td>
126
  </tr>
@@ -129,52 +114,49 @@
129
 
130
  <tr>
131
  <td>
132
- <strong>Like the plugin?</strong>
133
  </td>
134
  </tr>
135
  <tr>
136
  <td>
137
- Show your support by rating the plugin at wordpress.org, and/or by adding an attribution link to the sitemap.html file :)
138
  </td>
139
  </tr>
140
  <tr>
141
  <td>
142
- <input type="checkbox" name="simple_wp_attr_link" id="simple_wp_check" <?php echo $ops->getOption('simple_wp_attr_link'); ?>><label for="simple_wp_check"> Add "Generated by Simple Wp Sitemap" link at bottom of sitemap.html.</label>
143
  </td>
144
  </tr>
145
  <tr>
146
  <td>
147
- A donation is also always welcome!
148
- <a href="https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&amp;hosted_button_id=UH6ANJA7M8DNS" id="simple-wp-sitemap-donate" target="_blank">
149
- <img src="https://www.paypalobjects.com/en_US/i/btn/btn_donate_SM.gif" alt="PayPal - The safer, easier way to pay online!">
150
- </a>
151
  </td>
152
  </tr>
153
  </table><!-- sitemap-normal -->
154
 
155
- <table class="widefat form-table table-hidden" data-id="sitemap-advanced">
156
  <tr>
157
  <td>
158
- <strong>Display order &amp; titles</strong>
159
  </td>
160
  </tr>
161
  <tr>
162
  <td>
163
- If you want to change the display order in your sitemaps, click the arrows to move sections up or down. They will be displayed as ordered below <em>(highest up is displayed first and lowest down last)</em>.<br><br>
164
- Hit the "Change" buttons to change the title displayed in the sitemaps.
165
  </td>
166
  </tr>
167
  <tr>
168
  <td>
169
  <ul id="sitemap-display-order">
170
- <?php if (!($orderArray = $ops->getOption('simple_wp_disp_sitemap_order'))) {
171
  $orderArray = $ops->getDefaultOrder();
172
  }
173
  foreach ($orderArray as $key => $val) {
174
  printf(
175
- '<li><span class="swp-name" data-name="%s">%s</span><span class="sitemap-down" title="move down"></span><span class="sitemap-up" title="move up"></span>' .
176
- '<input type="hidden" name="simple_wp_%s_n" value="%d"><input type="button" value="Change" class="button-secondary sitemap-change-btn"></li>',
177
- $key, $val['title'], $key, $val['i']
178
  );
179
  } ?>
180
  </ul>
@@ -182,66 +164,60 @@
182
  </tr>
183
  <tr>
184
  <td>
185
- <strong>Last updated text:</strong>
186
- <input type="text" name="simple_wp_last_updated" placeholder="Last updated" value="<?php echo $ops->getOption('simple_wp_last_updated'); ?>" id="simple_wp_last_updated">
187
  </td>
188
  </tr>
189
  <tr>
190
  <td>
191
- <input type="button" id="sitemap-defaults" class="button-secondary" title="Restore the default display order" value="Restore defaults">
 
 
 
 
 
192
  </td>
193
  </tr>
194
- </table><!-- sitemap-advanced -->
195
-
196
- <table class="widefat form-table table-hidden" data-id="sitemap-premium">
197
  <tr>
198
  <td>
199
- <strong>Simple Wp Sitemap Premium</strong>
200
  </td>
201
  </tr>
 
 
 
202
  <tr>
203
  <td>
204
- Premium is an enhanced version of Simple Wp Sitemap and includes:
205
  </td>
206
  </tr>
207
  <tr>
208
  <td>
209
- <ul class="simple-wp-sitemap-includes">
210
- <li>Image sitemaps</li>
211
- <li>Split sitemaps into multiple files</li>
212
- <li>Add your logo</li>
213
- <li>Custom css</li>
214
- <li>Color picker</li>
215
- <li>Exclude directories</li>
216
- <li>And much more!</li>
217
- </ul>
218
  </td>
219
  </tr>
220
-
221
- <tr><td><hr></td></tr>
222
-
223
  <tr>
224
  <td>
225
- <strong>If you have a premium code, enter it here to upgrade</strong><br><br>
226
- <input type="text" id="upgradeField" value="<?php echo $ops->getPosted(); ?>"><span class="button-secondary" id="upgradeToPremium">Upgrade</span>
227
- <span id="swpErrorText"><?php echo $ops->getError(); ?></span>
 
 
 
 
228
  </td>
229
  </tr>
230
  <tr>
231
  <td>
232
- <hr><br><strong>Available at</strong>: <a target="_blank" href="https://www.webbjocke.com/downloads/simple-wp-sitemap-premium/">webbjocke.com/downloads/simple-wp-sitemap-premium</a>
233
  </td>
234
  </tr>
235
  </table><!-- sitemap-premium -->
236
 
237
- <p class="submit"><input type="submit" class="button-primary" value="Save Changes"></p>
238
-
239
- <p><em>(If you have a caching plugin, you might have to clear cache before changes will be shown in the sitemaps)</em></p>
240
 
241
- </form>
242
 
243
- <form method="post" action="<?php echo $ops->getSubmitUrl(); ?>" class="table-hidden" id="simpleWpHiddenForm">
244
- <input type="hidden">
245
  </form>
246
 
247
  </div><!-- wrap -->
1
+ <?php defined('ABSPATH') or die;
2
+
3
  /*
4
+ * Simple Wp Sitemap admin interface
5
  */
6
+
7
  ?>
8
  <div class="wrap">
9
 
10
  <h2 id="simple-wp-sitemap-h2">
11
+ <img src="<?php echo esc_url(plugins_url('sign.png', __FILE__)); ?>" alt="<?php esc_attr_e('Simple Wp Sitemap logo', 'simple-wp-sitemap'); ?>" width="40" height="40">
12
+ <span><?php _e('Simple Wp Sitemap settings', 'simple-wp-sitemap'); ?></span>
13
  </h2>
14
 
15
+ <p><?php _e('Your two sitemaps are active! Here you can change and customize them.', 'simple-wp-sitemap'); ?></p>
16
+ <p><b><?php _e('Links to your xml and html sitemap:', 'simple-wp-sitemap'); ?></b></p>
17
 
18
  <ul>
19
+ <li><?php printf('%1$s <a href="%2$s">%2$s</a>', __('Xml sitemap:', 'simple-wp-sitemap'), $ops->getSitemapUrl('xml')); ?></li>
20
+ <li>
21
+ <?php _e('Html sitemap:', 'simple-wp-sitemap'); ?>
22
+ <?php echo get_option('simple_wp_block_html') ? __('(disabled)', 'simple-wp-sitemap') : sprintf('<a href="%1$s">%1$s</a>', $ops->getSitemapUrl('html')); ?>
 
 
 
23
  </li>
24
  </ul>
25
 
26
+ <noscript><?php _e('(Please enable javascript to edit options)', 'simple-wp-sitemap'); ?></noscript>
27
 
28
+ <form method="post" action="<?php $ops->printSubmitUrl(); ?>" id="simple-wp-sitemap-form">
 
 
29
 
30
  <ul id="sitemap-settings">
31
+ <li><a href="#sitemap-normal"><?php _e('General', 'simple-wp-sitemap'); ?></a></li>
32
+ <li><a href="#sitemap-advanced"><?php _e('Order', 'simple-wp-sitemap'); ?></a></li>
33
+ <li><a href="#sitemap-premium"><?php _e('Premium', 'simple-wp-sitemap'); ?></a></li>
34
  </ul>
35
 
36
+ <table id="sitemap-normal" class="widefat form-table">
 
 
37
  <tr>
38
  <td>
39
+ <b><?php _e('Add pages', 'simple-wp-sitemap'); ?></b>
40
  </td>
41
  </tr>
42
  <tr>
43
  <td>
44
+ <?php _e('Add pages to the sitemaps in addition to your normal WordPress ones. Just paste "full" urls in the textarea like: <b>http://www.example.com/a-page/</b>. Each link on a new row (this will affect both your xml and html sitemap).', 'simple-wp-sitemap'); ?>
 
45
  </td>
46
  </tr>
47
  <tr>
48
  <td>
49
+ <textarea rows="7" name="simple_wp_other_urls" placeholder="<?php echo esc_url('http://www.example.com/a-page/'); ?>" class="large-text code" id="swsp-add-pages-textarea"><?php $ops->printUrls('simple_wp_other_urls'); ?></textarea>
50
  </td>
51
  </tr>
52
 
54
 
55
  <tr>
56
  <td>
57
+ <b><?php _e('Block pages', 'simple-wp-sitemap'); ?></b>
58
  </td>
59
  </tr>
60
  <tr>
61
  <td>
62
+ <?php _e('Add pages you want to block from showing up in the sitemaps. Same as above, just paste every link on a new row. (Tip: copy paste links from one of your sitemaps to get correct urls).', 'simple-wp-sitemap'); ?>
 
63
  </td>
64
  </tr>
65
  <tr>
66
  <td>
67
+ <textarea rows="7" name="simple_wp_block_urls" placeholder="<?php echo esc_url('http://www.example.com/block-this-page/'); ?>" class="large-text code"><?php $ops->printUrls('simple_wp_block_urls'); ?></textarea>
68
  </td>
69
  </tr>
70
 
72
 
73
  <tr>
74
  <td>
75
+ <b><?php _e('Extra sitemap includes', 'simple-wp-sitemap'); ?></b>
 
 
 
 
 
76
  </td>
77
  </tr>
78
  <tr>
79
  <td>
80
+ <?php _e('Check if you want to include categories, tags and/or author pages in the sitemaps.', 'simple-wp-sitemap'); ?>
81
  </td>
82
  </tr>
83
  <tr>
84
  <td>
85
+ <p><input type="checkbox" name="simple_wp_disp_categories" id="simple_wp_cat" <?php checked(get_option('simple_wp_disp_categories')); ?>><label for="simple_wp_cat"> <?php _e('Include categories', 'simple-wp-sitemap'); ?></label></p>
86
+ <p><input type="checkbox" name="simple_wp_disp_tags" id="simple_wp_tags" <?php checked(get_option('simple_wp_disp_tags')); ?>><label for="simple_wp_tags"> <?php _e('Include tags', 'simple-wp-sitemap'); ?></label></p>
87
+ <p><input type="checkbox" name="simple_wp_disp_authors" id="simple_wp_authors" <?php checked(get_option('simple_wp_disp_authors')); ?>><label for="simple_wp_authors"> <?php _e('Include authors', 'simple-wp-sitemap'); ?></label></p>
 
 
 
88
  </td>
89
  </tr>
90
 
92
 
93
  <tr>
94
  <td>
95
+ <b><?php _e('Html sitemap', 'simple-wp-sitemap'); ?></b>
96
  </td>
97
  </tr>
98
  <tr>
99
  <td>
100
+ <?php _e('Enable or disable your html sitemap. This will not effect your xml sitemap.', 'simple-wp-sitemap'); ?>
101
  </td>
102
  </tr>
103
  <tr>
104
  <td>
105
  <select name="simple_wp_block_html" id="simple_wp_block_html">
106
+ <?php foreach (array('' => __('Enable', 'simple-wp-sitemap'), '1' => __('Disable', 'simple-wp-sitemap'), '404' => __('Disable and set to 404', 'simple-wp-sitemap')) as $key => $val) { ?>
107
+ <option value="<?php echo $key; ?>" <?php selected(get_option('simple_wp_block_html'), $key); ?>><?php echo $val; ?></option>
108
+ <?php } ?>
109
  </select>
110
  </td>
111
  </tr>
114
 
115
  <tr>
116
  <td>
117
+ <b><?php _e('Like the plugin?', 'simple-wp-sitemap'); ?></b>
118
  </td>
119
  </tr>
120
  <tr>
121
  <td>
122
+ <?php _e('Show your support by rating the plugin at wordpress.org, and/or by adding an attribution link to the sitemap.html file :)', 'simple-wp-sitemap'); ?>
123
  </td>
124
  </tr>
125
  <tr>
126
  <td>
127
+ <input type="checkbox" name="simple_wp_attr_link" id="simple_wp_check" <?php checked(get_option('simple_wp_attr_link')); ?>><label for="simple_wp_check"> <?php _e('Add "Generated by Simple Wp Sitemap" link at bottom of sitemap.html', 'simple-wp-sitemap'); ?></label>
128
  </td>
129
  </tr>
130
  <tr>
131
  <td>
132
+ <?php _e('A donation is also always welcome!', 'simple-wp-sitemap'); ?>
133
+ <a href="<?php echo esc_url('https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&amp;hosted_button_id=UH6ANJA7M8DNS'); ?>" id="simple-wp-sitemap-donate" class="button-secondary" target="_blank"><?php _e('Donate', 'simple-wp-sitemap'); ?></a>
 
 
134
  </td>
135
  </tr>
136
  </table><!-- sitemap-normal -->
137
 
138
+ <table id="sitemap-advanced" class="widefat form-table">
139
  <tr>
140
  <td>
141
+ <b><?php _e('Display order and titles', 'simple-wp-sitemap'); ?></b>
142
  </td>
143
  </tr>
144
  <tr>
145
  <td>
146
+ <?php _e('If you want to change the display order in your sitemaps, click the arrows to move sections up or down. They will be displayed as ordered below (highest up is displayed first and lowest down last)', 'simple-wp-sitemap'); ?>
 
147
  </td>
148
  </tr>
149
  <tr>
150
  <td>
151
  <ul id="sitemap-display-order">
152
+ <?php if (!($orderArray = $ops->checkOrder(get_option('simple_wp_disp_sitemap_order')))) {
153
  $orderArray = $ops->getDefaultOrder();
154
  }
155
  foreach ($orderArray as $key => $val) {
156
  printf(
157
+ '<li><input type="text" class="swp-name" data-name="%1$s" value="%2$s"><span class="sitemap-down" title="move down"></span><span class="sitemap-up" title="move up"></span>' .
158
+ '<input type="hidden" name="simple_wp_%1$s_n" value="%3$d"></li>',
159
+ esc_attr($key), esc_attr($val['title']), esc_attr($val['i'])
160
  );
161
  } ?>
162
  </ul>
164
  </tr>
165
  <tr>
166
  <td>
167
+ <b><?php _e('Last updated text:', 'simple-wp-sitemap'); ?></b>
168
+ <input type="text" name="simple_wp_last_updated" placeholder="<?php esc_attr_e('Last updated', 'simple-wp-sitemap'); ?>" value="<?php echo esc_attr(get_option('simple_wp_last_updated')); ?>" id="simple_wp_last_updated">
169
  </td>
170
  </tr>
171
  <tr>
172
  <td>
173
+ <b><?php _e('Sort posts and pages:', 'simple-wp-sitemap'); ?></b>
174
+ <select id="simple_wp_order_by" name="simple_wp_order_by">
175
+ <?php foreach (array('' => __('Posted date', 'simple-wp-sitemap'), 'modified' => __('Last updated date', 'simple-wp-sitemap'), 'name' => __('Alphabetical', 'simple-wp-sitemap'), 'rand' => __('Random', 'simple-wp-sitemap'), 'comment_count' => __('Comments', 'simple-wp-sitemap'), 'parent' => __('Parents', 'simple-wp-sitemap')) as $key => $val) { ?>
176
+ <option value="<?php echo $key; ?>" <?php selected(get_option('simple_wp_order_by'), $key); ?>><?php echo $val; ?></option>
177
+ <?php } ?>
178
+ </select>
179
  </td>
180
  </tr>
 
 
 
181
  <tr>
182
  <td>
183
+ <input type="button" id="sitemap-defaults" class="button-secondary" value="<?php esc_attr_e('Restore default order', 'simple-wp-sitemap'); ?>">
184
  </td>
185
  </tr>
186
+ </table><!-- sitemap-advanced -->
187
+
188
+ <table id="sitemap-premium" class="widefat form-table">
189
  <tr>
190
  <td>
191
+ <b><?php _e('Simple Wp Sitemap Premium', 'simple-wp-sitemap'); ?></b>
192
  </td>
193
  </tr>
194
  <tr>
195
  <td>
196
+ <?php _e('There\'s a premium version of Simple Wp Sitemap available which includes:', 'simple-wp-sitemap'); ?>
 
 
 
 
 
 
 
 
197
  </td>
198
  </tr>
 
 
 
199
  <tr>
200
  <td>
201
+ <ul class="simple-wp-sitemap-includes">
202
+ <li><?php _e('Split sitemaps', 'simple-wp-sitemap'); ?></li>
203
+ <li><?php _e('Image sitemaps', 'simple-wp-sitemap'); ?></li>
204
+ <li><?php _e('Display with shortcode', 'simple-wp-sitemap'); ?></li>
205
+ <li><?php _e('Exclude directories', 'simple-wp-sitemap'); ?></li>
206
+ <li><?php _e('And much more!', 'simple-wp-sitemap'); ?></li>
207
+ </ul>
208
  </td>
209
  </tr>
210
  <tr>
211
  <td>
212
+ <?php printf(__('Available at: <a target="_blank" href="%s">webbjocke.com/downloads/simple-wp-sitemap-premium</a>', 'simple-wp-sitemap'), esc_url('https://www.webbjocke.com/downloads/simple-wp-sitemap-premium/')); ?>
213
  </td>
214
  </tr>
215
  </table><!-- sitemap-premium -->
216
 
217
+ <p class="submit"><input type="submit" class="button-primary" value="<?php esc_attr_e('Save Changes', 'simple-wp-sitemap'); ?>"></p>
 
 
218
 
219
+ <p><i><?php _e('(If you have a caching plugin, you might have to clear cache before changes will be shown in the sitemaps)', 'simple-wp-sitemap'); ?></i></p>
220
 
 
 
221
  </form>
222
 
223
  </div><!-- wrap -->
simpleWpMapBuilder.php CHANGED
@@ -1,11 +1,11 @@
1
- <?php defined('ABSPATH') || exit;
2
 
3
  /*
4
- * The sitemap creating class
5
  */
6
 
7
  class SimpleWpMapBuilder {
8
- public $home = null;
9
  private $xml = false;
10
  private $html = false;
11
  private $posts = '';
@@ -16,6 +16,7 @@ class SimpleWpMapBuilder {
16
  private $other;
17
  private $homeUrl;
18
  private $authors;
 
19
  private $pattern;
20
  private $categories;
21
  private $lastUpdated;
@@ -27,7 +28,7 @@ class SimpleWpMapBuilder {
27
  $this->categories = get_option('simple_wp_disp_categories') ? array(0 => 0) : false;
28
  $this->tags = get_option('simple_wp_disp_tags') ? array(0 => 0) : false;
29
  $this->authors = get_option('simple_wp_disp_authors') ? array(0 => 0) : false;
30
- $this->blockedUrls = get_option('simple_wp_block_urls');
31
  @date_default_timezone_set(get_option('timezone_string'));
32
  }
33
 
@@ -36,7 +37,7 @@ class SimpleWpMapBuilder {
36
  if ($type === 'xml' || $type === 'html') {
37
  $this->$type = true;
38
  $this->pattern = ($this->xml ? 'Y-m-d\TH:i:sP' : 'Y-m-d H:i');
39
- $this->other = $this->getOtherPages();
40
  $this->setUpBlockedUrls();
41
  $this->setLastUpdated();
42
  $this->generateContent();
@@ -44,20 +45,20 @@ class SimpleWpMapBuilder {
44
  }
45
  }
46
 
47
- // Returns custom urls user has added
48
  public function getOtherPages () {
49
- $xml = '';
50
- if ($options = get_option('simple_wp_other_urls')) {
51
- foreach ($options as $option) {
52
- if ($option && is_array($option)) {
53
- if (!is_int($option['date'])) { // fix for old versions of the plugin when date was stored in clear text
54
- $option['date'] = strtotime($option['date']);
55
- }
56
- $xml .= $this->getXml(esc_url($option['url']), date($this->pattern, $option['date']));
57
  }
58
  }
59
  }
60
- return $xml;
61
  }
62
 
63
  // Sets up blocked urls into an array
@@ -72,7 +73,7 @@ class SimpleWpMapBuilder {
72
 
73
  // Sets the "last updated" text
74
  public function setLastUpdated () {
75
- $this->lastUpdated = ($updated = get_option('simple_wp_last_updated')) ? esc_html($updated) : 'Last updated';
76
  }
77
 
78
  // Matches url against blocked ones that shouldn't be displayed
@@ -82,16 +83,19 @@ class SimpleWpMapBuilder {
82
 
83
  // Returns xml or html
84
  public function getXml ($link, $date) {
85
- if ($this->xml) {
86
- return "<url>\n\t<loc>$link</loc>\n\t<lastmod>$date</lastmod>\n</url>\n";
87
- } else {
88
- return "<li><a href=\"$link\"><span class=\"link\">$link</span><span class=\"date\">$date</span></a></li>";
89
- }
90
  }
91
 
92
  // Querys the database and gets the actual sitemaps content
93
  public function generateContent () {
94
- $q = new WP_Query(array('post_type' => 'any', 'post_status' => 'publish', 'posts_per_page' => 50000, 'has_password' => false));
 
 
 
 
 
 
 
95
 
96
  if ($q->have_posts()) {
97
  while ($q->have_posts()) {
@@ -148,8 +152,8 @@ class SimpleWpMapBuilder {
148
  echo '</urlset>';
149
 
150
  } else {
151
- $name = esc_html(get_bloginfo('name'));
152
- echo '<!doctype html><html lang="', get_locale(), '"><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><a href="', $this->homeUrl, '">', $name, '</a> Html Sitemap</h1>';
153
  $this->sortAndPrintSections();
154
  echo '</div></body></html>';
155
  }
@@ -159,7 +163,7 @@ class SimpleWpMapBuilder {
159
  public function sortAndPrintSections () {
160
  $orderArray = get_option('simple_wp_disp_sitemap_order');
161
 
162
- if (!$orderArray || !isset($orderArray['home'])) {
163
  require_once 'simpleWpMapOptions.php';
164
  $ops = new SimpleWpMapOptions();
165
  $orderArray = $ops->migrateFromOld();
@@ -168,28 +172,38 @@ class SimpleWpMapBuilder {
168
  $this->home = $this->getXml($this->homeUrl, date($this->pattern));
169
  }
170
 
171
- foreach ($orderArray as $key => $arr) {
172
- $this->printSection($key, $arr);
173
- }
174
  $this->attributionLink();
175
  }
176
 
177
  // Prints a sections xml/html
178
- public function printSection ($title, $arr) {
179
  if ($this->$title) {
180
- if (in_array($title, array('categories', 'tags', 'authors'))) {
181
- $this->$title = $this->getMetaLinks($title);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
182
  }
183
- if ($this->$title) {
184
  if ($this->html) {
185
- if ($arr['title'] === 'Authors' && count($this->authors) <= 2) {
186
- $arr['title'] = 'Author';
187
- }
188
- echo '<div class="header"><p class="header-txt">', esc_html($arr['title']), '</p><p class="header-date">', $this->lastUpdated, '</p></div><ul>', $this->$title, '</ul>';
189
  } else {
190
- echo $this->$title;
191
  }
192
- $this->$title = null;
193
  }
194
  }
195
  }
@@ -197,27 +211,21 @@ class SimpleWpMapBuilder {
197
  // Displays attribution link if user has checked the checkbox
198
  public function attributionLink () {
199
  if ($this->html && get_option('simple_wp_attr_link')) {
200
- echo '<p id="attr"><a id="attr-a" href="http://www.webbjocke.com/simple-wp-sitemap/" target="_blank" title="http://www.webbjocke.com/simple-wp-sitemap/">Generated by: Simple Wp Sitemap</a></p>';
201
  }
202
  }
203
 
204
- // Gets categories, tags and author links
205
- public function getMetaLinks ($title) {
206
- $xml = '';
207
- if ($this->$title) {
208
- foreach ($this->$title as $id => $date) {
209
- if ($date) {
210
- switch ($title) {
211
- case 'tags': $link = esc_url(get_tag_link($id)); break;
212
- case 'categories': $link = esc_url(get_category_link($id)); break;
213
- default: $link = esc_url(get_author_posts_url($id)); // Authors
214
- }
215
- if (!$this->isBlockedUrl($link)) {
216
- $xml .= $this->getXml($link, $date);
217
- }
218
- }
219
- }
220
  }
221
- return $xml;
 
 
 
 
 
222
  }
223
  }
1
+ <?php defined('ABSPATH') or die;
2
 
3
  /*
4
+ * Simple Wp Sitemap builder
5
  */
6
 
7
  class SimpleWpMapBuilder {
8
+ private $home = null;
9
  private $xml = false;
10
  private $html = false;
11
  private $posts = '';
16
  private $other;
17
  private $homeUrl;
18
  private $authors;
19
+ private $orderby;
20
  private $pattern;
21
  private $categories;
22
  private $lastUpdated;
28
  $this->categories = get_option('simple_wp_disp_categories') ? array(0 => 0) : false;
29
  $this->tags = get_option('simple_wp_disp_tags') ? array(0 => 0) : false;
30
  $this->authors = get_option('simple_wp_disp_authors') ? array(0 => 0) : false;
31
+ $this->orderby = get_option('simple_wp_order_by');
32
  @date_default_timezone_set(get_option('timezone_string'));
33
  }
34
 
37
  if ($type === 'xml' || $type === 'html') {
38
  $this->$type = true;
39
  $this->pattern = ($this->xml ? 'Y-m-d\TH:i:sP' : 'Y-m-d H:i');
40
+ $this->getOtherPages();
41
  $this->setUpBlockedUrls();
42
  $this->setLastUpdated();
43
  $this->generateContent();
45
  }
46
  }
47
 
48
+ // Gets custom urls user has added
49
  public function getOtherPages () {
50
+ $xml = array();
51
+ if ($others = get_option('simple_wp_other_urls')) {
52
+ if ($this->orderby === 'modified') {
53
+ uasort($others, array($this, 'sortDate'));
54
+ }
55
+ foreach ($others as $other) {
56
+ if ($other && is_array($other)) {
57
+ $xml[] = $this->getXml(esc_url($other['url']), date($this->pattern, is_int($other['date']) ? $other['date'] : strtotime($other['date'])));
58
  }
59
  }
60
  }
61
+ $this->other = $this->sortToString($xml);
62
  }
63
 
64
  // Sets up blocked urls into an array
73
 
74
  // Sets the "last updated" text
75
  public function setLastUpdated () {
76
+ $this->lastUpdated = ($updated = get_option('simple_wp_last_updated')) ? esc_html($updated) : __('Last updated', 'simple-wp-sitemap');
77
  }
78
 
79
  // Matches url against blocked ones that shouldn't be displayed
83
 
84
  // Returns xml or html
85
  public function getXml ($link, $date) {
86
+ return $this->xml ? "<url>\n\t<loc>$link</loc>\n\t<lastmod>$date</lastmod>\n</url>\n" : "<li><a href=\"$link\"><span class=\"link\">$link</span><span class=\"date\">$date</span></a></li>";
 
 
 
 
87
  }
88
 
89
  // Querys the database and gets the actual sitemaps content
90
  public function generateContent () {
91
+ $q = new WP_Query(array(
92
+ 'post_type' => 'any',
93
+ 'post_status' => 'publish',
94
+ 'posts_per_page' => 50000,
95
+ 'has_password' => false,
96
+ 'orderby' => $this->orderby ? ($this->orderby === 'parent' ? array('type' => 'DESC', 'parent' => 'DESC') : sanitize_text_field($this->orderby)) : 'date',
97
+ 'order' => $this->orderby === 'name' ? 'ASC' : 'DESC'
98
+ ));
99
 
100
  if ($q->have_posts()) {
101
  while ($q->have_posts()) {
152
  echo '</urlset>';
153
 
154
  } else {
155
+ $blogName = esc_html(get_bloginfo('name'));
156
+ echo '<!doctype html><html lang="', get_locale(), '"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><title>', $blogName, ' ', __('Html Sitemap', 'simple-wp-sitemap'), '</title><link rel="stylesheet" href="', $this->url, 'css/html.css"></head><body><div id="wrapper"><h1><a href="', $this->homeUrl, '">', $blogName, '</a> ', __('Html Sitemap', 'simple-wp-sitemap'), '</h1>';
157
  $this->sortAndPrintSections();
158
  echo '</div></body></html>';
159
  }
163
  public function sortAndPrintSections () {
164
  $orderArray = get_option('simple_wp_disp_sitemap_order');
165
 
166
+ if (!$orderArray || !isset($orderArray['home'])) { // Fix for old versions
167
  require_once 'simpleWpMapOptions.php';
168
  $ops = new SimpleWpMapOptions();
169
  $orderArray = $ops->migrateFromOld();
172
  $this->home = $this->getXml($this->homeUrl, date($this->pattern));
173
  }
174
 
175
+ array_walk($orderArray, array($this, 'printSection'));
 
 
176
  $this->attributionLink();
177
  }
178
 
179
  // Prints a sections xml/html
180
+ public function printSection ($arr, $title) {
181
  if ($this->$title) {
182
+ $xml = $this->$title;
183
+ unset($this->$title);
184
+
185
+ if (in_array($title, array('categories', 'tags', 'authors'))) { // Categories, tags or authors
186
+ $urls = array();
187
+ foreach ($xml as $id => $date) {
188
+ if ($date) {
189
+ switch ($title) {
190
+ case 'tags': $link = esc_url(get_tag_link($id)); break;
191
+ case 'categories': $link = esc_url(get_category_link($id)); break;
192
+ default: $link = esc_url(get_author_posts_url($id)); // Authors
193
+ }
194
+ if (!$this->isBlockedUrl($link)) {
195
+ $urls[] = $this->getXml($link, $date);
196
+ }
197
+ }
198
+ }
199
+ $xml = $this->sortToString($urls);
200
  }
201
+ if ($xml) {
202
  if ($this->html) {
203
+ echo '<div class="header"><p class="header-txt">', esc_html($arr['title']), '</p><p class="header-date">', $this->lastUpdated, '</p></div><ul>', $xml, '</ul>';
 
 
 
204
  } else {
205
+ echo $xml;
206
  }
 
207
  }
208
  }
209
  }
211
  // Displays attribution link if user has checked the checkbox
212
  public function attributionLink () {
213
  if ($this->html && get_option('simple_wp_attr_link')) {
214
+ echo '<p id="attr"><a id="attr-a" href="', esc_url('https://www.webbjocke.com/simple-wp-sitemap/'), '" target="_blank">', __('Generated by: Simple Wp Sitemap', 'simple-wp-sitemap'), '</a></p>';
215
  }
216
  }
217
 
218
+ // Sorts or shuffles array and returns as string
219
+ public function sortToString ($urls) {
220
+ switch ($this->orderby) {
221
+ case 'name': sort($urls); break;
222
+ case 'rand': shuffle($urls); break;
 
 
 
 
 
 
 
 
 
 
 
223
  }
224
+ return implode('', $urls);
225
+ }
226
+
227
+ // Sort function for uasort
228
+ public function sortDate ($a, $b) {
229
+ return $b['date'] - $a['date'];
230
  }
231
  }
simpleWpMapOptions.php CHANGED
@@ -1,221 +1,97 @@
1
- <?php defined('ABSPATH') || exit;
2
 
3
  /*
4
- * Class that handles all admin settings
5
  */
6
 
7
  class SimpleWpMapOptions {
8
- private $error = '';
9
- private $posted = '';
10
- private $cantDl = false;
11
- private $activePage = '';
12
-
13
- // Returns form submit url for the plugin directory
14
- public function getSubmitUrl () {
15
- return 'options-general.php?page=simpleWpSitemapSettings';
16
- }
17
 
18
  // Returns a sitemap url
19
- public function sitemapUrl ($format) {
20
- return sprintf('%ssitemap.%s', $this->esc(home_url('/'), 'url'), $format);
21
- }
22
-
23
- // Get the url to the plugin dir
24
- public function pluginUrl () {
25
- return plugins_url() . '/simple-wp-sitemap/';
26
  }
27
 
28
  // Returns default order option
29
  public function getDefaultOrder () {
30
- return array('home' => array('title' => 'Home', 'i' => 1), 'posts' => array('title' => 'Posts', 'i' => 2), 'pages' => array('title' => 'Pages', 'i' => 3), 'other' => array('title' => 'Other', 'i' => 4), 'categories' => array('title' => 'Categories', 'i' => 5), 'tags' => array('title' => 'Tags', 'i' => 6), 'authors' => array('title' => 'Authors', 'i' => 7));
31
  }
32
 
33
  // Updates all options
34
- public function setOptions ($otherUrls, $blockUrls, $attrLink, $categories, $tags, $authors, $orderArray, $activePage, $lastUpdated, $blockHtml) {
35
  @date_default_timezone_set(get_option('timezone_string'));
36
  update_option('simple_wp_other_urls', $this->addUrls($otherUrls, get_option('simple_wp_other_urls')));
37
  update_option('simple_wp_block_urls', $this->addUrls($blockUrls));
38
- update_option('simple_wp_attr_link', $attrLink);
39
- update_option('simple_wp_disp_categories', $categories);
40
- update_option('simple_wp_disp_tags', $tags);
41
- update_option('simple_wp_disp_authors', $authors);
42
- update_option('simple_wp_block_html', $this->esc($blockHtml));
43
- update_option('simple_wp_last_updated', $this->esc($lastUpdated));
44
-
45
- if ($this->checkOrder($orderArray) && uasort($orderArray, array($this, 'sortArr'))) { // sort the array here
 
46
  update_option('simple_wp_disp_sitemap_order', $orderArray);
47
  }
48
-
49
- $this->activePage = $this->esc($activePage);
50
- }
51
-
52
- // Returns an option value (to do: refactor this messy function)
53
- public function getOption ($val) {
54
- if (preg_match("/^simple_wp_(other_urls|block_urls)$/", $val)) {
55
- $val = get_option($val);
56
-
57
- } elseif (preg_match("/^simple_wp_(attr_link|disp_categories|disp_tags|disp_authors)$/", $val)) {
58
- return get_option($val) ? 'checked' : ''; // return checkbox checked values right here and dont bother with the loop below
59
-
60
- } elseif ($val === 'simple_wp_disp_sitemap_order' && ($orderArray = get_option($val))) {
61
- return $this->checkOrder($orderArray);
62
-
63
- } elseif ($val === 'simple_wp_last_updated' || ($val === 'simple_wp_block_html' && get_option($val))) {
64
- return $this->esc(get_option($val));
65
-
66
- } else {
67
- $val = null;
68
- }
69
-
70
- $str = '';
71
- if (!$this->isNullOrWhiteSpace($val)) {
72
- foreach ($val as $sArr) {
73
- $str .= $this->esc($sArr['url'], 'url') . "\n";
74
- }
75
- }
76
- return trim($str);
77
  }
78
 
79
- // Checks if string is empty (or an array: fix)
80
- public function isNullOrWhiteSpace ($word) {
81
- if (is_array($word)) {
82
- return false;
83
- }
84
- return ($word === null || $word === false || trim($word) === '');
85
  }
86
 
87
- // Escapes urls and html
88
- public function esc ($str, $isUrl = false) {
89
- return $isUrl ? esc_url(trim($str)) : stripslashes(esc_html(trim($str)));
90
- }
91
 
92
- // Checks if orderArray is valid
93
- public function checkOrder ($orderArray) {
94
- if (is_array($orderArray)) {
95
- foreach ($orderArray as $title => $arr) {
96
- if (!is_array($arr) || !preg_match("/^[1-7]{1}$/", $arr['i']) || (!($orderArray[$title]['title'] = $this->esc($arr['title'])))) {
97
- return false;
98
- }
99
  }
100
- return $orderArray;
101
  }
102
- return false;
103
  }
104
 
105
  // Adds new urls to the sitemaps
106
  public function addUrls ($urls, $oldUrls = null) {
107
  $arr = array();
 
108
 
109
- if (!$this->isNullOrWhiteSpace($urls)) {
110
  $urls = explode("\n", $urls);
111
 
112
  foreach ($urls as $url){
113
- if (!$this->isNullOrWhiteSpace($url)) {
114
- $url = $this->esc($url, 'url');
115
  $isOld = false;
116
  if ($oldUrls && is_array($oldUrls)) {
117
  foreach ($oldUrls as $oldUrl) {
118
  if ($oldUrl['url'] === $url && !$isOld) {
119
- $arr[] = $oldUrl;
120
  $isOld = true;
121
  }
122
  }
123
  }
124
  if (!$isOld && strlen($url) < 2000) {
125
- $arr[] = array('url' => $url, 'date' => time());
126
  }
127
  }
128
  }
129
  }
130
- return !empty($arr) ? $arr : '';
131
  }
132
 
133
- // Upgrades the plugin to premium
134
- public function upgradePlugin ($code) {
135
- $this->posted = $this->esc($code);
136
- $this->activePage = 'sitemap-premium';
137
- $url = 'https://www.webbjocke.com/downloads/update/'; // make sure it's https
138
-
139
- update_option('simple_wp_premium_code', $this->posted);
140
-
141
- try {
142
- if (!$this->posted) {
143
- throw new Exception('Please enter a code before submitting');
144
- }
145
- if (!class_exists('ZipArchive')) {
146
- $this->cantDl = true;
147
- throw new Exception('Your server doesn\'t support ZipArchive');
148
- }
149
-
150
- $res = wp_remote_post($url, array(
151
- 'body' => array(
152
- 'action' => 'verify',
153
- 'object' => 'simple-wp-sitemap-premium',
154
- 'code' => $this->posted
155
- )
156
- ));
157
-
158
- if (is_wp_error($res) || $res['response']['code'] !== 200) {
159
- $this->cantDl = true;
160
- throw new Exception('Could not connect to server. Try again later');
161
- }
162
- if (!$res['body'] || trim($res['body']) === '' || $res['body'] === 'Invalid Code') {
163
- throw new Exception('Invalid Code');
164
- }
165
- if ($res['body'] === 'Failed') {
166
- throw new Exception('Failed to download. Try again later');
167
- }
168
-
169
- $dir = plugin_dir_path(__FILE__);
170
- $file = sprintf('%supload.zip', $dir);
171
-
172
- $fp = fopen($file, 'w');
173
- fwrite($fp, $res['body']);
174
- fclose($fp);
175
-
176
- $zip = new ZipArchive();
177
-
178
- if (!file_exists($file)) {
179
- $this->cantDl = true;
180
- throw new Exception('Couldn\'t find the zip file, try again later');
181
- }
182
- if ($zip->open($file) !== true) {
183
- $this->cantDl = true;
184
- throw new Exception('Could not open file on the filesystem');
185
- }
186
- if (!$zip->extractTo($dir)) {
187
- $this->cantDl = true;
188
- throw new Exception('Failed to unpack files');
189
  }
190
-
191
- $zip->close();
192
- unlink($file);
193
- $this->redirect();
194
-
195
- } catch (Exception $ex) {
196
- $this->error = $this->esc($ex->getMessage());
197
- }
198
- }
199
-
200
- // Get method for posted
201
- public function getPosted () {
202
- return $this->posted;
203
- }
204
-
205
- // Get active page in admin menu (returns empty string as default)
206
- public function getPage () {
207
- return $this->activePage;
208
- }
209
-
210
- // Returns error message if upgrade went wrong (empty string on default)
211
- public function getError () {
212
- if ($this->error && $this->cantDl) {
213
- $this->error .= '<br><b>You might have to download and install the upgrade manually</b>';
214
  }
215
- return $this->error;
216
  }
217
 
218
- // Sort function for "uasort"
219
  public function sortArr ($a, $b) {
220
  return $a['i'] - $b['i'];
221
  }
@@ -231,9 +107,7 @@ class SimpleWpMapOptions {
231
  unlink($path . $file);
232
  }
233
  }
234
- } catch (Exception $ex) {
235
- return;
236
- }
237
  }
238
 
239
  if ($order = get_option('simple_wp_disp_sitemap_order')) {
@@ -250,22 +124,4 @@ class SimpleWpMapOptions {
250
  update_option('simple_wp_disp_sitemap_order', $order);
251
  return $order;
252
  }
253
-
254
- // Redirect function on successful upgrade to premium
255
- public function redirect () { ?>
256
- <h1>Successfully upgraded to Simple Wp Sitemap Premium!</h1>
257
- <p><strong>Get ready!</strong></p>
258
- <p>Redirecting in: <span id="redirectUrl">7</span> seconds</p>
259
- <script>
260
- var p = document.getElementById("redirectUrl"), time = 7;
261
- var inter = setInterval(function () {
262
- p.textContent = --time;
263
- if (time <= 0) {
264
- clearInterval(inter);
265
- location.href="<?php echo $this->getSubmitUrl(); ?>";
266
- }
267
- }, 1000);
268
- </script>
269
- <?php exit;
270
- }
271
  }
1
+ <?php defined('ABSPATH') or die;
2
 
3
  /*
4
+ * Simple Wp Sitemap options
5
  */
6
 
7
  class SimpleWpMapOptions {
 
 
 
 
 
 
 
 
 
8
 
9
  // Returns a sitemap url
10
+ public function getSitemapUrl ($format) {
11
+ return esc_url(sprintf('%ssitemap.%s', home_url('/'), $format));
 
 
 
 
 
12
  }
13
 
14
  // Returns default order option
15
  public function getDefaultOrder () {
16
+ return array('home' => array('title' => __('Home', 'simple-wp-sitemap'), 'i' => 1), 'posts' => array('title' => __('Posts', 'simple-wp-sitemap'), 'i' => 2), 'pages' => array('title' => __('Pages', 'simple-wp-sitemap'), 'i' => 3), 'other' => array('title' => __('Other', 'simple-wp-sitemap'), 'i' => 4), 'categories' => array('title' => __('Categories', 'simple-wp-sitemap'), 'i' => 5), 'tags' => array('title' => __('Tags', 'simple-wp-sitemap'), 'i' => 6), 'authors' => array('title' => __('Authors', 'simple-wp-sitemap'), 'i' => 7));
17
  }
18
 
19
  // Updates all options
20
+ public function setOptions ($otherUrls, $blockUrls, $attrLink, $categories, $tags, $authors, $orderArray, $lastUpdated, $blockHtml, $orderby) {
21
  @date_default_timezone_set(get_option('timezone_string'));
22
  update_option('simple_wp_other_urls', $this->addUrls($otherUrls, get_option('simple_wp_other_urls')));
23
  update_option('simple_wp_block_urls', $this->addUrls($blockUrls));
24
+ update_option('simple_wp_attr_link', intval($attrLink));
25
+ update_option('simple_wp_disp_categories', intval($categories));
26
+ update_option('simple_wp_disp_tags', intval($tags));
27
+ update_option('simple_wp_disp_authors', intval($authors));
28
+ update_option('simple_wp_block_html', sanitize_text_field($blockHtml));
29
+ update_option('simple_wp_last_updated', sanitize_text_field(stripslashes($lastUpdated)));
30
+ update_option('simple_wp_order_by', sanitize_text_field($orderby));
31
+
32
+ if (($orderArray = $this->checkOrder($orderArray)) && uasort($orderArray, array($this, 'sortArr'))) { // sort the array here
33
  update_option('simple_wp_disp_sitemap_order', $orderArray);
34
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
35
  }
36
 
37
+ // Prints admin form submit url
38
+ public function printSubmitUrl () {
39
+ echo esc_url(admin_url('options-general.php?page=simpleWpSitemapSettings'));
 
 
 
40
  }
41
 
42
+ // Prints urls in textarea
43
+ public function printUrls ($opt) {
44
+ $urls = get_option($opt);
 
45
 
46
+ if ($urls && is_array($urls)) {
47
+ foreach ($urls as $sArr) {
48
+ echo esc_url($sArr['url']) . "\n";
 
 
 
 
49
  }
 
50
  }
 
51
  }
52
 
53
  // Adds new urls to the sitemaps
54
  public function addUrls ($urls, $oldUrls = null) {
55
  $arr = array();
56
+ $urls = trim($urls);
57
 
58
+ if ($urls) {
59
  $urls = explode("\n", $urls);
60
 
61
  foreach ($urls as $url){
62
+ if ($url = esc_url(trim($url))) {
 
63
  $isOld = false;
64
  if ($oldUrls && is_array($oldUrls)) {
65
  foreach ($oldUrls as $oldUrl) {
66
  if ($oldUrl['url'] === $url && !$isOld) {
67
+ array_push($arr, $oldUrl);
68
  $isOld = true;
69
  }
70
  }
71
  }
72
  if (!$isOld && strlen($url) < 2000) {
73
+ array_push($arr, array('url' => $url, 'date' => time()));
74
  }
75
  }
76
  }
77
  }
78
+ return $arr;
79
  }
80
 
81
+ // Checks if orderArray is valid
82
+ public function checkOrder ($orderArray) {
83
+ if (is_array($orderArray)) {
84
+ foreach ($orderArray as $title => $arr) {
85
+ if (!is_array($arr) || !preg_match('/^[1-7]{1}$/', $arr['i']) || (!($orderArray[$title]['title'] = sanitize_text_field(stripslashes($arr['title']))))) {
86
+ return false;
87
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
88
  }
89
+ return $orderArray;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
90
  }
91
+ return false;
92
  }
93
 
94
+ // Sort function for uasort
95
  public function sortArr ($a, $b) {
96
  return $a['i'] - $b['i'];
97
  }
107
  unlink($path . $file);
108
  }
109
  }
110
+ } catch (Exception $ex) {}
 
 
111
  }
112
 
113
  if ($order = get_option('simple_wp_disp_sitemap_order')) {
124
  update_option('simple_wp_disp_sitemap_order', $order);
125
  return $order;
126
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
127
  }