Simple Wp Sitemap - Version 1.1.3

Version Description

(May 15, 2016) = * Added option to change titles in html sitemap * Fixed bug when upgrading to premium * Fixed bug that made admin submit button invisible * Moved admin settings page to it's own file * Made all previous private functions in "builder" public

Download this release

Release Info

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

Code changes from version 1.1.2 to 1.1.3

css/index.php CHANGED
@@ -1 +1 @@
1
- <?php // silence is golden
1
+ <?php // Simple Wp Sitemap
css/simple-wp-sitemap-admin.css CHANGED
@@ -55,18 +55,11 @@
55
  .table-hidden{
56
  display: none;
57
  }
58
- #sitemap-defaults{
59
- text-decoration: underline;
60
- float: left;
61
- margin: 0 0 10px 7px;
62
- padding: 5px;
63
- border: 1px solid transparent;
64
  transition: all 0.3s;
65
  }
66
- #sitemap-defaults:hover{
67
- cursor: pointer;
68
- background: #ffffe0;
69
- border: 1px solid #c0c0c0;
70
  }
71
  #sitemap-display-order{
72
  margin: 0;
@@ -83,6 +76,14 @@
83
  #sitemap-display-order li:last-child{
84
  border-bottom: 1px solid #c0c0c0;
85
  }
 
 
 
 
 
 
 
 
86
  .sitemap-down{
87
  position: absolute;
88
  right: 45px;
@@ -112,6 +113,11 @@
112
  cursor: pointer;
113
  border-bottom-color: #008000;
114
  }
 
 
 
 
 
115
  .simple-wp-s-image{
116
  width: 500px;
117
  max-width: 55%;
@@ -134,6 +140,10 @@
134
  padding-left: 25px;
135
  box-sizing: border-box;
136
  }
 
 
 
 
137
  @media screen and (max-width: 800px){
138
  .simple-wp-s-image{
139
  max-width: 100%;
@@ -166,4 +176,4 @@
166
  #simple-wp-sitemap-form table{
167
  padding: 2% 0 2% 2%;
168
  }
169
- }
55
  .table-hidden{
56
  display: none;
57
  }
58
+ .button-secondary{
 
 
 
 
 
59
  transition: all 0.3s;
60
  }
61
+ .button-secondary:hover{
62
+ background: #ffffe0 !important;
 
 
63
  }
64
  #sitemap-display-order{
65
  margin: 0;
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;
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-s-image{
122
  width: 500px;
123
  max-width: 55%;
140
  padding-left: 25px;
141
  box-sizing: border-box;
142
  }
143
+ .simple-wp-sitemap-includes{
144
+ padding: 0 20px;
145
+ list-style-type: disc;
146
+ }
147
  @media screen and (max-width: 800px){
148
  .simple-wp-s-image{
149
  max-width: 100%;
176
  #simple-wp-sitemap-form table{
177
  padding: 2% 0 2% 2%;
178
  }
179
+ }
imgs/add-logo.png DELETED
Binary file
imgs/custom-css.png DELETED
Binary file
imgs/exclude-dirs.png DELETED
Binary file
imgs/index.php DELETED
@@ -1 +0,0 @@
1
- <?php // silence is golden
 
imgs/split-sitemaps.png DELETED
Binary file
index.php CHANGED
@@ -1 +1 @@
1
- <?php // silence is golden
1
+ <?php // Simple Wp Sitemap
js/index.php CHANGED
@@ -1 +1 @@
1
- <?php // silence is golden
1
+ <?php // Simple Wp Sitemap
js/simple-wp-sitemap-admin.js CHANGED
@@ -1,82 +1,111 @@
1
  (function ($) {
2
- var SitemapAdmin = function () {
3
- this.run = function (config) {
4
- var that = this;
5
  this.c = config;
6
-
7
- this.c.btns.on('click', function () { that.changeState($(this)); });
8
- this.c.ul.on('click', function (e) { that.changeOrder($(e.target)); });
9
- this.c.defaults.on('click', function () { that.restoreDefaults(); });
10
- this.c.form.on('submit', function () { that.submitForm(); });
11
- this.c.theBtn.on('click', function () { that.upgrade(that.c.theField); });
12
- this.c.theField.on('keypress', function (e) {
13
  if (e.which === 13) {
14
- e.preventDefault();
15
- that.upgrade(that.c.theField);
 
 
 
 
16
  }
17
- }).on('click', function () {
18
- if (that.c.theBtn.next().text()) {
19
- that.c.theBtn.next().text('');
 
 
20
  }
21
  });
22
-
23
- if (this.c.theField.val()) {
24
- this.c.btns.eq(2).click();
25
  }
26
- };
27
-
28
- this.changeState = function (btn) {
29
  this.c.btns.attr('class', '');
30
- btn.attr('class', 'sitemap-active');
31
  this.c.tables.attr('id', '').parent().find('table[data-id="' + btn.attr('id') + '"]').attr('id', 'sitemap-table-show');
32
- };
 
33
 
34
- this.changeOrder = function (node) {
35
- var li = node.parent();
36
 
37
  if (node.attr('class') === 'sitemap-up' && li.prev()[0]) {
38
  li.prev().before(li);
39
- }
40
- else if (node.attr('class') === 'sitemap-down' && li.next()[0]) {
41
  li.next().after(li);
 
 
 
 
 
 
 
 
 
 
42
  }
43
- };
44
-
45
- this.submitForm = function () {
46
- var inputs = this.c.ul.find('input');
47
 
48
- $.each(inputs, function (i) {
49
- inputs.eq(i).val(i + 1);
 
 
 
 
 
50
  });
51
- };
52
-
53
- this.upgrade = function (input) {
 
54
  var form = $('#simpleWpHiddenForm');
55
-
56
- form.find('input[type=hidden]').attr({name: 'upgrade_to_premium', value: input.val()});
57
  form.submit();
58
- }
59
 
60
- this.restoreDefaults = function () {
61
  var sections = ['Home', 'Posts', 'Pages', 'Other', 'Categories', 'Tags', 'Authors'],
62
  html = '';
63
 
64
  $.each(sections, function (i) {
65
- html += '<li>' + sections[i] + '<span class="sitemap-down" title="move down"></span><span class="sitemap-up" title="move up"></span><input type="hidden" name="simple_wp_' + sections[i].toLowerCase() + '_n" value="' + (i + 1) + '"></li>';
 
66
  });
 
 
 
67
 
68
- this.c.ul.empty().append(html);
69
- };
 
 
 
70
  };
71
 
72
- var sitemap = new SitemapAdmin();
73
- sitemap.run({
74
- ul: $('#sitemap-display-order'),
75
- defaults: $('#sitemap-defaults'),
 
76
  form: $('#simple-wp-sitemap-form'),
 
 
77
  btns: $('#sitemap-settings li'),
78
- tables: $('#simple-wp-sitemap-form table'),
79
  theBtn: $('#upgradeToPremium'),
80
- theField: $('#upgradeField')
 
81
  });
82
- })(jQuery);
1
  (function ($) {
2
+ var Sitemap = {
3
+ run: function (config) {
4
+ var self = this;
5
  this.c = config;
6
+
7
+ this.c.btns.on('click', function () { self.changeState($(this)); });
8
+ this.c.ul.on('click', function (e) { self.makeChange($(e.target)); });
9
+ this.c.defaults.on('click', function () { self.restoreDefaults(); });
10
+ this.c.form.on('submit', function (e) { e.preventDefault(); self.submitForm(); });
11
+ this.c.theBtn.on('click', function () { self.upgrade(self.c.theField); });
12
+ this.c.theField.on('keypress', function (e) {
13
  if (e.which === 13) {
14
+ e.preventDefault();
15
+ self.upgrade(self.c.theField);
16
+ }
17
+ }).on('click', function () {
18
+ if (self.c.error.text()) {
19
+ self.c.error.text('');
20
  }
21
+ });
22
+
23
+ this.c.btns.each(function (i, btn) {
24
+ if (self.c.activeP.val() === $(btn).attr('id')) {
25
+ self.c.btns.eq(i).click();
26
  }
27
  });
28
+
29
+ if (!this.c.textarea.val()) {
30
+ this.c.textarea.attr('placeholder', 'http://www.example.com/a-page/\nhttp://www.example.com/fruits/apples.html');
31
  }
32
+ },
33
+
34
+ changeState: function (btn) {
35
  this.c.btns.attr('class', '');
36
+ btn.attr('class', 'sitemap-active');
37
  this.c.tables.attr('id', '').parent().find('table[data-id="' + btn.attr('id') + '"]').attr('id', 'sitemap-table-show');
38
+ this.c.activeP.val(btn.attr('id'));
39
+ },
40
 
41
+ makeChange: function (node) {
42
+ var li = node.parent(), elem;
43
 
44
  if (node.attr('class') === 'sitemap-up' && li.prev()[0]) {
45
  li.prev().before(li);
46
+ } else if (node.attr('class') === 'sitemap-down' && li.next()[0]) {
 
47
  li.next().after(li);
48
+ } else if (node.hasClass('sitemap-change-btn')) {
49
+ elem = li.find('.swp-name');
50
+
51
+ if (node.val() === 'Change') {
52
+ elem.replaceWith('<input type="text" class="swp-name" value="' + this.esc(elem.text()) + '" data-name="' + elem.attr('data-name') + '">');
53
+ node.val('Ok');
54
+ } else {
55
+ elem.replaceWith('<span class="swp-name" data-name="' + elem.attr('data-name') + '">' + this.esc(elem.val()) + '</span>');
56
+ node.val('Change');
57
+ }
58
  }
59
+ },
 
 
 
60
 
61
+ submitForm: function () {
62
+ var inputs = this.c.ul.find('input[type=hidden]'),
63
+ titles = this.c.ul.find('[data-name]'),
64
+ self = this;
65
+
66
+ $.each(inputs, function (i, node) {
67
+ inputs.eq(i).val(self.esc((i + 1) + '-|-' + (titles.eq(i).text() || titles.eq(i).val())));
68
  });
69
+ this.c.form[0].submit();
70
+ },
71
+
72
+ upgrade: function (input) {
73
  var form = $('#simpleWpHiddenForm');
74
+
75
+ form.find('input[type=hidden]').attr({name: 'upgrade_to_premium', value: this.esc(input.val())});
76
  form.submit();
77
+ },
78
 
79
+ restoreDefaults: function () {
80
  var sections = ['Home', 'Posts', 'Pages', 'Other', 'Categories', 'Tags', 'Authors'],
81
  html = '';
82
 
83
  $.each(sections, function (i) {
84
+ html += '<li><span class="swp-name" data-name="' + sections[i].toLowerCase() + '">' + sections[i] + '</span><span class="sitemap-down" title="move down"></span><span class="sitemap-up" title="move up"></span>' +
85
+ '<input type="hidden" name="simple_wp_' + sections[i].toLowerCase() + '_n" value="' + (i + 1) + '"><input type="button" value="Change" class="button-secondary sitemap-change-btn"></li>';
86
  });
87
+ this.c.ul.html(html);
88
+ this.c.updated.val('');
89
+ },
90
 
91
+ esc: function (str) {
92
+ return str.replace(/[<"'>]/g, function (ch) {
93
+ return {'<': "&lt;", '>': "&gt;", '"': '&quot;', '\'': '&#39;'}[ch];
94
+ });
95
+ }
96
  };
97
 
98
+ Sitemap.run({
99
+ tables: $('#simple-wp-sitemap-form table'),
100
+ textarea: $('#swsp-add-pages-textarea'),
101
+ updated: $('#simple_wp_last_updated'),
102
+ activeP: $('#simple_wp_active-page'),
103
  form: $('#simple-wp-sitemap-form'),
104
+ defaults: $('#sitemap-defaults'),
105
+ ul: $('#sitemap-display-order'),
106
  btns: $('#sitemap-settings li'),
 
107
  theBtn: $('#upgradeToPremium'),
108
+ theField: $('#upgradeField'),
109
+ error: $('#swpErrorText'),
110
  });
111
+ })(jQuery);
license.txt CHANGED
@@ -2,7 +2,7 @@ GNU GENERAL PUBLIC LICENSE
2
 
3
  Version 3, 29 June 2007
4
 
5
- Copyright 2007 Free Software Foundation, Inc. <http://fsf.org/>
6
 
7
  Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed.
8
 
@@ -31,30 +31,30 @@ The precise terms and conditions for copying, distribution and modification foll
31
  TERMS AND CONDITIONS
32
 
33
  0. Definitions.
34
- This License refers to version 3 of the GNU General Public License.
35
 
36
- Copyright also means copyright-like laws that apply to other kinds of works, such as semiconductor masks.
37
 
38
- The Program refers to any copyrightable work licensed under this License. Each licensee is addressed as you�. Licensees and recipients may be individuals or organizations.
39
 
40
- To modify a work means to copy from or adapt all or part of the work in a fashion requiring copyright permission, other than the making of an exact copy. The resulting work is called a modified version of the earlier work or a work based on the earlier work.
41
 
42
- A covered work means either the unmodified Program or a work based on the Program.
43
 
44
- To propagate a work means to do anything with it that, without permission, would make you directly or secondarily liable for infringement under applicable copyright law, except executing it on a computer or modifying a private copy. Propagation includes copying, distribution (with or without modification), making available to the public, and in some countries other activities as well.
45
 
46
- To convey a work means any kind of propagation that enables other parties to make or receive copies. Mere interaction with a user through a computer network, with no transfer of a copy, is not conveying.
47
 
48
- An interactive user interface displays Appropriate Legal Notices to the extent that it includes a convenient and prominently visible feature that (1) displays an appropriate copyright notice, and (2) tells the user that there is no warranty for the work (except to the extent that warranties are provided), that licensees may convey the work under this License, and how to view a copy of this License. If the interface presents a list of user commands or options, such as a menu, a prominent item in the list meets this criterion.
49
 
50
  1. Source Code.
51
- The source code for a work means the preferred form of the work for making modifications to it. Object code means any non-source form of a work.
52
 
53
- A Standard Interface means an interface that either is an official standard defined by a recognized standards body, or, in the case of interfaces specified for a particular programming language, one that is widely used among developers working in that language.
54
 
55
- The System Libraries of an executable work include anything, other than the work as a whole, that (a) is included in the normal form of packaging a Major Component, but which is not part of that Major Component, and (b) serves only to enable use of the work with that Major Component, or to implement a Standard Interface for which an implementation is available to the public in source code form. A Major Component�, in this context, means a major essential component (kernel, window system, and so on) of the specific operating system (if any) on which the executable work runs, or a compiler used to produce the work, or an object code interpreter used to run it.
56
 
57
- The Corresponding Source for a work in object code form means all the source code needed to generate, install, and (for an executable work) run the object code and to modify the work, including scripts to control those activities. However, it does not include the work's System Libraries, or general-purpose tools or generally available free programs which are used unmodified in performing those activities but which are not part of the work. For example, Corresponding Source includes interface definition files associated with source files for the work, and the source code for shared libraries and dynamically linked subprograms that the work is specifically designed to require, such as by intimate data communication or control flow between those subprograms and other parts of the work.
58
 
59
  The Corresponding Source need not include anything that users can regenerate automatically from other parts of the Corresponding Source.
60
 
@@ -81,10 +81,10 @@ You may charge any price or no price for each copy that you convey, and you may
81
  You may convey a work based on the Program, or the modifications to produce it from the Program, in the form of source code under the terms of section 4, provided that you also meet all of these conditions:
82
 
83
  a) The work must carry prominent notices stating that you modified it, and giving a relevant date.
84
- b) The work must carry prominent notices stating that it is released under this License and any conditions added under section 7. This requirement modifies the requirement in section 4 to keep intact all notices�.
85
  c) You must license the entire work, as a whole, under this License to anyone who comes into possession of a copy. This License will therefore apply, along with any applicable section 7 additional terms, to the whole of the work, and all its parts, regardless of how they are packaged. This License gives no permission to license the work in any other way, but it does not invalidate such permission if you have separately received it.
86
  d) If the work has interactive user interfaces, each must display Appropriate Legal Notices; however, if the Program has interactive interfaces that do not display Appropriate Legal Notices, your work need not make them do so.
87
- A compilation of a covered work with other separate and independent works, which are not by their nature extensions of the covered work, and which are not combined with it such as to form a larger program, in or on a volume of a storage or distribution medium, is called an aggregate if the compilation and its resulting copyright are not used to limit the access or legal rights of the compilation's users beyond what the individual works permit. Inclusion of a covered work in an aggregate does not cause this License to apply to the other parts of the aggregate.
88
 
89
  6. Conveying Non-Source Forms.
90
  You may convey a covered work in object code form under the terms of sections 4 and 5, provided that you also convey the machine-readable Corresponding Source under the terms of this License, in one of these ways:
@@ -96,9 +96,9 @@ d) Convey the object code by offering access from a designated place (gratis or
96
  e) Convey the object code using peer-to-peer transmission, provided you inform other peers where the object code and Corresponding Source of the work are being offered to the general public at no charge under subsection 6d.
97
  A separable portion of the object code, whose source code is excluded from the Corresponding Source as a System Library, need not be included in conveying the object code work.
98
 
99
- A User Product is either (1) a consumer product�, which means any tangible personal property which is normally used for personal, family, or household purposes, or (2) anything designed or sold for incorporation into a dwelling. In determining whether a product is a consumer product, doubtful cases shall be resolved in favor of coverage. For a particular product received by a particular user, normally used refers to a typical or common use of that class of product, regardless of the status of the particular user or of the way in which the particular user actually uses, or expects or is expected to use, the product. A product is a consumer product regardless of whether the product has substantial commercial, industrial or non-consumer uses, unless such uses represent the only significant mode of use of the product.
100
 
101
- Installation Information for a User Product means any methods, procedures, authorization keys, or other information required to install and execute modified versions of a covered work in that User Product from a modified version of its Corresponding Source. The information must suffice to ensure that the continued functioning of the modified object code is in no case prevented or interfered with solely because modification has been made.
102
 
103
  If you convey an object code work under this section in, or with, or specifically for use in, a User Product, and the conveying occurs as part of a transaction in which the right of possession and use of the User Product is transferred to the recipient in perpetuity or for a fixed term (regardless of how the transaction is characterized), the Corresponding Source conveyed under this section must be accompanied by the Installation Information. But this requirement does not apply if neither you nor any third party retains the ability to install modified object code on the User Product (for example, the work has been installed in ROM).
104
 
@@ -107,7 +107,7 @@ The requirement to provide Installation Information does not include a requireme
107
  Corresponding Source conveyed, and Installation Information provided, in accord with this section must be in a format that is publicly documented (and with an implementation available to the public in source code form), and must require no special password or key for unpacking, reading or copying.
108
 
109
  7. Additional Terms.
110
- Additional permissions are terms that supplement the terms of this License by making exceptions from one or more of its conditions. Additional permissions that are applicable to the entire Program shall be treated as though they were included in this License, to the extent that they are valid under applicable law. If additional permissions apply only to part of the Program, that part may be used separately under those permissions, but the entire Program remains governed by this License without regard to the additional permissions.
111
 
112
  When you convey a copy of a covered work, you may at your option remove any additional permissions from that copy, or from any part of it. (Additional permissions may be written to require their own removal in certain cases when you modify the work.) You may place additional permissions on material, added by you to a covered work, for which you have or can give appropriate copyright permission.
113
 
@@ -119,7 +119,7 @@ c) Prohibiting misrepresentation of the origin of that material, or requiring th
119
  d) Limiting the use for publicity purposes of names of licensors or authors of the material; or
120
  e) Declining to grant rights under trademark law for use of some trade names, trademarks, or service marks; or
121
  f) Requiring indemnification of licensors and authors of that material by anyone who conveys the material (or modified versions of it) with contractual assumptions of liability to the recipient, for any liability that these contractual assumptions directly impose on those licensors and authors.
122
- All other non-permissive additional terms are considered further restrictions within the meaning of section 10. If the Program as you received it, or any part of it, contains a notice stating that it is governed by this License along with a term that is a further restriction, you may remove that term. If a license document contains a further restriction but permits relicensing or conveying under this License, you may add to a covered work material governed by the terms of that license document, provided that the further restriction does not survive such relicensing or conveying.
123
 
124
  If you add terms to a covered work in accord with this section, you must place, in the relevant source files, a statement of the additional terms that apply to those files, or a notice indicating where to find the applicable terms.
125
 
@@ -140,24 +140,24 @@ You are not required to accept this License in order to receive or run a copy of
140
  10. Automatic Licensing of Downstream Recipients.
141
  Each time you convey a covered work, the recipient automatically receives a license from the original licensors, to run, modify and propagate that work, subject to this License. You are not responsible for enforcing compliance by third parties with this License.
142
 
143
- An entity transaction is a transaction transferring control of an organization, or substantially all assets of one, or subdividing an organization, or merging organizations. If propagation of a covered work results from an entity transaction, each party to that transaction who receives a copy of the work also receives whatever licenses to the work the party's predecessor in interest had or could give under the previous paragraph, plus a right to possession of the Corresponding Source of the work from the predecessor in interest, if the predecessor has it or can get it with reasonable efforts.
144
 
145
  You may not impose any further restrictions on the exercise of the rights granted or affirmed under this License. For example, you may not impose a license fee, royalty, or other charge for exercise of rights granted under this License, and you may not initiate litigation (including a cross-claim or counterclaim in a lawsuit) alleging that any patent claim is infringed by making, using, selling, offering for sale, or importing the Program or any portion of it.
146
 
147
  11. Patents.
148
- A contributor is a copyright holder who authorizes use under this License of the Program or a work on which the Program is based. The work thus licensed is called the contributor's contributor version�.
149
 
150
- A contributor's essential patent claims are all patent claims owned or controlled by the contributor, whether already acquired or hereafter acquired, that would be infringed by some manner, permitted by this License, of making, using, or selling its contributor version, but do not include claims that would be infringed only as a consequence of further modification of the contributor version. For purposes of this definition, control includes the right to grant patent sublicenses in a manner consistent with the requirements of this License.
151
 
152
  Each contributor grants you a non-exclusive, worldwide, royalty-free patent license under the contributor's essential patent claims, to make, use, sell, offer for sale, import and otherwise run, modify and propagate the contents of its contributor version.
153
 
154
- In the following three paragraphs, a patent license is any express agreement or commitment, however denominated, not to enforce a patent (such as an express permission to practice a patent or covenant not to sue for patent infringement). To grant such a patent license to a party means to make such an agreement or commitment not to enforce a patent against the party.
155
 
156
- If you convey a covered work, knowingly relying on a patent license, and the Corresponding Source of the work is not available for anyone to copy, free of charge and under the terms of this License, through a publicly available network server or other readily accessible means, then you must either (1) cause the Corresponding Source to be so available, or (2) arrange to deprive yourself of the benefit of the patent license for this particular work, or (3) arrange, in a manner consistent with the requirements of this License, to extend the patent license to downstream recipients. Knowingly relying means you have actual knowledge that, but for the patent license, your conveying the covered work in a country, or your recipient's use of the covered work in a country, would infringe one or more identifiable patents in that country that you have reason to believe are valid.
157
 
158
  If, pursuant to or in connection with a single transaction or arrangement, you convey, or propagate by procuring conveyance of, a covered work, and grant a patent license to some of the parties receiving the covered work authorizing them to use, propagate, modify or convey a specific copy of the covered work, then the patent license you grant is automatically extended to all recipients of the covered work and works based on it.
159
 
160
- A patent license is discriminatory if it does not include within the scope of its coverage, prohibits the exercise of, or is conditioned on the non-exercise of one or more of the rights that are specifically granted under this License. You may not convey a covered work if you are a party to an arrangement with a third party that is in the business of distributing software, under which you make payment to the third party based on the extent of your activity of conveying the work, and under which the third party grants, to any of the parties who would receive the covered work from you, a discriminatory patent license (a) in connection with copies of the covered work conveyed by you (or copies made from those copies), or (b) primarily for and in connection with specific products or compilations that contain the covered work, unless you entered into that arrangement, or that patent license was granted, prior to 28 March 2007.
161
 
162
  Nothing in this License shall be construed as excluding or limiting any implied license or other defenses to infringement that may otherwise be available to you under applicable patent law.
163
 
@@ -170,14 +170,14 @@ Notwithstanding any other provision of this License, you have permission to link
170
  14. Revised Versions of this License.
171
  The Free Software Foundation may publish revised and/or new versions of the GNU General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns.
172
 
173
- Each version is given a distinguishing version number. If the Program specifies that a certain numbered version of the GNU General Public License or any later version applies to it, you have the option of following the terms and conditions either of that numbered version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of the GNU General Public License, you may choose any version ever published by the Free Software Foundation.
174
 
175
  If the Program specifies that a proxy can decide which future versions of the GNU General Public License can be used, that proxy's public statement of acceptance of a version permanently authorizes you to choose that version for the Program.
176
 
177
  Later license versions may give you additional or different permissions. However, no additional obligations are imposed on any author or copyright holder as a result of your choosing to follow a later version.
178
 
179
  15. Disclaimer of Warranty.
180
- THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM AS IS WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
181
 
182
  16. Limitation of Liability.
183
  IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
@@ -185,4 +185,4 @@ IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY C
185
  17. Interpretation of Sections 15 and 16.
186
  If the disclaimer of warranty and limitation of liability provided above cannot be given local legal effect according to their terms, reviewing courts shall apply local law that most closely approximates an absolute waiver of all civil liability in connection with the Program, unless a warranty or assumption of liability accompanies a copy of the Program in return for a fee.
187
 
188
- END OF TERMS AND CONDITIONS
2
 
3
  Version 3, 29 June 2007
4
 
5
+ Copyright © 2007 Free Software Foundation, Inc. <http://fsf.org/>
6
 
7
  Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed.
8
 
31
  TERMS AND CONDITIONS
32
 
33
  0. Definitions.
34
+ This License refers to version 3 of the GNU General Public License.
35
 
36
+ Copyright also means copyright-like laws that apply to other kinds of works, such as semiconductor masks.
37
 
38
+ The Program refers to any copyrightable work licensed under this License. Each licensee is addressed as you”. Licensees and recipients may be individuals or organizations.
39
 
40
+ To modify a work means to copy from or adapt all or part of the work in a fashion requiring copyright permission, other than the making of an exact copy. The resulting work is called a modified version of the earlier work or a work based on the earlier work.
41
 
42
+ A covered work means either the unmodified Program or a work based on the Program.
43
 
44
+ To propagate a work means to do anything with it that, without permission, would make you directly or secondarily liable for infringement under applicable copyright law, except executing it on a computer or modifying a private copy. Propagation includes copying, distribution (with or without modification), making available to the public, and in some countries other activities as well.
45
 
46
+ To convey a work means any kind of propagation that enables other parties to make or receive copies. Mere interaction with a user through a computer network, with no transfer of a copy, is not conveying.
47
 
48
+ An interactive user interface displays Appropriate Legal Notices to the extent that it includes a convenient and prominently visible feature that (1) displays an appropriate copyright notice, and (2) tells the user that there is no warranty for the work (except to the extent that warranties are provided), that licensees may convey the work under this License, and how to view a copy of this License. If the interface presents a list of user commands or options, such as a menu, a prominent item in the list meets this criterion.
49
 
50
  1. Source Code.
51
+ The source code for a work means the preferred form of the work for making modifications to it. Object code means any non-source form of a work.
52
 
53
+ A Standard Interface means an interface that either is an official standard defined by a recognized standards body, or, in the case of interfaces specified for a particular programming language, one that is widely used among developers working in that language.
54
 
55
+ The System Libraries of an executable work include anything, other than the work as a whole, that (a) is included in the normal form of packaging a Major Component, but which is not part of that Major Component, and (b) serves only to enable use of the work with that Major Component, or to implement a Standard Interface for which an implementation is available to the public in source code form. A Major Component”, in this context, means a major essential component (kernel, window system, and so on) of the specific operating system (if any) on which the executable work runs, or a compiler used to produce the work, or an object code interpreter used to run it.
56
 
57
+ The Corresponding Source for a work in object code form means all the source code needed to generate, install, and (for an executable work) run the object code and to modify the work, including scripts to control those activities. However, it does not include the work's System Libraries, or general-purpose tools or generally available free programs which are used unmodified in performing those activities but which are not part of the work. For example, Corresponding Source includes interface definition files associated with source files for the work, and the source code for shared libraries and dynamically linked subprograms that the work is specifically designed to require, such as by intimate data communication or control flow between those subprograms and other parts of the work.
58
 
59
  The Corresponding Source need not include anything that users can regenerate automatically from other parts of the Corresponding Source.
60
 
81
  You may convey a work based on the Program, or the modifications to produce it from the Program, in the form of source code under the terms of section 4, provided that you also meet all of these conditions:
82
 
83
  a) The work must carry prominent notices stating that you modified it, and giving a relevant date.
84
+ b) The work must carry prominent notices stating that it is released under this License and any conditions added under section 7. This requirement modifies the requirement in section 4 to keep intact all notices”.
85
  c) You must license the entire work, as a whole, under this License to anyone who comes into possession of a copy. This License will therefore apply, along with any applicable section 7 additional terms, to the whole of the work, and all its parts, regardless of how they are packaged. This License gives no permission to license the work in any other way, but it does not invalidate such permission if you have separately received it.
86
  d) If the work has interactive user interfaces, each must display Appropriate Legal Notices; however, if the Program has interactive interfaces that do not display Appropriate Legal Notices, your work need not make them do so.
87
+ A compilation of a covered work with other separate and independent works, which are not by their nature extensions of the covered work, and which are not combined with it such as to form a larger program, in or on a volume of a storage or distribution medium, is called an aggregate if the compilation and its resulting copyright are not used to limit the access or legal rights of the compilation's users beyond what the individual works permit. Inclusion of a covered work in an aggregate does not cause this License to apply to the other parts of the aggregate.
88
 
89
  6. Conveying Non-Source Forms.
90
  You may convey a covered work in object code form under the terms of sections 4 and 5, provided that you also convey the machine-readable Corresponding Source under the terms of this License, in one of these ways:
96
  e) Convey the object code using peer-to-peer transmission, provided you inform other peers where the object code and Corresponding Source of the work are being offered to the general public at no charge under subsection 6d.
97
  A separable portion of the object code, whose source code is excluded from the Corresponding Source as a System Library, need not be included in conveying the object code work.
98
 
99
+ A User Product is either (1) a consumer product”, which means any tangible personal property which is normally used for personal, family, or household purposes, or (2) anything designed or sold for incorporation into a dwelling. In determining whether a product is a consumer product, doubtful cases shall be resolved in favor of coverage. For a particular product received by a particular user, normally used refers to a typical or common use of that class of product, regardless of the status of the particular user or of the way in which the particular user actually uses, or expects or is expected to use, the product. A product is a consumer product regardless of whether the product has substantial commercial, industrial or non-consumer uses, unless such uses represent the only significant mode of use of the product.
100
 
101
+ Installation Information for a User Product means any methods, procedures, authorization keys, or other information required to install and execute modified versions of a covered work in that User Product from a modified version of its Corresponding Source. The information must suffice to ensure that the continued functioning of the modified object code is in no case prevented or interfered with solely because modification has been made.
102
 
103
  If you convey an object code work under this section in, or with, or specifically for use in, a User Product, and the conveying occurs as part of a transaction in which the right of possession and use of the User Product is transferred to the recipient in perpetuity or for a fixed term (regardless of how the transaction is characterized), the Corresponding Source conveyed under this section must be accompanied by the Installation Information. But this requirement does not apply if neither you nor any third party retains the ability to install modified object code on the User Product (for example, the work has been installed in ROM).
104
 
107
  Corresponding Source conveyed, and Installation Information provided, in accord with this section must be in a format that is publicly documented (and with an implementation available to the public in source code form), and must require no special password or key for unpacking, reading or copying.
108
 
109
  7. Additional Terms.
110
+ Additional permissions are terms that supplement the terms of this License by making exceptions from one or more of its conditions. Additional permissions that are applicable to the entire Program shall be treated as though they were included in this License, to the extent that they are valid under applicable law. If additional permissions apply only to part of the Program, that part may be used separately under those permissions, but the entire Program remains governed by this License without regard to the additional permissions.
111
 
112
  When you convey a copy of a covered work, you may at your option remove any additional permissions from that copy, or from any part of it. (Additional permissions may be written to require their own removal in certain cases when you modify the work.) You may place additional permissions on material, added by you to a covered work, for which you have or can give appropriate copyright permission.
113
 
119
  d) Limiting the use for publicity purposes of names of licensors or authors of the material; or
120
  e) Declining to grant rights under trademark law for use of some trade names, trademarks, or service marks; or
121
  f) Requiring indemnification of licensors and authors of that material by anyone who conveys the material (or modified versions of it) with contractual assumptions of liability to the recipient, for any liability that these contractual assumptions directly impose on those licensors and authors.
122
+ All other non-permissive additional terms are considered further restrictions within the meaning of section 10. If the Program as you received it, or any part of it, contains a notice stating that it is governed by this License along with a term that is a further restriction, you may remove that term. If a license document contains a further restriction but permits relicensing or conveying under this License, you may add to a covered work material governed by the terms of that license document, provided that the further restriction does not survive such relicensing or conveying.
123
 
124
  If you add terms to a covered work in accord with this section, you must place, in the relevant source files, a statement of the additional terms that apply to those files, or a notice indicating where to find the applicable terms.
125
 
140
  10. Automatic Licensing of Downstream Recipients.
141
  Each time you convey a covered work, the recipient automatically receives a license from the original licensors, to run, modify and propagate that work, subject to this License. You are not responsible for enforcing compliance by third parties with this License.
142
 
143
+ An entity transaction is a transaction transferring control of an organization, or substantially all assets of one, or subdividing an organization, or merging organizations. If propagation of a covered work results from an entity transaction, each party to that transaction who receives a copy of the work also receives whatever licenses to the work the party's predecessor in interest had or could give under the previous paragraph, plus a right to possession of the Corresponding Source of the work from the predecessor in interest, if the predecessor has it or can get it with reasonable efforts.
144
 
145
  You may not impose any further restrictions on the exercise of the rights granted or affirmed under this License. For example, you may not impose a license fee, royalty, or other charge for exercise of rights granted under this License, and you may not initiate litigation (including a cross-claim or counterclaim in a lawsuit) alleging that any patent claim is infringed by making, using, selling, offering for sale, or importing the Program or any portion of it.
146
 
147
  11. Patents.
148
+ A contributor is a copyright holder who authorizes use under this License of the Program or a work on which the Program is based. The work thus licensed is called the contributor's contributor version”.
149
 
150
+ A contributor's essential patent claims are all patent claims owned or controlled by the contributor, whether already acquired or hereafter acquired, that would be infringed by some manner, permitted by this License, of making, using, or selling its contributor version, but do not include claims that would be infringed only as a consequence of further modification of the contributor version. For purposes of this definition, control includes the right to grant patent sublicenses in a manner consistent with the requirements of this License.
151
 
152
  Each contributor grants you a non-exclusive, worldwide, royalty-free patent license under the contributor's essential patent claims, to make, use, sell, offer for sale, import and otherwise run, modify and propagate the contents of its contributor version.
153
 
154
+ In the following three paragraphs, a patent license is any express agreement or commitment, however denominated, not to enforce a patent (such as an express permission to practice a patent or covenant not to sue for patent infringement). To grant such a patent license to a party means to make such an agreement or commitment not to enforce a patent against the party.
155
 
156
+ If you convey a covered work, knowingly relying on a patent license, and the Corresponding Source of the work is not available for anyone to copy, free of charge and under the terms of this License, through a publicly available network server or other readily accessible means, then you must either (1) cause the Corresponding Source to be so available, or (2) arrange to deprive yourself of the benefit of the patent license for this particular work, or (3) arrange, in a manner consistent with the requirements of this License, to extend the patent license to downstream recipients. Knowingly relying means you have actual knowledge that, but for the patent license, your conveying the covered work in a country, or your recipient's use of the covered work in a country, would infringe one or more identifiable patents in that country that you have reason to believe are valid.
157
 
158
  If, pursuant to or in connection with a single transaction or arrangement, you convey, or propagate by procuring conveyance of, a covered work, and grant a patent license to some of the parties receiving the covered work authorizing them to use, propagate, modify or convey a specific copy of the covered work, then the patent license you grant is automatically extended to all recipients of the covered work and works based on it.
159
 
160
+ A patent license is discriminatory if it does not include within the scope of its coverage, prohibits the exercise of, or is conditioned on the non-exercise of one or more of the rights that are specifically granted under this License. You may not convey a covered work if you are a party to an arrangement with a third party that is in the business of distributing software, under which you make payment to the third party based on the extent of your activity of conveying the work, and under which the third party grants, to any of the parties who would receive the covered work from you, a discriminatory patent license (a) in connection with copies of the covered work conveyed by you (or copies made from those copies), or (b) primarily for and in connection with specific products or compilations that contain the covered work, unless you entered into that arrangement, or that patent license was granted, prior to 28 March 2007.
161
 
162
  Nothing in this License shall be construed as excluding or limiting any implied license or other defenses to infringement that may otherwise be available to you under applicable patent law.
163
 
170
  14. Revised Versions of this License.
171
  The Free Software Foundation may publish revised and/or new versions of the GNU General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns.
172
 
173
+ Each version is given a distinguishing version number. If the Program specifies that a certain numbered version of the GNU General Public License or any later version applies to it, you have the option of following the terms and conditions either of that numbered version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of the GNU General Public License, you may choose any version ever published by the Free Software Foundation.
174
 
175
  If the Program specifies that a proxy can decide which future versions of the GNU General Public License can be used, that proxy's public statement of acceptance of a version permanently authorizes you to choose that version for the Program.
176
 
177
  Later license versions may give you additional or different permissions. However, no additional obligations are imposed on any author or copyright holder as a result of your choosing to follow a later version.
178
 
179
  15. Disclaimer of Warranty.
180
+ THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM AS IS WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
181
 
182
  16. Limitation of Liability.
183
  IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
185
  17. Interpretation of Sections 15 and 16.
186
  If the disclaimer of warranty and limitation of liability provided above cannot be given local legal effect according to their terms, reviewing courts shall apply local law that most closely approximates an absolute waiver of all civil liability in connection with the Program, unless a warranty or assumption of liability accompanies a copy of the Program in return for a fee.
187
 
188
+ END OF TERMS AND CONDITIONS
readme.txt CHANGED
@@ -5,8 +5,8 @@ License: GPLv3
5
  License URI: http://www.gnu.org/licenses/gpl.html
6
  Tags: sitemap, google sitemap, xml, simple sitemap, html, xml sitemap, html sitemap, seo, seo sitemap, sitemaps, site map, sitemap html, sitemap xml, sitemap plugin, wordpress sitemap
7
  Requires at least: 4.0
8
- Tested up to: 4.5
9
- Stable tag: 1.1.2
10
 
11
  An easy, fast and secure plugin that adds both an xml and an html sitemap to your site, which updates and maintains themselves so you dont have to!
12
 
@@ -22,27 +22,23 @@ Also supports the option to add pages to the sitemaps that aren't part of your o
22
 
23
  = What it does =
24
 
25
- So what the plugin actually does is making one sitemap.xml and one sitemap.html available directly on your site. These aren't actually real files that can be found in a folder or something, instead they get generated when visited and can be found at like yourpage.com/sitemap.xml and yourpage.com/sitemap.html.
26
 
27
  And yes, of course the sitemaps are mobile friendly. They also work well with caching plugins :)
28
 
29
- = A review =
30
 
31
- I would like to add a review here someone gave after installing this plugin:
32
-
33
- Q: So what do you like about this sitemap plugin?
34
-
35
- A: That the sitemaps are always updated automatically! Every time I add a new, update or delete a post or page my sitemap is also always updated. It means a lot to know that whenever a user or google visits my site the sitemaps are always up to date and shows what I want them to show, and blocks what I do not want them to.
36
 
37
  == Installation ==
38
 
39
  1. 1. Go to the plugins page in your wordpress admin area and hit "add new".
40
- 2. Either search for "simple-wp-sitemap" and click install, or hit "upload plugin" and upload the zip file.
41
  3. Another way is by just uploading the "simple-wp-sitemap" folder via ftp to the /wp-content/plugins/ directory.
42
 
43
- 2. Activate the plugin and that's it, done. The two sitemaps will be generated when visited, and can be found at like yourpage.com/sitemap.xml and yourpage.com/sitemap.html.
44
 
45
- 3. Customize the plugin and add/block pages by hitting the "Simple Wp Sitemap" option in the settings menu.
46
 
47
  == Frequently Asked Questions ==
48
 
@@ -86,6 +82,13 @@ When you deactivate the plugin they get removed automatically.
86
 
87
  == Changelog ==
88
 
 
 
 
 
 
 
 
89
  = 1.1.2 (Jan 20, 2016) =
90
  * Premium version of the plugin has been developed
91
  * Integrated option to upgrade
@@ -161,4 +164,4 @@ When you deactivate the plugin they get removed automatically.
161
  * Added max-length for user added urls
162
 
163
  = 1.0.0 (March 14, 2015) =
164
- * Initial public release
5
  License URI: http://www.gnu.org/licenses/gpl.html
6
  Tags: sitemap, google sitemap, xml, simple sitemap, html, xml sitemap, html sitemap, seo, seo sitemap, sitemaps, site map, sitemap html, sitemap xml, sitemap plugin, wordpress sitemap
7
  Requires at least: 4.0
8
+ Tested up to: 4.6
9
+ Stable tag: 1.1.3
10
 
11
  An easy, fast and secure plugin that adds both an xml and an html sitemap to your site, which updates and maintains themselves so you dont have to!
12
 
22
 
23
  = What it does =
24
 
25
+ So what the plugin actually does is making one sitemap.xml and one sitemap.html available directly on your site. These aren't actually real files that can be found in a folder or anything, instead they get generated when visited and can be found at like yourpage.com/sitemap.xml and yourpage.com/sitemap.html.
26
 
27
  And yes, of course the sitemaps are mobile friendly. They also work well with caching plugins :)
28
 
29
+ = Extra info =
30
 
31
+ The sitemaps are multisite and multilanguage compatible. Every site gets their own sitemap, and all multilanguage urls are included in the sitemaps!
 
 
 
 
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
 
39
+ 2. Activate the plugin and that's it, done. Your xml and html sitemaps will be generated when visited, and can be found at like yourpage.com/sitemap.xml and yourpage.com/sitemap.html.
40
 
41
+ 3. Customize the plugin and change titles or add/block pages by hitting the "Simple Wp Sitemap" option in the settings menu.
42
 
43
  == Frequently Asked Questions ==
44
 
82
 
83
  == Changelog ==
84
 
85
+ = 1.1.3 (May 15, 2016) =
86
+ * Added option to change titles in html sitemap
87
+ * Fixed bug when upgrading to premium
88
+ * Fixed bug that made admin submit button invisible
89
+ * Moved admin settings page to it's own file
90
+ * Made all previous private functions in "builder" public
91
+
92
  = 1.1.2 (Jan 20, 2016) =
93
  * Premium version of the plugin has been developed
94
  * Integrated option to upgrade
164
  * Added max-length for user added urls
165
 
166
  = 1.0.0 (March 14, 2015) =
167
+ * Initial public release
simple-wp-sitemap.php CHANGED
@@ -1,10 +1,10 @@
1
- <?php if (!defined( 'ABSPATH' )) { die(); }
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.1.2
8
  * Author: Webbjocke
9
  * Author URI: http://www.webbjocke.com/
10
  * License: GPLv3
@@ -31,247 +31,118 @@ along with this program. If not, see http://www.gnu.org/licenses/.
31
  // Main class
32
 
33
  class SimpleWpSitemap {
34
- private static $version = 8; // only changes when needed
35
-
36
- // Runs on plugin activation
37
- public static function activateSitemaps () {
38
- self::rewriteRules();
39
- flush_rewrite_rules();
40
- update_option('simple_wp_sitemap_version', self::$version);
41
-
42
- // deletes files sitemap.xml and .html from old versions of the plugin
43
- require_once('simpleWpMapBuilder.php');
44
- SimpleWpMapBuilder::deleteFiles();
45
- }
46
-
47
- // Runs on plugin deactivation
48
- public static function deactivateSitemaps () {
49
- flush_rewrite_rules();
50
- }
51
-
52
- // Updates the plugin if needed (calls activateSitemaps)
53
- public static function updateCheck () {
54
- $current = get_option('simple_wp_sitemap_version');
55
- if (!$current || $current < self::$version) {
56
- self::activateSitemaps();
57
- }
58
- }
59
-
60
- // Registers most hooks
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);
67
- add_filter('template_redirect', array(__CLASS__, 'generateSitemapContent'), 1);
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
- $theLink = array(sprintf('<a href="%s">%s</a>', esc_url(admin_url('options-general.php?page=simpleWpSitemapSettings')), __('Settings')));
74
- return array_merge($links, $theLink);
75
- }
76
-
77
- // Sets the option menu for admins and enqueues scripts n styles
78
- public static function sitemapAdminSetup () {
79
- add_options_page('Simple Wp Sitemap', 'Simple Wp Sitemap', 'administrator', 'simpleWpSitemapSettings', array(__CLASS__, 'sitemapAdminArea'));
80
- add_action('admin_enqueue_scripts', array(__CLASS__, 'sitemapScriptsAndStyles'));
81
- add_action('admin_init', array(__CLASS__, 'sitemapAdminInit'));
82
- }
83
-
84
- // Register settings on admin_init
85
- public static function sitemapAdminInit () {
86
- $group = 'simple_wp-sitemap-group';
87
- register_setting($group, 'simple_wp_other_urls');
88
- register_setting($group, 'simple_wp_block_urls');
89
- register_setting($group, 'simple_wp_attr_link');
90
- register_setting($group, 'simple_wp_disp_categories');
91
- register_setting($group, 'simple_wp_disp_tags');
92
- register_setting($group, 'simple_wp_disp_authors');
93
- register_setting($group, 'simple_wp_disp_sitemap_order');
94
- self::updateCheck();
95
- }
96
-
97
- // Rewrite rules for sitemaps
98
- public static function rewriteRules () {
99
- add_rewrite_rule('sitemap\.xml$', 'index.php?thesimplewpsitemap=xml', 'top');
100
- add_rewrite_rule('sitemap\.html$', 'index.php?thesimplewpsitemap=html', 'top');
101
- }
102
-
103
- // Add custom query
104
- public static function addSitemapQuery ($vars) {
105
- $vars[] = 'thesimplewpsitemap';
106
- return $vars;
107
- }
108
-
109
- // Generates the content
110
- public static function generateSitemapContent () {
111
- global $wp_query;
112
- if (isset($wp_query->query_vars['thesimplewpsitemap'])) {
113
- $q = $wp_query->query_vars['thesimplewpsitemap'];
114
- if (!empty($q) && ($q === 'xml' || $q === 'html')) {
115
- $wp_query->is_404 = false;
116
-
117
- require_once('simpleWpMapBuilder.php');
118
- $sitemap = new SimpleWpMapBuilder();
119
-
120
- if ($q === 'xml') {
121
- header('Content-type: application/xml; charset=utf-8');
122
- }
123
- $sitemap->getContent($q);
124
- exit;
125
- }
126
- }
127
- }
128
-
129
- // Add custom scripts and styles to the plugins customization page in admin area
130
- public static function sitemapScriptsAndStyles ($page) {
131
- if ($page === 'settings_page_simpleWpSitemapSettings') {
132
- wp_enqueue_style('simple-wp-sitemap-admin-css', plugin_dir_url( __FILE__ ) . 'css/simple-wp-sitemap-admin.css');
133
- wp_enqueue_script('simple-wp-sitemap-admin-js', plugin_dir_url( __FILE__ ) . 'js/simple-wp-sitemap-admin.js', array('jquery'), false, true);
134
- }
135
- }
136
-
137
- // Interface for settings page, also handles initial post request when settings are changed
138
- public static function sitemapAdminArea () {
139
- require_once('simpleWpMapOptions.php');
140
- $options = new SimpleWpMapOptions();
141
-
142
- 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'])) {
143
-
144
- $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), array('Home' => $_POST['simple_wp_home_n'], 'Posts' => $_POST['simple_wp_posts_n'], 'Pages' => $_POST['simple_wp_pages_n'], 'Other' => $_POST['simple_wp_other_n'], 'Categories' => $_POST['simple_wp_categories_n'], 'Tags' => $_POST['simple_wp_tags_n'], 'Authors' => $_POST['simple_wp_authors_n']));
145
- } elseif (isset($_POST['upgrade_to_premium']) && !empty($_POST['upgrade_to_premium'])) {
146
  $options->upgradePlugin($_POST['upgrade_to_premium']);
147
  }
148
- ?>
149
- <div class="wrap">
150
-
151
- <h2 id="simple-wp-sitemap-h2">
152
- <img src="<?php echo $options->pluginUrl() . 'sign.png'; ?>" alt="logo" width="40" height="40">
153
- <span>Simple Wp Sitemap settings</span>
154
- </h2>
155
-
156
- <p>Your two sitemaps are active! Here you can change and customize them.</p>
157
-
158
- <p><strong>Links to your xml and html sitemap:</strong></p>
159
-
160
- <ul>
161
- <li>Xml sitemap: <a href="<?php echo $options->sitemapUrl('xml'); ?>"><?php echo $options->sitemapUrl('xml'); ?></a></li>
162
- <li>Html sitemap: <a href="<?php echo $options->sitemapUrl('html'); ?>"><?php echo $options->sitemapUrl('html'); ?></a></li>
163
- </ul>
164
-
165
- <noscript>(Enable javascript for order options)</noscript>
166
-
167
- <form method="post" action="<?php echo $options->getSubmitUrl(); ?>" id="simple-wp-sitemap-form">
168
-
169
- <?php settings_fields('simple_wp-sitemap-group'); ?>
170
-
171
- <ul id="sitemap-settings">
172
- <li id="sitemap-normal" class="sitemap-active">General</li>
173
- <li id="sitemap-advanced">Order</li>
174
- <li id="sitemap-premium">Premium</li>
175
- </ul>
176
-
177
- <table id="sitemap-table-show" class="widefat form-table table-hidden" data-id="sitemap-normal">
178
-
179
- <tr><td><strong>Add pages</strong></td></tr>
180
- <tr><td>Add pages to the sitemaps in addition to your normal wordpress ones. Just paste "absolute" links in the textarea like: <strong>http://www.example.com/a-page/</strong>. Each link on a new row (this will affect both your xml and html sitemap).</td></tr>
181
- <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>
182
-
183
- <tr><td><strong>Block pages</strong></td></tr>
184
- <tr><td>Add pages you want to block from showing up in the sitemaps. Same as above, just paste every link on a new row. (Hint: copy paste links from one of the sitemaps to get correct urls).</td></tr>
185
- <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>
186
-
187
- <tr><td><strong>Extra sitemap includes</strong></td></tr>
188
- <tr><td>Check if you want to include categories, tags and/or author pages in the sitemaps.</td></tr>
189
- <tr><td><input type="checkbox" name="simple_wp_disp_categories" id="simple_wp_cat" <?php echo $options->getOptions('simple_wp_disp_categories'); ?>><label for="simple_wp_cat"> Include categories</label></td></tr>
190
- <tr><td><input type="checkbox" name="simple_wp_disp_tags" id="simple_wp_tags" <?php echo $options->getOptions('simple_wp_disp_tags'); ?>><label for="simple_wp_tags"> Include tags</label></td></tr>
191
- <tr><td><input type="checkbox" name="simple_wp_disp_authors" id="simple_wp_authors" <?php echo $options->getOptions('simple_wp_disp_authors'); ?>><label for="simple_wp_authors"> Include authors</label></td></tr>
192
-
193
- <tr><td><strong>Like the plugin?</strong></td></tr>
194
- <tr><td>Show your support by rating the plugin at wordpress.org, and/or by adding an attribution link to the sitemap.html file :)</td></tr>
195
- <tr><td><input type="checkbox" name="simple_wp_attr_link" id="simple_wp_check" <?php echo $options->getOptions('simple_wp_attr_link'); ?>><label for="simple_wp_check"> Add "Generated by Simple Wp Sitemap" link at bottom of sitemap.html.</label></td></tr>
196
- <tr><td>A donation is also always welcome! <a href="https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=UH6ANJA7M8DNS" id="simple-wp-sitemap-donate" target="_blank"><img src="https://www.paypalobjects.com/en_US/i/btn/btn_donate_SM.gif" alt="PayPal - The safer, easier way to pay online!"></a></td></tr>
197
-
198
- </table>
199
-
200
- <table class="widefat form-table table-hidden" data-id="sitemap-advanced">
201
-
202
- <tr><td><strong>Change display order</strong></td></tr>
203
- <tr><td>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.</td></tr>
204
- <tr><td>
205
-
206
- <ul id="sitemap-display-order">
207
-
208
- <?php
209
- if (!($orderArray = $options->getOptions('simple_wp_disp_sitemap_order'))) {
210
- $orderArray = array('Home' => null, 'Posts' => null, 'Pages' => null, 'Other' => null, 'Categories' => null, 'Tags' => null, 'Authors' => null);
211
- }
212
- $count = 1;
213
-
214
- foreach ($orderArray as $title => $val) {
215
- printf('<li>%s<span class="sitemap-down" title="move down"></span><span class="sitemap-up" title="move up"></span><input type="hidden" name="simple_wp_%s_n" value="%d"></li>', $title, lcfirst($title), ($count++));
216
- }
217
- ?>
218
-
219
- </ul>
220
-
221
- </td></tr>
222
-
223
- <tr><td id="sitemap-defaults" title="Restore the default display order">Restore default order</td></tr>
224
-
225
- </table>
226
-
227
- <table class="widefat form-table table-hidden" data-id="sitemap-premium">
228
-
229
- <tr><td><strong>Upgrade to Simple Wp Sitmap Premium!</strong></td></tr>
230
- <tr><td>Premium version includes all the features below. It's a one time payment, all future updates to premium will of course be free.</td></tr>
231
- <tr><td><strong>Have upgrade code?</strong></td></tr>
232
- <tr><td><input type="text" id="upgradeField" value="<?php echo esc_html($options->getPosted()); ?>"><span class="button-secondary" id="upgradeToPremium">Upgrade</span> <span style="color:red;"><?php echo $options->getError(); ?></span></td></tr>
233
-
234
- <tr><td><p class="simple-wp-s-p"><strong>Split sitemaps</strong><br>Enable the Premium layout. Instead of having all links in one document, split your xml and html sitemap up into multiple for better overview, usability and performance. Supports sites with over 5000 pages easily. (Unlimited amount of pages)</p><img class="simple-wp-s-image" src="<?php echo $options->pluginUrl() . 'imgs/split-sitemaps.png'; ?>" alt="image"></td></tr>
235
- <tr><td><p class="simple-wp-s-p"><strong>Add your logo</strong><br>Add your logo to the html sitemap header to make it look nice and professional.</p><img class="simple-wp-s-image" src="<?php echo $options->pluginUrl() . 'imgs/add-logo.png'; ?>" alt="image"></td></tr>
236
- <tr><td><p class="simple-wp-s-p"><strong>Custom css</strong><br>Add custom css to your html sitemap. Style it and make it look anyway you want! External fonts can also be added here.</p><img class="simple-wp-s-image" src="<?php echo $options->pluginUrl() . 'imgs/custom-css.png'; ?>" alt="image"></td></tr>
237
- <tr><td><p class="simple-wp-s-p"><strong>Exclude directories</strong><br>Enhanced version of "block pages". Can now block entire directories in an easy way, in addition to only normal urls as before.</p><img class="simple-wp-s-image" src="<?php echo $options->pluginUrl() . 'imgs/exclude-dirs.png'; ?>" alt="image"></td></tr>
238
- <tr><td><p class="simple-wp-s-p"><strong>Also includes</strong>
239
- <ul class="simple-wp-also">
240
- <li>Custom color picker. To change link colors in an easy way (if you don't know css).</li>
241
- <li>Paging. So not too many links are displayed at the same time for users.</li>
242
- <li>Free updates.</li>
243
- <li>You can also use it on up to 5 sites, so you don't have to buy it for every site you have.</li>
244
- </ul>
245
- </td></tr>
246
-
247
- <tr><td><strong>How to:</strong>
248
- <ol>
249
- <li>Click the purchase button and go to paypal</li>
250
- <li>Pay with your account or directly with credit card</li>
251
- <li>You get your unique premium code and a receipt</li>
252
- <li>Copy the code to here above where it says "have upgrade code?" and hit upgrade</li>
253
- <li>That's it!</li>
254
- </ol>
255
- </td></tr>
256
-
257
- <tr><td><hr><strong>Upgrade now!</strong><br>Price: 6.99$ USD (tax included)</td></tr>
258
- <tr><td><a href="https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=NSPEB5BT72YHL" target="_blank" class="button-primary">Purchase with paypal</a></td></tr>
259
-
260
- <tr><td>Or purchase via: <a target="_blank" href="https://www.webbjocke.com/downloads/simple-wp-sitemap-premium">webbjocke.com/downloads/simple-wp-sitemap-premium</a></td></tr>
261
-
262
- </table>
263
-
264
- <p class="submit"><input type="submit" class="button-primary" value="<?php _e('Save Changes'); ?>"></p>
265
-
266
- <p>(If you have a caching plugin, you might have to clear cache before changes will be shown in the sitemaps)</p>
267
-
268
- </form>
269
-
270
- <form method="post" action="<?php echo $options->getSubmitUrl(); ?>" class="table-hidden" id="simpleWpHiddenForm">
271
- <input type="hidden">
272
- </form>
273
-
274
- </div>
275
- <?php }
276
  }
277
- SimpleWpSitemap::registerHooks();
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, fast and secure plugin that adds both an xml and an html sitemap to your site, which updates and maintains themselves so you dont have to!
7
+ * Version: 1.1.3
8
  * Author: Webbjocke
9
  * Author URI: http://www.webbjocke.com/
10
  * License: GPLv3
31
  // Main class
32
 
33
  class SimpleWpSitemap {
34
+ private static $version = 13; // only changes when needed
35
+
36
+ // Runs on plugin activation
37
+ public static function activateSitemaps () {
38
+ self::rewriteRules();
39
+ flush_rewrite_rules();
40
+
41
+ require_once 'simpleWpMapOptions.php';
42
+ $ops = new SimpleWpMapOptions();
43
+ $ops->migrateFromOld();
44
+
45
+ update_option('simple_wp_sitemap_version', self::$version);
46
+ }
47
+
48
+ // Runs on plugin deactivation
49
+ public static function deactivateSitemaps () {
50
+ flush_rewrite_rules();
51
+ }
52
+
53
+ // Updates the plugin if needed (calls activateSitemaps)
54
+ public static function updateCheck () {
55
+ if (!($current = get_option('simple_wp_sitemap_version')) || $current < self::$version) {
56
+ self::activateSitemaps();
57
+ }
58
+ }
59
+
60
+ // Registers most hooks
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);
67
+ add_filter('template_redirect', array(__CLASS__, 'generateSitemapContent'), 1);
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('simple_wp_other_urls', 'simple_wp_block_urls', 'simple_wp_attr_link', 'simple_wp_disp_categories', 'simple_wp_disp_tags', 'simple_wp_disp_authors', 'simple_wp_disp_sitemap_order', 'simple_wp_sitemap_version', 'simple_wp_last_updated') as $setting) {
86
+ register_setting('simple_wp-sitemap-group', $setting);
87
+ }
88
+ self::updateCheck();
89
+ }
90
+
91
+ // Rewrite rules for sitemaps
92
+ public static function rewriteRules () {
93
+ add_rewrite_rule('sitemap\.xml$', 'index.php?thesimplewpsitemap=xml', 'top');
94
+ add_rewrite_rule('sitemap\.html$', 'index.php?thesimplewpsitemap=html', 'top');
95
+ }
96
+
97
+ // Add custom query
98
+ public static function addSitemapQuery ($vars) {
99
+ $vars[] = 'thesimplewpsitemap';
100
+ return $vars;
101
+ }
102
+
103
+ // Generates the content
104
+ public static function generateSitemapContent () {
105
+ global $wp_query;
106
+ if (isset($wp_query->query_vars['thesimplewpsitemap']) && in_array(($q = $wp_query->query_vars['thesimplewpsitemap']), array('xml', 'html'))) {
107
+ $wp_query->is_404 = false;
108
+
109
+ require_once 'simpleWpMapBuilder.php';
110
+ $sitemap = new SimpleWpMapBuilder();
111
+
112
+ if ($q === 'xml') {
113
+ header('Content-type: application/xml; charset=utf-8');
114
+ }
115
+ $sitemap->getContent($q);
116
+ exit;
117
+ }
118
+ }
119
+
120
+ // Add custom scripts and styles to the plugins customization page in admin area
121
+ public static function sitemapScriptsAndStyles ($page) {
122
+ if ($page === 'settings_page_simpleWpSitemapSettings') {
123
+ wp_enqueue_style('simple-wp-sitemap-admin-css', plugin_dir_url( __FILE__ ) . 'css/simple-wp-sitemap-admin.css', array(), self::$version);
124
+ wp_enqueue_script('simple-wp-sitemap-admin-js', plugin_dir_url( __FILE__ ) . 'js/simple-wp-sitemap-admin.js', array('jquery'), self::$version, true);
125
+ }
126
+ }
127
+
128
+ // Interface for settings page, also handles initial post request when settings are changed
129
+ public static function sitemapAdminArea () {
130
+ require_once 'simpleWpMapOptions.php';
131
+ $options = new SimpleWpMapOptions();
132
+
133
+ 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'])) {
134
+
135
+ $order = $options->getDefaultOrder();
136
+ foreach ($order as $key => $val) {
137
+ $arr = explode('-|-', $_POST['simple_wp_' . $key . '_n']);
138
+ $order[$key] = array('i' => $arr[0], 'title' => isset($arr[1]) ? $arr[1] : $key);
139
+ }
140
+ $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), $order, $_POST['simple_wp_active-page'], $_POST['simple_wp_last_updated']);
141
+ }
142
+ elseif (isset($_POST['upgrade_to_premium'])) {
 
 
 
143
  $options->upgradePlugin($_POST['upgrade_to_premium']);
144
  }
145
+ require_once 'simpleWpMapAdmin.php';
146
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
147
  }
148
+ SimpleWpSitemap::registerHooks();
simpleWpMapAdmin.php ADDED
@@ -0,0 +1,100 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php defined('ABSPATH') || exit;
2
+ /*
3
+ * Simple Wp Sitemap Admin interface
4
+ */
5
+ ?>
6
+ <div class="wrap">
7
+ <h2 id="simple-wp-sitemap-h2">
8
+ <img src="<?php printf('%ssign.png', $options->pluginUrl()); ?>" alt="logo" width="40" height="40">
9
+ <span>Simple Wp Sitemap settings</span>
10
+ </h2>
11
+ <p>Your two sitemaps are active! Here you can change and customize them.</p>
12
+ <p><strong>Links to your xml and html sitemap:</strong></p>
13
+ <ul>
14
+ <li>Xml sitemap: <a href="<?php echo $options->sitemapUrl('xml'); ?>"><?php echo $options->sitemapUrl('xml'); ?></a></li>
15
+ <li>Html sitemap: <a href="<?php echo $options->sitemapUrl('html'); ?>"><?php echo $options->sitemapUrl('html'); ?></a></li>
16
+ </ul>
17
+ <noscript>(Please enable javascript to edit options)</noscript>
18
+ <form method="post" action="<?php echo $options->getSubmitUrl(); ?>" id="simple-wp-sitemap-form">
19
+
20
+ <?php settings_fields('simple_wp-sitemap-group'); ?>
21
+
22
+ <ul id="sitemap-settings">
23
+ <li id="sitemap-normal" class="sitemap-active">General</li>
24
+ <li id="sitemap-advanced">Order</li>
25
+ <li id="sitemap-premium">Premium</li>
26
+ </ul>
27
+ <input type="hidden" id="simple_wp_active-page" name="simple_wp_active-page" value="<?php echo $options->getPage(); ?>">
28
+
29
+ <table id="sitemap-table-show" class="widefat form-table table-hidden" data-id="sitemap-normal">
30
+ <tr><td><strong>Add pages</strong></td></tr>
31
+ <tr><td>Add pages to the sitemaps in addition to your normal wordpress ones. Just paste "full" urls in the textarea like: <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>.</td></tr>
32
+ <tr><td><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 $options->getOptions('simple_wp_other_urls'); ?></textarea></td></tr>
33
+
34
+ <tr><td><strong>Block pages</strong></td></tr>
35
+ <tr><td>Add pages you want to block from showing up in the sitemaps. Same as above, just paste every link on a new row. <em>(Hint: copy paste links from one of the sitemaps to get correct urls)</em>.</td></tr>
36
+ <tr><td><textarea rows="7" name="simple_wp_block_urls" placeholder="http://www.example.com/block-this-page/" class="large-text code"><?php echo $options->getOptions('simple_wp_block_urls'); ?></textarea></td></tr>
37
+
38
+ <tr><td><strong>Extra sitemap includes</strong></td></tr>
39
+ <tr><td>Check if you want to include categories, tags and/or author pages in the sitemaps.</td></tr>
40
+ <tr><td><input type="checkbox" name="simple_wp_disp_categories" id="simple_wp_cat" <?php echo $options->getOptions('simple_wp_disp_categories'); ?>><label for="simple_wp_cat"> Include categories</label></td></tr>
41
+ <tr><td><input type="checkbox" name="simple_wp_disp_tags" id="simple_wp_tags" <?php echo $options->getOptions('simple_wp_disp_tags'); ?>><label for="simple_wp_tags"> Include tags</label></td></tr>
42
+ <tr><td><input type="checkbox" name="simple_wp_disp_authors" id="simple_wp_authors" <?php echo $options->getOptions('simple_wp_disp_authors'); ?>><label for="simple_wp_authors"> Include authors</label></td></tr>
43
+
44
+ <tr><td><strong>Like the plugin?</strong></td></tr>
45
+ <tr><td>Show your support by rating the plugin at wordpress.org, and/or by adding an attribution link to the sitemap.html file :)</td></tr>
46
+ <tr><td><input type="checkbox" name="simple_wp_attr_link" id="simple_wp_check" <?php echo $options->getOptions('simple_wp_attr_link'); ?>><label for="simple_wp_check"> Add "Generated by Simple Wp Sitemap" link at bottom of sitemap.html.</label></td></tr>
47
+ <tr><td>A donation is also always welcome! <a href="https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=UH6ANJA7M8DNS" id="simple-wp-sitemap-donate" target="_blank"><img src="https://www.paypalobjects.com/en_US/i/btn/btn_donate_SM.gif" alt="PayPal - The safer, easier way to pay online!"></a></td></tr>
48
+ </table>
49
+
50
+ <table class="widefat form-table table-hidden" data-id="sitemap-advanced">
51
+ <tr><td><strong>Display order &amp; titles</strong></td></tr>
52
+ <tr><td>
53
+ 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>
54
+ Hit the "Change" buttons to change the title displayed in the sitemaps.
55
+ </td></tr>
56
+ <tr><td>
57
+ <ul id="sitemap-display-order">
58
+ <?php if (!($orderArray = $options->getOptions('simple_wp_disp_sitemap_order'))) {
59
+ $orderArray = $options->getDefaultOrder();
60
+ }
61
+ foreach ($orderArray as $key => $val) {
62
+ printf('<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><input type="hidden" name="simple_wp_%s_n" value="%d"><input type="button" value="Change" class="button-secondary sitemap-change-btn"></li>', $key, $val['title'], $key, $val['i']);
63
+ } ?>
64
+ </ul>
65
+ </td></tr>
66
+ <tr><td><strong>Last updated text:</strong> <input type="text" name="simple_wp_last_updated" placeholder="Last updated" value="<?php echo $options->getOptions('simple_wp_last_updated'); ?>" id="simple_wp_last_updated"></td></tr>
67
+ <tr><td><input type="button" id="sitemap-defaults" class="button-secondary" title="Restore the default display order" value="Restore defaults"></td></tr>
68
+ </table>
69
+
70
+ <table class="widefat form-table table-hidden" data-id="sitemap-premium">
71
+ <tr><td><strong>Upgrade to Simple Wp Sitemap Premium!</strong></td></tr>
72
+ <tr><td>Premium is an enhanced version of Simple Wp Sitemap. It's a one time payment and can be used on multiple sites!</td></tr>
73
+ <tr><td><strong>Includes:</strong>
74
+ <ul class="simple-wp-sitemap-includes">
75
+ <li>Split sitemaps <em>(option to have multiple files instead of having all links in one document)</em></li>
76
+ <li>Add a logo to the sitemaps</li>
77
+ <li>Custom css</li>
78
+ <li>Color picker <em>(to change colors if you don't know css)</em></li>
79
+ <li>Exclude directories</li>
80
+ <li>Free updates</li>
81
+ </ul>
82
+ </td></tr>
83
+ <tr><td><strong>If you have a premium code, enter it here to upgrade</strong></td></tr>
84
+ <tr><td><input type="text" id="upgradeField" value="<?php echo $options->getPosted(); ?>"><span class="button-secondary" id="upgradeToPremium">Upgrade</span> <span style="color:red;" id="swpErrorText"><?php echo $options->getError(); ?></span></td></tr>
85
+ <tr><td><hr><strong>Purchase via</strong>: <a target="_blank" href="https://www.webbjocke.com/downloads/simple-wp-sitemap-premium">webbjocke.com/downloads/simple-wp-sitemap-premium</a>
86
+ <ul class="simple-wp-sitemap-includes">
87
+ <li>It's: 6.99$ USD (tax included)</li>
88
+ <li>A "how to" guide is available on the site!</li>
89
+ </ul>
90
+ </td></tr>
91
+ </table>
92
+
93
+ <p class="submit"><input type="submit" class="button-primary" value="Save Changes"></p>
94
+ <p><em>(If you have a caching plugin, you might have to clear cache before changes will be shown in the sitemaps)</em></p>
95
+ </form>
96
+
97
+ <form method="post" action="<?php echo $options->getSubmitUrl(); ?>" class="table-hidden" id="simpleWpHiddenForm">
98
+ <input type="hidden">
99
+ </form>
100
+ </div>
simpleWpMapBuilder.php CHANGED
@@ -1,216 +1,207 @@
1
- <?php if (!defined( 'ABSPATH' )) { die(); }
2
 
3
  /*
4
  * The sitemap creating class
5
  */
 
6
  class SimpleWpMapBuilder {
7
- private $home = null;
8
- private $xml = false;
9
- private $html = false;
10
- private $posts = '';
11
- private $pages = '';
12
- private $blockedUrls = null;
13
- private $url;
14
- private $tags;
15
  private $other;
16
- private $homeUrl;
17
- private $authors;
18
  private $pattern;
19
- private $categories;
20
-
21
- // Constructor
22
- public function __construct () {
23
- $this->url = esc_url(plugins_url() . '/simple-wp-sitemap');
24
- $this->homeUrl = esc_url(get_home_url() . (substr(get_home_url(), -1) === '/' ? '' : '/'));
25
- $this->categories = get_option('simple_wp_disp_categories') ? array(0 => 0) : false;
26
- $this->tags = get_option('simple_wp_disp_tags') ? array(0 => 0) : false;
27
- $this->authors = get_option('simple_wp_disp_authors') ? array(0 => 0) : false;
 
28
  $this->blockedUrls = get_option('simple_wp_block_urls');
29
  @date_default_timezone_set(get_option('timezone_string'));
30
- }
31
-
32
- // Generates the sitemaps and returns the content
33
- public function getContent ($type) {
34
- if ($type === 'xml' || $type === 'html') {
35
- $this->$type = true;
36
  $this->pattern = ($this->xml ? 'Y-m-d\TH:i:sP' : 'Y-m-d H:i');
37
  $this->other = $this->getOtherPages();
38
- $this->setUpBlockedUrls();
39
- $this->generateContent();
40
- $this->mergeAndPrint();
41
- }
42
- }
43
-
44
- // Returns other urls user has submitted
45
- private function getOtherPages () {
46
- $xml = '';
47
- if ($options = get_option('simple_wp_other_urls')) {
48
- foreach ($options as $option) {
49
- if ($option && is_array($option)) {
 
50
  if (!is_int($option['date'])) { // fix for old versions of the plugin when date was stored in clear text
51
  $option['date'] = strtotime($option['date']);
52
  }
53
- $xml .= $this->getXml(esc_url($option['url']), esc_html(date($this->pattern, $option['date'])));
54
- }
55
- }
56
- }
57
- return $xml;
58
- }
59
-
60
- // Sets up blocked urls into an array
61
- private function setUpBlockedUrls () {
62
- if (($blocked = get_option('simple_wp_block_urls')) && is_array($blocked)) {
63
- $this->blockedUrls = array();
64
- foreach ($blocked as $block) {
65
- $this->blockedUrls[$block['url']] = true;
66
- }
67
- }
68
- }
69
-
70
- // Matches url against blocked ones that shouldn't be displayed
71
- private function isBlockedUrl($url) {
72
- return $this->blockedUrls && isset($this->blockedUrls[$url]);
73
  }
74
-
75
- // Returns an xml or html string
76
- private function getXml ($link, $date) {
 
 
 
 
 
 
 
 
 
 
77
  if ($this->xml) {
78
  return "<url>\n\t<loc>$link</loc>\n\t<lastmod>$date</lastmod>\n</url>\n";
79
  } else {
80
  return "<li><a href=\"$link\"><span class=\"link\">$link</span><span class=\"date\">$date</span></a></li>";
81
  }
82
- }
83
-
84
- // Querys the database and gets the actual sitemaps content
85
- private function generateContent () {
86
  $q = new WP_Query(array('post_type' => 'any', 'post_status' => 'publish', 'posts_per_page' => 50000, 'has_password' => false));
87
-
88
- if ($q->have_posts()) {
89
- while ($q->have_posts()) {
90
- $q->the_post();
91
-
92
- $link = esc_url(get_permalink());
93
- $date = get_the_modified_date($this->pattern);
94
- $this->getCategoriesTagsAndAuthor($date);
95
-
96
- if (!$this->isBlockedUrl($link)) {
97
- if (!$this->home && $link === $this->homeUrl) {
98
- $this->home = $this->getXml($link, $date);
99
- } elseif (get_post_type() === 'page') {
100
- $this->pages .= $this->getXml($link, $date);
101
- } else { // posts (also all custom post types are added here)
102
- $this->posts .= $this->getXml($link, $date);
103
- }
104
- }
105
- }
106
- }
107
- wp_reset_postdata();
108
- }
109
-
110
- // Gets a posts categories, tags and author, and compares for last modified date
111
- private function getCategoriesTagsAndAuthor ($date) {
112
- if ($this->categories && ($postCats = get_the_category())) {
113
- foreach ($postCats as $category) {
114
- $id = $category->term_id;
115
- if (!isset($this->categories[$id]) || $this->categories[$id] < $date) {
116
- $this->categories[$id] = $date;
117
- }
118
- }
119
- }
120
- if ($this->tags && ($postTags = get_the_tags())) {
121
- foreach ($postTags as $tag) {
122
- $id = $tag->term_id;
123
- if (!isset($this->tags[$id]) || $this->tags[$id] < $date) {
124
- $this->tags[$id] = $date;
125
- }
126
- }
127
- }
128
- if ($this->authors && ($id = get_the_author_meta('ID'))) {
129
- if (is_int($id) && (!isset($this->authors[$id]) || $this->authors[$id] < $date)) {
130
- $this->authors[$id] = $date;
131
- }
132
- }
133
- }
134
-
135
- // Merges the arrays with post data into strings and gets user submitted pages, categories, tags and author pages
136
- private function mergeAndPrint () {
137
- if ($this->xml) {
138
  echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<?xml-stylesheet type=\"text/css\" href=\"" . $this->url . "/css/xml.css\"?>\n<urlset xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://www.sitemaps.org/schemas/sitemap/0.9\n\thttp://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd\" xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\">\n" . $this->sortAndGetString() . "</urlset>\n<!-- Sitemap content by Simple Wp Sitemap -->";
139
  } else {
140
  echo '<!doctype html><html lang="' . get_locale() . '"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><title>' . get_bloginfo('name') . ' Html Sitemap</title><link rel="stylesheet" href="' . $this->url . '/css/html.css"></head><body><div id="wrapper"><h1><a href="' . $this->homeUrl . '">' . get_bloginfo('name') . '</a> Html Sitemap</h1>' . $this->sortAndGetString() . $this->attributionLink() . "</div></body></html>\n<!-- Sitemap content by Simple Wp Sitemap -->";
141
  }
142
- }
143
-
144
- // Displays attribution link if admin has checked the checkbox
145
- private function attributionLink () {
146
- if (get_option('simple_wp_attr_link')) {
147
- return '<p id="attr"><a id="attr-a" href="http://www.webbjocke.com/simple-wp-sitemap/" title="http://www.webbjocke.com/simple-wp-sitemap/">Generated by: Simple Wp Sitemap</a></p>';
148
- }
149
- return '';
150
- }
151
-
152
- // Returns sorted array as string according to specified order
153
- private function sortAndGetString () {
154
- if (!($arr = get_option('simple_wp_disp_sitemap_order'))) { $arr = array('Home' => null, 'Posts' => null, 'Pages' => null, 'Other' => null, 'Categories' => null, 'Tags' => null, 'Authors' => null); }
155
- if (!$this->home) { $this->home = $this->getXml($this->homeUrl, date($this->pattern)); }
156
-
 
 
 
 
157
  $str = '';
158
- foreach ($arr as $title => $val) {
159
- $str .= $this->getTitleStr(lcfirst($title));
160
- }
161
- return $str;
162
- }
163
-
164
- // Returns a title as string
165
- private function getTitleStr ($title) {
166
- $xml = $this->$title ? $this->$title : '';
167
- if ($xml) {
168
  if (in_array($title, array('categories', 'tags', 'authors'))) {
169
- $xml = $this->stringifyCatsTagsAuths($title, $xml);
170
- if ($title === 'authors' && count($this->authors) <= 2) { $title = 'author'; } // if one or more authors
171
  }
172
  if ($xml) {
173
- $xml = $this->xml ? $xml : '<div class="header"><p class="header-txt">' . ucfirst($title) . ':</p><p class="header-date">Last updated:</p></div><ul>' . $xml . '</ul>';
174
- $this->$title = null; // clear some memory (sites with huge amount of posts will be happy)
175
  }
176
  }
177
  return $xml;
178
  }
179
-
180
- // Returns category, tag and author links as ready xml and html strings
181
- private function stringifyCatsTagsAuths ($type, $content) {
182
- $xml = '';
183
- if ($content) {
184
  foreach ($content as $id => $date) {
185
- if ($date) {
186
- switch ($type) {
187
  case 'tags': $link = esc_url(get_tag_link($id)); break;
188
  case 'categories': $link = esc_url(get_category_link($id)); break;
189
  default: $link = esc_url(get_author_posts_url($id)); // Authors
190
- }
191
  if (!$this->isBlockedUrl($link)) {
192
  $xml .= $this->getXml($link, $date);
193
  }
194
  }
195
  }
196
  }
197
- return $xml;
198
- }
199
-
200
- // Deletes the sitemap files from old versions of the plugin
201
- public static function deleteFiles () {
202
- if (function_exists('get_home_path')) {
203
- $path = sprintf('%s%ssitemap.', get_home_path(), (substr(get_home_path(), -1) === '/' ? '' : '/'));
204
- try {
205
- foreach (array('xml', 'html') as $file) {
206
- if (file_exists($path . $file)) {
207
- unlink($path . $file);
208
- }
209
- }
210
- }
211
- catch (Exception $ex) {
212
- return;
213
- }
214
- }
215
- }
216
- }
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 = '';
12
+ private $pages = '';
13
+ private $blockedUrls = null;
14
+ private $url;
15
+ private $tags;
16
  private $other;
17
+ private $homeUrl;
18
+ private $authors;
19
  private $pattern;
20
+ private $categories;
21
+ private $lastUpdated;
22
+
23
+ // Constructor
24
+ public function __construct () {
25
+ $this->url = esc_url(plugins_url() . '/simple-wp-sitemap');
26
+ $this->homeUrl = esc_url(get_home_url() . (substr(get_home_url(), -1) === '/' ? '' : '/'));
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
+
34
+ // Generates the sitemaps and returns the content
35
+ public function getContent ($type) {
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();
43
+ $this->mergeAndPrint();
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
64
+ public function setUpBlockedUrls () {
65
+ if (($blocked = get_option('simple_wp_block_urls')) && is_array($blocked)) {
66
+ $this->blockedUrls = array();
67
+ foreach ($blocked as $block) {
68
+ $this->blockedUrls[$block['url']] = true;
69
+ }
70
+ }
 
 
 
 
 
71
  }
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
79
+ public function isBlockedUrl($url) {
80
+ return $this->blockedUrls && isset($this->blockedUrls[$url]);
81
+ }
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()) {
98
+ $q->the_post();
99
+
100
+ $link = esc_url(get_permalink());
101
+ $date = get_the_modified_date($this->pattern);
102
+ $this->getCategoriesTagsAndAuthor($date);
103
+
104
+ if (!$this->isBlockedUrl($link)) {
105
+ if (!$this->home && $link === $this->homeUrl) {
106
+ $this->home = $this->getXml($link, $date);
107
+ } elseif (get_post_type() === 'page') {
108
+ $this->pages .= $this->getXml($link, $date);
109
+ } else { // posts (also all custom post types are added here)
110
+ $this->posts .= $this->getXml($link, $date);
111
+ }
112
+ }
113
+ }
114
+ }
115
+ wp_reset_postdata();
116
+ }
117
+
118
+ // Gets a posts categories, tags and author, and compares for last modified date
119
+ public function getCategoriesTagsAndAuthor ($date) {
120
+ if ($this->categories && ($postCategories = get_the_category())) {
121
+ foreach ($postCategories as $category) {
122
+ if (!isset($this->categories[($id = $category->term_id)]) || $this->categories[$id] < $date) {
123
+ $this->categories[$id] = $date;
124
+ }
125
+ }
126
+ }
127
+ if ($this->tags && ($postTags = get_the_tags())) {
128
+ foreach ($postTags as $tag) {
129
+ if (!isset($this->tags[($id = $tag->term_id)]) || $this->tags[$id] < $date) {
130
+ $this->tags[$id] = $date;
131
+ }
132
+ }
133
+ }
134
+ if ($this->authors && ($id = get_the_author_meta('ID'))) {
135
+ if (!isset($this->authors[$id]) || $this->authors[$id] < $date) {
136
+ $this->authors[$id] = $date;
137
+ }
138
+ }
139
+ }
140
+
141
+ // Merges the arrays with post data into strings and gets user submitted pages, categories, tags and author pages
142
+ public function mergeAndPrint () {
143
+ if ($this->xml) {
 
 
144
  echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<?xml-stylesheet type=\"text/css\" href=\"" . $this->url . "/css/xml.css\"?>\n<urlset xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://www.sitemaps.org/schemas/sitemap/0.9\n\thttp://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd\" xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\">\n" . $this->sortAndGetString() . "</urlset>\n<!-- Sitemap content by Simple Wp Sitemap -->";
145
  } else {
146
  echo '<!doctype html><html lang="' . get_locale() . '"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><title>' . get_bloginfo('name') . ' Html Sitemap</title><link rel="stylesheet" href="' . $this->url . '/css/html.css"></head><body><div id="wrapper"><h1><a href="' . $this->homeUrl . '">' . get_bloginfo('name') . '</a> Html Sitemap</h1>' . $this->sortAndGetString() . $this->attributionLink() . "</div></body></html>\n<!-- Sitemap content by Simple Wp Sitemap -->";
147
  }
148
+ }
149
+
150
+ // Displays attribution link if user has checked the checkbox
151
+ public function attributionLink () {
152
+ if (get_option('simple_wp_attr_link')) {
153
+ return '<p id="attr"><a id="attr-a" href="http://www.webbjocke.com/simple-wp-sitemap/" title="http://www.webbjocke.com/simple-wp-sitemap/">Generated by: Simple Wp Sitemap</a></p>';
154
+ }
155
+ return '';
156
+ }
157
+
158
+ // Sorts, builds up and returns the content in xml or html
159
+ public function sortAndGetString () {
160
+ if (!($orderArray = get_option('simple_wp_disp_sitemap_order')) || !isset($orderArray['home'])) {
161
+ require_once 'simpleWpMapOptions.php'; $ops = new SimpleWpMapOptions(); $orderArray = $ops->migrateFromOld();
162
+ }
163
+ if (!$this->home) {
164
+ $this->home = $this->getXml($this->homeUrl, date($this->pattern));
165
+ }
166
+
167
  $str = '';
168
+ foreach ($orderArray as $key => $arr) {
169
+ $str .= $this->getTitleStr($key, $arr);
170
+ }
171
+ return $str;
172
+ }
173
+
174
+ // Gets titles xml or html
175
+ public function getTitleStr ($title, &$arr) {
176
+ if ($xml = $this->$title ? $this->$title : '') {
 
177
  if (in_array($title, array('categories', 'tags', 'authors'))) {
178
+ $xml = $this->stringifyCatsTagsAuths($xml, $title);
 
179
  }
180
  if ($xml) {
181
+ $xml = $this->xml ? $xml : '<div class="header"><p class="header-txt">' . (($arr['title'] === 'Authors' && count($this->authors) <= 2) ? 'Author' : $arr['title']) . '</p><p class="header-date">' . $this->lastUpdated . '</p></div><ul>' . $xml . '</ul>';
182
+ $this->$title = null;
183
  }
184
  }
185
  return $xml;
186
  }
187
+
188
+ // Gets categories, tags and author links
189
+ public function stringifyCatsTagsAuths ($content, $title) {
190
+ $xml = '';
191
+ if ($content) {
192
  foreach ($content as $id => $date) {
193
+ if ($date) {
194
+ switch ($title) {
195
  case 'tags': $link = esc_url(get_tag_link($id)); break;
196
  case 'categories': $link = esc_url(get_category_link($id)); break;
197
  default: $link = esc_url(get_author_posts_url($id)); // Authors
198
+ }
199
  if (!$this->isBlockedUrl($link)) {
200
  $xml .= $this->getXml($link, $date);
201
  }
202
  }
203
  }
204
  }
205
+ return $xml;
206
+ }
207
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
simpleWpMapOptions.php CHANGED
@@ -1,131 +1,153 @@
1
- <?php if (!defined( 'ABSPATH' )) { die(); }
2
 
3
  /*
4
  * Class that handles all admin settings
5
  */
 
6
  class SimpleWpMapOptions {
7
  private $posted = '';
8
  private $error = '';
9
  private $cantDl = false;
10
- private $homeUrl;
11
-
12
- // Constructor: sets homeUrl with trailing slash
13
- public function __construct () {
14
- $this->homeUrl = esc_url(get_home_url() . (substr(get_home_url(), -1) === '/' ? '' : '/'));
15
- }
16
-
17
- // returns form submit url for the plugin directory
 
18
  public function getSubmitUrl () {
19
  return 'options-general.php?page=simpleWpSitemapSettings';
20
  }
21
-
22
- // Returns a sitemap url
23
- public function sitemapUrl ($format) {
24
- return sprintf('%ssitemap.%s', $this->homeUrl, $format);
25
- }
26
-
 
27
  public function pluginUrl () {
28
  return plugins_url() . '/simple-wp-sitemap/';
29
  }
30
-
31
- // Updates the settings/options
32
- public function setOptions ($otherUrls, $blockUrls, $attrLink, $categories, $tags, $authors, $orderArray) {
33
- @date_default_timezone_set(get_option('timezone_string'));
34
- update_option('simple_wp_other_urls', $this->addUrls($otherUrls, get_option('simple_wp_other_urls')));
35
- update_option('simple_wp_block_urls', $this->addUrls($blockUrls));
36
- update_option('simple_wp_attr_link', $attrLink);
37
- update_option('simple_wp_disp_categories', $categories);
38
- update_option('simple_wp_disp_tags', $tags);
39
- update_option('simple_wp_disp_authors', $authors);
40
-
41
- if ($this->checkOrder($orderArray)) {
42
- asort($orderArray); // sort the array here
43
- update_option('simple_wp_disp_sitemap_order', $orderArray);
44
- }
45
- }
46
-
47
- // Returns the options as strings to be displayed in textareas, checkbox values and orderarray (to do: refactor this messy function)
48
- public function getOptions ($val) {
49
- if (preg_match("/^simple_wp_(other_urls|block_urls)$/", $val)) {
50
- $val = get_option($val);
51
- } elseif (preg_match("/^simple_wp_(attr_link|disp_categories|disp_tags|disp_authors)$/", $val)) {
52
- return get_option($val) ? 'checked' : ''; // return checkbox checked values right here and dont bother with the loop below
53
- } elseif ($val === 'simple_wp_disp_sitemap_order' && ($orderArray = get_option($val))) {
54
- return $this->checkOrder($orderArray);
55
- } else {
56
- $val = null;
57
- }
58
-
59
- $str = '';
60
- if (!$this->isNullOrWhiteSpace($val)) {
61
- foreach ($val as $sArr) {
62
- $str .= $this->sanitizeUrl($sArr['url']) . "\n";
63
- }
64
- }
65
- return trim($str);
66
- }
67
-
68
- // Checks if string/array is empty
69
- private function isNullOrWhiteSpace ($word) {
70
- if (is_array($word)) {
71
- return false;
72
- }
73
- return ($word === null || $word === false || trim($word) === '');
74
- }
75
-
76
- // Sanitizes urls with esc_url and trim
77
- private function sanitizeUrl ($url) {
78
- return esc_url(trim($url));
79
- }
80
-
81
- // Checks if orderArray has valid numbers (from 1 to 7)
82
- private function checkOrder ($numbers) {
83
- if (is_array($numbers)) {
84
- foreach ($numbers as $key => $num) {
85
- if (!preg_match("/^[1-7]{1}$/", $num)) {
86
- return false;
87
- }
88
- }
89
- return $numbers;
90
- }
91
- return false;
92
- }
93
-
94
- // Adds new urls to the sitemaps
95
- private function addUrls ($urls, $oldUrls=null) {
96
- $arr = array();
97
-
98
- if (!$this->isNullOrWhiteSpace($urls)) {
99
- $urls = explode("\n", $urls);
100
-
101
- foreach ($urls as $u){
102
- if (!$this->isNullOrWhiteSpace($u)) {
103
- $u = $this->sanitizeUrl($u);
104
- $b = false;
105
- if ($oldUrls && is_array($oldUrls)) {
106
- foreach ($oldUrls as $o) {
107
- if ($o['url'] === $u && !$b) {
108
- $arr[] = $o;
109
- $b = true;
110
- }
111
- }
112
- }
113
- if (!$b && strlen($u) < 500) {
114
- $arr[] = array('url' => $u, 'date' => time());
115
- }
116
- }
117
- }
118
- }
119
- return !empty($arr) ? $arr : '';
120
- }
121
-
122
- // upgrades the plugin to premium
 
 
 
 
 
 
 
 
 
 
 
 
 
 
123
  public function upgradePlugin ($code) {
124
- $this->posted = esc_html(strip_tags($code));
 
 
 
125
  update_option('simple_wp_premium_code', $this->posted);
126
- $url = 'https://www.webbjocke.com/downloads/update/';
127
-
128
  try {
 
 
 
129
  if (!class_exists('ZipArchive')) {
130
  $this->cantDl = true;
131
  throw new Exception('Your server doesn\'t support ZipArchive');
@@ -138,74 +160,109 @@ class SimpleWpMapOptions {
138
  'code' => $this->posted
139
  )
140
  ));
141
-
142
  if (is_wp_error($res) || $res['response']['code'] !== 200) {
143
  throw new Exception('Could not connect to server. Try again later');
144
  }
145
-
146
  if (!$res['body'] || trim($res['body']) === '' || $res['body'] === 'Invalid Code') {
147
  throw new Exception('Invalid Code');
148
  }
149
-
150
  if ($res['body'] === 'Failed') {
151
- throw new Exception($data . ' to download. Try again later');
152
- }
153
-
154
  $dir = plugin_dir_path(__FILE__);
155
- $file = $dir . 'upload.zip';
156
-
157
  $fp = fopen($file, 'w');
158
  fwrite($fp, $res['body']);
159
  fclose($fp);
160
-
161
- $zip = new ZipArchive();
162
-
163
  if (!file_exists($file)) {
164
  $this->cantDl = true;
165
  throw new Exception('Couldn\'t find the zip file, try again later');
166
- }
167
-
168
- if ($zip->open($dir . 'upload.zip') !== true) {
169
  $this->cantDl = true;
170
  throw new Exception('Could not open file on the filesystem');
171
  }
172
-
173
  if (!$zip->extractTo($dir)) {
174
  $this->cantDl = true;
175
  throw new Exception('Failed to unpack files');
176
  }
177
-
178
  $zip->close();
179
-
180
  unlink($file);
181
-
182
  $this->redirect();
183
-
184
  } catch (Exception $ex) {
185
  $this->error = $ex->getMessage();
186
  }
187
  }
188
-
189
- // get method for posted
190
  public function getPosted () {
191
  return $this->posted;
192
  }
193
-
194
- // get method for error
 
 
 
 
 
195
  public function getError () {
196
  if ($this->error) {
197
- return esc_html($this->error) . ($this->cantDl ? '<p style="black">You might have to manually download and install the upgrade. Do it at <a href="https://www.webbjocke.com/downloads/archive/">webbjocke.com/downloads/archive</a></p>' : '');
198
  }
199
  return '';
200
  }
201
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
202
  public function redirect () { ?>
203
  <h1>Successfully upgraded to Simple Wp Sitemap Premium!</h1>
204
  <p><strong>Get ready!</strong></p>
205
  <p>Redirecting in: <span id="redirectUrl">7</span> seconds</p>
206
  <script>
207
  var p = document.getElementById("redirectUrl"), time = 7;
208
- var inter = setInterval(function(){
209
  p.textContent = --time;
210
  if (time <= 0) {
211
  clearInterval(inter);
@@ -215,4 +272,4 @@ class SimpleWpMapOptions {
215
  </script>
216
  <?php exit;
217
  }
218
- }
1
+ <?php defined('ABSPATH') || exit;
2
 
3
  /*
4
  * Class that handles all admin settings
5
  */
6
+
7
  class SimpleWpMapOptions {
8
  private $posted = '';
9
  private $error = '';
10
  private $cantDl = false;
11
+ private $activePage = '';
12
+ private $homeUrl;
13
+
14
+ // Constructor: sets homeUrl with trailing slash
15
+ public function __construct () {
16
+ $this->homeUrl = $this->sanitizeUrl(get_home_url() . (substr(get_home_url(), -1) === '/' ? '' : '/'));
17
+ }
18
+
19
+ // Returns form submit url for the plugin directory
20
  public function getSubmitUrl () {
21
  return 'options-general.php?page=simpleWpSitemapSettings';
22
  }
23
+
24
+ // Returns a sitemap url
25
+ public function sitemapUrl ($format) {
26
+ return sprintf('%ssitemap.%s', $this->homeUrl, $format);
27
+ }
28
+
29
+ // Get the url to the plugin dir
30
  public function pluginUrl () {
31
  return plugins_url() . '/simple-wp-sitemap/';
32
  }
33
+
34
+ // Returns default order option
35
+ public function getDefaultOrder () {
36
+ return array('home' => ['title' => 'Home', 'i' => 1], 'posts' => ['title' => 'Posts', 'i' => 2], 'pages' => ['title' => 'Pages', 'i' => 3], 'other' => ['title' => 'Other', 'i' => 4], 'categories' => ['title' => 'Categories', 'i' => 5], 'tags' => ['title' => 'Tags', 'i' => 6], 'authors' => ['title' => 'Authors', 'i' => 7]);
37
+ }
38
+
39
+ // Updates the settings/options
40
+ public function setOptions ($otherUrls, $blockUrls, $attrLink, $categories, $tags, $authors, $orderArray, $activePage, $lastUpdated) {
41
+ @date_default_timezone_set(get_option('timezone_string'));
42
+ update_option('simple_wp_other_urls', $this->addUrls($otherUrls, get_option('simple_wp_other_urls')));
43
+ update_option('simple_wp_block_urls', $this->addUrls($blockUrls));
44
+ update_option('simple_wp_attr_link', $attrLink);
45
+ update_option('simple_wp_disp_categories', $categories);
46
+ update_option('simple_wp_disp_tags', $tags);
47
+ update_option('simple_wp_disp_authors', $authors);
48
+ update_option('simple_wp_last_updated', $this->sanitHtml($lastUpdated));
49
+
50
+ if ($this->checkOrder($orderArray) && uasort($orderArray, array($this, 'sortArr'))) { // sort the array here
51
+ update_option('simple_wp_disp_sitemap_order', $orderArray);
52
+ }
53
+
54
+ $this->activePage = $this->sanitHtml($activePage);
55
+ }
56
+
57
+ // Returns the options as strings to be displayed in textareas, checkbox values and orderarray (to do: refactor this messy function)
58
+ public function getOptions ($val) {
59
+ if (preg_match("/^simple_wp_(other_urls|block_urls)$/", $val)) {
60
+ $val = get_option($val);
61
+ } elseif (preg_match("/^simple_wp_(attr_link|disp_categories|disp_tags|disp_authors)$/", $val)) {
62
+ return get_option($val) ? 'checked' : ''; // return checkbox checked values right here and dont bother with the loop below
63
+ } elseif ($val === 'simple_wp_disp_sitemap_order' && ($orderArray = get_option($val))) {
64
+ return $this->checkOrder($orderArray);
65
+ } elseif ($val === 'simple_wp_last_updated') {
66
+ return $this->sanitHtml(get_option($val));
67
+ } else {
68
+ $val = null;
69
+ }
70
+
71
+ $str = '';
72
+ if (!$this->isNullOrWhiteSpace($val)) {
73
+ foreach ($val as $sArr) {
74
+ $str .= $this->sanitizeUrl($sArr['url']) . "\n";
75
+ }
76
+ }
77
+ return trim($str);
78
+ }
79
+
80
+ // Checks if string is empty (or an array: fix)
81
+ public function isNullOrWhiteSpace ($word) {
82
+ if (is_array($word)) {
83
+ return false;
84
+ }
85
+ return ($word === null || $word === false || trim($word) === '');
86
+ }
87
+
88
+ // Sanitizes urls with esc_url and trims
89
+ public function sanitizeUrl ($url) {
90
+ return esc_url(trim($url));
91
+ }
92
+
93
+ // Escapes and trims html
94
+ public function sanitHtml ($html) {
95
+ return stripslashes(esc_html(trim($html)));
96
+ }
97
+
98
+ // Checks if orderArray is valid
99
+ public function checkOrder ($orderArray) {
100
+ if (is_array($orderArray)) {
101
+ foreach ($orderArray as $title => $arr) {
102
+ if (!is_array($arr) || !preg_match("/^[1-7]{1}$/", $arr['i']) || (!($orderArray[$title]['title'] = $this->sanitHtml($arr['title'])))) {
103
+ return false;
104
+ }
105
+ }
106
+ return $orderArray;
107
+ }
108
+ return false;
109
+ }
110
+
111
+ // Adds new urls to the sitemaps
112
+ public function addUrls ($urls, $oldUrls=null) {
113
+ $arr = array();
114
+
115
+ if (!$this->isNullOrWhiteSpace($urls)) {
116
+ $urls = explode("\n", $urls);
117
+
118
+ foreach ($urls as $u){
119
+ if (!$this->isNullOrWhiteSpace($u)) {
120
+ $u = $this->sanitizeUrl($u);
121
+ $b = false;
122
+ if ($oldUrls && is_array($oldUrls)) {
123
+ foreach ($oldUrls as $o) {
124
+ if ($o['url'] === $u && !$b) {
125
+ $arr[] = $o;
126
+ $b = true;
127
+ }
128
+ }
129
+ }
130
+ if (!$b && strlen($u) < 500) {
131
+ $arr[] = array('url' => $u, 'date' => time());
132
+ }
133
+ }
134
+ }
135
+ }
136
+ return !empty($arr) ? $arr : '';
137
+ }
138
+
139
+ // Upgrades the plugin to premium
140
  public function upgradePlugin ($code) {
141
+ $this->posted = $this->sanitHtml(strip_tags($code));
142
+ $this->activePage = 'sitemap-premium';
143
+ $url = 'https://www.webbjocke.com/downloads/update/'; // make sure it's https
144
+
145
  update_option('simple_wp_premium_code', $this->posted);
146
+
 
147
  try {
148
+ if (!$this->posted) {
149
+ throw new Exception('Please enter a code before submitting');
150
+ }
151
  if (!class_exists('ZipArchive')) {
152
  $this->cantDl = true;
153
  throw new Exception('Your server doesn\'t support ZipArchive');
160
  'code' => $this->posted
161
  )
162
  ));
163
+
164
  if (is_wp_error($res) || $res['response']['code'] !== 200) {
165
  throw new Exception('Could not connect to server. Try again later');
166
  }
 
167
  if (!$res['body'] || trim($res['body']) === '' || $res['body'] === 'Invalid Code') {
168
  throw new Exception('Invalid Code');
169
  }
 
170
  if ($res['body'] === 'Failed') {
171
+ throw new Exception('Failed to download. Try again later');
172
+ }
173
+
174
  $dir = plugin_dir_path(__FILE__);
175
+ $file = sprintf('%supload.zip', $dir);
176
+
177
  $fp = fopen($file, 'w');
178
  fwrite($fp, $res['body']);
179
  fclose($fp);
180
+
181
+ $zip = new ZipArchive();
182
+
183
  if (!file_exists($file)) {
184
  $this->cantDl = true;
185
  throw new Exception('Couldn\'t find the zip file, try again later');
186
+ }
187
+ if ($zip->open($file) !== true) {
 
188
  $this->cantDl = true;
189
  throw new Exception('Could not open file on the filesystem');
190
  }
 
191
  if (!$zip->extractTo($dir)) {
192
  $this->cantDl = true;
193
  throw new Exception('Failed to unpack files');
194
  }
195
+
196
  $zip->close();
 
197
  unlink($file);
 
198
  $this->redirect();
199
+
200
  } catch (Exception $ex) {
201
  $this->error = $ex->getMessage();
202
  }
203
  }
204
+
205
+ // Get method for posted
206
  public function getPosted () {
207
  return $this->posted;
208
  }
209
+
210
+ // Get active page in admin menu (returns empty string as default)
211
+ public function getPage () {
212
+ return $this->activePage;
213
+ }
214
+
215
+ // Get method for error text (empty string on default)
216
  public function getError () {
217
  if ($this->error) {
218
+ return $this->sanitHtml($this->error) . ($this->cantDl ? '<p style="black">You might have to manually download and install the upgrade. Do it at <a href="https://www.webbjocke.com/downloads/manual-download/">webbjocke.com/downloads/manual-download</a></p>' : '');
219
  }
220
  return '';
221
  }
222
+
223
+ // Sort function for "uasort"
224
+ public function sortArr ($a, $b) {
225
+ return $a['i'] - $b['i'];
226
+ }
227
+
228
+ // Deletes old or current sitemap files and updates order options
229
+ public function migrateFromOld () {
230
+ if (function_exists('get_home_path')) {
231
+ $path = sprintf('%s%ssitemap.', get_home_path(), (substr(get_home_path(), -1) === '/' ? '' : '/'));
232
+ try {
233
+ foreach (array('xml', 'html') as $file) {
234
+ if (file_exists($path . $file)) {
235
+ unlink($path . $file);
236
+ }
237
+ }
238
+ } catch (Exception $ex) {
239
+ return;
240
+ }
241
+ }
242
+
243
+ if ($order = get_option('simple_wp_disp_sitemap_order')) {
244
+ foreach ($order as $key => $val) {
245
+ if (is_array($val)) { // It's ok
246
+ break;
247
+ }
248
+ $order[lcfirst($key)] = array('title' => $key, 'i' => $val);
249
+ unset($order[$key]);
250
+ }
251
+ } else {
252
+ $order = $this->getDefaultOrder();
253
+ }
254
+ update_option('simple_wp_disp_sitemap_order', $order);
255
+ return $order;
256
+ }
257
+
258
+ // Redirect function on successful upgrade to premium
259
  public function redirect () { ?>
260
  <h1>Successfully upgraded to Simple Wp Sitemap Premium!</h1>
261
  <p><strong>Get ready!</strong></p>
262
  <p>Redirecting in: <span id="redirectUrl">7</span> seconds</p>
263
  <script>
264
  var p = document.getElementById("redirectUrl"), time = 7;
265
+ var inter = setInterval(function () {
266
  p.textContent = --time;
267
  if (time <= 0) {
268
  clearInterval(inter);
272
  </script>
273
  <?php exit;
274
  }
275
+ }