Version Description
(April 18, 2015) = * Added option to specify own display order * Excluded drafts, private and password protected pages * Added some javascript and css to the admin area * Added a noscript tag in admin area * Increased amount of FAQ's * Made sure global post is resetted after loop * Fixed bug that gave error if no timezone was set * Couple other changes done in php and css
Download this release
Release Info
Developer | Webbjocke |
Plugin | Simple Wp Sitemap |
Version | 1.0.7 |
Comparing to | |
See all releases |
Code changes from version 1.0.6 to 1.0.7
- css/html.css +8 -0
- css/simple-wp-sitemap-admin.css +88 -0
- css/xml.css +14 -1
- js/index.php +1 -0
- js/simple-wp-sitemap-admin.js +64 -0
- readme.txt +21 -3
- screenshot-1.png +0 -0
- simple-wp-sitemap.php +65 -17
- simpleWpMapBuilder.php +95 -110
- simpleWpMapOptions.php +26 -5
css/html.css
CHANGED
@@ -68,6 +68,9 @@ ul a, .date{
|
|
68 |
box-sizing: border-box;
|
69 |
}
|
70 |
@media screen and (max-width: 960px){
|
|
|
|
|
|
|
71 |
#wrapper{
|
72 |
padding-left: 0%;
|
73 |
padding-right: 0%;
|
@@ -97,4 +100,9 @@ ul a, .date{
|
|
97 |
#attr{
|
98 |
padding-right: 7px;
|
99 |
}
|
|
|
|
|
|
|
|
|
|
|
100 |
}
|
68 |
box-sizing: border-box;
|
69 |
}
|
70 |
@media screen and (max-width: 960px){
|
71 |
+
body{
|
72 |
+
font-size: 12px;
|
73 |
+
}
|
74 |
#wrapper{
|
75 |
padding-left: 0%;
|
76 |
padding-right: 0%;
|
100 |
#attr{
|
101 |
padding-right: 7px;
|
102 |
}
|
103 |
+
}
|
104 |
+
@media screen and (max-width: 500px){
|
105 |
+
body{
|
106 |
+
font-size: 11px;
|
107 |
+
}
|
108 |
}
|
css/simple-wp-sitemap-admin.css
ADDED
@@ -0,0 +1,88 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
#sitemap-settings{
|
2 |
+
background: #fff;
|
3 |
+
margin: 0;
|
4 |
+
float: left;
|
5 |
+
}
|
6 |
+
#sitemap-settings li{
|
7 |
+
float: left;
|
8 |
+
padding: 10px 0;
|
9 |
+
width: 100px;
|
10 |
+
margin: 0;
|
11 |
+
text-align: center;
|
12 |
+
border: 1px solid #f1f1f1;
|
13 |
+
transition: all 0.3s;
|
14 |
+
}
|
15 |
+
#sitemap-settings li:hover{
|
16 |
+
cursor: pointer;
|
17 |
+
background: #ffffe0;
|
18 |
+
border-color: #c0c0c0 !important;
|
19 |
+
}
|
20 |
+
#sitemap-settings li:active, #sitemap-settings li:focus{
|
21 |
+
border-color: #000 !important;
|
22 |
+
}
|
23 |
+
.sitemap-active{
|
24 |
+
border-color: #c0c0c0 !important;
|
25 |
+
}
|
26 |
+
#sitemap-table-hide, .sitemap-hidden{
|
27 |
+
display: none;
|
28 |
+
}
|
29 |
+
#sitemap-table-show, .sitemap-shown{
|
30 |
+
display: block;
|
31 |
+
}
|
32 |
+
#sitemap-defaults{
|
33 |
+
text-decoration: underline;
|
34 |
+
float: left;
|
35 |
+
margin: 0 0 10px 7px;
|
36 |
+
padding: 5px;
|
37 |
+
border: 1px solid transparent;
|
38 |
+
transition: all 0.3s;
|
39 |
+
}
|
40 |
+
#sitemap-defaults:hover{
|
41 |
+
cursor: pointer;
|
42 |
+
background: #ffffe0;
|
43 |
+
border: 1px solid #c0c0c0;
|
44 |
+
}
|
45 |
+
#sitemap-display-order{
|
46 |
+
margin: 0;
|
47 |
+
}
|
48 |
+
#sitemap-display-order li{
|
49 |
+
margin: 0;
|
50 |
+
padding: 8px;
|
51 |
+
max-width: 250px;
|
52 |
+
position: relative;
|
53 |
+
border-top: 1px solid #c0c0c0;
|
54 |
+
border-left: 1px solid #c0c0c0;
|
55 |
+
border-right: 1px solid #c0c0c0;
|
56 |
+
}
|
57 |
+
#sitemap-display-order li:last-child{
|
58 |
+
border-bottom: 1px solid #c0c0c0;
|
59 |
+
}
|
60 |
+
.sitemap-down{
|
61 |
+
position: absolute;
|
62 |
+
right: 45px;
|
63 |
+
top: 6px;
|
64 |
+
border-left: 18px solid transparent;
|
65 |
+
border-right: 18px solid transparent;
|
66 |
+
border-top: 25px solid #d3d3d3;
|
67 |
+
transition: border-color 0.3s;
|
68 |
+
}
|
69 |
+
.sitemap-down:last-child{
|
70 |
+
border-color: blue;
|
71 |
+
}
|
72 |
+
.sitemap-up{
|
73 |
+
position: absolute;
|
74 |
+
right: 5px;
|
75 |
+
top: 5px;
|
76 |
+
border-left: 18px solid transparent;
|
77 |
+
border-right: 18px solid transparent;
|
78 |
+
border-bottom: 25px solid #d3d3d3;
|
79 |
+
transition: border-color 0.3s;
|
80 |
+
}
|
81 |
+
.sitemap-down:hover{
|
82 |
+
cursor: pointer;
|
83 |
+
border-top-color: #ff0000;
|
84 |
+
}
|
85 |
+
.sitemap-up:hover{
|
86 |
+
cursor: pointer;
|
87 |
+
border-bottom-color: #008000;
|
88 |
+
}
|
css/xml.css
CHANGED
@@ -3,12 +3,12 @@ urlset{
|
|
3 |
max-width: 1080px;
|
4 |
margin: 10px auto;
|
5 |
font-family: "Lucida Sans Unicode", "Lucida Grande", sans-serif;
|
|
|
6 |
}
|
7 |
url{
|
8 |
display: block;
|
9 |
overflow: auto;
|
10 |
padding: 5px;
|
11 |
-
font-size: 13px;
|
12 |
word-wrap: break-word;
|
13 |
}
|
14 |
url:nth-child(2n+1){
|
@@ -22,6 +22,19 @@ lastmod{
|
|
22 |
float: right;
|
23 |
}
|
24 |
@media screen and (max-width: 960px){
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
25 |
loc, lastmod{
|
26 |
max-width: 100%;
|
27 |
width: 100%;
|
3 |
max-width: 1080px;
|
4 |
margin: 10px auto;
|
5 |
font-family: "Lucida Sans Unicode", "Lucida Grande", sans-serif;
|
6 |
+
font-size: 13px;
|
7 |
}
|
8 |
url{
|
9 |
display: block;
|
10 |
overflow: auto;
|
11 |
padding: 5px;
|
|
|
12 |
word-wrap: break-word;
|
13 |
}
|
14 |
url:nth-child(2n+1){
|
22 |
float: right;
|
23 |
}
|
24 |
@media screen and (max-width: 960px){
|
25 |
+
urlset{
|
26 |
+
font-size: 12px;
|
27 |
+
}
|
28 |
+
loc, lastmod{
|
29 |
+
max-width: 100%;
|
30 |
+
width: 100%;
|
31 |
+
float: left;
|
32 |
+
}
|
33 |
+
}
|
34 |
+
@media screen and (max-device-width: 500px){
|
35 |
+
urlset{
|
36 |
+
zoom: 2;
|
37 |
+
}
|
38 |
loc, lastmod{
|
39 |
max-width: 100%;
|
40 |
width: 100%;
|
js/index.php
ADDED
@@ -0,0 +1 @@
|
|
|
1 |
+
<?php // silence is golden
|
js/simple-wp-sitemap-admin.js
ADDED
@@ -0,0 +1,64 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
(function ($) {
|
2 |
+
"use strict";
|
3 |
+
var SitemapAdmin = function () {
|
4 |
+
this.run = function (config) {
|
5 |
+
var that = this;
|
6 |
+
this.c = config;
|
7 |
+
|
8 |
+
this.c.normal.on('click', function () { that.changeState($(this), that.c.advanced, that.c.tableNormal, that.c.tableAdvanced); });
|
9 |
+
this.c.advanced.on('click', function () { that.changeState($(this), that.c.normal, that.c.tableAdvanced, that.c.tableNormal); });
|
10 |
+
this.c.ul.on('click', function (e) { that.changeOrder($(e.target)); });
|
11 |
+
this.c.defaults.on('click', function () { that.restoreDefaults(); });
|
12 |
+
this.c.form.on('submit', function (e) { that.submitForm(e); });
|
13 |
+
};
|
14 |
+
|
15 |
+
this.changeState = function (btn, otherBtn, table, otherTable) {
|
16 |
+
btn.attr('class', 'sitemap-active');
|
17 |
+
otherBtn.attr('class', '');
|
18 |
+
table.attr('id', 'sitemap-table-show');
|
19 |
+
otherTable.attr('id', 'sitemap-table-hide');
|
20 |
+
};
|
21 |
+
|
22 |
+
this.changeOrder = function (node) {
|
23 |
+
var li = node.parent();
|
24 |
+
|
25 |
+
if (node.attr('class') === 'sitemap-up' && li.prev()[0]) {
|
26 |
+
li.prev().before(li.clone());
|
27 |
+
li.remove();
|
28 |
+
}
|
29 |
+
else if (node.attr('class') === 'sitemap-down' && li.next()[0]) {
|
30 |
+
li.next().after(li.clone());
|
31 |
+
li.remove();
|
32 |
+
}
|
33 |
+
}
|
34 |
+
|
35 |
+
this.submitForm = function (e) {
|
36 |
+
var inputs = this.c.ul.find('input');
|
37 |
+
|
38 |
+
$.each(inputs, function (i) {
|
39 |
+
inputs.eq(i).val(i + 1);
|
40 |
+
});
|
41 |
+
};
|
42 |
+
|
43 |
+
this.restoreDefaults = function () {
|
44 |
+
var sections = ['Home', 'Posts', 'Pages', 'Other', 'Categories', 'Tags', 'Authors'];
|
45 |
+
|
46 |
+
this.c.ul.empty();
|
47 |
+
|
48 |
+
for (var i = 0; i < sections.length; i++) {
|
49 |
+
this.c.ul.append('<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>');
|
50 |
+
}
|
51 |
+
};
|
52 |
+
};
|
53 |
+
|
54 |
+
var sitemap = new SitemapAdmin();
|
55 |
+
sitemap.run({
|
56 |
+
normal: $('#sitemap-normal'),
|
57 |
+
ul: $('#sitemap-display-order'),
|
58 |
+
advanced: $('#sitemap-advanced'),
|
59 |
+
defaults: $('#sitemap-defaults'),
|
60 |
+
form: $('#simple-wp-sitemap-form'),
|
61 |
+
tableNormal: $('#sitemap-table-show'),
|
62 |
+
tableAdvanced: $('#sitemap-table-hide')
|
63 |
+
});
|
64 |
+
})(jQuery);
|
readme.txt
CHANGED
@@ -4,8 +4,8 @@ License: GPLv3
|
|
4 |
License URI: http://www.gnu.org/licenses/gpl.html
|
5 |
Tags: sitemap, google sitemap, xml, simple sitemap, html, xml sitemap, html sitemap, seo, seo sitemap
|
6 |
Requires at least: 4.0
|
7 |
-
Tested up to: 4.
|
8 |
-
Stable tag: 1.0.
|
9 |
|
10 |
An easy, fast and secure plugin that adds both an xml and an html sitemap to your site, which updates and maintains themselves so you dont have to!
|
11 |
|
@@ -49,6 +49,14 @@ Yes sir, it does.
|
|
49 |
|
50 |
Sorry no, not at the moment it isn't.
|
51 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
52 |
= Are the sitemaps created "on the fly" dynamically or as static files? =
|
53 |
|
54 |
As static files. They get updated everytime you create, edit or delete a post or page. And also when changes are made in the admin area.
|
@@ -65,10 +73,20 @@ When you deactivate the plugin they get removed automatically.
|
|
65 |
|
66 |
== Changelog ==
|
67 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
68 |
= 1.0.6 (April 7, 2015) =
|
69 |
* Made the plugin more user friendly
|
70 |
* Added links to the sitemaps from the admin area
|
71 |
-
* Added FAQ's
|
72 |
* Formatted the code a bit better
|
73 |
|
74 |
= 1.0.5 (March 26, 2015) =
|
4 |
License URI: http://www.gnu.org/licenses/gpl.html
|
5 |
Tags: sitemap, google sitemap, xml, simple sitemap, html, xml sitemap, html sitemap, seo, seo sitemap
|
6 |
Requires at least: 4.0
|
7 |
+
Tested up to: 4.2
|
8 |
+
Stable tag: 1.0.7
|
9 |
|
10 |
An easy, fast and secure plugin that adds both an xml and an html sitemap to your site, which updates and maintains themselves so you dont have to!
|
11 |
|
49 |
|
50 |
Sorry no, not at the moment it isn't.
|
51 |
|
52 |
+
= Which one of the sitemaps should I submit to google and to other search engines? =
|
53 |
+
|
54 |
+
The sitemap.xml one.
|
55 |
+
|
56 |
+
= Do I actually have to go ahead and submit the sitemaps anywhere? =
|
57 |
+
|
58 |
+
Not really, search engines usually finds them automatically when they visit your site. However if you have webmaster tools at google or bing etc, that could be a good place to do it to get statistics over indexed pages and stuff.
|
59 |
+
|
60 |
= Are the sitemaps created "on the fly" dynamically or as static files? =
|
61 |
|
62 |
As static files. They get updated everytime you create, edit or delete a post or page. And also when changes are made in the admin area.
|
73 |
|
74 |
== Changelog ==
|
75 |
|
76 |
+
= 1.0.7 (April 18, 2015) =
|
77 |
+
* Added option to specify own display order
|
78 |
+
* Excluded drafts, private and password protected pages
|
79 |
+
* Added some javascript and css to the admin area
|
80 |
+
* Added a noscript tag in admin area
|
81 |
+
* Increased amount of FAQ's
|
82 |
+
* Made sure global post is resetted after loop
|
83 |
+
* Fixed bug that gave error if no timezone was set
|
84 |
+
* Couple other changes done in php and css
|
85 |
+
|
86 |
= 1.0.6 (April 7, 2015) =
|
87 |
* Made the plugin more user friendly
|
88 |
* Added links to the sitemaps from the admin area
|
89 |
+
* Added FAQ's
|
90 |
* Formatted the code a bit better
|
91 |
|
92 |
= 1.0.5 (March 26, 2015) =
|
screenshot-1.png
CHANGED
Binary file
|
simple-wp-sitemap.php
CHANGED
@@ -4,7 +4,7 @@
|
|
4 |
* Plugin Name: Simple Wp Sitemap
|
5 |
* Plugin URI: http://www.webbjocke.com/simple-wp-sitemap/
|
6 |
* Description: An easy, fast and secure plugin that adds both an xml and an html sitemap to your site, which updates and maintains themselves so you dont have to!
|
7 |
-
* Version: 1.0.
|
8 |
* Author: Webbjocke
|
9 |
* Author URI: http://www.webbjocke.com/
|
10 |
* License: GPLv3
|
@@ -32,13 +32,14 @@ class SimpleWpSitemap {
|
|
32 |
return array_merge($links, $theLink);
|
33 |
}
|
34 |
|
35 |
-
// Sets the menu option for admins
|
36 |
public static function sitemapAdminSetup() {
|
37 |
add_options_page('Simple Wp Sitemap', 'Simple Wp Sitemap', 'administrator', 'simpleWpSitemapSettings', array('SimpleWpSitemap', 'sitemapAdminArea'));
|
|
|
38 |
add_action('admin_init', array('SimpleWpSitemap', 'sitemapAdminInit'));
|
39 |
}
|
40 |
|
41 |
-
//
|
42 |
public static function sitemapAdminInit() {
|
43 |
register_setting('simple_wp-sitemap-group', 'simple_wp_other_urls');
|
44 |
register_setting('simple_wp-sitemap-group', 'simple_wp_block_urls');
|
@@ -46,6 +47,16 @@ class SimpleWpSitemap {
|
|
46 |
register_setting('simple_wp-sitemap-group', 'simple_wp_disp_categories');
|
47 |
register_setting('simple_wp-sitemap-group', 'simple_wp_disp_tags');
|
48 |
register_setting('simple_wp-sitemap-group', 'simple_wp_disp_authors');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
49 |
}
|
50 |
|
51 |
// Interface for settings page, also handles initial post request when settings are changed
|
@@ -53,14 +64,15 @@ class SimpleWpSitemap {
|
|
53 |
require_once('simpleWpMapOptions.php');
|
54 |
$options = new SimpleWpMapOptions();
|
55 |
|
56 |
-
if (isset($_POST['simple_wp_other_urls'], $_POST['simple_wp_block_urls'])) {
|
57 |
-
|
|
|
58 |
self::updateSitemaps();
|
59 |
} ?>
|
60 |
|
61 |
<div class="wrap">
|
62 |
|
63 |
-
<
|
64 |
|
65 |
<p>Your two sitemaps have been created and are active! Here you can change and customize them</p>
|
66 |
|
@@ -71,34 +83,70 @@ class SimpleWpSitemap {
|
|
71 |
<li>Html sitemap: <a href="<?php echo $options->sitemapUrl('html'); ?>"><?php echo $options->sitemapUrl('html'); ?></a></li>
|
72 |
</ul>
|
73 |
|
74 |
-
<
|
|
|
|
|
75 |
|
76 |
<?php settings_fields('simple_wp-sitemap-group'); ?>
|
77 |
|
78 |
-
<
|
|
|
|
|
|
|
|
|
|
|
79 |
|
80 |
<tr><td><strong>Add pages</strong></td></tr>
|
81 |
-
<tr><td>Add pages to the sitemaps in addition to your
|
82 |
<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>
|
83 |
|
84 |
<tr><td><strong>Block pages</strong></td></tr>
|
85 |
-
<tr><td>Add pages you
|
86 |
<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>
|
87 |
|
88 |
<tr><td><strong>Extra sitemap includes</strong></td></tr>
|
89 |
<tr><td>Check if you want to include categories, tags and/or author pages in the sitemaps.</td></tr>
|
90 |
-
<tr><td><input type="checkbox" name="simple_wp_disp_categories" id="simple_wp_cat" <?php echo $options->getOptions('simple_wp_disp_categories');
|
91 |
-
<tr><td><input type="checkbox" name="simple_wp_disp_tags" id="simple_wp_tags" <?php echo $options->getOptions('simple_wp_disp_tags');
|
92 |
-
<tr><td><input type="checkbox" name="simple_wp_disp_authors" id="simple_wp_authors" <?php echo $options->getOptions('simple_wp_disp_authors');
|
93 |
-
|
94 |
<tr><td><strong>Like the plugin?</strong></td></tr>
|
95 |
-
<tr><td>Show your support by rating the plugin at wordpress.org, or
|
96 |
-
<tr><td><input type="checkbox" name="simple_wp_attr_link" id="simple_wp_check" <?php echo $options->getOptions('simple_wp_attr_link');
|
97 |
|
98 |
</table>
|
99 |
|
100 |
-
<
|
|
|
|
|
|
|
|
|
101 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
102 |
</form>
|
103 |
|
104 |
</div>
|
4 |
* Plugin Name: Simple Wp Sitemap
|
5 |
* Plugin URI: http://www.webbjocke.com/simple-wp-sitemap/
|
6 |
* Description: An easy, fast and secure plugin that adds both an xml and an html sitemap to your site, which updates and maintains themselves so you dont have to!
|
7 |
+
* Version: 1.0.7
|
8 |
* Author: Webbjocke
|
9 |
* Author URI: http://www.webbjocke.com/
|
10 |
* License: GPLv3
|
32 |
return array_merge($links, $theLink);
|
33 |
}
|
34 |
|
35 |
+
// Sets the menu option for admins and enqueues scripts n styles
|
36 |
public static function sitemapAdminSetup() {
|
37 |
add_options_page('Simple Wp Sitemap', 'Simple Wp Sitemap', 'administrator', 'simpleWpSitemapSettings', array('SimpleWpSitemap', 'sitemapAdminArea'));
|
38 |
+
add_action('admin_enqueue_scripts', array('simpleWpSitemap', 'sitemapScriptsAndStyles'));
|
39 |
add_action('admin_init', array('SimpleWpSitemap', 'sitemapAdminInit'));
|
40 |
}
|
41 |
|
42 |
+
// Register settings on admin_init
|
43 |
public static function sitemapAdminInit() {
|
44 |
register_setting('simple_wp-sitemap-group', 'simple_wp_other_urls');
|
45 |
register_setting('simple_wp-sitemap-group', 'simple_wp_block_urls');
|
47 |
register_setting('simple_wp-sitemap-group', 'simple_wp_disp_categories');
|
48 |
register_setting('simple_wp-sitemap-group', 'simple_wp_disp_tags');
|
49 |
register_setting('simple_wp-sitemap-group', 'simple_wp_disp_authors');
|
50 |
+
register_setting('simple_wp-sitemap-group', 'simple_wp_disp_sitemap_order');
|
51 |
+
}
|
52 |
+
|
53 |
+
// Add custom scripts and styles to the plugins customization page in admin area
|
54 |
+
public static function sitemapScriptsAndStyles($page) {
|
55 |
+
if ($page !== 'settings_page_simpleWpSitemapSettings') {
|
56 |
+
return;
|
57 |
+
}
|
58 |
+
wp_enqueue_style('simple-wp-sitemap-admin-css', plugin_dir_url( __FILE__ ) . '/css/simple-wp-sitemap-admin.css');
|
59 |
+
wp_enqueue_script('simple-wp-sitemap-admin-js', plugin_dir_url( __FILE__ ) . '/js/simple-wp-sitemap-admin.js', array('jquery'), false, true);
|
60 |
}
|
61 |
|
62 |
// Interface for settings page, also handles initial post request when settings are changed
|
64 |
require_once('simpleWpMapOptions.php');
|
65 |
$options = new SimpleWpMapOptions();
|
66 |
|
67 |
+
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'])) {
|
68 |
+
|
69 |
+
$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']));
|
70 |
self::updateSitemaps();
|
71 |
} ?>
|
72 |
|
73 |
<div class="wrap">
|
74 |
|
75 |
+
<h2>Simple Wp Sitemap settings</h2>
|
76 |
|
77 |
<p>Your two sitemaps have been created and are active! Here you can change and customize them</p>
|
78 |
|
83 |
<li>Html sitemap: <a href="<?php echo $options->sitemapUrl('html'); ?>"><?php echo $options->sitemapUrl('html'); ?></a></li>
|
84 |
</ul>
|
85 |
|
86 |
+
<noscript>(Enable javascript for order options)</noscript>
|
87 |
+
|
88 |
+
<form method="post" action="options-general.php?page=simpleWpSitemapSettings" id="simple-wp-sitemap-form">
|
89 |
|
90 |
<?php settings_fields('simple_wp-sitemap-group'); ?>
|
91 |
|
92 |
+
<ul id="sitemap-settings">
|
93 |
+
<li id="sitemap-normal" class="sitemap-active">General</li>
|
94 |
+
<li id="sitemap-advanced">Order</li>
|
95 |
+
</ul>
|
96 |
+
|
97 |
+
<table id="sitemap-table-show" class="widefat form-table">
|
98 |
|
99 |
<tr><td><strong>Add pages</strong></td></tr>
|
100 |
+
<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>
|
101 |
<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>
|
102 |
|
103 |
<tr><td><strong>Block pages</strong></td></tr>
|
104 |
+
<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>
|
105 |
<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>
|
106 |
|
107 |
<tr><td><strong>Extra sitemap includes</strong></td></tr>
|
108 |
<tr><td>Check if you want to include categories, tags and/or author pages in the sitemaps.</td></tr>
|
109 |
+
<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>
|
110 |
+
<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>
|
111 |
+
<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>
|
112 |
+
|
113 |
<tr><td><strong>Like the plugin?</strong></td></tr>
|
114 |
+
<tr><td>Show your support by rating the plugin at wordpress.org, or/and by adding an attribution link to the sitemap.html file :)</td></tr>
|
115 |
+
<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>
|
116 |
|
117 |
</table>
|
118 |
|
119 |
+
<table id="sitemap-table-hide" class="widefat form-table">
|
120 |
+
|
121 |
+
<tr><td><strong>Change display order</td></tr>
|
122 |
+
<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>
|
123 |
+
<tr><td>
|
124 |
|
125 |
+
<ul id="sitemap-display-order">
|
126 |
+
|
127 |
+
<?php
|
128 |
+
|
129 |
+
if (!($orderArray = $options->getOptions('simple_wp_disp_sitemap_order'))) {
|
130 |
+
$orderArray = array('Home' => null, 'Posts' => null, 'Pages' => null, 'Other' => null, 'Categories' => null, 'Tags' => null, 'Authors' => null);
|
131 |
+
}
|
132 |
+
$count = 0;
|
133 |
+
|
134 |
+
foreach ($orderArray as $title => $val) {
|
135 |
+
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));
|
136 |
+
}
|
137 |
+
|
138 |
+
?>
|
139 |
+
|
140 |
+
</ul>
|
141 |
+
|
142 |
+
</td></tr>
|
143 |
+
|
144 |
+
<tr><td id="sitemap-defaults" title="Restore the default display order">Restore default order</td></tr>
|
145 |
+
|
146 |
+
</table>
|
147 |
+
|
148 |
+
<p class="submit"><input type="submit" class="button-primary" value="<?php _e('Save Changes'); ?>"></p>
|
149 |
+
|
150 |
</form>
|
151 |
|
152 |
</div>
|
simpleWpMapBuilder.php
CHANGED
@@ -10,9 +10,13 @@ class SimpleWpMapBuilder {
|
|
10 |
private $url;
|
11 |
private $homeUrl;
|
12 |
private $blockedUrls;
|
|
|
|
|
|
|
13 |
private $categories;
|
14 |
private $tags;
|
15 |
private $authors;
|
|
|
16 |
|
17 |
// Constructor, the only public function this class has
|
18 |
public function __construct($command) {
|
@@ -29,10 +33,14 @@ class SimpleWpMapBuilder {
|
|
29 |
}
|
30 |
|
31 |
// Generates the maps
|
32 |
-
private function generateSitemaps() {
|
33 |
-
$this->categories = (get_option('simple_wp_disp_categories') ? array(0 => 0) :
|
34 |
-
$this->tags = (get_option('simple_wp_disp_tags') ? array(0 => 0) :
|
35 |
-
$this->authors = (get_option('simple_wp_disp_authors') ? array(0 => 0) :
|
|
|
|
|
|
|
|
|
36 |
|
37 |
$this->setUpBlockedUrls();
|
38 |
$this->getContent();
|
@@ -47,7 +55,7 @@ class SimpleWpMapBuilder {
|
|
47 |
$this->deleteFile('html');
|
48 |
}
|
49 |
|
50 |
-
// Returns other urls
|
51 |
private function getOtherPages() {
|
52 |
$html = '';
|
53 |
$xml = '';
|
@@ -100,18 +108,18 @@ class SimpleWpMapBuilder {
|
|
100 |
return "\t<div class=\"header\">\n\t\t<p class=\"header-txt\">$name:</p>\n\t\t<p class=\"header-date\">Last modified:</p>\n\t</div>\n";
|
101 |
}
|
102 |
|
103 |
-
// Creates the actual sitemaps content, and querys the database
|
104 |
private function getContent() {
|
105 |
-
$q = new WP_Query('post_type
|
106 |
$name = get_bloginfo('name');
|
107 |
-
$xml = sprintf("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<?xml-stylesheet type=\"text/css\" href=\"%s/css/xml.css\"?>\n<urlset xmlns
|
108 |
-
$html = sprintf("<!doctype html>\n<html>\n<head>\n\t<meta charset=\"utf-8\">\n\t<meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">\n\t<title>%s Html Sitemap</title>\n\t<link rel=\"stylesheet\" href=\"%s/css/html.css\">\n</head>\n<body>\n<div id=\"wrapper\">\n\n\t<h1>%s Html Sitemap</h1>\n\n
|
109 |
-
|
110 |
-
$
|
111 |
-
$
|
112 |
|
113 |
if ($q->have_posts()) {
|
114 |
-
while ($q->have_posts()) {
|
115 |
$q->the_post();
|
116 |
|
117 |
$link = esc_url(get_permalink());
|
@@ -119,136 +127,116 @@ class SimpleWpMapBuilder {
|
|
119 |
|
120 |
$this->getCategoriesTagsAndAuthor($date);
|
121 |
|
122 |
-
if (!$this->isBlockedUrl($link)) {
|
123 |
-
if ($link === $this->homeUrl) {
|
124 |
-
$xml
|
125 |
-
$html .= $this->getHtml($link, $date);
|
126 |
-
$homePage = true;
|
127 |
}
|
128 |
elseif ('page' === get_post_type()) {
|
129 |
-
$pages['xml'] .= $this->getXml($link, $date);
|
130 |
-
$pages['html'] .= $this->getHtml($link, $date);
|
131 |
}
|
132 |
else { // posts (also all custom post types are added here)
|
133 |
-
$posts['xml'] .= $this->getXml($link, $date);
|
134 |
-
$posts['html'] .= $this->getHtml($link, $date);
|
135 |
}
|
136 |
}
|
137 |
}
|
138 |
}
|
139 |
|
140 |
-
$
|
141 |
-
|
142 |
-
$this->xml = sprintf("%s%s</urlset>", $xml, $localArr['xml']);
|
143 |
-
$this->html = sprintf("%s%s%s</div>\n</body>\n</html>", $html, $localArr['html'], $this->attributionLink());
|
144 |
wp_reset_postdata();
|
145 |
-
|
146 |
-
|
147 |
-
// Displays attribution link if admin has checked the checkbox
|
148 |
-
private function attributionLink() {
|
149 |
-
if (get_option('simple_wp_attr_link')) {
|
150 |
-
return "\t<p id=\"attr\">Generated by: <a href=\"http://www.webbjocke.com/simple-wp-sitemap/\">Simple Wp Sitemap</a></p>\n";
|
151 |
-
}
|
152 |
-
return '';
|
153 |
}
|
154 |
|
155 |
// Gets a posts categories, tags and author, and compares for last modified date
|
156 |
private function getCategoriesTagsAndAuthor($date) {
|
157 |
-
if ($this->categories) {
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
$this->categories[$id] = $date;
|
163 |
-
}
|
164 |
}
|
165 |
}
|
166 |
}
|
167 |
-
if ($this->tags) {
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
$this->tags[$id] = $date;
|
173 |
-
}
|
174 |
}
|
175 |
}
|
176 |
}
|
177 |
-
if ($this->authors) {
|
178 |
-
if ($id
|
179 |
-
|
180 |
-
$this->authors[$id] = $date;
|
181 |
-
}
|
182 |
}
|
183 |
}
|
184 |
}
|
185 |
|
186 |
// Merges the arrays with post data into strings and gets user submitted pages, categories, tags and author pages
|
187 |
-
private function mergeArraysAndGetOtherPages(
|
188 |
$xml = '';
|
189 |
-
$html = '';
|
|
|
190 |
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
199 |
}
|
200 |
|
201 |
-
|
202 |
-
|
203 |
-
|
|
|
|
|
|
|
|
|
|
|
204 |
}
|
205 |
-
|
206 |
-
|
207 |
-
|
|
|
|
|
|
|
|
|
208 |
}
|
209 |
|
210 |
-
|
211 |
-
|
212 |
-
$
|
213 |
-
$
|
214 |
}
|
215 |
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
$xml .= $locArr['xml'];
|
224 |
-
$html .= $locArr['html'];
|
225 |
-
}
|
226 |
-
if ($this->authors) {
|
227 |
-
$locArr = $this->stringifyCatsTagsAuths(count($this->authors) > 2 ? 'Authors' : 'Author');
|
228 |
-
$xml .= $locArr['xml'];
|
229 |
-
$html .= $locArr['html'];
|
230 |
-
}
|
231 |
|
232 |
-
return
|
233 |
}
|
234 |
|
235 |
// Returns category, tag and author links as ready xml and html strings
|
236 |
-
private function stringifyCatsTagsAuths($type) {
|
237 |
-
$html =
|
238 |
$xml = '';
|
239 |
|
240 |
-
|
241 |
-
case 'Tags':
|
242 |
-
$arr = $this->tags;
|
243 |
-
break;
|
244 |
-
case 'Categories':
|
245 |
-
$arr = $this->categories;
|
246 |
-
break;
|
247 |
-
default: // 'Author'
|
248 |
-
$arr = $this->authors;
|
249 |
-
}
|
250 |
-
|
251 |
-
foreach ($arr as $id => $date) {
|
252 |
if ($date) {
|
253 |
$link = esc_url($this->getLink($id, $type));
|
254 |
if (!$this->isBlockedUrl($link)) {
|
@@ -257,18 +245,15 @@ class SimpleWpMapBuilder {
|
|
257 |
}
|
258 |
}
|
259 |
}
|
260 |
-
return array('xml' => $xml, 'html' => $html
|
261 |
}
|
262 |
|
263 |
// Returns either a category, tag or an author link
|
264 |
private function getLink($id, $type) {
|
265 |
switch ($type) {
|
266 |
-
case 'Tags':
|
267 |
-
|
268 |
-
|
269 |
-
return get_category_link($id);
|
270 |
-
default: // 'Author'
|
271 |
-
return get_author_posts_url($id);
|
272 |
}
|
273 |
}
|
274 |
|
10 |
private $url;
|
11 |
private $homeUrl;
|
12 |
private $blockedUrls;
|
13 |
+
private $home;
|
14 |
+
private $posts;
|
15 |
+
private $pages;
|
16 |
private $categories;
|
17 |
private $tags;
|
18 |
private $authors;
|
19 |
+
private $order;
|
20 |
|
21 |
// Constructor, the only public function this class has
|
22 |
public function __construct($command) {
|
33 |
}
|
34 |
|
35 |
// Generates the maps
|
36 |
+
private function generateSitemaps() {
|
37 |
+
$this->categories = (get_option('simple_wp_disp_categories') ? array(0 => 0) : false);
|
38 |
+
$this->tags = (get_option('simple_wp_disp_tags') ? array(0 => 0) : false);
|
39 |
+
$this->authors = (get_option('simple_wp_disp_authors') ? array(0 => 0) : false);
|
40 |
+
$this->order = get_option('simple_wp_disp_sitemap_order');
|
41 |
+
$this->posts = array('xml' => '', 'html' => '');
|
42 |
+
$this->pages = array('xml' => '', 'html' => '');
|
43 |
+
$this->home = null;
|
44 |
|
45 |
$this->setUpBlockedUrls();
|
46 |
$this->getContent();
|
55 |
$this->deleteFile('html');
|
56 |
}
|
57 |
|
58 |
+
// Returns other urls user has submitted
|
59 |
private function getOtherPages() {
|
60 |
$html = '';
|
61 |
$xml = '';
|
108 |
return "\t<div class=\"header\">\n\t\t<p class=\"header-txt\">$name:</p>\n\t\t<p class=\"header-date\">Last modified:</p>\n\t</div>\n";
|
109 |
}
|
110 |
|
111 |
+
// Creates the actual sitemaps content, and querys the database. Might be long strings in one line.. I have a big screen
|
112 |
private function getContent() {
|
113 |
+
$q = new WP_Query(array('post_type' => 'any', 'post_status' => 'publish', 'posts_per_page' => -1, 'has_password' => false));
|
114 |
$name = get_bloginfo('name');
|
115 |
+
$this->xml = sprintf("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<?xml-stylesheet type=\"text/css\" href=\"%s/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->url);
|
116 |
+
$this->html = sprintf("<!doctype html>\n<html>\n<head>\n\t<meta charset=\"utf-8\">\n\t<meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">\n\t<title>%s Html Sitemap</title>\n\t<link rel=\"stylesheet\" href=\"%s/css/html.css\">\n</head>\n<body>\n<div id=\"wrapper\">\n\n\t<h1>%s Html Sitemap</h1>\n\n", $name, $this->url, $name);
|
117 |
+
|
118 |
+
global $post;
|
119 |
+
$localPost = $post;
|
120 |
|
121 |
if ($q->have_posts()) {
|
122 |
+
while ($q->have_posts()) {
|
123 |
$q->the_post();
|
124 |
|
125 |
$link = esc_url(get_permalink());
|
127 |
|
128 |
$this->getCategoriesTagsAndAuthor($date);
|
129 |
|
130 |
+
if (!$this->isBlockedUrl($link)) {
|
131 |
+
if (!$this->home && $link === $this->homeUrl) {
|
132 |
+
$this->home = array('xml' => $this->getXml($link, $date), 'html' => $this->getHtml($link, $date));
|
|
|
|
|
133 |
}
|
134 |
elseif ('page' === get_post_type()) {
|
135 |
+
$this->pages['xml'] .= $this->getXml($link, $date);
|
136 |
+
$this->pages['html'] .= $this->getHtml($link, $date);
|
137 |
}
|
138 |
else { // posts (also all custom post types are added here)
|
139 |
+
$this->posts['xml'] .= $this->getXml($link, $date);
|
140 |
+
$this->posts['html'] .= $this->getHtml($link, $date);
|
141 |
}
|
142 |
}
|
143 |
}
|
144 |
}
|
145 |
|
146 |
+
$this->mergeArraysAndGetOtherPages();
|
|
|
|
|
|
|
147 |
wp_reset_postdata();
|
148 |
+
|
149 |
+
$post = $localPost; // reset global post to its value before the loop
|
|
|
|
|
|
|
|
|
|
|
|
|
150 |
}
|
151 |
|
152 |
// Gets a posts categories, tags and author, and compares for last modified date
|
153 |
private function getCategoriesTagsAndAuthor($date) {
|
154 |
+
if ($this->categories && ($postCats = get_the_category())) {
|
155 |
+
foreach ($postCats as $category) {
|
156 |
+
$id = $category->term_id;
|
157 |
+
if (!isset($this->categories[$id]) || $this->categories[$id] < $date) {
|
158 |
+
$this->categories[$id] = $date;
|
|
|
|
|
159 |
}
|
160 |
}
|
161 |
}
|
162 |
+
if ($this->tags && ($postTags = get_the_tags())) {
|
163 |
+
foreach ($postTags as $tag) {
|
164 |
+
$id = $tag->term_id;
|
165 |
+
if (!isset($this->tags[$id]) || $this->tags[$id] < $date) {
|
166 |
+
$this->tags[$id] = $date;
|
|
|
|
|
167 |
}
|
168 |
}
|
169 |
}
|
170 |
+
if ($this->authors && ($id = get_the_author_meta('ID'))) {
|
171 |
+
if (is_int($id) && (!isset($this->authors[$id]) || $this->authors[$id] < $date)) {
|
172 |
+
$this->authors[$id] = $date;
|
|
|
|
|
173 |
}
|
174 |
}
|
175 |
}
|
176 |
|
177 |
// Merges the arrays with post data into strings and gets user submitted pages, categories, tags and author pages
|
178 |
+
private function mergeArraysAndGetOtherPages() {
|
179 |
$xml = '';
|
180 |
+
$html = '';
|
181 |
+
$sections = $this->getSortedArray();
|
182 |
|
183 |
+
foreach ($sections as $title => $content) {
|
184 |
+
if ($content) {
|
185 |
+
if ($title === 'Categories' || $title === 'Tags' || $title === 'Authors') {
|
186 |
+
$content = $this->stringifyCatsTagsAuths($title, $content);
|
187 |
+
if ($title === 'Authors' && count($this->authors) <= 2) { // only one author (<= 2 cause one extra item is added to the array earlier)
|
188 |
+
$title = 'Author';
|
189 |
+
}
|
190 |
+
}
|
191 |
+
|
192 |
+
if ($content['xml']) {
|
193 |
+
$xml .= $content['xml'];
|
194 |
+
$html .= sprintf("%s\t<ul>\n%s\t</ul>\n", $this->htmlTableH($title), $content['html']);
|
195 |
+
}
|
196 |
+
}
|
197 |
}
|
198 |
|
199 |
+
$this->xml = sprintf("%s%s</urlset>", $this->xml, $xml);
|
200 |
+
$this->html = sprintf("%s%s%s</div>\n</body>\n</html>", $this->html, $html, $this->attributionLink());
|
201 |
+
}
|
202 |
+
|
203 |
+
// Displays attribution link if admin has checked the checkbox
|
204 |
+
private function attributionLink() {
|
205 |
+
if (get_option('simple_wp_attr_link')) {
|
206 |
+
return "\t<p id=\"attr\">Generated by: <a href=\"http://www.webbjocke.com/simple-wp-sitemap/\">Simple Wp Sitemap</a></p>\n";
|
207 |
}
|
208 |
+
return '';
|
209 |
+
}
|
210 |
+
|
211 |
+
// Gets sorted array according to specified order
|
212 |
+
private function getSortedArray() {
|
213 |
+
if (!($arr = $this->order)) {
|
214 |
+
$arr = array('Home' => null, 'Posts' => null, 'Pages' => null, 'Other' => null, 'Categories' => null, 'Tags' => null, 'Authors' => null);
|
215 |
}
|
216 |
|
217 |
+
if (!$this->home) { // if homepage isn't found in the query (for instance if it's not a real "page" it wont be found)
|
218 |
+
@date_default_timezone_set(get_option('timezone_string'));
|
219 |
+
$date = date('Y-m-d\TH:i:sP');
|
220 |
+
$this->home = array('xml' => $this->getXml($this->homeUrl, $date), 'html' => $this->getHtml($this->homeUrl, $date));
|
221 |
}
|
222 |
|
223 |
+
$arr['Home'] = $this->home;
|
224 |
+
$arr['Posts'] = $this->posts;
|
225 |
+
$arr['Pages'] = $this->pages;
|
226 |
+
$arr['Other'] = $this->getOtherPages();
|
227 |
+
$arr['Categories'] = $this->categories;
|
228 |
+
$arr['Tags'] = $this->tags;
|
229 |
+
$arr['Authors'] = $this->authors;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
230 |
|
231 |
+
return $arr;
|
232 |
}
|
233 |
|
234 |
// Returns category, tag and author links as ready xml and html strings
|
235 |
+
private function stringifyCatsTagsAuths($type, $content) {
|
236 |
+
$html = '';
|
237 |
$xml = '';
|
238 |
|
239 |
+
foreach ($content as $id => $date) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
240 |
if ($date) {
|
241 |
$link = esc_url($this->getLink($id, $type));
|
242 |
if (!$this->isBlockedUrl($link)) {
|
245 |
}
|
246 |
}
|
247 |
}
|
248 |
+
return array('xml' => $xml, 'html' => $html);
|
249 |
}
|
250 |
|
251 |
// Returns either a category, tag or an author link
|
252 |
private function getLink($id, $type) {
|
253 |
switch ($type) {
|
254 |
+
case 'Tags': return get_tag_link($id);
|
255 |
+
case 'Categories': return get_category_link($id);
|
256 |
+
default: return get_author_posts_url($id); // Authors
|
|
|
|
|
|
|
257 |
}
|
258 |
}
|
259 |
|
simpleWpMapOptions.php
CHANGED
@@ -17,17 +17,22 @@ class SimpleWpMapOptions {
|
|
17 |
}
|
18 |
|
19 |
// Updates the settings/options
|
20 |
-
public function setOptions($otherUrls, $blockUrls, $attrLink, $categories, $tags, $authors) {
|
21 |
-
date_default_timezone_set(get_option('timezone_string'));
|
22 |
update_option('simple_wp_other_urls', $this->addUrls($otherUrls, get_option('simple_wp_other_urls')));
|
23 |
update_option('simple_wp_block_urls', $this->addUrls($blockUrls));
|
24 |
update_option('simple_wp_attr_link', $attrLink);
|
25 |
update_option('simple_wp_disp_categories', $categories);
|
26 |
update_option('simple_wp_disp_tags', $tags);
|
27 |
update_option('simple_wp_disp_authors', $authors);
|
|
|
|
|
|
|
|
|
|
|
28 |
}
|
29 |
|
30 |
-
// Returns the options as strings to be displayed in textareas, and
|
31 |
public function getOptions($val) {
|
32 |
if ($val === 'simple_wp_other_urls' || $val === 'simple_wp_block_urls') {
|
33 |
$val = get_option($val);
|
@@ -35,13 +40,16 @@ class SimpleWpMapOptions {
|
|
35 |
elseif ($val === 'simple_wp_attr_link' || $val === 'simple_wp_disp_categories' || $val === 'simple_wp_disp_tags' || $val === 'simple_wp_disp_authors') {
|
36 |
return get_option($val) ? 'checked' : ''; // return checkbox checked values right here and dont bother with the loop below
|
37 |
}
|
|
|
|
|
|
|
38 |
else {
|
39 |
$val = null;
|
40 |
-
}
|
41 |
|
42 |
if (!$this->isNullOrWhiteSpace($val)) {
|
43 |
$str = '';
|
44 |
-
foreach ($val as $sArr){
|
45 |
$str .= $this->sanitizeUrl($sArr['url']) . "\n";
|
46 |
}
|
47 |
return trim($str);
|
@@ -62,6 +70,19 @@ class SimpleWpMapOptions {
|
|
62 |
return esc_url(trim($url));
|
63 |
}
|
64 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
65 |
// Adds new urls to the sitemaps
|
66 |
private function addUrls($urls, $oldUrls=null) {
|
67 |
$arr = array();
|
17 |
}
|
18 |
|
19 |
// Updates the settings/options
|
20 |
+
public function setOptions($otherUrls, $blockUrls, $attrLink, $categories, $tags, $authors, $orderArray) {
|
21 |
+
@date_default_timezone_set(get_option('timezone_string'));
|
22 |
update_option('simple_wp_other_urls', $this->addUrls($otherUrls, get_option('simple_wp_other_urls')));
|
23 |
update_option('simple_wp_block_urls', $this->addUrls($blockUrls));
|
24 |
update_option('simple_wp_attr_link', $attrLink);
|
25 |
update_option('simple_wp_disp_categories', $categories);
|
26 |
update_option('simple_wp_disp_tags', $tags);
|
27 |
update_option('simple_wp_disp_authors', $authors);
|
28 |
+
|
29 |
+
if ($this->checkOrder($orderArray)) {
|
30 |
+
asort($orderArray); // sort the array here
|
31 |
+
update_option('simple_wp_disp_sitemap_order', $orderArray);
|
32 |
+
}
|
33 |
}
|
34 |
|
35 |
+
// Returns the options as strings to be displayed in textareas, checkbox values and orderarray (to do: refactor this messy function)
|
36 |
public function getOptions($val) {
|
37 |
if ($val === 'simple_wp_other_urls' || $val === 'simple_wp_block_urls') {
|
38 |
$val = get_option($val);
|
40 |
elseif ($val === 'simple_wp_attr_link' || $val === 'simple_wp_disp_categories' || $val === 'simple_wp_disp_tags' || $val === 'simple_wp_disp_authors') {
|
41 |
return get_option($val) ? 'checked' : ''; // return checkbox checked values right here and dont bother with the loop below
|
42 |
}
|
43 |
+
elseif ($val === 'simple_wp_disp_sitemap_order' && ($orderArray = get_option($val))) {
|
44 |
+
return $this->checkOrder($orderArray);
|
45 |
+
}
|
46 |
else {
|
47 |
$val = null;
|
48 |
+
}
|
49 |
|
50 |
if (!$this->isNullOrWhiteSpace($val)) {
|
51 |
$str = '';
|
52 |
+
foreach ($val as $sArr) {
|
53 |
$str .= $this->sanitizeUrl($sArr['url']) . "\n";
|
54 |
}
|
55 |
return trim($str);
|
70 |
return esc_url(trim($url));
|
71 |
}
|
72 |
|
73 |
+
// Checks if orderArray has valid numbers (from 1 to 7)
|
74 |
+
private function checkOrder($numbers) {
|
75 |
+
if (is_array($numbers)) {
|
76 |
+
foreach ($numbers as $key => $num) {
|
77 |
+
if (!preg_match("/^[1-7]{1}$/", $num)) {
|
78 |
+
return false;
|
79 |
+
}
|
80 |
+
}
|
81 |
+
return $numbers;
|
82 |
+
}
|
83 |
+
return false;
|
84 |
+
}
|
85 |
+
|
86 |
// Adds new urls to the sitemaps
|
87 |
private function addUrls($urls, $oldUrls=null) {
|
88 |
$arr = array();
|