Version Description
Major DB query reduction and speed improvements. Bugfixes.
=
Download this release
Release Info
Developer | deployer |
Plugin | XML Sitemap & Google News feeds |
Version | 5.2 |
Comparing to | |
See all releases |
Code changes from version 5.1.2 to 5.2
- README.md +6 -0
- {views → assets}/images/sitemapxml.gif +0 -0
- {views → assets}/styles/admin.css +0 -0
- assets/styles/sitemap-custom.xsl +43 -0
- {views → assets}/styles/sitemap-index.xsl +2 -3
- {views → assets}/styles/sitemap-news.xsl +3 -6
- {views → assets}/styles/sitemap-taxonomy.xsl +2 -3
- {views → assets}/styles/sitemap.xsl +3 -3
- controllers/{admin/notices.php → class.xmlsf-admin-notices.php} +2 -4
- controllers/{admin/sitemap-news.php → class.xmlsf-admin-sitemap-news.php} +30 -56
- controllers/{admin/sitemap.php → class.xmlsf-admin-sitemap.php} +77 -83
- controllers/{admin/main.php → class.xmlsf-admin.php} +53 -36
- controllers/class.xmlsf-sitemap-news.php +89 -0
- controllers/class.xmlsf-sitemap.php +414 -0
- controllers/{global.php → functions.php} +30 -15
- controllers/functions.shared.php +73 -0
- controllers/main.php +0 -50
- controllers/sitemap-news.php +0 -67
- controllers/sitemap.php +0 -241
- models/admin/sitemap.php +0 -104
- models/class-xmlsitemapfeed.php +22 -11
- models/{admin/sitemap-news.php → class.xmlsf-admin-sitemap-news-sanitize.php} +0 -0
- models/class.xmlsf-admin-sitemap-sanitize.php +148 -0
- models/{admin/main.php → functions.admin.php} +11 -0
- models/{global.php → functions.php} +1 -1
- models/functions.public-shared.php +68 -0
- models/{public/sitemap-news.php → functions.public-sitemap-news.php} +61 -13
- models/{public/sitemap.php → functions.public-sitemap.php} +264 -234
- models/{main.php → functions.shared.php} +25 -24
- models/{sitemap-news.php → functions.sitemap-news.php} +1 -1
- models/functions.sitemap.php +255 -0
- models/public/shared.php +0 -123
- models/sitemap.php +0 -68
- readme.txt +19 -9
- uninstall.php +23 -4
- controllers/upgrade.php → upgrade.php +7 -0
- views/_generator.php +1 -1
- views/_usage.php +1 -1
- views/admin/field-news-categories.php +8 -8
- views/admin/field-news-image.php +0 -10
- views/admin/field-sitemap-taxonomies.php +18 -14
- views/admin/field-sitemap-taxonomy-settings.php +32 -34
- views/admin/help-tab-news-images.php +0 -7
- views/admin/meta-box-news.php +1 -2
- views/admin/meta-box.php +13 -9
- views/admin/notice-static-files.php +1 -1
- views/admin/page-sitemap-news.php +3 -3
- views/admin/page-sitemap.php +8 -3
- views/feed-sitemap-custom.php +2 -1
- views/feed-sitemap-home.php +2 -1
- views/feed-sitemap-news.php +4 -38
- views/feed-sitemap-post_type.php +30 -29
- views/feed-sitemap-taxonomy.php +4 -3
- views/feed-sitemap.php +6 -5
- xml-sitemap.php +8 -4
README.md
ADDED
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# XML Sitemap & Google News feeds
|
2 |
+
|
3 |
+
XML and Google News Sitemaps for WordPress to feed the hungry spiders. Multisite, WP Super Cache, Polylang and WPML compatible.
|
4 |
+
|
5 |
+
[https://wordpress.org/plugins/xml-sitemap-feed/](https://wordpress.org/plugins/xml-sitemap-feed/)
|
6 |
+
|
{views → assets}/images/sitemapxml.gif
RENAMED
File without changes
|
{views → assets}/styles/admin.css
RENAMED
File without changes
|
assets/styles/sitemap-custom.xsl
ADDED
@@ -0,0 +1,43 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0" encoding="UTF-8"?>
|
2 |
+
<xsl:stylesheet version="2.0"
|
3 |
+
xmlns:html="http://www.w3.org/TR/REC-html40"
|
4 |
+
xmlns:sitemap="http://www.sitemaps.org/schemas/sitemap/0.9"
|
5 |
+
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
|
6 |
+
<xsl:output method="html" version="1.0" encoding="UTF-8" indent="yes"/>
|
7 |
+
<xsl:template match="/">
|
8 |
+
<html xmlns="http://www.w3.org/1999/xhtml">
|
9 |
+
<head>
|
10 |
+
<title>XML Sitemap Feed</title>
|
11 |
+
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
12 |
+
<style type="text/css">body{font-family:"Lucida Grande","Lucida Sans Unicode",Tahoma,Verdana,sans-serif;font-size:13px}#header,#footer{padding:2px;margin:10px;font-size:8pt;color:gray}a{color:black}td{font-size:11px}th{text-align:left;padding-right:30px;font-size:11px}tr.high{background-color:whitesmoke}#footer img{vertical-align:middle}</style>
|
13 |
+
</head>
|
14 |
+
<body>
|
15 |
+
<h1>XML Sitemap Feed</h1>
|
16 |
+
<div id="header">
|
17 |
+
<p>This is an XML Sitemap to aid search engines like <a href="https://www.google.com">Google</a>, <a href="https://www.bing.com/">Bing</a>, <a href="https://www.yahoo.com">Yahoo!</a> and <a href="https://www.ask.com">Ask</a> indexing your site better. Read more about XML sitemaps on <a href="https://www.sitemaps.org/">Sitemaps.org</a>.</p>
|
18 |
+
</div>
|
19 |
+
<div id="content">
|
20 |
+
<table cellpadding="5">
|
21 |
+
<tr class="high">
|
22 |
+
<th>#</th>
|
23 |
+
<th>URL</th>
|
24 |
+
<th>Priority</th>
|
25 |
+
</tr>
|
26 |
+
<xsl:variable name="lower" select="'abcdefghijklmnopqrstuvwxyz'"/>
|
27 |
+
<xsl:variable name="upper" select="'ABCDEFGHIJKLMNOPQRSTUVWXYZ'"/>
|
28 |
+
<xsl:for-each select="sitemap:urlset/sitemap:url">
|
29 |
+
<tr><xsl:if test="position() mod 2 != 1"><xsl:attribute name="class">high</xsl:attribute></xsl:if>
|
30 |
+
<td><xsl:value-of select="position()"/></td>
|
31 |
+
<td><xsl:variable name="itemURL"><xsl:value-of select="sitemap:loc"/></xsl:variable><a href="{$itemURL}"><xsl:value-of select="sitemap:loc"/></a></td>
|
32 |
+
<td><xsl:value-of select="concat(sitemap:priority*100,'%')"/></td>
|
33 |
+
</tr>
|
34 |
+
</xsl:for-each>
|
35 |
+
</table>
|
36 |
+
</div>
|
37 |
+
<div id="footer">
|
38 |
+
<p><img src="data:image/gif;base64,R0lGODlhUAAPAJEAAGZmZv////9mAImOeSwAAAAAUAAPAAACoISPqcvtD0+YtNqLs968myCE4kiW5jkGw8q27gvDwYfWdq3G+i7T9w/M8Ya7GQAUoiSTEyYSKYA2nSKhdXUdCIlaXzRVDVdB0+dS2lJZ1bkt0Sgti6NysvM5jbq2ai2WywJHYrZUaEhIWJXm99foNiRI9XUoV4g4GJjJyEgBGAkEivIIyPUZeppCqorlheo6ulr00UFba3uLEaG7y9urUAAAOw%3D%3D" alt="XML Sitemap" title="XML Sitemap" /> generated by <a href="https://status301.net/wordpress-plugins/xml-sitemap-feed/">XML Sitemap & Google News</a> for <a href="https://wordpress.org/">WordPress</a>.</p>
|
39 |
+
</div>
|
40 |
+
</body>
|
41 |
+
</html>
|
42 |
+
</xsl:template>
|
43 |
+
</xsl:stylesheet>
|
{views → assets}/styles/sitemap-index.xsl
RENAMED
@@ -2,7 +2,6 @@
|
|
2 |
<xsl:stylesheet version="2.0"
|
3 |
xmlns:html="http://www.w3.org/TR/REC-html40"
|
4 |
xmlns:sitemap="http://www.sitemaps.org/schemas/sitemap/0.9"
|
5 |
-
sitemap:news="http://www.google.com/schemas/sitemap-news/0.9"
|
6 |
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
|
7 |
<xsl:output method="html" version="1.0" encoding="UTF-8" indent="yes"/>
|
8 |
<xsl:template match="/">
|
@@ -23,7 +22,7 @@
|
|
23 |
<tr class="high">
|
24 |
<th>#</th>
|
25 |
<th>XML Sitemap</th>
|
26 |
-
<th>Last
|
27 |
</tr>
|
28 |
<xsl:variable name="lower" select="'abcdefghijklmnopqrstuvwxyz'"/>
|
29 |
<xsl:variable name="upper" select="'ABCDEFGHIJKLMNOPQRSTUVWXYZ'"/>
|
@@ -33,7 +32,7 @@
|
|
33 |
<td><xsl:variable name="itemURL"><xsl:value-of select="sitemap:loc"/></xsl:variable>
|
34 |
<a href="{$itemURL}"><xsl:value-of select="sitemap:loc"/></a>
|
35 |
</td>
|
36 |
-
<td><xsl:value-of select="concat(substring(sitemap:lastmod,0,11),concat(' ', substring(sitemap:lastmod,12,
|
37 |
</tr>
|
38 |
</xsl:for-each>
|
39 |
</table>
|
2 |
<xsl:stylesheet version="2.0"
|
3 |
xmlns:html="http://www.w3.org/TR/REC-html40"
|
4 |
xmlns:sitemap="http://www.sitemaps.org/schemas/sitemap/0.9"
|
|
|
5 |
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
|
6 |
<xsl:output method="html" version="1.0" encoding="UTF-8" indent="yes"/>
|
7 |
<xsl:template match="/">
|
22 |
<tr class="high">
|
23 |
<th>#</th>
|
24 |
<th>XML Sitemap</th>
|
25 |
+
<th>Last Modified</th>
|
26 |
</tr>
|
27 |
<xsl:variable name="lower" select="'abcdefghijklmnopqrstuvwxyz'"/>
|
28 |
<xsl:variable name="upper" select="'ABCDEFGHIJKLMNOPQRSTUVWXYZ'"/>
|
32 |
<td><xsl:variable name="itemURL"><xsl:value-of select="sitemap:loc"/></xsl:variable>
|
33 |
<a href="{$itemURL}"><xsl:value-of select="sitemap:loc"/></a>
|
34 |
</td>
|
35 |
+
<td><xsl:value-of select="concat(substring(sitemap:lastmod,0,11),concat(' ', substring(sitemap:lastmod,12,8)))"/> (<xsl:value-of select="substring(sitemap:lastmod,20,6)"/>)</td>
|
36 |
</tr>
|
37 |
</xsl:for-each>
|
38 |
</table>
|
{views → assets}/styles/sitemap-news.xsl
RENAMED
@@ -2,8 +2,7 @@
|
|
2 |
<xsl:stylesheet version="2.0"
|
3 |
xmlns:html="http://www.w3.org/TR/REC-html40"
|
4 |
xmlns:sitemap="http://www.sitemaps.org/schemas/sitemap/0.9"
|
5 |
-
|
6 |
-
xmlns:image="http://www.google.com/schemas/sitemap-image/1.1"
|
7 |
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
|
8 |
<xsl:output method="html" version="1.0" encoding="UTF-8" indent="yes"/>
|
9 |
<xsl:template match="/">
|
@@ -26,10 +25,9 @@
|
|
26 |
<th>#</th>
|
27 |
<th>Title</th>
|
28 |
<th>Language</th>
|
29 |
-
<th>Image(s)</th>
|
30 |
<th>Keyword(s)</th>
|
31 |
<th>Stock(s)</th>
|
32 |
-
<th>Publication Date
|
33 |
</tr>
|
34 |
<xsl:variable name="lower" select="'abcdefghijklmnopqrstuvwxyz'"/>
|
35 |
<xsl:variable name="upper" select="'ABCDEFGHIJKLMNOPQRSTUVWXYZ'"/>
|
@@ -40,10 +38,9 @@
|
|
40 |
<a href="{$itemURL}"><xsl:value-of select="news:news/news:title"/></a>
|
41 |
</td>
|
42 |
<td><xsl:value-of select="news:news/news:publication/news:language"/></td>
|
43 |
-
<td><xsl:value-of select="count(image:image)"/></td>
|
44 |
<td><xsl:value-of select="news:news/news:keywords"/></td>
|
45 |
<td><xsl:value-of select="news:news/news:stock_tickers"/></td>
|
46 |
-
<td><xsl:value-of select="concat(substring(news:news/news:publication_date,0,11),concat(' ', substring(news:news/news:publication_date,12,8)))"
|
47 |
</tr>
|
48 |
</xsl:for-each>
|
49 |
</table>
|
2 |
<xsl:stylesheet version="2.0"
|
3 |
xmlns:html="http://www.w3.org/TR/REC-html40"
|
4 |
xmlns:sitemap="http://www.sitemaps.org/schemas/sitemap/0.9"
|
5 |
+
xmlns:news="http://www.google.com/schemas/sitemap-news/0.9"
|
|
|
6 |
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
|
7 |
<xsl:output method="html" version="1.0" encoding="UTF-8" indent="yes"/>
|
8 |
<xsl:template match="/">
|
25 |
<th>#</th>
|
26 |
<th>Title</th>
|
27 |
<th>Language</th>
|
|
|
28 |
<th>Keyword(s)</th>
|
29 |
<th>Stock(s)</th>
|
30 |
+
<th>Publication Date</th>
|
31 |
</tr>
|
32 |
<xsl:variable name="lower" select="'abcdefghijklmnopqrstuvwxyz'"/>
|
33 |
<xsl:variable name="upper" select="'ABCDEFGHIJKLMNOPQRSTUVWXYZ'"/>
|
38 |
<a href="{$itemURL}"><xsl:value-of select="news:news/news:title"/></a>
|
39 |
</td>
|
40 |
<td><xsl:value-of select="news:news/news:publication/news:language"/></td>
|
|
|
41 |
<td><xsl:value-of select="news:news/news:keywords"/></td>
|
42 |
<td><xsl:value-of select="news:news/news:stock_tickers"/></td>
|
43 |
+
<td><xsl:value-of select="concat(substring(news:news/news:publication_date,0,11),concat(' ', substring(news:news/news:publication_date,12,8)))"/> (<xsl:value-of select="substring(news:news/news:publication_date,20,6)"/>)</td>
|
44 |
</tr>
|
45 |
</xsl:for-each>
|
46 |
</table>
|
{views → assets}/styles/sitemap-taxonomy.xsl
RENAMED
@@ -2,7 +2,6 @@
|
|
2 |
<xsl:stylesheet version="2.0"
|
3 |
xmlns:html="http://www.w3.org/TR/REC-html40"
|
4 |
xmlns:sitemap="http://www.sitemaps.org/schemas/sitemap/0.9"
|
5 |
-
xmlns:image="http://www.google.com/schemas/sitemap-image/1.1"
|
6 |
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
|
7 |
<xsl:output method="html" version="1.0" encoding="UTF-8" indent="yes"/>
|
8 |
<xsl:template match="/">
|
@@ -23,7 +22,7 @@
|
|
23 |
<th>#</th>
|
24 |
<th>URL</th>
|
25 |
<th>Priority</th>
|
26 |
-
<th>Last
|
27 |
</tr>
|
28 |
<xsl:variable name="lower" select="'abcdefghijklmnopqrstuvwxyz'"/>
|
29 |
<xsl:variable name="upper" select="'ABCDEFGHIJKLMNOPQRSTUVWXYZ'"/>
|
@@ -32,7 +31,7 @@
|
|
32 |
<td><xsl:value-of select="position()"/></td>
|
33 |
<td><xsl:variable name="itemURL"><xsl:value-of select="sitemap:loc"/></xsl:variable><a href="{$itemURL}"><xsl:value-of select="sitemap:loc"/></a></td>
|
34 |
<td><xsl:value-of select="concat(sitemap:priority*100,'%')"/></td>
|
35 |
-
<td><xsl:value-of select="concat(substring(sitemap:lastmod,0,11),concat(' ', substring(sitemap:lastmod,12,
|
36 |
</tr>
|
37 |
</xsl:for-each>
|
38 |
</table>
|
2 |
<xsl:stylesheet version="2.0"
|
3 |
xmlns:html="http://www.w3.org/TR/REC-html40"
|
4 |
xmlns:sitemap="http://www.sitemaps.org/schemas/sitemap/0.9"
|
|
|
5 |
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
|
6 |
<xsl:output method="html" version="1.0" encoding="UTF-8" indent="yes"/>
|
7 |
<xsl:template match="/">
|
22 |
<th>#</th>
|
23 |
<th>URL</th>
|
24 |
<th>Priority</th>
|
25 |
+
<th>Last Modified</th>
|
26 |
</tr>
|
27 |
<xsl:variable name="lower" select="'abcdefghijklmnopqrstuvwxyz'"/>
|
28 |
<xsl:variable name="upper" select="'ABCDEFGHIJKLMNOPQRSTUVWXYZ'"/>
|
31 |
<td><xsl:value-of select="position()"/></td>
|
32 |
<td><xsl:variable name="itemURL"><xsl:value-of select="sitemap:loc"/></xsl:variable><a href="{$itemURL}"><xsl:value-of select="sitemap:loc"/></a></td>
|
33 |
<td><xsl:value-of select="concat(sitemap:priority*100,'%')"/></td>
|
34 |
+
<td><xsl:value-of select="concat(substring(sitemap:lastmod,0,11),concat(' ', substring(sitemap:lastmod,12,8)))"/> (<xsl:value-of select="substring(sitemap:lastmod,20,6)"/>)</td>
|
35 |
</tr>
|
36 |
</xsl:for-each>
|
37 |
</table>
|
{views → assets}/styles/sitemap.xsl
RENAMED
@@ -2,7 +2,7 @@
|
|
2 |
<xsl:stylesheet version="2.0"
|
3 |
xmlns:html="http://www.w3.org/TR/REC-html40"
|
4 |
xmlns:sitemap="http://www.sitemaps.org/schemas/sitemap/0.9"
|
5 |
-
|
6 |
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
|
7 |
<xsl:output method="html" version="1.0" encoding="UTF-8" indent="yes"/>
|
8 |
<xsl:template match="/">
|
@@ -24,7 +24,7 @@
|
|
24 |
<th>URL</th>
|
25 |
<th># Images</th>
|
26 |
<th>Priority</th>
|
27 |
-
<th>Last
|
28 |
</tr>
|
29 |
<xsl:variable name="lower" select="'abcdefghijklmnopqrstuvwxyz'"/>
|
30 |
<xsl:variable name="upper" select="'ABCDEFGHIJKLMNOPQRSTUVWXYZ'"/>
|
@@ -34,7 +34,7 @@
|
|
34 |
<td><xsl:variable name="itemURL"><xsl:value-of select="sitemap:loc"/></xsl:variable><a href="{$itemURL}"><xsl:value-of select="sitemap:loc"/></a></td>
|
35 |
<td><xsl:value-of select="count(image:image)"/></td>
|
36 |
<td><xsl:value-of select="concat(sitemap:priority*100,'%')"/></td>
|
37 |
-
<td><xsl:value-of select="concat(substring(sitemap:lastmod,0,11),concat(' ', substring(sitemap:lastmod,12,
|
38 |
</tr>
|
39 |
</xsl:for-each>
|
40 |
</table>
|
2 |
<xsl:stylesheet version="2.0"
|
3 |
xmlns:html="http://www.w3.org/TR/REC-html40"
|
4 |
xmlns:sitemap="http://www.sitemaps.org/schemas/sitemap/0.9"
|
5 |
+
xmlns:image="http://www.google.com/schemas/sitemap-image/1.1"
|
6 |
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
|
7 |
<xsl:output method="html" version="1.0" encoding="UTF-8" indent="yes"/>
|
8 |
<xsl:template match="/">
|
24 |
<th>URL</th>
|
25 |
<th># Images</th>
|
26 |
<th>Priority</th>
|
27 |
+
<th>Last Modified</th>
|
28 |
</tr>
|
29 |
<xsl:variable name="lower" select="'abcdefghijklmnopqrstuvwxyz'"/>
|
30 |
<xsl:variable name="upper" select="'ABCDEFGHIJKLMNOPQRSTUVWXYZ'"/>
|
34 |
<td><xsl:variable name="itemURL"><xsl:value-of select="sitemap:loc"/></xsl:variable><a href="{$itemURL}"><xsl:value-of select="sitemap:loc"/></a></td>
|
35 |
<td><xsl:value-of select="count(image:image)"/></td>
|
36 |
<td><xsl:value-of select="concat(sitemap:priority*100,'%')"/></td>
|
37 |
+
<td><xsl:value-of select="concat(substring(sitemap:lastmod,0,11),concat(' ', substring(sitemap:lastmod,12,8)))"/> (<xsl:value-of select="substring(sitemap:lastmod,20,6)"/>)</td>
|
38 |
</tr>
|
39 |
</xsl:for-each>
|
40 |
</table>
|
controllers/{admin/notices.php → class.xmlsf-admin-notices.php}
RENAMED
@@ -4,16 +4,14 @@
|
|
4 |
* Dismissable or interactive admin notices
|
5 |
*/
|
6 |
|
7 |
-
class XMLSF_Admin_Notices extends
|
8 |
{
|
9 |
function __construct() {}
|
10 |
|
11 |
public static function notice_static_files()
|
12 |
{
|
13 |
$number = count( parent::$static_files );
|
14 |
-
if (
|
15 |
-
|
16 |
-
$static_files = parent::$static_files;
|
17 |
|
18 |
include XMLSF_DIR . '/views/admin/notice-static-files.php';
|
19 |
}
|
4 |
* Dismissable or interactive admin notices
|
5 |
*/
|
6 |
|
7 |
+
class XMLSF_Admin_Notices extends XMLSF_Admin
|
8 |
{
|
9 |
function __construct() {}
|
10 |
|
11 |
public static function notice_static_files()
|
12 |
{
|
13 |
$number = count( parent::$static_files );
|
14 |
+
if ( ! $number ) return;
|
|
|
|
|
15 |
|
16 |
include XMLSF_DIR . '/views/admin/notice-static-files.php';
|
17 |
}
|
controllers/{admin/sitemap-news.php → class.xmlsf-admin-sitemap-news.php}
RENAMED
@@ -1,6 +1,6 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
class XMLSF_Admin_Sitemap_News extends
|
4 |
{
|
5 |
/**
|
6 |
* Holds the values to be used in the fields callbacks
|
@@ -33,40 +33,35 @@ class XMLSF_Admin_Sitemap_News extends XMLSF_Admin_Controller
|
|
33 |
|
34 |
public function tools_actions()
|
35 |
{
|
36 |
-
if ( ! isset( $_POST['xmlsf-ping-sitemap-news'] ) )
|
37 |
return;
|
38 |
|
39 |
-
|
|
|
40 |
|
41 |
-
|
42 |
-
|
|
|
|
|
|
|
43 |
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
break;
|
49 |
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
default:
|
61 |
-
$msg = sprintf( /* Translators: Search engine / Service name, response code number */ __( 'Ping %s failed with response code: %d', 'xml-sitemap-feed' ), __( 'Google News', 'xml-sitemap-feed' ), $result );
|
62 |
-
$type = 'error';
|
63 |
-
}
|
64 |
|
65 |
-
|
66 |
|
67 |
-
} else {
|
68 |
-
add_settings_error( 'ping_sitemap', 'ping_sitemap', translate('Security check failed.') );
|
69 |
-
}
|
70 |
}
|
71 |
|
72 |
/**
|
@@ -107,17 +102,18 @@ class XMLSF_Admin_Sitemap_News extends XMLSF_Admin_Controller
|
|
107 |
/* When the post is saved, save our meta data */
|
108 |
public function save_metadata( $post_id )
|
109 |
{
|
110 |
-
if (
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
|
|
115 |
|
116 |
// _xmlsf_news_exclude
|
117 |
if ( empty($_POST['xmlsf_news_exclude']) )
|
118 |
-
delete_post_meta($post_id, '_xmlsf_news_exclude');
|
119 |
else
|
120 |
-
update_post_meta($post_id, '_xmlsf_news_exclude',
|
121 |
}
|
122 |
|
123 |
/**
|
@@ -195,9 +191,6 @@ class XMLSF_Admin_Sitemap_News extends XMLSF_Admin_Controller
|
|
195 |
}
|
196 |
}
|
197 |
|
198 |
-
// Images
|
199 |
-
add_settings_field( 'xmlsf_news_image', translate('Images'), array( $this,'image_field' ), 'xmlsf_news_general', 'news_sitemap_general_section' );
|
200 |
-
|
201 |
// Source labels - deprecated
|
202 |
add_settings_field( 'xmlsf_news_labels', __('Source labels', 'xml-sitemap-feed' ), array($this,'labels_field'), 'xmlsf_news_general', 'news_sitemap_general_section' );
|
203 |
}
|
@@ -251,17 +244,6 @@ class XMLSF_Admin_Sitemap_News extends XMLSF_Admin_Controller
|
|
251 |
'content' => $content
|
252 |
) );
|
253 |
|
254 |
-
ob_start();
|
255 |
-
include XMLSF_DIR . '/views/admin/help-tab-news-images.php';
|
256 |
-
include XMLSF_DIR . '/views/admin/help-tab-support.php';
|
257 |
-
$content = ob_get_clean();
|
258 |
-
|
259 |
-
$screen->add_help_tab( array(
|
260 |
-
'id' => 'sitemap-news-images',
|
261 |
-
'title' => translate('Images'),
|
262 |
-
'content' => $content
|
263 |
-
) );
|
264 |
-
|
265 |
ob_start();
|
266 |
include XMLSF_DIR . '/views/admin/help-tab-news-keywords.php';
|
267 |
include XMLSF_DIR . '/views/admin/help-tab-support.php';
|
@@ -345,14 +327,6 @@ class XMLSF_Admin_Sitemap_News extends XMLSF_Admin_Controller
|
|
345 |
include XMLSF_DIR . '/views/admin/field-news-categories.php';
|
346 |
}
|
347 |
|
348 |
-
public function image_field()
|
349 |
-
{
|
350 |
-
$image = !empty( $this->options['image'] ) ? $this->options['image'] : '';
|
351 |
-
|
352 |
-
// The actual fields for data entry
|
353 |
-
include XMLSF_DIR . '/views/admin/field-news-image.php';
|
354 |
-
}
|
355 |
-
|
356 |
public function keywords_field()
|
357 |
{
|
358 |
// The actual fields for data entry
|
1 |
<?php
|
2 |
|
3 |
+
class XMLSF_Admin_Sitemap_News extends XMLSF_Admin
|
4 |
{
|
5 |
/**
|
6 |
* Holds the values to be used in the fields callbacks
|
33 |
|
34 |
public function tools_actions()
|
35 |
{
|
36 |
+
if ( ! isset( $_POST['xmlsf-ping-sitemap-news'] ) || ! xmlsf_verify_nonce('help') )
|
37 |
return;
|
38 |
|
39 |
+
$sitemaps = get_option( 'xmlsf_sitemaps' );
|
40 |
+
$result = xmlsf_ping( 'google', $sitemaps['sitemap-news'], 5 * MINUTE_IN_SECONDS );
|
41 |
|
42 |
+
switch( $result ) {
|
43 |
+
case 200:
|
44 |
+
$msg = sprintf( /* Translators: Search engine / Service name */ __( 'Pinged %s with success.', 'xml-sitemap-feed' ), __( 'Google News', 'xml-sitemap-feed' ) );
|
45 |
+
$type = 'updated';
|
46 |
+
break;
|
47 |
|
48 |
+
case 999:
|
49 |
+
$msg = sprintf( /* Translators: Search engine / Service name, interval number */ __( 'Ping %s skipped: Sitemap already sent within the last %d minutes.', 'xml-sitemap-feed' ), __( 'Google News', 'xml-sitemap-feed' ), 5 );
|
50 |
+
$type = 'notice-warning';
|
51 |
+
break;
|
|
|
52 |
|
53 |
+
case '':
|
54 |
+
$msg = sprintf( translate('Oops: %s'), translate('Something went wrong.') );
|
55 |
+
$type = 'error';
|
56 |
+
break;
|
57 |
|
58 |
+
default:
|
59 |
+
$msg = sprintf( /* Translators: Search engine / Service name, response code number */ __( 'Ping %s failed with response code: %d', 'xml-sitemap-feed' ), __( 'Google News', 'xml-sitemap-feed' ), $result );
|
60 |
+
$type = 'error';
|
61 |
+
}
|
|
|
|
|
|
|
|
|
|
|
62 |
|
63 |
+
add_settings_error( 'ping_sitemap', 'ping_sitemap', $msg, $type );
|
64 |
|
|
|
|
|
|
|
65 |
}
|
66 |
|
67 |
/**
|
102 |
/* When the post is saved, save our meta data */
|
103 |
public function save_metadata( $post_id )
|
104 |
{
|
105 |
+
if (
|
106 |
+
// verify nonce
|
107 |
+
! isset($_POST['_xmlsf_news_nonce']) || ! wp_verify_nonce($_POST['_xmlsf_news_nonce'], XMLSF_BASENAME) ||
|
108 |
+
// user not allowed
|
109 |
+
! current_user_can( 'edit_post', $post_id )
|
110 |
+
) return;
|
111 |
|
112 |
// _xmlsf_news_exclude
|
113 |
if ( empty($_POST['xmlsf_news_exclude']) )
|
114 |
+
delete_post_meta( $post_id, '_xmlsf_news_exclude' );
|
115 |
else
|
116 |
+
update_post_meta( $post_id, '_xmlsf_news_exclude', '1' );
|
117 |
}
|
118 |
|
119 |
/**
|
191 |
}
|
192 |
}
|
193 |
|
|
|
|
|
|
|
194 |
// Source labels - deprecated
|
195 |
add_settings_field( 'xmlsf_news_labels', __('Source labels', 'xml-sitemap-feed' ), array($this,'labels_field'), 'xmlsf_news_general', 'news_sitemap_general_section' );
|
196 |
}
|
244 |
'content' => $content
|
245 |
) );
|
246 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
247 |
ob_start();
|
248 |
include XMLSF_DIR . '/views/admin/help-tab-news-keywords.php';
|
249 |
include XMLSF_DIR . '/views/admin/help-tab-support.php';
|
327 |
include XMLSF_DIR . '/views/admin/field-news-categories.php';
|
328 |
}
|
329 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
330 |
public function keywords_field()
|
331 |
{
|
332 |
// The actual fields for data entry
|
controllers/{admin/sitemap.php → class.xmlsf-admin-sitemap.php}
RENAMED
@@ -1,22 +1,22 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
class XMLSF_Admin_Sitemap extends
|
4 |
{
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
|
10 |
/**
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
add_action( 'admin_menu', array( $this, 'add_settings_page' ) );
|
21 |
add_action( 'admin_init', array( $this, 'tools_actions' ) );
|
22 |
add_action( 'admin_init', array( $this, 'check_plugin_conflicts' ), 11 );
|
@@ -27,45 +27,40 @@ class XMLSF_Admin_Sitemap extends XMLSF_Admin_Controller
|
|
27 |
|
28 |
public function tools_actions()
|
29 |
{
|
30 |
-
if ( ! isset( $_POST['xmlsf-ping-sitemap'] ) )
|
31 |
return;
|
32 |
|
33 |
-
|
34 |
|
35 |
-
|
|
|
36 |
|
37 |
-
|
38 |
-
$result = xmlsf_ping( $se, $sitemaps['sitemap'], HOUR_IN_SECONDS );
|
39 |
|
40 |
-
|
|
|
|
|
|
|
|
|
41 |
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
break;
|
47 |
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
break;
|
57 |
-
|
58 |
-
default:
|
59 |
-
$msg = sprintf( /* Translators: Search engine / Service name, response code number */ __( 'Ping %s failed with response code: %d', 'xml-sitemap-feed' ), $se_name, $result );
|
60 |
-
$type = 'error';
|
61 |
-
}
|
62 |
-
|
63 |
-
add_settings_error( 'ping_sitemap', 'ping_sitemap', $msg, $type );
|
64 |
}
|
65 |
|
66 |
-
|
67 |
-
add_settings_error( 'ping_sitemap', 'ping_sitemap', translate('Security check failed.') );
|
68 |
}
|
|
|
69 |
}
|
70 |
|
71 |
/**
|
@@ -190,17 +185,18 @@ class XMLSF_Admin_Sitemap extends XMLSF_Admin_Controller
|
|
190 |
/* When the post is saved, save our meta data */
|
191 |
public function save_metadata( $post_id )
|
192 |
{
|
193 |
-
if (
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
|
|
198 |
|
199 |
// _xmlsf_priority
|
200 |
if ( empty($_POST['xmlsf_priority']) )
|
201 |
delete_post_meta($post_id, '_xmlsf_priority');
|
202 |
else
|
203 |
-
|
204 |
|
205 |
// _xmlsf_exclude
|
206 |
if ( empty($_POST['xmlsf_exclude']) )
|
@@ -210,13 +206,11 @@ class XMLSF_Admin_Sitemap extends XMLSF_Admin_Controller
|
|
210 |
}
|
211 |
|
212 |
/**
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
{
|
217 |
if ( !isset( $this->public_taxonomies ) ) {
|
218 |
-
require_once XMLSF_DIR . '/models/public/sitemap.php';
|
219 |
-
|
220 |
$this->public_taxonomies = xmlsf_public_taxonomies();
|
221 |
}
|
222 |
|
@@ -224,25 +218,25 @@ class XMLSF_Admin_Sitemap extends XMLSF_Admin_Controller
|
|
224 |
}
|
225 |
|
226 |
/**
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
{
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
// SECTIONS & SETTINGS
|
247 |
// post_types
|
248 |
add_settings_section( 'xml_sitemap_post_types_section', /*'<a name="xmlsf"></a>'.__('XML Sitemap','xml-sitemap-feed')*/ '', '', 'xmlsf_post_types' );
|
@@ -261,9 +255,9 @@ class XMLSF_Admin_Sitemap extends XMLSF_Admin_Controller
|
|
261 |
// taxonomies
|
262 |
add_settings_section( 'xml_sitemap_taxonomies_section', /*'<a name="xmlsf"></a>'.__('XML Sitemap','xml-sitemap-feed')*/ '', '', 'xmlsf_taxonomies' );
|
263 |
add_settings_field( 'xmlsf_taxonomy_settings', translate('General'), array($this,'taxonomy_settings_field'), 'xmlsf_taxonomies', 'xml_sitemap_taxonomies_section' );
|
264 |
-
|
265 |
-
|
266 |
-
add_settings_field( 'xmlsf_taxonomies', __('
|
267 |
|
268 |
add_settings_section( 'xml_sitemap_advanced_section', /*'<a name="xmlsf"></a>'.__('XML Sitemap','xml-sitemap-feed')*/ '', '', 'xmlsf_advanced' );
|
269 |
// custom urls
|
@@ -277,13 +271,13 @@ class XMLSF_Admin_Sitemap extends XMLSF_Admin_Controller
|
|
277 |
$url = trailingslashit(get_bloginfo('url')) . ( xmlsf()->plain_permalinks() || empty($sitemaps['sitemap']) ? '?feed=sitemap' : $sitemaps['sitemap'] );
|
278 |
|
279 |
include XMLSF_DIR . '/views/admin/page-sitemap.php';
|
280 |
-
|
281 |
|
282 |
-
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
// Help tab
|
288 |
add_action( 'load-'.$this->screen_id, array($this,'help_tab') );
|
289 |
|
@@ -296,7 +290,7 @@ class XMLSF_Admin_Sitemap extends XMLSF_Admin_Controller
|
|
296 |
register_setting( 'xmlsf_advanced', 'xmlsf_urls', array('XMLSF_Admin_Sitemap_Sanitize','custom_urls_settings') );
|
297 |
// custom sitemaps
|
298 |
register_setting( 'xmlsf_advanced', 'xmlsf_custom_sitemaps', array('XMLSF_Admin_Sitemap_Sanitize','custom_sitemaps_settings') );
|
299 |
-
|
300 |
|
301 |
/**
|
302 |
* XML SITEMAP SECTION
|
@@ -369,7 +363,6 @@ class XMLSF_Admin_Sitemap extends XMLSF_Admin_Controller
|
|
369 |
|
370 |
public function taxonomy_settings_field()
|
371 |
{
|
372 |
-
$taxonomies = get_option( 'xmlsf_taxonomies' );
|
373 |
$taxonomy_settings = get_option( 'xmlsf_taxonomy_settings' );
|
374 |
|
375 |
// The actual fields for data entry
|
@@ -393,7 +386,8 @@ class XMLSF_Admin_Sitemap extends XMLSF_Admin_Controller
|
|
393 |
include XMLSF_DIR . '/views/admin/field-sitemap-custom.php';
|
394 |
}
|
395 |
|
396 |
-
public function urls_settings_field()
|
|
|
397 |
$urls = get_option( 'xmlsf_urls' );
|
398 |
$lines = array();
|
399 |
|
1 |
<?php
|
2 |
|
3 |
+
class XMLSF_Admin_Sitemap extends XMLSF_Admin
|
4 |
{
|
5 |
+
/**
|
6 |
+
* Holds the values to be used in the fields callbacks
|
7 |
+
*/
|
8 |
+
private $screen_id;
|
9 |
|
10 |
/**
|
11 |
+
* Holds the public taxonomies array
|
12 |
+
*/
|
13 |
+
private $public_taxonomies;
|
14 |
+
|
15 |
+
/**
|
16 |
+
* Start up
|
17 |
+
*/
|
18 |
+
public function __construct()
|
19 |
+
{
|
20 |
add_action( 'admin_menu', array( $this, 'add_settings_page' ) );
|
21 |
add_action( 'admin_init', array( $this, 'tools_actions' ) );
|
22 |
add_action( 'admin_init', array( $this, 'check_plugin_conflicts' ), 11 );
|
27 |
|
28 |
public function tools_actions()
|
29 |
{
|
30 |
+
if ( ! isset( $_POST['xmlsf-ping-sitemap'] ) || ! xmlsf_verify_nonce('help') )
|
31 |
return;
|
32 |
|
33 |
+
$sitemaps = get_option( 'xmlsf_sitemaps' );
|
34 |
|
35 |
+
foreach ( array('google','bing') as $se ) {
|
36 |
+
$result = xmlsf_ping( $se, $sitemaps['sitemap'], HOUR_IN_SECONDS );
|
37 |
|
38 |
+
$se_name = 'google' == $se ? __('Google','xml-sitemap-feed') : __('Bing & Yahoo','xml-sitemap-feed');
|
|
|
39 |
|
40 |
+
switch( $result ) {
|
41 |
+
case 200:
|
42 |
+
$msg = sprintf( /* Translators: Search engine / Service name */ __( 'Pinged %s with success.', 'xml-sitemap-feed' ), $se_name );
|
43 |
+
$type = 'updated';
|
44 |
+
break;
|
45 |
|
46 |
+
case 999:
|
47 |
+
$msg = sprintf( /* Translators: Search engine / Service name, interval number */ __( 'Ping %s skipped: Sitemap already sent within the last %d minutes.', 'xml-sitemap-feed' ), $se_name, 60 );
|
48 |
+
$type = 'notice-warning';
|
49 |
+
break;
|
|
|
50 |
|
51 |
+
case '':
|
52 |
+
$msg = sprintf( translate('Oops: %s'), translate('Something went wrong.') );
|
53 |
+
$type = 'error';
|
54 |
+
break;
|
55 |
|
56 |
+
default:
|
57 |
+
$msg = sprintf( /* Translators: Search engine / Service name, response code number */ __( 'Ping %s failed with response code: %d', 'xml-sitemap-feed' ), $se_name, $result );
|
58 |
+
$type = 'error';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
59 |
}
|
60 |
|
61 |
+
add_settings_error( 'ping_sitemap', 'ping_sitemap', $msg, $type );
|
|
|
62 |
}
|
63 |
+
|
64 |
}
|
65 |
|
66 |
/**
|
185 |
/* When the post is saved, save our meta data */
|
186 |
public function save_metadata( $post_id )
|
187 |
{
|
188 |
+
if (
|
189 |
+
// verify nonce
|
190 |
+
! isset($_POST['_xmlsf_nonce']) || ! wp_verify_nonce($_POST['_xmlsf_nonce'], XMLSF_BASENAME) ||
|
191 |
+
// user not allowed
|
192 |
+
! current_user_can( 'edit_post', $post_id )
|
193 |
+
) return;
|
194 |
|
195 |
// _xmlsf_priority
|
196 |
if ( empty($_POST['xmlsf_priority']) )
|
197 |
delete_post_meta($post_id, '_xmlsf_priority');
|
198 |
else
|
199 |
+
update_post_meta($post_id, '_xmlsf_priority', xmlsf_sanitize_priority( $_POST['xmlsf_priority'] ) );
|
200 |
|
201 |
// _xmlsf_exclude
|
202 |
if ( empty($_POST['xmlsf_exclude']) )
|
206 |
}
|
207 |
|
208 |
/**
|
209 |
+
* Gets public taxonomies
|
210 |
+
*/
|
211 |
+
public function public_taxonomies()
|
212 |
{
|
213 |
if ( !isset( $this->public_taxonomies ) ) {
|
|
|
|
|
214 |
$this->public_taxonomies = xmlsf_public_taxonomies();
|
215 |
}
|
216 |
|
218 |
}
|
219 |
|
220 |
/**
|
221 |
+
* Add options page
|
222 |
+
*/
|
223 |
+
public function add_settings_page()
|
224 |
{
|
225 |
+
// This page will be under "Settings"
|
226 |
+
$this->screen_id = add_options_page(
|
227 |
+
__('XML Sitemap','xml-sitemap-feed'),
|
228 |
+
__('XML Sitemap','xml-sitemap-feed'),
|
229 |
+
'manage_options',
|
230 |
+
'xmlsf',
|
231 |
+
array( $this, 'settings_page' )
|
232 |
+
);
|
233 |
+
}
|
234 |
+
|
235 |
+
/**
|
236 |
+
* Options page callback
|
237 |
+
*/
|
238 |
+
public function settings_page()
|
239 |
+
{
|
240 |
// SECTIONS & SETTINGS
|
241 |
// post_types
|
242 |
add_settings_section( 'xml_sitemap_post_types_section', /*'<a name="xmlsf"></a>'.__('XML Sitemap','xml-sitemap-feed')*/ '', '', 'xmlsf_post_types' );
|
255 |
// taxonomies
|
256 |
add_settings_section( 'xml_sitemap_taxonomies_section', /*'<a name="xmlsf"></a>'.__('XML Sitemap','xml-sitemap-feed')*/ '', '', 'xmlsf_taxonomies' );
|
257 |
add_settings_field( 'xmlsf_taxonomy_settings', translate('General'), array($this,'taxonomy_settings_field'), 'xmlsf_taxonomies', 'xml_sitemap_taxonomies_section' );
|
258 |
+
//$taxonomy_settings = get_option( 'xmlsf_taxonomy_settings' );
|
259 |
+
if ( apply_filters( 'xmlsf_taxonomies', ! empty( get_option( 'xmlsf_taxonomies' ) ) ) )
|
260 |
+
add_settings_field( 'xmlsf_taxonomies', __('Taxonomies','xml-sitemap-feed'), array($this,'taxonomies_field'), 'xmlsf_taxonomies', 'xml_sitemap_taxonomies_section' );
|
261 |
|
262 |
add_settings_section( 'xml_sitemap_advanced_section', /*'<a name="xmlsf"></a>'.__('XML Sitemap','xml-sitemap-feed')*/ '', '', 'xmlsf_advanced' );
|
263 |
// custom urls
|
271 |
$url = trailingslashit(get_bloginfo('url')) . ( xmlsf()->plain_permalinks() || empty($sitemaps['sitemap']) ? '?feed=sitemap' : $sitemaps['sitemap'] );
|
272 |
|
273 |
include XMLSF_DIR . '/views/admin/page-sitemap.php';
|
274 |
+
}
|
275 |
|
276 |
+
/**
|
277 |
+
* Register and add settings
|
278 |
+
*/
|
279 |
+
public function register_settings()
|
280 |
+
{
|
281 |
// Help tab
|
282 |
add_action( 'load-'.$this->screen_id, array($this,'help_tab') );
|
283 |
|
290 |
register_setting( 'xmlsf_advanced', 'xmlsf_urls', array('XMLSF_Admin_Sitemap_Sanitize','custom_urls_settings') );
|
291 |
// custom sitemaps
|
292 |
register_setting( 'xmlsf_advanced', 'xmlsf_custom_sitemaps', array('XMLSF_Admin_Sitemap_Sanitize','custom_sitemaps_settings') );
|
293 |
+
}
|
294 |
|
295 |
/**
|
296 |
* XML SITEMAP SECTION
|
363 |
|
364 |
public function taxonomy_settings_field()
|
365 |
{
|
|
|
366 |
$taxonomy_settings = get_option( 'xmlsf_taxonomy_settings' );
|
367 |
|
368 |
// The actual fields for data entry
|
386 |
include XMLSF_DIR . '/views/admin/field-sitemap-custom.php';
|
387 |
}
|
388 |
|
389 |
+
public function urls_settings_field()
|
390 |
+
{
|
391 |
$urls = get_option( 'xmlsf_urls' );
|
392 |
$lines = array();
|
393 |
|
controllers/{admin/main.php → class.xmlsf-admin.php}
RENAMED
@@ -3,8 +3,14 @@
|
|
3 |
* XMLSF Admin CLASS
|
4 |
* ------------------------------ */
|
5 |
|
6 |
-
class
|
7 |
{
|
|
|
|
|
|
|
|
|
|
|
|
|
8 |
/**
|
9 |
* Static files conflicting with this plugin
|
10 |
* @var array
|
@@ -19,24 +25,23 @@ class XMLSF_Admin_Controller
|
|
19 |
|
20 |
/**
|
21 |
* CONSTRUCTOR
|
22 |
-
* Runs on init
|
23 |
*/
|
24 |
|
25 |
function __construct()
|
26 |
{
|
27 |
-
require XMLSF_DIR . '/models/admin
|
28 |
-
require XMLSF_DIR . '/controllers/admin
|
29 |
|
30 |
$this->sitemaps = (array) get_option( 'xmlsf_sitemaps', array() );
|
31 |
|
32 |
if ( isset($this->sitemaps['sitemap']) ) {
|
33 |
-
require XMLSF_DIR . '/models/admin
|
34 |
-
require XMLSF_DIR . '/controllers/admin
|
35 |
}
|
36 |
|
37 |
if ( isset($this->sitemaps['sitemap-news']) ) {
|
38 |
-
require XMLSF_DIR . '/models/admin
|
39 |
-
require XMLSF_DIR . '/controllers/admin
|
40 |
}
|
41 |
|
42 |
// ACTION LINK
|
@@ -49,8 +54,7 @@ class XMLSF_Admin_Controller
|
|
49 |
|
50 |
// ACTIONS & CHECKS
|
51 |
add_action( 'admin_init', array( $this, 'tools_actions' ) );
|
52 |
-
|
53 |
-
add_action( 'admin_init', array( $this, 'static_files' ) );
|
54 |
add_action( 'admin_init', array( $this, 'check_theme_conflicts' ) );
|
55 |
}
|
56 |
|
@@ -260,6 +264,8 @@ class XMLSF_Admin_Controller
|
|
260 |
*/
|
261 |
public function static_files()
|
262 |
{
|
|
|
|
|
263 |
if ( null === self::$static_files )
|
264 |
self::$static_files = get_transient( 'xmlsf_static_files' );
|
265 |
|
@@ -281,7 +287,7 @@ class XMLSF_Admin_Controller
|
|
281 |
}
|
282 |
|
283 |
foreach ( $check_for as $name => $pretty ) {
|
284 |
-
if ( file_exists( $home_path . $pretty ) ) {
|
285 |
self::$static_files[$pretty] = $home_path . $pretty;
|
286 |
}
|
287 |
}
|
@@ -308,23 +314,19 @@ class XMLSF_Admin_Controller
|
|
308 |
public function tools_actions()
|
309 |
{
|
310 |
if ( isset( $_POST['xmlsf-clear-settings-submit'] ) && isset( $_POST['xmlsf-clear-settings'] ) ) {
|
311 |
-
if (
|
312 |
$this->clear_settings( $_POST['xmlsf-clear-settings'] );
|
313 |
-
} else {
|
314 |
-
add_settings_error( 'clear_settings', 'clear_settings_failed', translate('Security check failed.') );
|
315 |
}
|
316 |
}
|
317 |
|
318 |
if ( isset( $_POST['xmlsf-delete-submit'] ) ) {
|
319 |
-
if (
|
320 |
$this->delete_static_files();
|
321 |
-
} else {
|
322 |
-
add_settings_error( 'delete_files', 'delete_files_failed', translate('Security check failed.') );
|
323 |
}
|
324 |
}
|
325 |
|
326 |
if ( isset( $_POST['xmlsf-check-conflicts'] ) ) {
|
327 |
-
if (
|
328 |
// reset ignored warnings
|
329 |
delete_user_meta( get_current_user_id(), 'xmlsf_dismissed' );
|
330 |
self::$dismissed = array();
|
@@ -332,20 +334,43 @@ class XMLSF_Admin_Controller
|
|
332 |
$this->check_static_files();
|
333 |
if ( empty( self::$static_files ) )
|
334 |
add_settings_error( 'static_files_notice', 'static_files', __('No conflicting static files found.','xml-sitemap-feed'), 'notice-info');
|
335 |
-
} else {
|
336 |
-
add_settings_error( 'check_conflicts', 'check_conflicts_failed', translate('Security check failed.') );
|
337 |
}
|
338 |
}
|
339 |
|
340 |
if ( isset( $_POST['xmlsf-flush-rewrite-rules'] ) ) {
|
341 |
-
if (
|
342 |
// flush rewrite rules
|
343 |
flush_rewrite_rules();
|
344 |
add_settings_error( 'flush_admin_notice', 'flush_admin_notice', __('WordPress rewrite rules have been flushed.','xml-sitemap-feed'), 'updated' );
|
345 |
-
} else {
|
346 |
-
add_settings_error( 'flush_rewrite_rules', 'flush_rewrite_rules_failed', translate('Security check failed.') );
|
347 |
}
|
348 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
349 |
}
|
350 |
|
351 |
public function notices_actions()
|
@@ -353,11 +378,9 @@ class XMLSF_Admin_Controller
|
|
353 |
self::$dismissed = (array) get_user_meta( get_current_user_id(), 'xmlsf_dismissed' );
|
354 |
|
355 |
if ( isset( $_POST['xmlsf-dismiss-submit'] ) && isset( $_POST['xmlsf-dismiss'] ) ) {
|
356 |
-
if (
|
357 |
add_user_meta( get_current_user_id(), 'xmlsf_dismissed', $_POST['xmlsf-dismiss'], false );
|
358 |
self::$dismissed[] = $_POST['xmlsf-dismiss'];
|
359 |
-
} else {
|
360 |
-
add_settings_error( 'dismiss_notice', 'dismiss_notice_failed', translate('Security check failed.') );
|
361 |
}
|
362 |
}
|
363 |
}
|
@@ -365,18 +388,12 @@ class XMLSF_Admin_Controller
|
|
365 |
public function transients_actions()
|
366 |
{
|
367 |
// CATCH TRANSIENT for flushing rewrite rules after the sitemaps setting has changed
|
368 |
-
|
369 |
-
flush_rewrite_rules();
|
370 |
-
if ( defined('WP_DEBUG') && WP_DEBUG == true ) {
|
371 |
-
error_log('Rewrite rules flushed by XML Sitemap Feeds.');
|
372 |
-
}
|
373 |
-
}
|
374 |
|
375 |
// CATCH TRANSIENT for static file check
|
376 |
-
|
377 |
-
$this->check_static_files();
|
378 |
-
}
|
379 |
}
|
|
|
380 |
}
|
381 |
|
382 |
-
new
|
3 |
* XMLSF Admin CLASS
|
4 |
* ------------------------------ */
|
5 |
|
6 |
+
class XMLSF_Admin
|
7 |
{
|
8 |
+
/**
|
9 |
+
* Sitemaps settings
|
10 |
+
* @var array
|
11 |
+
*/
|
12 |
+
private $sitemaps = array();
|
13 |
+
|
14 |
/**
|
15 |
* Static files conflicting with this plugin
|
16 |
* @var array
|
25 |
|
26 |
/**
|
27 |
* CONSTRUCTOR
|
|
|
28 |
*/
|
29 |
|
30 |
function __construct()
|
31 |
{
|
32 |
+
require XMLSF_DIR . '/models/functions.admin.php';
|
33 |
+
require XMLSF_DIR . '/controllers/class.xmlsf-admin-notices.php';
|
34 |
|
35 |
$this->sitemaps = (array) get_option( 'xmlsf_sitemaps', array() );
|
36 |
|
37 |
if ( isset($this->sitemaps['sitemap']) ) {
|
38 |
+
require XMLSF_DIR . '/models/class.xmlsf-admin-sitemap-sanitize.php';
|
39 |
+
require XMLSF_DIR . '/controllers/class.xmlsf-admin-sitemap.php';
|
40 |
}
|
41 |
|
42 |
if ( isset($this->sitemaps['sitemap-news']) ) {
|
43 |
+
require XMLSF_DIR . '/models/class.xmlsf-admin-sitemap-news-sanitize.php';
|
44 |
+
require XMLSF_DIR . '/controllers/class.xmlsf-admin-sitemap-news.php';
|
45 |
}
|
46 |
|
47 |
// ACTION LINK
|
54 |
|
55 |
// ACTIONS & CHECKS
|
56 |
add_action( 'admin_init', array( $this, 'tools_actions' ) );
|
57 |
+
add_action( 'admin_init', array( $this, 'static_files' ) );
|
|
|
58 |
add_action( 'admin_init', array( $this, 'check_theme_conflicts' ) );
|
59 |
}
|
60 |
|
264 |
*/
|
265 |
public function static_files()
|
266 |
{
|
267 |
+
if ( ( is_multisite() && ! is_super_admin() ) || ! current_user_can( 'manage_options' ) ) return;
|
268 |
+
|
269 |
if ( null === self::$static_files )
|
270 |
self::$static_files = get_transient( 'xmlsf_static_files' );
|
271 |
|
287 |
}
|
288 |
|
289 |
foreach ( $check_for as $name => $pretty ) {
|
290 |
+
if ( ! empty( $pretty ) && file_exists( $home_path . $pretty ) ) {
|
291 |
self::$static_files[$pretty] = $home_path . $pretty;
|
292 |
}
|
293 |
}
|
314 |
public function tools_actions()
|
315 |
{
|
316 |
if ( isset( $_POST['xmlsf-clear-settings-submit'] ) && isset( $_POST['xmlsf-clear-settings'] ) ) {
|
317 |
+
if ( xmlsf_verify_nonce('help') ) {
|
318 |
$this->clear_settings( $_POST['xmlsf-clear-settings'] );
|
|
|
|
|
319 |
}
|
320 |
}
|
321 |
|
322 |
if ( isset( $_POST['xmlsf-delete-submit'] ) ) {
|
323 |
+
if ( xmlsf_verify_nonce('help') ) {
|
324 |
$this->delete_static_files();
|
|
|
|
|
325 |
}
|
326 |
}
|
327 |
|
328 |
if ( isset( $_POST['xmlsf-check-conflicts'] ) ) {
|
329 |
+
if ( xmlsf_verify_nonce('help') ) {
|
330 |
// reset ignored warnings
|
331 |
delete_user_meta( get_current_user_id(), 'xmlsf_dismissed' );
|
332 |
self::$dismissed = array();
|
334 |
$this->check_static_files();
|
335 |
if ( empty( self::$static_files ) )
|
336 |
add_settings_error( 'static_files_notice', 'static_files', __('No conflicting static files found.','xml-sitemap-feed'), 'notice-info');
|
|
|
|
|
337 |
}
|
338 |
}
|
339 |
|
340 |
if ( isset( $_POST['xmlsf-flush-rewrite-rules'] ) ) {
|
341 |
+
if ( xmlsf_verify_nonce('help') ) {
|
342 |
// flush rewrite rules
|
343 |
flush_rewrite_rules();
|
344 |
add_settings_error( 'flush_admin_notice', 'flush_admin_notice', __('WordPress rewrite rules have been flushed.','xml-sitemap-feed'), 'updated' );
|
|
|
|
|
345 |
}
|
346 |
}
|
347 |
+
|
348 |
+
if ( isset( $_POST['xmlsf-clear-term-meta'] ) ) {
|
349 |
+
if ( xmlsf_verify_nonce('help') ) {
|
350 |
+
// remove metadata
|
351 |
+
global $wpdb;
|
352 |
+
// terms meta
|
353 |
+
$wpdb->delete( $wpdb->prefix.'termmeta', array( 'meta_key' => 'term_modified' ) );
|
354 |
+
add_settings_error( 'clear_meta_notice', 'clear_meta_notice', __('Sitemap term meta cache has been cleared.','xml-sitemap-feed'), 'updated' );
|
355 |
+
}
|
356 |
+
}
|
357 |
+
|
358 |
+
if ( isset( $_POST['xmlsf-clear-post-meta'] ) ) {
|
359 |
+
if ( xmlsf_verify_nonce('help') ) {
|
360 |
+
// remove metadata
|
361 |
+
global $wpdb;
|
362 |
+
// images meta
|
363 |
+
$wpdb->delete( $wpdb->prefix.'postmeta', array( 'meta_key' => '_xmlsf_image_attached' ) );
|
364 |
+
$wpdb->delete( $wpdb->prefix.'postmeta', array( 'meta_key' => '_xmlsf_image_featured' ) );
|
365 |
+
update_option( 'xmlsf_images_meta_primed', array() );
|
366 |
+
// comments meta
|
367 |
+
$wpdb->delete( $wpdb->prefix.'postmeta', array( 'meta_key' => '_xmlsf_comment_date' ) );
|
368 |
+
update_option( 'xmlsf_comments_meta_primed', array() );
|
369 |
+
|
370 |
+
add_settings_error( 'clear_meta_notice', 'clear_meta_notice', __('Sitemap post meta caches have been cleared.','xml-sitemap-feed'), 'updated' );
|
371 |
+
}
|
372 |
+
}
|
373 |
+
|
374 |
}
|
375 |
|
376 |
public function notices_actions()
|
378 |
self::$dismissed = (array) get_user_meta( get_current_user_id(), 'xmlsf_dismissed' );
|
379 |
|
380 |
if ( isset( $_POST['xmlsf-dismiss-submit'] ) && isset( $_POST['xmlsf-dismiss'] ) ) {
|
381 |
+
if ( xmlsf_verify_nonce('notice') ) {
|
382 |
add_user_meta( get_current_user_id(), 'xmlsf_dismissed', $_POST['xmlsf-dismiss'], false );
|
383 |
self::$dismissed[] = $_POST['xmlsf-dismiss'];
|
|
|
|
|
384 |
}
|
385 |
}
|
386 |
}
|
388 |
public function transients_actions()
|
389 |
{
|
390 |
// CATCH TRANSIENT for flushing rewrite rules after the sitemaps setting has changed
|
391 |
+
delete_transient('xmlsf_flush_rewrite_rules') && flush_rewrite_rules();
|
|
|
|
|
|
|
|
|
|
|
392 |
|
393 |
// CATCH TRANSIENT for static file check
|
394 |
+
delete_transient('xmlsf_check_static_files') && $this->check_static_files();
|
|
|
|
|
395 |
}
|
396 |
+
|
397 |
}
|
398 |
|
399 |
+
new XMLSF_Admin();
|
controllers/class.xmlsf-sitemap-news.php
ADDED
@@ -0,0 +1,89 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/* ------------------------------
|
3 |
+
* XMLSF Controller CLASS
|
4 |
+
* ------------------------------ */
|
5 |
+
|
6 |
+
class XMLSF_Sitemap_News
|
7 |
+
{
|
8 |
+
/**
|
9 |
+
* Sitemap index name
|
10 |
+
* @var string
|
11 |
+
*/
|
12 |
+
private $sitemap = 'sitemap-news.xml';
|
13 |
+
|
14 |
+
/**
|
15 |
+
* Post types included in sitemap index
|
16 |
+
* @var array
|
17 |
+
*/
|
18 |
+
private $post_types;
|
19 |
+
|
20 |
+
/**
|
21 |
+
* CONSTRUCTOR
|
22 |
+
* Runs on init
|
23 |
+
*/
|
24 |
+
|
25 |
+
function __construct( $sitemap )
|
26 |
+
{
|
27 |
+
$this->sitemap = $sitemap;
|
28 |
+
|
29 |
+
// PINGING
|
30 |
+
add_action( 'transition_post_status', array( $this, 'do_ping' ), 10, 3 );
|
31 |
+
|
32 |
+
// FEED TEMPLATES
|
33 |
+
add_action( 'do_feed_sitemap-news', 'xmlsf_news_load_template', 10, 1 );
|
34 |
+
}
|
35 |
+
|
36 |
+
/**
|
37 |
+
* Do pings, hooked to transition post status
|
38 |
+
*
|
39 |
+
* @param $new_status
|
40 |
+
* @param $old_status
|
41 |
+
* @param $post
|
42 |
+
*/
|
43 |
+
public function do_ping( $new_status, $old_status, $post )
|
44 |
+
{
|
45 |
+
// bail out when already published or not publishing
|
46 |
+
if ( $old_status == 'publish' || $new_status != 'publish' ) return;
|
47 |
+
|
48 |
+
// bail out when REST API call without new post data, see Gutenberg issue https://github.com/WordPress/gutenberg/issues/15094
|
49 |
+
// NO ! Don't bail out now because there will be no other chance as long as bug is not fixed...
|
50 |
+
// ... we'll have to make do without $_POST data so potentially incorrect get_post_meta() information.
|
51 |
+
//if ( defined( 'REST_REQUEST' ) && REST_REQUEST ) return;
|
52 |
+
|
53 |
+
// bail out when Google ping not checked
|
54 |
+
if ( ! in_array( 'google', (array) get_option( 'xmlsf_ping' ) ) ) return;
|
55 |
+
|
56 |
+
// we're saving from post edit screen
|
57 |
+
if ( ! empty( $_POST ) && 'editpost' == $_POST['action'] ) {
|
58 |
+
// bail out when exclude field is checked
|
59 |
+
if ( ! empty( $_POST['_xmlsf_news_exclude'] ) ) return;
|
60 |
+
} else {
|
61 |
+
// fall back on exclude meta data from DB whic may be outdated (see bug)
|
62 |
+
if ( ! empty( get_post_meta( $post->ID, '_xmlsf_news_exclude' ) ) ) return;
|
63 |
+
}
|
64 |
+
|
65 |
+
$news_tags = (array) get_option('xmlsf_news_tags');
|
66 |
+
|
67 |
+
error_log('6');
|
68 |
+
// is this an active post type?
|
69 |
+
if ( empty( $news_tags['post_type'] ) || ! in_array( $post->post_type, (array) $news_tags['post_type'] ) ) return;
|
70 |
+
|
71 |
+
error_log('7');
|
72 |
+
// are categories limited and is not in correct category?
|
73 |
+
if ( ! empty( $news_tags['categories'] ) ) {
|
74 |
+
$cats = wp_get_post_categories( $post->ID, array( 'fields' => 'ids' ) );
|
75 |
+
if ( empty( array_intersect( (array) $cats, (array) $news_tags['categories'] ) ) ) return;
|
76 |
+
}
|
77 |
+
|
78 |
+
// PING
|
79 |
+
xmlsf_ping( 'google', $this->sitemap, 5 * MINUTE_IN_SECONDS );
|
80 |
+
}
|
81 |
+
|
82 |
+
}
|
83 |
+
|
84 |
+
/**
|
85 |
+
* set up the news sitemap template
|
86 |
+
*/
|
87 |
+
function xmlsf_news_load_template() {
|
88 |
+
load_template( XMLSF_DIR . '/views/feed-sitemap-news.php' );
|
89 |
+
}
|
controllers/class.xmlsf-sitemap.php
ADDED
@@ -0,0 +1,414 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/* ------------------------------
|
4 |
+
* XMLSF Controller CLASS
|
5 |
+
* ------------------------------ */
|
6 |
+
|
7 |
+
class XMLSF_Sitemap
|
8 |
+
{
|
9 |
+
/**
|
10 |
+
* Sitemap index name
|
11 |
+
* @var string
|
12 |
+
*/
|
13 |
+
private $sitemap = 'sitemap.xml';
|
14 |
+
|
15 |
+
/**
|
16 |
+
* Post types included in sitemap index
|
17 |
+
* @var array
|
18 |
+
*/
|
19 |
+
private $post_types = array();
|
20 |
+
|
21 |
+
/**
|
22 |
+
* CONSTRUCTOR
|
23 |
+
* Runs on init
|
24 |
+
*/
|
25 |
+
|
26 |
+
function __construct( $sitemap )
|
27 |
+
{
|
28 |
+
$this->sitemap = $sitemap;
|
29 |
+
|
30 |
+
// Cache clearance
|
31 |
+
add_action( 'clean_post_cache', array($this,'clean_post_cache'), 99, 2 );
|
32 |
+
|
33 |
+
// Update term meta lastmod date
|
34 |
+
add_action( 'transition_post_status', array($this,'update_term_modified_meta'), 10, 3 );
|
35 |
+
|
36 |
+
// Update images post meta
|
37 |
+
add_action( 'transition_post_status', array($this,'update_post_images_meta'), 10, 3 );
|
38 |
+
|
39 |
+
// Update last comment date post meta
|
40 |
+
add_action( 'transition_comment_status', array($this,'update_post_comment_meta'), 10, 3 );
|
41 |
+
add_action( 'comment_post', array($this,'update_post_comment_meta_cp'), 10, 3 ); // when comment is not held for moderation
|
42 |
+
|
43 |
+
// PINGING
|
44 |
+
add_action( 'transition_post_status', array($this,'do_pings'), 10, 3 );
|
45 |
+
|
46 |
+
// FEED TEMPLATES
|
47 |
+
add_action( 'do_feed_sitemap', 'xmlsf_load_template_index', 10, 1 );
|
48 |
+
add_action( 'do_feed_sitemap_index', 'xmlsf_load_template_index', 10, 1 );
|
49 |
+
add_action( 'do_feed_sitemap-home', 'xmlsf_load_template_home', 10, 1 );
|
50 |
+
add_action( 'do_feed_sitemap-custom', 'xmlsf_load_template_custom', 10, 1 );
|
51 |
+
|
52 |
+
$this->post_types = (array) get_option( 'xmlsf_post_types', array() );
|
53 |
+
|
54 |
+
if ( is_array($this->post_types) ) {
|
55 |
+
foreach ( $this->post_types as $post_type => $settings ) {
|
56 |
+
if ( !empty($settings['active']) )
|
57 |
+
// FEED TEMPLATES
|
58 |
+
add_action( 'do_feed_sitemap-posttype-'.$post_type, 'xmlsf_load_template', 10, 1 );
|
59 |
+
}
|
60 |
+
}
|
61 |
+
|
62 |
+
foreach ( xmlsf_get_taxonomies() as $name ) {
|
63 |
+
add_action( 'do_feed_sitemap-taxonomy-'.$name, 'xmlsf_load_template_taxonomy', 10, 1 );
|
64 |
+
}
|
65 |
+
}
|
66 |
+
|
67 |
+
/**
|
68 |
+
* Do pings, hooked to transition post status
|
69 |
+
*
|
70 |
+
* @param $new_status
|
71 |
+
* @param $old_status
|
72 |
+
* @param $post
|
73 |
+
*/
|
74 |
+
public function do_pings( $new_status, $old_status, $post )
|
75 |
+
{
|
76 |
+
// bail out when already published or not publishing
|
77 |
+
if ( $old_status == 'publish' || $new_status != 'publish' ) return;
|
78 |
+
|
79 |
+
// bail out when REST API call without new post data, see Gutenberg issue https://github.com/WordPress/gutenberg/issues/15094
|
80 |
+
// NO ! Don't bail out now because there will be no other chance as long as bug is not fixed...
|
81 |
+
// ... we'll have to make do without $_POST data so potentially incorrect get_post_meta() information.
|
82 |
+
//if ( defined( 'REST_REQUEST' ) && REST_REQUEST ) return;
|
83 |
+
|
84 |
+
// bail out when inactive post type
|
85 |
+
if ( ! array_key_exists( $post->post_type, (array) $this->post_types ) ) return;
|
86 |
+
|
87 |
+
// we're saving from post edit screen (f.e. 'inline-save' would be from quick edit)
|
88 |
+
if ( ! empty( $_POST ) && 'editpost' == $_POST['action'] ) {
|
89 |
+
// bail out when exclude field is checked
|
90 |
+
if ( ! empty( $_POST['_xmlsf_exclude'] ) ) return;
|
91 |
+
} else {
|
92 |
+
// fall back on exclude meta data from DB whic may be outdated (see bug)
|
93 |
+
if ( ! empty( get_post_meta( $post->ID, '_xmlsf_exclude' ) ) ) return;
|
94 |
+
}
|
95 |
+
|
96 |
+
$ping = (array) get_option( 'xmlsf_ping', array() );
|
97 |
+
// PING !
|
98 |
+
foreach ( $ping as $se ) {
|
99 |
+
xmlsf_ping( $se, $this->sitemap, HOUR_IN_SECONDS );
|
100 |
+
}
|
101 |
+
}
|
102 |
+
|
103 |
+
/**
|
104 |
+
* Cache delete on clean_post_cache
|
105 |
+
*
|
106 |
+
* @param $post_ID
|
107 |
+
* @param $post
|
108 |
+
*/
|
109 |
+
public function clean_post_cache( $post_ID, $post )
|
110 |
+
{
|
111 |
+
// are we moving the post in or out of published status?
|
112 |
+
wp_cache_delete( 'xmlsf_get_archives', 'general' );
|
113 |
+
|
114 |
+
// TODO get year / month here to delete specific keys too !!!!
|
115 |
+
$m = mysql2date( 'Ym', $post->post_date, false );
|
116 |
+
$y = substr( $m, 0, 4 );
|
117 |
+
|
118 |
+
// clear possible last post modified cache keys
|
119 |
+
wp_cache_delete( 'lastpostmodified:gmt', 'timeinfo' ); // should be handled by WP core?
|
120 |
+
wp_cache_delete( 'lastpostmodified'.$y.':gmt', 'timeinfo' );
|
121 |
+
wp_cache_delete( 'lastpostmodified'.$m.':gmt', 'timeinfo' );
|
122 |
+
wp_cache_delete( 'lastpostmodified'.$y.':gmt:'.$post->post_type, 'timeinfo' );
|
123 |
+
wp_cache_delete( 'lastpostmodified'.$m.':gmt:'.$post->post_type, 'timeinfo' );
|
124 |
+
|
125 |
+
// clear possible last post date cache keys
|
126 |
+
wp_cache_delete( 'lastpostdate:gmt', 'timeinfo' );
|
127 |
+
wp_cache_delete( 'lastpostdate:gmt:'.$post->post_type, 'timeinfo' );
|
128 |
+
|
129 |
+
// clear possible fist post date cache keys
|
130 |
+
wp_cache_delete( 'firstpostdate:gmt', 'timeinfo' );
|
131 |
+
wp_cache_delete( 'firstpostdate:gmt:'.$post->post_type, 'timeinfo' );
|
132 |
+
}
|
133 |
+
|
134 |
+
/**
|
135 |
+
* Update term modified meta, hooked to transition post status
|
136 |
+
*
|
137 |
+
* @param $new_status
|
138 |
+
* @param $old_status
|
139 |
+
* @param $post
|
140 |
+
*/
|
141 |
+
public function update_term_modified_meta( $new_status, $old_status, $post )
|
142 |
+
{
|
143 |
+
// bail when...
|
144 |
+
if (
|
145 |
+
// no status transition or not moving in or out of 'publish' status
|
146 |
+
$old_status == $new_status || ( 'publish' != $new_status && 'publish' != $old_status ) ||
|
147 |
+
// inactive post type
|
148 |
+
! array_key_exists($post->post_type, $this->post_types) || empty( $this->post_types[$post->post_type]['active'] )
|
149 |
+
) return;
|
150 |
+
|
151 |
+
$taxonomy_settings = get_option( 'xmlsf_taxonomy_settings' );
|
152 |
+
|
153 |
+
// bail if no taxonomies activated
|
154 |
+
if ( ! is_array($taxonomy_settings) || empty( $taxonomy_settings['active'] ) )
|
155 |
+
return;
|
156 |
+
|
157 |
+
$taxonomies = get_option( 'xmlsf_taxonomies' );
|
158 |
+
if ( empty( $taxonomies ) )
|
159 |
+
$taxonomies = xmlsf_public_taxonomies();
|
160 |
+
|
161 |
+
$term_ids = array();
|
162 |
+
foreach ( (array) $taxonomies as $slug => $name ) {
|
163 |
+
$terms = wp_get_post_terms( $post->ID, $slug, array( 'fields' => 'ids' ));
|
164 |
+
if ( !is_wp_error($terms) ) {
|
165 |
+
$term_ids = array_merge( $term_ids, $terms );
|
166 |
+
}
|
167 |
+
}
|
168 |
+
|
169 |
+
$time = date('Y-m-d H:i:s');
|
170 |
+
|
171 |
+
foreach( $term_ids as $id ) {
|
172 |
+
update_term_meta( $id, 'term_modified', $time );
|
173 |
+
}
|
174 |
+
}
|
175 |
+
|
176 |
+
/**
|
177 |
+
* Update post images meta, hooked to transition post status
|
178 |
+
*
|
179 |
+
* @since 5.2
|
180 |
+
*
|
181 |
+
* @param $new_status
|
182 |
+
* @param $old_status
|
183 |
+
* @param $post
|
184 |
+
*/
|
185 |
+
public function update_post_images_meta( $new_status, $old_status, $post )
|
186 |
+
{
|
187 |
+
// bail when...
|
188 |
+
if (
|
189 |
+
// not publishing or updating
|
190 |
+
$new_status != 'publish' ||
|
191 |
+
// inactive post type
|
192 |
+
! array_key_exists($post->post_type, $this->post_types) || empty( $this->post_types[$post->post_type]['active'] ) ||
|
193 |
+
// no image tags active
|
194 |
+
empty( $this->post_types[$post->post_type]['tags']['image'] )
|
195 |
+
) return;
|
196 |
+
|
197 |
+
$which = $this->post_types[$post->post_type]['tags']['image'];
|
198 |
+
|
199 |
+
// delete old image meta data
|
200 |
+
delete_post_meta( $post->ID, '_xmlsf_image_'.$which );
|
201 |
+
|
202 |
+
$this->_add_images_meta( $post, $which );
|
203 |
+
|
204 |
+
}
|
205 |
+
|
206 |
+
/**
|
207 |
+
* Update post comment meta, hooked to transition comment status
|
208 |
+
*
|
209 |
+
* @since 5.2
|
210 |
+
*
|
211 |
+
* @param string $new_status
|
212 |
+
* @param string $old_status
|
213 |
+
* @param object $comment
|
214 |
+
*/
|
215 |
+
public function update_post_comment_meta( $new_status, $old_status, $comment )
|
216 |
+
{
|
217 |
+
// bail when not publishing or unpublishing
|
218 |
+
if ( $old_status == $new_status || ( $new_status != 'approved' && $old_status != 'approved' ) ) return;
|
219 |
+
|
220 |
+
$post_type = get_post_type( $comment->comment_post_ID );
|
221 |
+
|
222 |
+
// bail when...
|
223 |
+
if ( ! array_key_exists($post_type, $this->post_types) // inactive post type
|
224 |
+
|| empty( $this->post_types[$post_type]['update_lastmod_on_comments'] ) // comments date irrelevant
|
225 |
+
) return;
|
226 |
+
|
227 |
+
// update comment meta data
|
228 |
+
update_post_meta( $comment->comment_post_ID, '_xmlsf_comment_date', $comment->comment_date );
|
229 |
+
}
|
230 |
+
|
231 |
+
/**
|
232 |
+
* Update post comment meta, hooked to transition comment status
|
233 |
+
*
|
234 |
+
* @since 5.2
|
235 |
+
*
|
236 |
+
* @param int $comment_ID
|
237 |
+
* @param int $comment_approved
|
238 |
+
* @param array $commentdata
|
239 |
+
*/
|
240 |
+
public function update_post_comment_meta_cp( $comment_ID, $comment_approved, $commentdata )
|
241 |
+
{
|
242 |
+
// bail when not published
|
243 |
+
if ( $comment_approved !== 1 ) return;
|
244 |
+
|
245 |
+
$post_type = get_post_type( $commentdata['comment_post_ID'] );
|
246 |
+
|
247 |
+
// bail when...
|
248 |
+
if ( ! array_key_exists($post_type, $this->post_types) // inactive post type
|
249 |
+
|| empty( $this->post_types[$post_type]['update_lastmod_on_comments'] ) // comments date irrelevant
|
250 |
+
) return;
|
251 |
+
|
252 |
+
// update comment meta data
|
253 |
+
update_post_meta( $commentdata['comment_post_ID'], '_xmlsf_comment_date', $commentdata['comment_date'] );
|
254 |
+
}
|
255 |
+
|
256 |
+
/**
|
257 |
+
* Prefetch all queried posts image and comment meta data
|
258 |
+
*
|
259 |
+
* @since 5.2
|
260 |
+
* @uses global $wp_query
|
261 |
+
*/
|
262 |
+
public function prefetch_posts_meta()
|
263 |
+
{
|
264 |
+
if ( ! is_sitemap() ) return;
|
265 |
+
|
266 |
+
global $wp_query;
|
267 |
+
|
268 |
+
$post_type = $wp_query->get( 'post_type' );
|
269 |
+
|
270 |
+
if ( ! isset($this->post_types[$post_type]) ) return;
|
271 |
+
|
272 |
+
$y = $wp_query->get( 'year' );
|
273 |
+
$m = $wp_query->get( 'm' );
|
274 |
+
if ( empty($m) ) $m = 'all';
|
275 |
+
|
276 |
+
// if image tag active then prefetch images
|
277 |
+
if (
|
278 |
+
isset($this->post_types[$post_type]['tags']) &&
|
279 |
+
is_array( $this->post_types[$post_type]['tags'] ) &&
|
280 |
+
!empty( $this->post_types[$post_type]['tags']['image'] )
|
281 |
+
) {
|
282 |
+
$primed = (array) get_option( 'xmlsf_images_meta_primed', array() );
|
283 |
+
|
284 |
+
if (
|
285 |
+
! isset( $primed[$post_type] ) ||
|
286 |
+
! is_array( $primed[$post_type] ) ||
|
287 |
+
(
|
288 |
+
! in_array( $m, $primed[$post_type] ) &&
|
289 |
+
! in_array( $y, $primed[$post_type] ) &&
|
290 |
+
! in_array( 'all', $primed[$post_type] )
|
291 |
+
)
|
292 |
+
) {
|
293 |
+
// prime images meta data
|
294 |
+
foreach ( $wp_query->posts as $post ) {
|
295 |
+
$this->_add_images_meta( $post, $this->post_types[$post_type]['tags']['image'] );
|
296 |
+
}
|
297 |
+
|
298 |
+
// add query to primed array
|
299 |
+
$primed[$post_type][] = $m;
|
300 |
+
|
301 |
+
// update
|
302 |
+
update_option( 'xmlsf_images_meta_primed', $primed );
|
303 |
+
}
|
304 |
+
}
|
305 |
+
|
306 |
+
// if update_lastmod_on_comments active then prefetch comments
|
307 |
+
if ( !empty($this->post_types[$post_type]['update_lastmod_on_comments']) ) {
|
308 |
+
$primed = (array) get_option( 'xmlsf_comments_meta_primed', array() );
|
309 |
+
|
310 |
+
if (
|
311 |
+
! isset( $primed[$post_type] ) ||
|
312 |
+
! is_array( $primed[$post_type] ) ||
|
313 |
+
(
|
314 |
+
! in_array( $m, $primed[$post_type] ) &&
|
315 |
+
! in_array( $y, $primed[$post_type] ) &&
|
316 |
+
! in_array( 'all', $primed[$post_type] )
|
317 |
+
)
|
318 |
+
) {
|
319 |
+
// prime comment meta data
|
320 |
+
foreach ( $wp_query->posts as $post ) {
|
321 |
+
$this->_add_comment_meta( $post );
|
322 |
+
}
|
323 |
+
|
324 |
+
// add query to primed array
|
325 |
+
$primed[$post_type][] = $m;
|
326 |
+
|
327 |
+
// update
|
328 |
+
update_option( 'xmlsf_comments_meta_primed', $primed );
|
329 |
+
}
|
330 |
+
}
|
331 |
+
|
332 |
+
}
|
333 |
+
|
334 |
+
/**
|
335 |
+
* Set posts images meta data
|
336 |
+
*
|
337 |
+
* @since 5.2
|
338 |
+
* @param array $post Post object
|
339 |
+
* @param string $which
|
340 |
+
*/
|
341 |
+
private function _add_images_meta( $post, $which )
|
342 |
+
{
|
343 |
+
if ( ! is_object($post) || ! isset( $post->ID ) ) return;
|
344 |
+
|
345 |
+
$stored = (array) get_post_meta( $post->ID, '_xmlsf_image_'.$which );
|
346 |
+
|
347 |
+
// populate images and add as meta data
|
348 |
+
foreach ( xmlsf_images_data( $post, $which ) as $data ) {
|
349 |
+
if ( ! in_array( $data, $stored ) )
|
350 |
+
add_post_meta( $post->ID, '_xmlsf_image_'.$which, $data );
|
351 |
+
}
|
352 |
+
}
|
353 |
+
|
354 |
+
/**
|
355 |
+
* Set post comment meta data
|
356 |
+
*
|
357 |
+
* @since 5.2
|
358 |
+
* @param array $post Post object
|
359 |
+
*/
|
360 |
+
private function _add_comment_meta( $post )
|
361 |
+
{
|
362 |
+
if ( ! is_object( $post ) || ! isset( $post->ID ) ) return;
|
363 |
+
|
364 |
+
// get latest post comment
|
365 |
+
$comments = get_comments( array(
|
366 |
+
'status' => 'approve',
|
367 |
+
'number' => 1,
|
368 |
+
'post_id' => $post->ID,
|
369 |
+
) );
|
370 |
+
|
371 |
+
if ( isset( $comments[0]->comment_date ) )
|
372 |
+
update_post_meta( $post->ID, '_xmlsf_comment_date', $comments[0]->comment_date );
|
373 |
+
}
|
374 |
+
|
375 |
+
}
|
376 |
+
|
377 |
+
/**
|
378 |
+
* FEED TEMPLATES
|
379 |
+
*/
|
380 |
+
|
381 |
+
/**
|
382 |
+
* Set up the sitemap index template
|
383 |
+
*/
|
384 |
+
function xmlsf_load_template_index() {
|
385 |
+
load_template( XMLSF_DIR . '/views/feed-sitemap.php' );
|
386 |
+
}
|
387 |
+
|
388 |
+
/**
|
389 |
+
* set up the sitemap home page(s) template
|
390 |
+
*/
|
391 |
+
function xmlsf_load_template_home() {
|
392 |
+
load_template( XMLSF_DIR . '/views/feed-sitemap-home.php' );
|
393 |
+
}
|
394 |
+
|
395 |
+
/**
|
396 |
+
* set up the post types sitemap template
|
397 |
+
*/
|
398 |
+
function xmlsf_load_template() {
|
399 |
+
load_template( XMLSF_DIR . '/views/feed-sitemap-post_type.php' );
|
400 |
+
}
|
401 |
+
|
402 |
+
/**
|
403 |
+
* set up the taxonomy sitemap template
|
404 |
+
*/
|
405 |
+
function xmlsf_load_template_taxonomy() {
|
406 |
+
load_template( XMLSF_DIR . '/views/feed-sitemap-taxonomy.php' );
|
407 |
+
}
|
408 |
+
|
409 |
+
/**
|
410 |
+
* set up the custom sitemap template
|
411 |
+
*/
|
412 |
+
function xmlsf_load_template_custom() {
|
413 |
+
load_template( XMLSF_DIR . '/views/feed-sitemap-custom.php' );
|
414 |
+
}
|
controllers/{global.php → functions.php}
RENAMED
@@ -9,19 +9,15 @@ function xmlsf_init() {
|
|
9 |
// Upgrade/install, maybe...
|
10 |
$db_version = get_option( 'xmlsf_version', 0 );
|
11 |
if ( ! version_compare( XMLSF_VERSION, $db_version, '=' ) ) {
|
12 |
-
|
13 |
new XMLSitemapFeed_Upgrade( $db_version );
|
14 |
}
|
15 |
|
16 |
-
if ( is_admin() ) {
|
17 |
-
require XMLSF_DIR . '/controllers/admin/main.php';
|
18 |
-
}
|
19 |
-
|
20 |
$sitemaps = get_option( 'xmlsf_sitemaps' );
|
21 |
// include sitemaps if any enabled
|
22 |
if ( $sitemaps ) {
|
23 |
// main model functions
|
24 |
-
require XMLSF_DIR . '/models/
|
25 |
|
26 |
// force remove url trailing slash
|
27 |
add_filter( 'user_trailingslashit', 'xmlsf_untrailingslash' );
|
@@ -33,25 +29,33 @@ function xmlsf_init() {
|
|
33 |
add_filter( 'rt_nginx_helper_purge_urls', 'xmlsf_nginx_helper_purge_urls', 10, 2 );
|
34 |
|
35 |
// main controller functions
|
36 |
-
require XMLSF_DIR . '/controllers/
|
|
|
|
|
37 |
|
38 |
// include and instantiate class
|
39 |
xmlsf();
|
40 |
|
41 |
if ( ! empty( $sitemaps['sitemap-news'] ) ) {
|
42 |
-
require XMLSF_DIR . '/models/sitemap-news.php';
|
43 |
add_filter( 'xmlsf_news_post_types', 'xmlsf_news_filter_post_types' );
|
44 |
|
45 |
-
require XMLSF_DIR . '/controllers/sitemap-news.php';
|
46 |
-
new
|
47 |
-
|
|
|
|
|
|
|
48 |
|
49 |
if ( ! empty( $sitemaps['sitemap'] ) ) {
|
50 |
-
require XMLSF_DIR . '/models/sitemap.php';
|
51 |
add_filter( 'xmlsf_post_types', 'xmlsf_filter_post_types' );
|
52 |
|
53 |
-
|
54 |
-
|
|
|
|
|
|
|
55 |
}
|
56 |
|
57 |
// common sitemap element filters
|
@@ -86,7 +90,18 @@ function xmlsf_activate() {
|
|
86 |
function xmlsf_deactivate() {
|
87 |
delete_transient( 'xmlsf_flush_rewrite_rules' );
|
88 |
delete_transient( 'xmlsf_check_static_files' );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
89 |
// remove filter and flush rules
|
90 |
-
remove_filter( 'rewrite_rules_array', 'xmlsf_rewrite_rules',
|
|
|
91 |
flush_rewrite_rules();
|
92 |
}
|
9 |
// Upgrade/install, maybe...
|
10 |
$db_version = get_option( 'xmlsf_version', 0 );
|
11 |
if ( ! version_compare( XMLSF_VERSION, $db_version, '=' ) ) {
|
12 |
+
require_once XMLSF_DIR . '/upgrade.php';
|
13 |
new XMLSitemapFeed_Upgrade( $db_version );
|
14 |
}
|
15 |
|
|
|
|
|
|
|
|
|
16 |
$sitemaps = get_option( 'xmlsf_sitemaps' );
|
17 |
// include sitemaps if any enabled
|
18 |
if ( $sitemaps ) {
|
19 |
// main model functions
|
20 |
+
require XMLSF_DIR . '/models/functions.shared.php';
|
21 |
|
22 |
// force remove url trailing slash
|
23 |
add_filter( 'user_trailingslashit', 'xmlsf_untrailingslash' );
|
29 |
add_filter( 'rt_nginx_helper_purge_urls', 'xmlsf_nginx_helper_purge_urls', 10, 2 );
|
30 |
|
31 |
// main controller functions
|
32 |
+
require XMLSF_DIR . '/controllers/functions.shared.php';
|
33 |
+
|
34 |
+
add_action( 'xmlsf_ping', 'xmlsf_debug_ping', 9, 4 );
|
35 |
|
36 |
// include and instantiate class
|
37 |
xmlsf();
|
38 |
|
39 |
if ( ! empty( $sitemaps['sitemap-news'] ) ) {
|
40 |
+
require XMLSF_DIR . '/models/functions.sitemap-news.php';
|
41 |
add_filter( 'xmlsf_news_post_types', 'xmlsf_news_filter_post_types' );
|
42 |
|
43 |
+
require XMLSF_DIR . '/controllers/class.xmlsf-sitemap-news.php';
|
44 |
+
new XMLSF_Sitemap_News( $sitemaps['sitemap-news'] );
|
45 |
+
|
46 |
+
// add feed type, news can now be accessed via /feed/sitemap-news too
|
47 |
+
add_feed( 'sitemap-news', 'xmlsf_news_load_template' );
|
48 |
+
}
|
49 |
|
50 |
if ( ! empty( $sitemaps['sitemap'] ) ) {
|
51 |
+
require XMLSF_DIR . '/models/functions.sitemap.php';
|
52 |
add_filter( 'xmlsf_post_types', 'xmlsf_filter_post_types' );
|
53 |
|
54 |
+
xmlsf_sitemap( $sitemaps['sitemap'] );
|
55 |
+
|
56 |
+
// add feed type, index can now be accessed via /feed/sitemap too
|
57 |
+
add_feed( 'sitemap', 'xmlsf_load_template_index' );
|
58 |
+
//add_filter( 'feed_content_type', 'xmlsf_content_type', 10, 2 );
|
59 |
}
|
60 |
|
61 |
// common sitemap element filters
|
90 |
function xmlsf_deactivate() {
|
91 |
delete_transient( 'xmlsf_flush_rewrite_rules' );
|
92 |
delete_transient( 'xmlsf_check_static_files' );
|
93 |
+
|
94 |
+
// remove metadata
|
95 |
+
global $wpdb;
|
96 |
+
// posts meta
|
97 |
+
$wpdb->delete( $wpdb->prefix.'postmeta', array( 'meta_key' => '_xmlsf_image_attached' ) );
|
98 |
+
$wpdb->delete( $wpdb->prefix.'postmeta', array( 'meta_key' => '_xmlsf_image_featured' ) );
|
99 |
+
$wpdb->delete( $wpdb->prefix.'postmeta', array( 'meta_key' => '_xmlsf_comment_date' ) );
|
100 |
+
// terms meta
|
101 |
+
$wpdb->delete( $wpdb->prefix.'termmeta', array( 'meta_key' => 'term_modified' ) );
|
102 |
+
|
103 |
// remove filter and flush rules
|
104 |
+
remove_filter( 'rewrite_rules_array', 'xmlsf_rewrite_rules', 99 );
|
105 |
+
// how to unset add_feed() ?
|
106 |
flush_rewrite_rules();
|
107 |
}
|
controllers/functions.shared.php
ADDED
@@ -0,0 +1,73 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* WPML: switch language
|
5 |
+
* @see https://wpml.org/wpml-hook/wpml_post_language_details/
|
6 |
+
*/
|
7 |
+
function xmlsf_wpml_language_switcher() {
|
8 |
+
global $sitepress, $post;
|
9 |
+
if ( isset( $sitepress ) ) {
|
10 |
+
$post_language = apply_filters( 'wpml_post_language_details', NULL, $post->ID );
|
11 |
+
$sitepress->switch_lang( $post_language['language_code'] );
|
12 |
+
}
|
13 |
+
}
|
14 |
+
|
15 |
+
/**
|
16 |
+
* Generator info
|
17 |
+
*/
|
18 |
+
function xmlsf_generator() {
|
19 |
+
$date = date( 'c' );
|
20 |
+
|
21 |
+
require XMLSF_DIR . '/views/_generator.php';
|
22 |
+
}
|
23 |
+
|
24 |
+
/**
|
25 |
+
* Usage info for debugging
|
26 |
+
*/
|
27 |
+
function xmlsf_usage() {
|
28 |
+
if ( defined('WP_DEBUG') && WP_DEBUG == true ) {
|
29 |
+
$num = get_num_queries();
|
30 |
+
$mem = function_exists('memory_get_peak_usage') ? round( memory_get_peak_usage()/1024/1024, 2 ) . 'M' : false;
|
31 |
+
$limit = ini_get('memory_limit');
|
32 |
+
|
33 |
+
require XMLSF_DIR . '/views/_usage.php';
|
34 |
+
}
|
35 |
+
}
|
36 |
+
|
37 |
+
/**
|
38 |
+
* Try to turn on ob_gzhandler output compression
|
39 |
+
*/
|
40 |
+
function xmlsf_output_compression() {
|
41 |
+
// try to enable zlib.output_compression or fall back to output buffering with ob_gzhandler
|
42 |
+
if ( false !== ini_set( 'zlib.output_compression', 'On' ) )
|
43 |
+
// if zlib.output_compression turned on, then make sure to remove wp_ob_end_flush_all
|
44 |
+
remove_action( 'shutdown', 'wp_ob_end_flush_all', 1 );
|
45 |
+
else {
|
46 |
+
ob_get_length()
|
47 |
+
|| in_array('ob_gzhandler', ob_list_handlers())
|
48 |
+
|| ob_start('ob_gzhandler');
|
49 |
+
}
|
50 |
+
|
51 |
+
if ( defined('WP_DEBUG') && WP_DEBUG == true ) {
|
52 |
+
// zlib
|
53 |
+
$zlib = ini_get( 'zlib.output_compression' ) ? 'ENABLED' : 'DISABLED';
|
54 |
+
error_log('Zlib output compression '.$zlib);
|
55 |
+
|
56 |
+
// ob_gzhandler
|
57 |
+
$gz = in_array('ob_gzhandler', ob_list_handlers()) ? 'ENABLED' : 'DISABLED';
|
58 |
+
error_log('GZhandler output buffer compression '.$gz);
|
59 |
+
}
|
60 |
+
}
|
61 |
+
|
62 |
+
/**
|
63 |
+
* Error messages for ping
|
64 |
+
*/
|
65 |
+
function xmlsf_debug_ping( $se, $sitemap, $ping_url, $response_code ) {
|
66 |
+
if ( defined('WP_DEBUG') && WP_DEBUG == true ) {
|
67 |
+
if ( $response_code == 999 ) {
|
68 |
+
error_log( 'Ping '. $se .' skipped.' );
|
69 |
+
} else {
|
70 |
+
error_log( 'Pinged '. $ping_url .' with response code: ' . $response_code );
|
71 |
+
}
|
72 |
+
}
|
73 |
+
}
|
controllers/main.php
DELETED
@@ -1,50 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/**
|
4 |
-
* WPML: switch language
|
5 |
-
* @see https://wpml.org/wpml-hook/wpml_post_language_details/
|
6 |
-
*/
|
7 |
-
function xmlsf_wpml_language_switcher() {
|
8 |
-
global $sitepress, $post;
|
9 |
-
if ( isset( $sitepress ) ) {
|
10 |
-
$post_language = apply_filters( 'wpml_post_language_details', NULL, $post->ID );
|
11 |
-
$sitepress->switch_lang( $post_language['language_code'] );
|
12 |
-
}
|
13 |
-
}
|
14 |
-
|
15 |
-
/**
|
16 |
-
* Generator info
|
17 |
-
*/
|
18 |
-
function xmlsf_generator() {
|
19 |
-
$date = date('Y-m-d\TH:i:s+00:00');
|
20 |
-
|
21 |
-
require XMLSF_DIR . '/views/_generator.php';
|
22 |
-
}
|
23 |
-
|
24 |
-
/**
|
25 |
-
* Usage info for debugging
|
26 |
-
*/
|
27 |
-
function xmlsf_usage() {
|
28 |
-
if ( defined('WP_DEBUG') && WP_DEBUG == true ) {
|
29 |
-
$num = get_num_queries();
|
30 |
-
$mem = function_exists('memory_get_peak_usage') ? round(memory_get_peak_usage()/1024/1024,2) : 0;
|
31 |
-
|
32 |
-
require XMLSF_DIR . '/views/_usage.php';
|
33 |
-
}
|
34 |
-
}
|
35 |
-
|
36 |
-
/**
|
37 |
-
* Try to turn on ob_gzhandler output compression
|
38 |
-
*/
|
39 |
-
function xmlsf_ob_gzhandler() {
|
40 |
-
in_array('ob_gzhandler', ob_list_handlers())
|
41 |
-
|| ob_get_contents()
|
42 |
-
|| ini_get("zlib.output_compression")
|
43 |
-
|| ( isset($_SERVER['HTTP_X_VARNISH']) && is_numeric($_SERVER['HTTP_X_VARNISH']) )
|
44 |
-
|| ob_start("ob_gzhandler");
|
45 |
-
|
46 |
-
if ( defined('WP_DEBUG') && WP_DEBUG == true ) {
|
47 |
-
$status = in_array('ob_gzhandler', ob_list_handlers()) ? 'ENABLED' : 'DISABLED';
|
48 |
-
error_log('GZhandler output buffer compression '.$status);
|
49 |
-
}
|
50 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
controllers/sitemap-news.php
DELETED
@@ -1,67 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/* ------------------------------
|
3 |
-
* XMLSF Controller CLASS
|
4 |
-
* ------------------------------ */
|
5 |
-
|
6 |
-
class XMLSF_Sitemap_News_Controller
|
7 |
-
{
|
8 |
-
/**
|
9 |
-
* Sitemap index name
|
10 |
-
* @var string
|
11 |
-
*/
|
12 |
-
private $sitemap = 'sitemap-news.xml';
|
13 |
-
|
14 |
-
/**
|
15 |
-
* Post types included in sitemap index
|
16 |
-
* @var array
|
17 |
-
*/
|
18 |
-
private $post_types;
|
19 |
-
|
20 |
-
/**
|
21 |
-
* CONSTRUCTOR
|
22 |
-
* Runs on init
|
23 |
-
*/
|
24 |
-
|
25 |
-
function __construct( $sitemap )
|
26 |
-
{
|
27 |
-
$this->sitemap = $sitemap;
|
28 |
-
|
29 |
-
// PINGING
|
30 |
-
add_action( 'transition_post_status', array($this,'do_pings'), 10, 3 );
|
31 |
-
|
32 |
-
// FEED TEMPLATES
|
33 |
-
add_action('do_feed_sitemap-news', 'xmlsf_news_load_template', 10, 1);
|
34 |
-
}
|
35 |
-
|
36 |
-
/**
|
37 |
-
* Do pings, hooked to transition post status
|
38 |
-
*
|
39 |
-
* @param $new_status
|
40 |
-
* @param $old_status
|
41 |
-
* @param $post
|
42 |
-
*/
|
43 |
-
public function do_pings( $new_status, $old_status, $post ) {
|
44 |
-
// are we publishing?
|
45 |
-
if ( $old_status == 'publish' || $new_status != 'publish' )
|
46 |
-
return;
|
47 |
-
|
48 |
-
$ping = (array) get_option( 'xmlsf_ping', array() );
|
49 |
-
|
50 |
-
if ( in_array( 'google', $ping ) ) {
|
51 |
-
// check if we've got a post type that is included in our news sitemap
|
52 |
-
// TODO also check category if needed
|
53 |
-
$news_tags = get_option('xmlsf_news_tags');
|
54 |
-
if ( ! empty( $news_tags['post_type'] ) && in_array( $post->post_type, (array) $news_tags['post_type'] ) ) {
|
55 |
-
xmlsf_ping( 'google', $this->sitemap, 5 * MINUTE_IN_SECONDS );
|
56 |
-
}
|
57 |
-
}
|
58 |
-
}
|
59 |
-
|
60 |
-
}
|
61 |
-
|
62 |
-
/**
|
63 |
-
* set up the news sitemap template
|
64 |
-
*/
|
65 |
-
function xmlsf_news_load_template() {
|
66 |
-
load_template( XMLSF_DIR . '/views/feed-sitemap-news.php' );
|
67 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
controllers/sitemap.php
DELETED
@@ -1,241 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/* ------------------------------
|
4 |
-
* XMLSF Controller CLASS
|
5 |
-
* ------------------------------ */
|
6 |
-
|
7 |
-
class XMLSF_Sitemap_Controller
|
8 |
-
{
|
9 |
-
/**
|
10 |
-
* Sitemap index name
|
11 |
-
* @var string
|
12 |
-
*/
|
13 |
-
private $sitemap = 'sitemap.xml';
|
14 |
-
|
15 |
-
/**
|
16 |
-
* Post types included in sitemap index
|
17 |
-
* @var array
|
18 |
-
*/
|
19 |
-
private $post_types;
|
20 |
-
|
21 |
-
/**
|
22 |
-
* CONSTRUCTOR
|
23 |
-
* Runs on init
|
24 |
-
*/
|
25 |
-
|
26 |
-
function __construct( $sitemap )
|
27 |
-
{
|
28 |
-
$this->sitemap = $sitemap;
|
29 |
-
|
30 |
-
// Cache clearance
|
31 |
-
add_action( 'clean_post_cache', array($this,'clean_post_cache'), 99, 2 );
|
32 |
-
|
33 |
-
// Update term meta lastmod date
|
34 |
-
add_action( 'transition_post_status', array($this,'update_term_modified_meta'), 10, 3 );
|
35 |
-
|
36 |
-
// PINGING
|
37 |
-
add_action( 'transition_post_status', array($this,'do_pings'), 10, 3 );
|
38 |
-
|
39 |
-
// FEED TEMPLATES
|
40 |
-
add_action( 'do_feed_sitemap', 'xmlsf_load_template_index', 10, 1 );
|
41 |
-
add_action( 'do_feed_sitemap_index', 'xmlsf_load_template_index', 10, 1 );
|
42 |
-
add_action( 'do_feed_sitemap-home', 'xmlsf_load_template_home', 10, 1 );
|
43 |
-
add_action( 'do_feed_sitemap-custom', 'xmlsf_load_template_custom', 10, 1 );
|
44 |
-
|
45 |
-
$this->post_types = get_option( 'xmlsf_post_types' );
|
46 |
-
|
47 |
-
if ( is_array($this->post_types) ) {
|
48 |
-
foreach ( $this->post_types as $post_type => $settings ) {
|
49 |
-
if ( !empty($settings['active']) )
|
50 |
-
add_action( 'do_feed_sitemap-posttype-'.$post_type, 'xmlsf_load_template', 10, 1 );
|
51 |
-
}
|
52 |
-
}
|
53 |
-
|
54 |
-
foreach ( xmlsf_get_taxonomies() as $name ) {
|
55 |
-
add_action( 'do_feed_sitemap-taxonomy-'.$name, 'xmlsf_load_template_taxonomy', 10, 1 );
|
56 |
-
}
|
57 |
-
}
|
58 |
-
|
59 |
-
/**
|
60 |
-
* Do pings, hooked to transition post status
|
61 |
-
*
|
62 |
-
* @param $new_status
|
63 |
-
* @param $old_status
|
64 |
-
* @param $post
|
65 |
-
*/
|
66 |
-
public function do_pings( $new_status, $old_status, $post ) {
|
67 |
-
// are we publishing?
|
68 |
-
if ( $old_status == 'publish' || $new_status != 'publish' )
|
69 |
-
return;
|
70 |
-
|
71 |
-
$ping = get_option( 'xmlsf_ping' );
|
72 |
-
|
73 |
-
if ( empty( $ping ) )
|
74 |
-
return;
|
75 |
-
|
76 |
-
// check if we've got a post type that is included in our sitemap
|
77 |
-
$post_types = get_option( 'xmlsf_post_types' );
|
78 |
-
if ( array_key_exists( $post->post_type, (array) $this->post_types ) ) {
|
79 |
-
|
80 |
-
foreach ( $ping as $se ) {
|
81 |
-
xmlsf_ping( $se, $this->sitemap, HOUR_IN_SECONDS );
|
82 |
-
}
|
83 |
-
}
|
84 |
-
}
|
85 |
-
|
86 |
-
/**
|
87 |
-
* Cache delete on clean_post_cache
|
88 |
-
*
|
89 |
-
* @param $post_ID
|
90 |
-
* @param $post
|
91 |
-
*/
|
92 |
-
public function clean_post_cache( $post_ID, $post ) {
|
93 |
-
// are we moving the post in or out of published status?
|
94 |
-
wp_cache_delete( 'xmlsf_get_archives', 'general' );
|
95 |
-
|
96 |
-
// TODO get year / month here to delete specific keys too !!!!
|
97 |
-
$m = mysql2date( 'Ym', $post->post_date_gmt, false );
|
98 |
-
$y = substr( $m, 0, 4 );
|
99 |
-
|
100 |
-
// clear possible last post modified cache keys
|
101 |
-
wp_cache_delete( 'lastpostmodified:gmt', 'timeinfo' ); // should be handled by WP core?
|
102 |
-
wp_cache_delete( 'lastpostmodified'.$y.':gmt', 'timeinfo' );
|
103 |
-
wp_cache_delete( 'lastpostmodified'.$m.':gmt', 'timeinfo' );
|
104 |
-
wp_cache_delete( 'lastpostmodified'.$y.':gmt:'.$post->post_type, 'timeinfo' );
|
105 |
-
wp_cache_delete( 'lastpostmodified'.$m.':gmt:'.$post->post_type, 'timeinfo' );
|
106 |
-
|
107 |
-
// clear possible last post date cache keys
|
108 |
-
wp_cache_delete( 'lastpostdate:gmt', 'timeinfo' );
|
109 |
-
wp_cache_delete( 'lastpostdate:gmt:'.$post->post_type, 'timeinfo' );
|
110 |
-
|
111 |
-
// clear possible fist post date cache keys
|
112 |
-
wp_cache_delete( 'firstpostdate:gmt', 'timeinfo' );
|
113 |
-
wp_cache_delete( 'firstpostdate:gmt:'.$post->post_type, 'timeinfo' );
|
114 |
-
}
|
115 |
-
|
116 |
-
/**
|
117 |
-
* Update term modified meta, hooked to transition post status
|
118 |
-
*
|
119 |
-
* @param $new_status
|
120 |
-
* @param $old_status
|
121 |
-
* @param $post
|
122 |
-
*/
|
123 |
-
public function update_term_modified_meta( $new_status, $old_status, $post ) {
|
124 |
-
|
125 |
-
// bail out on inactive post types
|
126 |
-
if ( ! array_key_exists($post->post_type, $this->post_types) || empty( $this->post_types[$post->post_type]['active'] ) )
|
127 |
-
return;
|
128 |
-
|
129 |
-
// bail out when not publishing or unpublishing or editing a live post
|
130 |
-
// note: prepend " $old_status == $new_status || " to exclude live editong too
|
131 |
-
if ( $new_status != 'publish' && $old_status != 'publish' )
|
132 |
-
return;
|
133 |
-
|
134 |
-
$taxonomy_settings = get_option( 'xmlsf_taxonomy_settings' );
|
135 |
-
|
136 |
-
// bail if no taxonomies activated
|
137 |
-
if ( ! is_array($taxonomy_settings) || empty( $taxonomy_settings['active'] ) )
|
138 |
-
return;
|
139 |
-
|
140 |
-
require_once XMLSF_DIR . '/models/public/sitemap.php';
|
141 |
-
|
142 |
-
$taxonomies = get_option( 'xmlsf_taxonomies' );
|
143 |
-
if ( empty( $taxonomies ) )
|
144 |
-
$taxonomies = xmlsf_public_taxonomies();
|
145 |
-
|
146 |
-
$term_ids = array();
|
147 |
-
foreach ( (array) $taxonomies as $tax_name ) {
|
148 |
-
$terms = wp_get_post_terms( $post->ID, $tax_name, array( 'fields' => 'ids' ));
|
149 |
-
if ( !is_wp_error($terms) ) {
|
150 |
-
$term_ids = array_merge( $term_ids, $terms );
|
151 |
-
}
|
152 |
-
}
|
153 |
-
|
154 |
-
$time = date('Y-m-d H:i:s');
|
155 |
-
|
156 |
-
foreach( $term_ids as $id ) {
|
157 |
-
update_term_meta( $id, 'term_modified_gmt', $time );
|
158 |
-
}
|
159 |
-
}
|
160 |
-
|
161 |
-
}
|
162 |
-
|
163 |
-
/**
|
164 |
-
* FEED TEMPLATES
|
165 |
-
*/
|
166 |
-
|
167 |
-
/**
|
168 |
-
* Set up the sitemap index template
|
169 |
-
*/
|
170 |
-
function xmlsf_load_template_index() {
|
171 |
-
load_template( XMLSF_DIR . '/views/feed-sitemap.php' );
|
172 |
-
}
|
173 |
-
|
174 |
-
/**
|
175 |
-
* set up the sitemap home page(s) template
|
176 |
-
*/
|
177 |
-
function xmlsf_load_template_home() {
|
178 |
-
load_template( XMLSF_DIR . '/views/feed-sitemap-home.php' );
|
179 |
-
}
|
180 |
-
|
181 |
-
/**
|
182 |
-
* set up the post types sitemap template
|
183 |
-
*/
|
184 |
-
function xmlsf_load_template() {
|
185 |
-
load_template( XMLSF_DIR . '/views/feed-sitemap-post_type.php' );
|
186 |
-
}
|
187 |
-
|
188 |
-
/**
|
189 |
-
* set up the taxonomy sitemap template
|
190 |
-
*/
|
191 |
-
function xmlsf_load_template_taxonomy() {
|
192 |
-
load_template( XMLSF_DIR . '/views/feed-sitemap-taxonomy.php' );
|
193 |
-
}
|
194 |
-
|
195 |
-
/**
|
196 |
-
* set up the custom sitemap template
|
197 |
-
*/
|
198 |
-
function xmlsf_load_template_custom() {
|
199 |
-
load_template( XMLSF_DIR . '/views/feed-sitemap-custom.php' );
|
200 |
-
}
|
201 |
-
|
202 |
-
/* -------------------------------------
|
203 |
-
* MISSING WORDPRESS FUNCTIONS
|
204 |
-
* ------------------------------------- */
|
205 |
-
|
206 |
-
/**
|
207 |
-
* Retrieve the date that the first post/page was published.
|
208 |
-
* Variation of function get_lastpostdate, uses _get_post_time
|
209 |
-
*
|
210 |
-
* The server timezone is the default and is the difference between GMT and
|
211 |
-
* server time. The 'blog' value is the date when the last post was posted. The
|
212 |
-
* 'gmt' is when the last post was posted in GMT formatted date.
|
213 |
-
*
|
214 |
-
* @uses apply_filters() Calls 'get_firstpostdate' filter
|
215 |
-
* @param string $timezone The location to get the time. Can be 'gmt', 'blog', or 'server'.
|
216 |
-
* @param string $post_type Post type to check.
|
217 |
-
* @return string The date of the last post.
|
218 |
-
*/
|
219 |
-
if( !function_exists('get_firstpostdate') ) {
|
220 |
-
function get_firstpostdate($timezone = 'server', $post_type = 'any') {
|
221 |
-
return apply_filters( 'get_firstpostdate', _get_post_time( $timezone, 'date', $post_type, 'first' ), $timezone );
|
222 |
-
}
|
223 |
-
}
|
224 |
-
|
225 |
-
/**
|
226 |
-
* Retrieve last post/page modified date depending on timezone.
|
227 |
-
* Variation of function get_lastpostmodified, uses _get_post_time
|
228 |
-
*
|
229 |
-
* The server timezone is the default and is the difference between GMT and
|
230 |
-
* server time. The 'blog' value is the date when the last post was posted. The
|
231 |
-
* 'gmt' is when the last post was posted in GMT formatted date.
|
232 |
-
*
|
233 |
-
* @uses apply_filters() Calls 'get_lastmodified' filter
|
234 |
-
* @param string $timezone The location to get the time. Can be 'gmt', 'blog', or 'server'.
|
235 |
-
* @return string The date of the oldest modified post.
|
236 |
-
*/
|
237 |
-
if( !function_exists('get_lastmodified') ) {
|
238 |
-
function get_lastmodified( $timezone = 'server', $post_type = 'any', $m = '' ) {
|
239 |
-
return apply_filters( 'get_lastmodified', _get_post_time( $timezone, 'modified', $post_type, 'last', $m ), $timezone );
|
240 |
-
}
|
241 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
models/admin/sitemap.php
DELETED
@@ -1,104 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
class XMLSF_Admin_Sitemap_Sanitize
|
4 |
-
{
|
5 |
-
public static function taxonomies( $new )
|
6 |
-
{
|
7 |
-
return $new;
|
8 |
-
}
|
9 |
-
|
10 |
-
public static function taxonomy_settings( $new )
|
11 |
-
{
|
12 |
-
$sanitized = array();
|
13 |
-
|
14 |
-
$sanitized['active'] = !empty($new['active']) ? '1' : '';
|
15 |
-
$sanitized['priority'] = isset($new['priority']) ? self::priority($new['priority'],'0.1','0.9') : '0.3';
|
16 |
-
$sanitized['dynamic_priority'] = !empty($new['dynamic_priority']) ? '1' : '';
|
17 |
-
$sanitized['term_limit'] = isset($new['term_limit']) ? intval($new['term_limit']) : 5000;
|
18 |
-
if ( $sanitized['term_limit'] < 1 || $sanitized['term_limit'] > 50000 ) $sanitized['term_limit'] = 50000;
|
19 |
-
|
20 |
-
return $sanitized;
|
21 |
-
}
|
22 |
-
|
23 |
-
public static function post_types_settings( $new = array() )
|
24 |
-
{
|
25 |
-
$sanitized = is_array($new) ? $new : array();
|
26 |
-
|
27 |
-
foreach ($sanitized as $post_type => $settings) {
|
28 |
-
$sanitized[$post_type]['priority'] = isset($settings['priority']) ? self::priority($settings['priority'],'0.1','0.9') : '0.5';
|
29 |
-
}
|
30 |
-
|
31 |
-
return $sanitized;
|
32 |
-
}
|
33 |
-
|
34 |
-
public static function priority( $priority, $min = 0, $max = 1 )
|
35 |
-
{
|
36 |
-
// make sure we have the proper locale setting for calculations
|
37 |
-
setlocale( LC_NUMERIC, 'C' );
|
38 |
-
|
39 |
-
$priority = floatval(str_replace(',','.',$priority));
|
40 |
-
|
41 |
-
if ( $priority <= (float) $min ) {
|
42 |
-
return number_format( $min, 1 );
|
43 |
-
} elseif ( $priority >= (float) $max ) {
|
44 |
-
return number_format( $max, 1 );
|
45 |
-
} else {
|
46 |
-
return number_format( $priority, 1 );
|
47 |
-
}
|
48 |
-
}
|
49 |
-
|
50 |
-
public static function custom_sitemaps_settings( $new )
|
51 |
-
{
|
52 |
-
// clean up input
|
53 |
-
if ( is_array( $new ) ) {
|
54 |
-
$new = array_filter($new);
|
55 |
-
$new = reset($new);
|
56 |
-
}
|
57 |
-
|
58 |
-
if ( empty($new) )
|
59 |
-
return '';
|
60 |
-
|
61 |
-
// build sanitized output
|
62 |
-
$input = explode( PHP_EOL, sanitize_textarea_field($new) );
|
63 |
-
$sanitized = array();
|
64 |
-
foreach ( $input as $line ) {
|
65 |
-
$line = filter_var( esc_url( trim( $line ) ), FILTER_VALIDATE_URL, FILTER_FLAG_PATH_REQUIRED );
|
66 |
-
if ( ! empty( $line ) )
|
67 |
-
$sanitized[] = $line;
|
68 |
-
}
|
69 |
-
|
70 |
-
return !empty($sanitized) ? $sanitized : '';
|
71 |
-
}
|
72 |
-
|
73 |
-
public static function custom_urls_settings( $new )
|
74 |
-
{
|
75 |
-
// clean up input
|
76 |
-
if ( is_array( $new ) ) {
|
77 |
-
$new = array_filter($new);
|
78 |
-
$new = reset($new);
|
79 |
-
}
|
80 |
-
|
81 |
-
if ( empty($new) )
|
82 |
-
return '';
|
83 |
-
|
84 |
-
$input = explode( PHP_EOL, sanitize_textarea_field( $new ) );
|
85 |
-
|
86 |
-
// build sanitized output
|
87 |
-
$sanitized = array();
|
88 |
-
foreach ( $input as $line ) {
|
89 |
-
if ( empty( $line ) )
|
90 |
-
continue;
|
91 |
-
|
92 |
-
$arr = explode( " ", trim( $line ) );
|
93 |
-
|
94 |
-
$url = filter_var( esc_url( trim( $arr[0] ) ), FILTER_VALIDATE_URL );
|
95 |
-
|
96 |
-
if ( !empty( $url ) ) {
|
97 |
-
$priority = isset( $arr[1] ) ? self::priority($arr[1]) : '0.5';
|
98 |
-
$sanitized[] = array( $url, $priority );
|
99 |
-
}
|
100 |
-
}
|
101 |
-
|
102 |
-
return !empty($sanitized) ? $sanitized : '';
|
103 |
-
}
|
104 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
models/class-xmlsitemapfeed.php
CHANGED
@@ -9,14 +9,13 @@ class XMLSitemapFeed {
|
|
9 |
private $defaults = array();
|
10 |
|
11 |
/**
|
12 |
-
*
|
13 |
* @var array
|
14 |
*/
|
15 |
public $default_news_tags = array(
|
16 |
'name' => '',
|
17 |
'post_type' => array('post'),
|
18 |
-
'categories' => ''
|
19 |
-
'image' => 'featured'
|
20 |
);
|
21 |
|
22 |
/**
|
@@ -100,6 +99,13 @@ class XMLSitemapFeed {
|
|
100 |
*/
|
101 |
public $timespan = 0;
|
102 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
103 |
/**
|
104 |
* Blog pages
|
105 |
*
|
@@ -123,8 +129,8 @@ class XMLSitemapFeed {
|
|
123 |
* @param $key
|
124 |
* @return array
|
125 |
*/
|
126 |
-
public function defaults( $key = false )
|
127 |
-
|
128 |
if ( empty($this->defaults) ) :
|
129 |
|
130 |
// sitemaps
|
@@ -141,7 +147,7 @@ class XMLSitemapFeed {
|
|
141 |
'priority' => '0.7',
|
142 |
'dynamic_priority' => '1',
|
143 |
'tags' => array(
|
144 |
-
'image' => '
|
145 |
/*'video' => ''*/
|
146 |
)
|
147 |
),
|
@@ -187,7 +193,8 @@ class XMLSitemapFeed {
|
|
187 |
* Get domain
|
188 |
* @return string
|
189 |
*/
|
190 |
-
public function get_allowed_domains()
|
|
|
191 |
// allowed domain
|
192 |
if ( null === $this->domains ) {
|
193 |
|
@@ -210,7 +217,8 @@ class XMLSitemapFeed {
|
|
210 |
*
|
211 |
* @return bool
|
212 |
*/
|
213 |
-
public function plain_permalinks()
|
|
|
214 |
if ( null === $this->plain_permalinks ) {
|
215 |
$permalink_structure = get_option('permalink_structure');
|
216 |
$this->plain_permalinks = ('' == $permalink_structure || 0 === strpos($permalink_structure,'/index.php') ) ? true : false;
|
@@ -222,7 +230,8 @@ class XMLSitemapFeed {
|
|
222 |
* Get scheme
|
223 |
* @return string
|
224 |
*/
|
225 |
-
public function blog_language()
|
|
|
226 |
if ( $this->blog_language === null ) {
|
227 |
// get site language for default language
|
228 |
$this->blog_language = xmlsf_parse_language_string( get_bloginfo('language') );
|
@@ -235,7 +244,8 @@ class XMLSitemapFeed {
|
|
235 |
* Get scheme
|
236 |
* @return string
|
237 |
*/
|
238 |
-
public function scheme()
|
|
|
239 |
// scheme to use
|
240 |
if ( empty($this->scheme) ) {
|
241 |
$scheme = parse_url( home_url(), PHP_URL_SCHEME );
|
@@ -249,7 +259,8 @@ class XMLSitemapFeed {
|
|
249 |
* Get disabled taxonomies
|
250 |
* @return array
|
251 |
*/
|
252 |
-
public function disabled_taxonomies()
|
|
|
253 |
return apply_filters( 'xmlsf_disabled_taxonomies', $this->disabled_taxonomies );
|
254 |
}
|
255 |
|
9 |
private $defaults = array();
|
10 |
|
11 |
/**
|
12 |
+
* News defaults
|
13 |
* @var array
|
14 |
*/
|
15 |
public $default_news_tags = array(
|
16 |
'name' => '',
|
17 |
'post_type' => array('post'),
|
18 |
+
'categories' => ''
|
|
|
19 |
);
|
20 |
|
21 |
/**
|
99 |
*/
|
100 |
public $timespan = 0;
|
101 |
|
102 |
+
/**
|
103 |
+
* Post type total approved comment count
|
104 |
+
*
|
105 |
+
* @var int $comment_count
|
106 |
+
*/
|
107 |
+
public $comment_count = 0;
|
108 |
+
|
109 |
/**
|
110 |
* Blog pages
|
111 |
*
|
129 |
* @param $key
|
130 |
* @return array
|
131 |
*/
|
132 |
+
public function defaults( $key = false )
|
133 |
+
{
|
134 |
if ( empty($this->defaults) ) :
|
135 |
|
136 |
// sitemaps
|
147 |
'priority' => '0.7',
|
148 |
'dynamic_priority' => '1',
|
149 |
'tags' => array(
|
150 |
+
'image' => 'featured'
|
151 |
/*'video' => ''*/
|
152 |
)
|
153 |
),
|
193 |
* Get domain
|
194 |
* @return string
|
195 |
*/
|
196 |
+
public function get_allowed_domains()
|
197 |
+
{
|
198 |
// allowed domain
|
199 |
if ( null === $this->domains ) {
|
200 |
|
217 |
*
|
218 |
* @return bool
|
219 |
*/
|
220 |
+
public function plain_permalinks()
|
221 |
+
{
|
222 |
if ( null === $this->plain_permalinks ) {
|
223 |
$permalink_structure = get_option('permalink_structure');
|
224 |
$this->plain_permalinks = ('' == $permalink_structure || 0 === strpos($permalink_structure,'/index.php') ) ? true : false;
|
230 |
* Get scheme
|
231 |
* @return string
|
232 |
*/
|
233 |
+
public function blog_language()
|
234 |
+
{
|
235 |
if ( $this->blog_language === null ) {
|
236 |
// get site language for default language
|
237 |
$this->blog_language = xmlsf_parse_language_string( get_bloginfo('language') );
|
244 |
* Get scheme
|
245 |
* @return string
|
246 |
*/
|
247 |
+
public function scheme()
|
248 |
+
{
|
249 |
// scheme to use
|
250 |
if ( empty($this->scheme) ) {
|
251 |
$scheme = parse_url( home_url(), PHP_URL_SCHEME );
|
259 |
* Get disabled taxonomies
|
260 |
* @return array
|
261 |
*/
|
262 |
+
public function disabled_taxonomies()
|
263 |
+
{
|
264 |
return apply_filters( 'xmlsf_disabled_taxonomies', $this->disabled_taxonomies );
|
265 |
}
|
266 |
|
models/{admin/sitemap-news.php → class.xmlsf-admin-sitemap-news-sanitize.php}
RENAMED
File without changes
|
models/class.xmlsf-admin-sitemap-sanitize.php
ADDED
@@ -0,0 +1,148 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class XMLSF_Admin_Sitemap_Sanitize
|
4 |
+
{
|
5 |
+
public static function taxonomies( $new )
|
6 |
+
{
|
7 |
+
$old = (array) get_option( 'xmlsf_taxonomies', array() );
|
8 |
+
if (
|
9 |
+
empty($old) != empty($new) ||
|
10 |
+
( ! empty( array_diff( (array) $old, (array) $new ) ) )
|
11 |
+
) {
|
12 |
+
global $wpdb;
|
13 |
+
$wpdb->delete( $wpdb->prefix.'termmeta', array( 'meta_key' => 'term_modified' ) );
|
14 |
+
}
|
15 |
+
|
16 |
+
return $new;
|
17 |
+
}
|
18 |
+
|
19 |
+
public static function taxonomy_settings( $new )
|
20 |
+
{
|
21 |
+
setlocale( LC_NUMERIC, 'C' );
|
22 |
+
|
23 |
+
$sanitized = array();
|
24 |
+
|
25 |
+
$sanitized['active'] = !empty($new['active']) ? '1' : '';
|
26 |
+
$sanitized['priority'] = isset($new['priority']) ? xmlsf_sanitize_priority( str_replace( ',', '.', $new['priority'] ), '0.1', '0.9' ) : '0.3';
|
27 |
+
$sanitized['dynamic_priority'] = !empty($new['dynamic_priority']) ? '1' : '';
|
28 |
+
$sanitized['term_limit'] = isset($new['term_limit']) ? intval($new['term_limit']) : 5000;
|
29 |
+
if ( $sanitized['term_limit'] < 1 || $sanitized['term_limit'] > 50000 ) $sanitized['term_limit'] = 50000;
|
30 |
+
|
31 |
+
// clear term meta cache if deactivating...
|
32 |
+
if ( empty($sanitized['active']) ) {
|
33 |
+
$old = (array) get_option( 'xmlsf_taxonomy_settings', array() );
|
34 |
+
if ( ! empty($old['active']) ) {
|
35 |
+
global $wpdb;
|
36 |
+
$wpdb->delete( $wpdb->prefix.'termmeta', array( 'meta_key' => 'term_modified' ) );
|
37 |
+
}
|
38 |
+
}
|
39 |
+
|
40 |
+
return $sanitized;
|
41 |
+
}
|
42 |
+
|
43 |
+
public static function post_types_settings( $new = array() )
|
44 |
+
{
|
45 |
+
$sanitized = is_array($new) ? $new : array();
|
46 |
+
|
47 |
+
$old = (array) get_option( 'xmlsf_post_types', array() );
|
48 |
+
$clear_images = false;
|
49 |
+
$clear_comments = false;
|
50 |
+
|
51 |
+
foreach ( $sanitized as $post_type => $settings ) {
|
52 |
+
setlocale( LC_NUMERIC, 'C' );
|
53 |
+
$sanitized[$post_type]['priority'] = isset($settings['priority']) ? xmlsf_sanitize_priority( str_replace( ',', '.', $settings['priority'] ), '0.1', '0.9' ) : '0.5';
|
54 |
+
|
55 |
+
// poll for changes that warrant clearing meta data
|
56 |
+
if ( isset($old[$post_type]) && is_array($old[$post_type]) ) {
|
57 |
+
|
58 |
+
if ( empty($settings['active']) ) {
|
59 |
+
if ( !empty($old[$post_type]['active']) ) {
|
60 |
+
$clear_images = true;
|
61 |
+
$clear_comments = true;
|
62 |
+
}
|
63 |
+
} else {
|
64 |
+
if ( isset($old[$post_type]['tags']) && is_array($old[$post_type]['tags']) && isset($old[$post_type]['tags']['image']) && $old[$post_type]['tags']['image'] != $settings['tags']['image'] ) {
|
65 |
+
$clear_images = true;
|
66 |
+
}
|
67 |
+
if ( ! empty($old[$post_type]['update_lastmod_on_comments']) && empty($settings['update_lastmod_on_comments']) ) {
|
68 |
+
$clear_comments = true;
|
69 |
+
}
|
70 |
+
}
|
71 |
+
|
72 |
+
}
|
73 |
+
}
|
74 |
+
|
75 |
+
global $wpdb;
|
76 |
+
|
77 |
+
// clear images meta caches...
|
78 |
+
if ( $clear_images ) {
|
79 |
+
$wpdb->delete( $wpdb->prefix.'postmeta', array( 'meta_key' => '_xmlsf_image_attached' ) );
|
80 |
+
$wpdb->delete( $wpdb->prefix.'postmeta', array( 'meta_key' => '_xmlsf_image_featured' ) );
|
81 |
+
update_option( 'xmlsf_images_meta_primed', array() );
|
82 |
+
}
|
83 |
+
|
84 |
+
// clear comments meta caches...
|
85 |
+
if ( $clear_comments ) {
|
86 |
+
$wpdb->delete( $wpdb->prefix.'postmeta', array( 'meta_key' => '_xmlsf_comment_date' ) );
|
87 |
+
update_option( 'xmlsf_comments_meta_primed', array() );
|
88 |
+
}
|
89 |
+
|
90 |
+
return $sanitized;
|
91 |
+
}
|
92 |
+
|
93 |
+
public static function custom_sitemaps_settings( $new )
|
94 |
+
{
|
95 |
+
// clean up input
|
96 |
+
if ( is_array( $new ) ) {
|
97 |
+
$new = array_filter($new);
|
98 |
+
$new = reset($new);
|
99 |
+
}
|
100 |
+
|
101 |
+
if ( empty($new) )
|
102 |
+
return '';
|
103 |
+
|
104 |
+
// build sanitized output
|
105 |
+
$input = explode( PHP_EOL, sanitize_textarea_field( $new ) );
|
106 |
+
$sanitized = array();
|
107 |
+
foreach ( $input as $line ) {
|
108 |
+
$line = filter_var( esc_url( trim( $line ) ), FILTER_VALIDATE_URL, FILTER_FLAG_PATH_REQUIRED );
|
109 |
+
if ( ! empty( $line ) )
|
110 |
+
$sanitized[] = $line;
|
111 |
+
}
|
112 |
+
|
113 |
+
return !empty($sanitized) ? $sanitized : '';
|
114 |
+
}
|
115 |
+
|
116 |
+
public static function custom_urls_settings( $new )
|
117 |
+
{
|
118 |
+
// clean up input
|
119 |
+
if ( is_array( $new ) ) {
|
120 |
+
$new = array_filter($new);
|
121 |
+
$new = reset($new);
|
122 |
+
}
|
123 |
+
|
124 |
+
if ( empty($new) )
|
125 |
+
return '';
|
126 |
+
|
127 |
+
$input = explode( PHP_EOL, sanitize_textarea_field( $new ) );
|
128 |
+
|
129 |
+
// build sanitized output
|
130 |
+
$sanitized = array();
|
131 |
+
foreach ( $input as $line ) {
|
132 |
+
if ( empty( $line ) )
|
133 |
+
continue;
|
134 |
+
|
135 |
+
$arr = explode( " ", trim( $line ) );
|
136 |
+
|
137 |
+
$url = filter_var( esc_url( trim( $arr[0] ) ), FILTER_VALIDATE_URL );
|
138 |
+
|
139 |
+
if ( !empty( $url ) ) {
|
140 |
+
setlocale( LC_NUMERIC, 'C' );
|
141 |
+
$priority = isset( $arr[1] ) ? xmlsf_sanitize_priority( str_replace( ',', '.', $arr[1] ) ) : '0.5';
|
142 |
+
$sanitized[] = array( $url, $priority );
|
143 |
+
}
|
144 |
+
}
|
145 |
+
|
146 |
+
return !empty($sanitized) ? $sanitized : '';
|
147 |
+
}
|
148 |
+
}
|
models/{admin/main.php → functions.admin.php}
RENAMED
@@ -20,6 +20,17 @@ function xmlsf_plugin_meta_links( $links, $file ) {
|
|
20 |
return $links;
|
21 |
}
|
22 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
23 |
// sanitization
|
24 |
|
25 |
class XMLSF_Admin_Sanitize
|
20 |
return $links;
|
21 |
}
|
22 |
|
23 |
+
function xmlsf_verify_nonce( $context ) {
|
24 |
+
|
25 |
+
if ( isset( $_POST['_xmlsf_'.$context.'_nonce'] ) && wp_verify_nonce( $_POST['_xmlsf_'.$context.'_nonce'], XMLSF_BASENAME.'-'.$context ) )
|
26 |
+
return true;
|
27 |
+
|
28 |
+
// Still here? Then add security check failed error message and return false.
|
29 |
+
add_settings_error( 'security_check_failed', 'security_check_failed', translate('Security check failed.') );
|
30 |
+
|
31 |
+
return false;
|
32 |
+
}
|
33 |
+
|
34 |
// sanitization
|
35 |
|
36 |
class XMLSF_Admin_Sanitize
|
models/{global.php → functions.php}
RENAMED
@@ -35,7 +35,7 @@ function xmlsf_rewrite_rules( $rewrite_rules ) {
|
|
35 |
if ( isset($sitemaps['sitemap']) ) {
|
36 |
/* One rule to ring them all */
|
37 |
//add_rewrite_rule('sitemap(-[a-z0-9_\-]+)?\.([0-9]+\.)?xml$', $wp_rewrite->index . '?feed=sitemap$matches[1]&m=$matches[2]', 'top');
|
38 |
-
return array_merge( array( 'sitemap(\-[a-z0-
|
39 |
} elseif ( isset($sitemaps['sitemap-news']) ) {
|
40 |
//add_rewrite_rule('sitemap-news\.xml$', $wp_rewrite->index . '?feed=sitemap-news', 'top');
|
41 |
return array_merge( array( 'sitemap-news\.xml(\.gz)?$' => $wp_rewrite->index . '?feed=sitemap-news$matches[1]' ), $rewrite_rules );
|
35 |
if ( isset($sitemaps['sitemap']) ) {
|
36 |
/* One rule to ring them all */
|
37 |
//add_rewrite_rule('sitemap(-[a-z0-9_\-]+)?\.([0-9]+\.)?xml$', $wp_rewrite->index . '?feed=sitemap$matches[1]&m=$matches[2]', 'top');
|
38 |
+
return array_merge( array( 'sitemap(?:_index)?(\-[a-z0-9\-_]+)?(\.[0-9]+)?\.xml(\.gz)?$' => $wp_rewrite->index . '?feed=sitemap$matches[1]$matches[3]&m=$matches[2]' ), $rewrite_rules );
|
39 |
} elseif ( isset($sitemaps['sitemap-news']) ) {
|
40 |
//add_rewrite_rule('sitemap-news\.xml$', $wp_rewrite->index . '?feed=sitemap-news', 'top');
|
41 |
return array_merge( array( 'sitemap-news\.xml(\.gz)?$' => $wp_rewrite->index . '?feed=sitemap-news$matches[1]' ), $rewrite_rules );
|
models/functions.public-shared.php
ADDED
@@ -0,0 +1,68 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Response headers filter
|
5 |
+
* Does not check if we are really in a sitemap feed.
|
6 |
+
*
|
7 |
+
* @param $headers
|
8 |
+
*
|
9 |
+
* @return array
|
10 |
+
*/
|
11 |
+
function xmlsf_headers( $headers ) {
|
12 |
+
// set noindex
|
13 |
+
$headers['X-Robots-Tag'] = 'noindex, follow';
|
14 |
+
$headers['Content-Type'] = 'text/xml; charset=' . get_bloginfo('charset');
|
15 |
+
return $headers;
|
16 |
+
}
|
17 |
+
|
18 |
+
/**
|
19 |
+
* Get absolute URL
|
20 |
+
* Converts path or protocol relative URLs to absolute ones.
|
21 |
+
*
|
22 |
+
* @param string $url
|
23 |
+
*
|
24 |
+
* @return string|bool
|
25 |
+
*/
|
26 |
+
function xmlsf_get_absolute_url( $url = false ) {
|
27 |
+
// have a string or return false
|
28 |
+
if ( empty( $url ) || ! is_string( $url ) ) {
|
29 |
+
return false;
|
30 |
+
}
|
31 |
+
|
32 |
+
// check for scheme
|
33 |
+
if ( strpos( $url, 'http' ) !== 0 ) {
|
34 |
+
// check for relative url path
|
35 |
+
if ( strpos( $url, '//' ) !== 0 ) {
|
36 |
+
return ( strpos( $url, '/' ) === 0 ) ? untrailingslashit( home_url() ) . $url : trailingslashit( home_url() ) . $url;
|
37 |
+
}
|
38 |
+
return xmlsf()->scheme() . ':' . $url;
|
39 |
+
}
|
40 |
+
|
41 |
+
return $url;
|
42 |
+
}
|
43 |
+
|
44 |
+
/**
|
45 |
+
* Is allowed domain
|
46 |
+
*
|
47 |
+
* @param $url
|
48 |
+
*
|
49 |
+
* @return mixed|void
|
50 |
+
*/
|
51 |
+
function xmlsf_is_allowed_domain( $url ) {
|
52 |
+
|
53 |
+
$domains = xmlsf()->get_allowed_domains();
|
54 |
+
|
55 |
+
$return = false;
|
56 |
+
$parsed_url = parse_url($url);
|
57 |
+
|
58 |
+
if (isset($parsed_url['host'])) {
|
59 |
+
foreach ( $domains as $domain ) {
|
60 |
+
if ( $parsed_url['host'] == $domain || strpos($parsed_url['host'],'.'.$domain) !== false ) {
|
61 |
+
$return = true;
|
62 |
+
break;
|
63 |
+
}
|
64 |
+
}
|
65 |
+
}
|
66 |
+
|
67 |
+
return apply_filters( 'xmlsf_allowed_domain', $return, $url );
|
68 |
+
}
|
models/{public/sitemap-news.php → functions.public-sitemap-news.php}
RENAMED
@@ -9,7 +9,7 @@
|
|
9 |
* @return string
|
10 |
*/
|
11 |
function xmlsf_news_filter_where( $where = '' ) {
|
12 |
-
return $where . ' AND post_date_gmt > \'' .
|
13 |
}
|
14 |
|
15 |
/**
|
@@ -45,13 +45,14 @@ function xmlsf_sitemap_news_parse_request( $request ) {
|
|
45 |
$post_types = apply_filters( 'xmlsf_news_post_types', $post_types);
|
46 |
|
47 |
// disable caching
|
|
|
48 |
if ( ! defined('DONOTCACHEPAGE') ) define('DONOTCACHEPAGE', true);
|
49 |
if ( ! defined('DONOTCACHEDB') ) define('DONOTCACHEDB', true);
|
50 |
|
51 |
// set up query filters
|
52 |
$live = false;
|
53 |
foreach ($post_types as $post_type) {
|
54 |
-
if ( get_lastpostdate('gmt', $post_type) >
|
55 |
$live = true;
|
56 |
break;
|
57 |
}
|
@@ -75,6 +76,53 @@ function xmlsf_sitemap_news_parse_request( $request ) {
|
|
75 |
return $request;
|
76 |
}
|
77 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
78 |
/**
|
79 |
* Get language used in News Sitemap
|
80 |
*
|
@@ -88,18 +136,19 @@ function xmlsf_get_language( $post_id ) {
|
|
88 |
|
89 |
// WPML compat
|
90 |
global $sitepress;
|
91 |
-
|
92 |
-
if ( function_exists('pll_get_post_language') ) {
|
93 |
-
$lang = pll_get_post_language( $post_id, 'slug' );
|
94 |
-
if ( !empty($lang) )
|
95 |
-
$language = xmlsf_parse_language_string( $lang );
|
96 |
-
} elseif ( is_object($sitepress) && method_exists($sitepress, 'get_language_for_element') ) {
|
97 |
$post_type = (array) get_query_var( 'post_type', 'post' );
|
98 |
$lang = $sitepress->get_language_for_element( $post_id, 'post_'.$post_type[0] );
|
99 |
//apply_filters( 'wpml_element_language_code', null, array( 'element_id' => $post_id, 'element_type' => $post_type ) );
|
100 |
if ( !empty($lang) )
|
101 |
$language = xmlsf_parse_language_string( $lang );
|
102 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
103 |
|
104 |
return apply_filters( 'xmlsf_post_language', $language, $post_id );
|
105 |
}
|
@@ -115,13 +164,12 @@ function xmlsf_parse_language_string( $lang ) {
|
|
115 |
$lang = convert_chars( strtolower( strip_tags( $lang ) ) );
|
116 |
|
117 |
// no underscores
|
118 |
-
|
119 |
-
$expl = explode('_', $lang);
|
120 |
-
$lang = $expl[0];
|
121 |
-
}
|
122 |
|
123 |
// no hyphens except...
|
124 |
-
if (
|
|
|
|
|
125 |
// explode on hyphen and use only first part
|
126 |
$expl = explode('-', $lang);
|
127 |
$lang = $expl[0];
|
9 |
* @return string
|
10 |
*/
|
11 |
function xmlsf_news_filter_where( $where = '' ) {
|
12 |
+
return $where . ' AND post_date_gmt > \'' . gmdate( 'Y-m-d H:i:s', strtotime('-48 hours') ) . '\'';
|
13 |
}
|
14 |
|
15 |
/**
|
45 |
$post_types = apply_filters( 'xmlsf_news_post_types', $post_types);
|
46 |
|
47 |
// disable caching
|
48 |
+
$request['cache_results'] = false;
|
49 |
if ( ! defined('DONOTCACHEPAGE') ) define('DONOTCACHEPAGE', true);
|
50 |
if ( ! defined('DONOTCACHEDB') ) define('DONOTCACHEDB', true);
|
51 |
|
52 |
// set up query filters
|
53 |
$live = false;
|
54 |
foreach ($post_types as $post_type) {
|
55 |
+
if ( strtotime( get_lastpostdate( 'gmt', $post_type ) ) > strtotime( gmdate( 'Y-m-d H:i:s', strtotime('-48 hours') ) ) ) {
|
56 |
$live = true;
|
57 |
break;
|
58 |
}
|
76 |
return $request;
|
77 |
}
|
78 |
|
79 |
+
/**
|
80 |
+
* Get images
|
81 |
+
*
|
82 |
+
* @param string $which
|
83 |
+
*
|
84 |
+
* @return array
|
85 |
+
*/
|
86 |
+
/*
|
87 |
+
function xmlsf_news_get_images( $which ) {
|
88 |
+
global $post;
|
89 |
+
$images = array();
|
90 |
+
|
91 |
+
if ( 'attached' == $which ) {
|
92 |
+
$args = array( 'post_type' => 'attachment', 'post_mime_type' => 'image', 'numberposts' => 1, 'post_status' =>'inherit', 'post_parent' => $post->ID );
|
93 |
+
$attachments = get_posts($args);
|
94 |
+
if ( ! empty( $attachments[0] ) ) {
|
95 |
+
$url = wp_get_attachment_image_url( $attachments[0]->ID, 'full' );
|
96 |
+
$url = xmlsf_get_absolute_url( $url );
|
97 |
+
if ( !empty($url) ) {
|
98 |
+
$images[] = array(
|
99 |
+
'loc' => esc_attr( esc_url_raw( $url ) ),
|
100 |
+
'title' => apply_filters( 'the_title_xmlsitemap', $attachments[0]->post_title ),
|
101 |
+
'caption' => apply_filters( 'the_title_xmlsitemap', $attachments[0]->post_excerpt )
|
102 |
+
// 'caption' => apply_filters( 'the_title_xmlsitemap', get_post_meta( $attachment->ID, '_wp_attachment_image_alt', true ) )
|
103 |
+
);
|
104 |
+
}
|
105 |
+
}
|
106 |
+
} elseif ( 'featured' == $which ) {
|
107 |
+
if ( has_post_thumbnail( $post->ID ) ) {
|
108 |
+
$attachment = get_post( get_post_thumbnail_id( $post->ID ) );
|
109 |
+
$url = wp_get_attachment_image_url( get_post_thumbnail_id( $post->ID ), 'full' );
|
110 |
+
$url = xmlsf_get_absolute_url( $url );
|
111 |
+
if ( !empty($url) ) {
|
112 |
+
$images[] = array(
|
113 |
+
'loc' => esc_attr( esc_url_raw( $url ) ),
|
114 |
+
'title' => apply_filters( 'the_title_xmlsitemap', $attachment->post_title ),
|
115 |
+
'caption' => apply_filters( 'the_title_xmlsitemap', $attachment->post_excerpt )
|
116 |
+
// 'caption' => apply_filters( 'the_title_xmlsitemap', get_post_meta( $attachment->ID, '_wp_attachment_image_alt', true ) )
|
117 |
+
);
|
118 |
+
}
|
119 |
+
}
|
120 |
+
}
|
121 |
+
|
122 |
+
return $images;
|
123 |
+
}
|
124 |
+
*/
|
125 |
+
|
126 |
/**
|
127 |
* Get language used in News Sitemap
|
128 |
*
|
136 |
|
137 |
// WPML compat
|
138 |
global $sitepress;
|
139 |
+
if ( is_object($sitepress) && method_exists($sitepress, 'get_language_for_element') ) {
|
|
|
|
|
|
|
|
|
|
|
140 |
$post_type = (array) get_query_var( 'post_type', 'post' );
|
141 |
$lang = $sitepress->get_language_for_element( $post_id, 'post_'.$post_type[0] );
|
142 |
//apply_filters( 'wpml_element_language_code', null, array( 'element_id' => $post_id, 'element_type' => $post_type ) );
|
143 |
if ( !empty($lang) )
|
144 |
$language = xmlsf_parse_language_string( $lang );
|
145 |
}
|
146 |
+
// Polylang
|
147 |
+
elseif ( function_exists('pll_get_post_language') ) {
|
148 |
+
$lang = pll_get_post_language( $post_id, 'slug' );
|
149 |
+
if ( !empty($lang) )
|
150 |
+
$language = xmlsf_parse_language_string( $lang );
|
151 |
+
}
|
152 |
|
153 |
return apply_filters( 'xmlsf_post_language', $language, $post_id );
|
154 |
}
|
164 |
$lang = convert_chars( strtolower( strip_tags( $lang ) ) );
|
165 |
|
166 |
// no underscores
|
167 |
+
$lang = str_replace( '_', '-', $lang );
|
|
|
|
|
|
|
168 |
|
169 |
// no hyphens except...
|
170 |
+
if ( 0 === strpos( $lang, 'zh' ) ) {
|
171 |
+
$lang = strpos( $lang, 'hant' ) || strpos( $lang, 'hk' ) || strpos( $lang, 'tw' ) ? 'zh-tw' : 'zh-cn';
|
172 |
+
} else {
|
173 |
// explode on hyphen and use only first part
|
174 |
$expl = explode('-', $lang);
|
175 |
$lang = $expl[0];
|
models/{public/sitemap.php → functions.public-sitemap.php}
RENAMED
@@ -1,50 +1,14 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
/**
|
4 |
-
* Get index url
|
5 |
-
*
|
6 |
-
* @param string $sitemap
|
7 |
-
* @param string $type
|
8 |
-
* @param string $parm
|
9 |
-
*
|
10 |
-
* @return string
|
11 |
-
*/
|
12 |
-
function xmlsf_get_index_url( $sitemap = 'home', $type = false, $param = false ) {
|
13 |
-
|
14 |
-
if ( xmlsf()->plain_permalinks() ) {
|
15 |
-
$name = '?feed=sitemap-'.$sitemap;
|
16 |
-
$name .= $type ? '-'.$type : '';
|
17 |
-
$name .= $param ? '&m='.$param : '';
|
18 |
-
} else {
|
19 |
-
$name = 'sitemap-'.$sitemap;
|
20 |
-
$name .= $type ? '-'.$type : '';
|
21 |
-
$name .= $param ? '.'.$param : '';
|
22 |
-
$name .= '.xml';
|
23 |
-
}
|
24 |
-
|
25 |
-
return esc_url( trailingslashit( home_url() ) . $name );
|
26 |
-
}
|
27 |
-
|
28 |
-
/**
|
29 |
-
* Get last modified date
|
30 |
-
*
|
31 |
-
* @param string $sitemap
|
32 |
-
* @param string $term
|
33 |
-
*
|
34 |
-
* @return string|bool date|false
|
35 |
-
*/
|
36 |
-
function xmlsf_get_lastmod( $sitemap = 'post_type', $term = '' ) {
|
37 |
-
$modified = trim( mysql2date( 'Y-m-d\TH:i:s+00:00', xmlsf_modified( $sitemap, $term ), false ) );
|
38 |
-
return !empty($modified) ? $modified : false;
|
39 |
-
}
|
40 |
-
|
41 |
/**
|
42 |
* Get root pages data
|
43 |
* @return array
|
44 |
*/
|
45 |
function xmlsf_get_root_data() {
|
|
|
46 |
// language roots
|
47 |
global $sitepress;
|
|
|
48 |
// Polylang and WPML compat
|
49 |
if ( function_exists('pll_the_languages') && function_exists('pll_home_url') ) {
|
50 |
$languages = pll_the_languages( array( 'raw' => 1 ) );
|
@@ -53,7 +17,7 @@ function xmlsf_get_root_data() {
|
|
53 |
$url = pll_home_url( $language['slug'] );
|
54 |
$data[$url] = array(
|
55 |
'priority' => '1.0',
|
56 |
-
'lastmod' => mysql2date( '
|
57 |
// TODO make lastmod date language specific
|
58 |
);
|
59 |
}
|
@@ -63,7 +27,7 @@ function xmlsf_get_root_data() {
|
|
63 |
$url = $sitepress->language_url($term);
|
64 |
$data[$url] = array(
|
65 |
'priority' => '1.0',
|
66 |
-
'lastmod' => mysql2date( '
|
67 |
// TODO make lastmod date language specific
|
68 |
);
|
69 |
}
|
@@ -72,14 +36,13 @@ function xmlsf_get_root_data() {
|
|
72 |
$data = array(
|
73 |
trailingslashit( home_url() ) => array(
|
74 |
'priority' => '1.0',
|
75 |
-
'lastmod' => mysql2date( '
|
76 |
)
|
77 |
);
|
78 |
}
|
79 |
|
80 |
-
// TODO custom post type root pages here
|
81 |
-
|
82 |
return $data;
|
|
|
83 |
}
|
84 |
|
85 |
/**
|
@@ -90,6 +53,7 @@ function xmlsf_get_root_data() {
|
|
90 |
* @return array
|
91 |
*/
|
92 |
function xmlsf_do_tags( $type = 'post' ) {
|
|
|
93 |
$post_types = get_option( 'xmlsf_post_types' );
|
94 |
|
95 |
// make sure it's an array we are returning
|
@@ -98,6 +62,7 @@ function xmlsf_do_tags( $type = 'post' ) {
|
|
98 |
is_array($post_types) &&
|
99 |
!empty($post_types[$type]['tags'])
|
100 |
) ? (array) $post_types[$type]['tags'] : array();
|
|
|
101 |
}
|
102 |
|
103 |
/**
|
@@ -105,16 +70,41 @@ function xmlsf_do_tags( $type = 'post' ) {
|
|
105 |
* @return array
|
106 |
*/
|
107 |
function xmlsf_get_frontpages() {
|
|
|
108 |
if ( null === xmlsf()->frontpages ) :
|
|
|
109 |
$frontpages = array();
|
110 |
if ( 'page' == get_option('show_on_front') ) {
|
111 |
$frontpage = (int) get_option('page_on_front');
|
112 |
$frontpages = array_merge( (array) $frontpage, xmlsf_get_translations($frontpage) );
|
113 |
}
|
114 |
xmlsf()->frontpages = $frontpages;
|
|
|
115 |
endif;
|
116 |
|
117 |
return xmlsf()->frontpages;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
118 |
}
|
119 |
|
120 |
/**
|
@@ -125,215 +115,246 @@ function xmlsf_get_frontpages() {
|
|
125 |
* @return array
|
126 |
*/
|
127 |
function xmlsf_get_translations( $post_id ) {
|
128 |
-
$translation_ids = array();
|
129 |
|
130 |
-
// WPML compat
|
131 |
global $sitepress;
|
|
|
|
|
132 |
// Polylang compat
|
133 |
if ( function_exists('pll_get_post_translations') ) {
|
|
|
134 |
$translations = pll_get_post_translations($post_id);
|
|
|
135 |
foreach ( $translations as $slug => $id ) {
|
136 |
if ( $post_id != $id ) $translation_ids[] = $id;
|
137 |
}
|
|
|
|
|
138 |
} elseif ( is_object($sitepress) && method_exists($sitepress, 'get_languages') && method_exists($sitepress, 'get_object_id') ) {
|
|
|
139 |
foreach ( array_keys ( $sitepress->get_languages(false,true) ) as $term ) {
|
140 |
$id = $sitepress->get_object_id($post_id,'page',false,$term);
|
141 |
if ( $post_id != $id ) $translation_ids[] = $id;
|
142 |
}
|
|
|
143 |
}
|
144 |
|
145 |
return $translation_ids;
|
|
|
146 |
}
|
147 |
|
148 |
/**
|
149 |
-
*
|
150 |
-
*
|
|
|
151 |
*/
|
152 |
-
function
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
160 |
}
|
161 |
-
xmlsf()->blogpages = $blogpages;
|
162 |
-
endif;
|
163 |
|
164 |
-
|
|
|
|
|
|
|
165 |
}
|
166 |
|
167 |
/**
|
168 |
-
*
|
169 |
*
|
170 |
-
* @param $
|
171 |
*
|
172 |
-
* @return
|
173 |
*/
|
174 |
-
function
|
175 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
176 |
}
|
177 |
|
178 |
/**
|
179 |
-
* Modified
|
180 |
*
|
181 |
-
* @param string $
|
182 |
-
* @param string $term
|
183 |
*
|
184 |
* @return string
|
185 |
*/
|
186 |
-
function
|
187 |
-
$lastmod = '';
|
188 |
|
189 |
-
|
190 |
-
global $post;
|
191 |
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
|
|
|
|
196 |
|
197 |
-
|
|
|
|
|
198 |
|
199 |
-
|
200 |
|
201 |
-
|
202 |
-
$lastcomment = get_comments( array(
|
203 |
-
'status' => 'approve',
|
204 |
-
'number' => 1,
|
205 |
-
'post_id' => $post->ID,
|
206 |
-
) );
|
207 |
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
|
|
|
|
|
|
|
|
|
|
212 |
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
};
|
217 |
|
218 |
-
|
219 |
|
220 |
-
|
221 |
-
$lastmod = get_term_meta( $term->term_id, 'term_modified_gmt', true );
|
222 |
|
223 |
-
|
224 |
-
// get the latest post in this taxonomy item, to use its post_date as lastmod
|
225 |
-
$posts = get_posts (
|
226 |
-
array(
|
227 |
-
'post_type' => 'any',
|
228 |
-
'numberposts' => 1,
|
229 |
-
'no_found_rows' => true,
|
230 |
-
'update_post_meta_cache' => false,
|
231 |
-
'update_post_term_cache' => false,
|
232 |
-
'update_cache' => false,
|
233 |
-
'tax_query' => array(
|
234 |
-
array(
|
235 |
-
'taxonomy' => $term->taxonomy,
|
236 |
-
'field' => 'slug',
|
237 |
-
'terms' => $term->slug
|
238 |
-
)
|
239 |
-
)
|
240 |
-
)
|
241 |
-
);
|
242 |
-
$lastmod = isset($posts[0]->post_date_gmt) ? $posts[0]->post_date_gmt : '';
|
243 |
-
// get post date here, not modified date because we're only
|
244 |
-
// concerned about new entries on the (first) taxonomy page
|
245 |
|
246 |
-
|
247 |
-
}
|
248 |
-
} else {
|
249 |
|
250 |
-
|
251 |
|
252 |
-
|
253 |
-
foreach ( (array)$obj->object_type as $object_type ) {
|
254 |
-
$lastmodified[] = get_lastpostdate( 'gmt', $object_type );
|
255 |
-
// get post date here, not modified date because we're only
|
256 |
-
// concerned about new entries on the (first) taxonomy page
|
257 |
-
}
|
258 |
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
|
|
263 |
|
264 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
265 |
|
266 |
-
return $lastmod;
|
267 |
}
|
268 |
|
269 |
/**
|
270 |
-
* Get priority
|
271 |
*
|
272 |
-
* @param string $sitemap
|
273 |
* @param WP_Term|string $term
|
274 |
*
|
275 |
-
* @return
|
276 |
*/
|
277 |
-
function
|
278 |
|
279 |
// locale LC_NUMERIC should be set to C for these calculations
|
280 |
// it is assumed to be done at the request filter
|
281 |
//setlocale( LC_NUMERIC, 'C' );
|
282 |
|
283 |
-
$
|
284 |
-
|
285 |
-
if ( 'post_type' == $sitemap ) :
|
286 |
-
|
287 |
-
global $post;
|
288 |
-
$options = get_option( 'xmlsf_post_types' );
|
289 |
-
$priority = isset($options[$post->post_type]['priority']) && is_numeric($options[$post->post_type]['priority']) ? floatval($options[$post->post_type]['priority']) : 0.5;
|
290 |
|
291 |
-
|
292 |
-
$priority = floatval(str_replace(',','.',$priority_meta));
|
293 |
-
} elseif ( !empty($options[$post->post_type]['dynamic_priority']) ) {
|
294 |
-
$post_modified = mysql2date('U',$post->post_modified_gmt, false);
|
295 |
|
296 |
-
|
297 |
-
|
298 |
-
|
299 |
-
|
300 |
-
}
|
301 |
-
|
302 |
-
// increase by relative comment count
|
303 |
-
if ( $post->comment_count > 0 && $priority < 1 ) {
|
304 |
-
$priority += 0.1 + ( 1 - $priority ) * $post->comment_count / wp_count_comments($post->post_type)->approved;
|
305 |
-
}
|
306 |
}
|
307 |
|
308 |
-
$priority
|
309 |
-
|
310 |
-
elseif ( 'taxonomy' == $sitemap ) :
|
311 |
|
312 |
-
|
313 |
-
$priority = isset( $options['priority'] ) && is_numeric( $options['priority'] ) ? floatval( $options['priority'] ) : 0.5 ;
|
314 |
|
315 |
-
|
316 |
-
|
317 |
-
if ( null == xmlsf()->taxonomy_termmaxposts ) {
|
318 |
-
xmlsf()->taxonomy_termmaxposts = $term->count;
|
319 |
-
}
|
320 |
|
321 |
-
|
322 |
-
}
|
323 |
-
|
324 |
-
$priority = apply_filters( 'xmlsf_term_priority', $priority, $term->slug );
|
325 |
|
326 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
327 |
|
328 |
-
//
|
329 |
-
|
330 |
-
$priority = 0.1;
|
331 |
-
}
|
332 |
-
if ( (float) $priority > 1 ) {
|
333 |
-
$priority = 1;
|
334 |
-
}
|
335 |
|
336 |
-
return
|
337 |
}
|
338 |
|
339 |
/**
|
@@ -385,16 +406,21 @@ function xmlsf_sitemap_parse_request( $request ) {
|
|
385 |
|
386 |
case 'posttype':
|
387 |
|
388 |
-
if ( !isset( $feed[2] ) ) break;
|
|
|
|
|
|
|
389 |
|
390 |
-
$options = get_option( 'xmlsf_post_types' );
|
391 |
|
392 |
// prepare priority calculation
|
393 |
-
if (
|
394 |
// last posts or page modified date in Unix seconds
|
395 |
-
xmlsf()->lastmodified = mysql2date( 'U', get_lastpostmodified('
|
396 |
-
// uses get_firstpostdate() function defined in xml-sitemap/inc/functions.php !
|
397 |
-
xmlsf()->timespan = xmlsf()->lastmodified - mysql2date( 'U', get_firstpostdate('
|
|
|
|
|
398 |
};
|
399 |
|
400 |
// setup filter
|
@@ -402,6 +428,7 @@ function xmlsf_sitemap_parse_request( $request ) {
|
|
402 |
|
403 |
$request['post_type'] = $feed[2];
|
404 |
$request['orderby'] = 'modified';
|
|
|
405 |
$request['is_date'] = false;
|
406 |
|
407 |
break;
|
@@ -410,6 +437,9 @@ function xmlsf_sitemap_parse_request( $request ) {
|
|
410 |
|
411 |
if ( !isset( $feed[2] ) ) break;
|
412 |
|
|
|
|
|
|
|
413 |
// WPML compat
|
414 |
global $sitepress;
|
415 |
if ( is_object($sitepress) ) {
|
@@ -442,6 +472,7 @@ function xmlsf_sitemap_parse_request( $request ) {
|
|
442 |
* @return array
|
443 |
*/
|
444 |
function xmlsf_cache_get_archives( $query ) {
|
|
|
445 |
global $wpdb;
|
446 |
|
447 |
$key = md5($query);
|
@@ -456,50 +487,7 @@ function xmlsf_cache_get_archives( $query ) {
|
|
456 |
}
|
457 |
|
458 |
return $arcresults;
|
459 |
-
}
|
460 |
|
461 |
-
/**
|
462 |
-
* Get archives
|
463 |
-
*
|
464 |
-
* @param string $post_type
|
465 |
-
* @param string $type
|
466 |
-
*
|
467 |
-
* @return array
|
468 |
-
*/
|
469 |
-
function xmlsf_get_archives( $post_type = 'post', $type = '' ) {
|
470 |
-
global $wpdb;
|
471 |
-
$return = array();
|
472 |
-
|
473 |
-
if ( 'monthly' == $type ) :
|
474 |
-
|
475 |
-
$query = "SELECT YEAR(post_date) as `year`, LPAD(MONTH(post_date),2,'0') as `month`, count(ID) as posts FROM {$wpdb->posts} WHERE post_type = '{$post_type}' AND post_status = 'publish' GROUP BY YEAR(post_date), MONTH(post_date) ORDER BY post_date DESC";
|
476 |
-
$arcresults = xmlsf_cache_get_archives( $query );
|
477 |
-
|
478 |
-
foreach ( (array) $arcresults as $arcresult ) {
|
479 |
-
$return[$arcresult->year.$arcresult->month] = xmlsf_get_index_url( 'posttype', $post_type, $arcresult->year . $arcresult->month );
|
480 |
-
};
|
481 |
-
|
482 |
-
elseif ( 'yearly' == $type ) :
|
483 |
-
|
484 |
-
$query = "SELECT YEAR(post_date) as `year`, count(ID) as posts FROM {$wpdb->posts} WHERE post_type = '{$post_type}' AND post_status = 'publish' GROUP BY YEAR(post_date) ORDER BY post_date DESC";
|
485 |
-
$arcresults = xmlsf_cache_get_archives( $query );
|
486 |
-
|
487 |
-
foreach ( (array) $arcresults as $arcresult ) {
|
488 |
-
$return[$arcresult->year] = xmlsf_get_index_url( 'posttype', $post_type, $arcresult->year );
|
489 |
-
};
|
490 |
-
|
491 |
-
else :
|
492 |
-
|
493 |
-
$query = "SELECT count(ID) as posts FROM {$wpdb->posts} WHERE post_type = '{$post_type}' AND post_status = 'publish' ORDER BY post_date DESC";
|
494 |
-
$arcresults = xmlsf_cache_get_archives( $query );
|
495 |
-
|
496 |
-
if ( is_object($arcresults[0]) && $arcresults[0]->posts > 0 ) {
|
497 |
-
$return[] = xmlsf_get_index_url( 'posttype', $post_type ); // $sitemap = 'home', $type = false, $param = false
|
498 |
-
};
|
499 |
-
|
500 |
-
endif;
|
501 |
-
|
502 |
-
return $return;
|
503 |
}
|
504 |
|
505 |
/* -------------------------------------
|
@@ -519,6 +507,7 @@ function xmlsf_get_archives( $post_type = 'post', $type = '' ) {
|
|
519 |
*/
|
520 |
if( !function_exists('_get_post_time') ) {
|
521 |
function _get_post_time( $timezone, $field, $post_type = 'any', $which = 'last', $m = '' ) {
|
|
|
522 |
global $wpdb;
|
523 |
|
524 |
if ( !in_array( $field, array( 'date', 'modified' ) ) ) {
|
@@ -572,6 +561,12 @@ if( !function_exists('_get_post_time') ) {
|
|
572 |
|
573 |
$order = ( $which == 'last' ) ? 'DESC' : 'ASC';
|
574 |
|
|
|
|
|
|
|
|
|
|
|
|
|
575 |
switch ( $timezone ) {
|
576 |
case 'gmt':
|
577 |
$date = $wpdb->get_var("SELECT post_{$field}_gmt FROM $wpdb->posts WHERE $where ORDER BY post_{$field}_gmt $order LIMIT 1");
|
@@ -592,12 +587,47 @@ if( !function_exists('_get_post_time') ) {
|
|
592 |
}
|
593 |
|
594 |
return false;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
595 |
}
|
596 |
}
|
597 |
-
/* CODE SUGGESTION BY Frédéric Demarle
|
598 |
-
* to make this language aware.
|
599 |
|
600 |
-
|
601 |
-
|
602 |
-
|
603 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
<?php
|
2 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3 |
/**
|
4 |
* Get root pages data
|
5 |
* @return array
|
6 |
*/
|
7 |
function xmlsf_get_root_data() {
|
8 |
+
|
9 |
// language roots
|
10 |
global $sitepress;
|
11 |
+
|
12 |
// Polylang and WPML compat
|
13 |
if ( function_exists('pll_the_languages') && function_exists('pll_home_url') ) {
|
14 |
$languages = pll_the_languages( array( 'raw' => 1 ) );
|
17 |
$url = pll_home_url( $language['slug'] );
|
18 |
$data[$url] = array(
|
19 |
'priority' => '1.0',
|
20 |
+
'lastmod' => mysql2date( 'c', get_lastpostdate('blog') )
|
21 |
// TODO make lastmod date language specific
|
22 |
);
|
23 |
}
|
27 |
$url = $sitepress->language_url($term);
|
28 |
$data[$url] = array(
|
29 |
'priority' => '1.0',
|
30 |
+
'lastmod' => mysql2date( 'c', get_lastpostdate('blog') )
|
31 |
// TODO make lastmod date language specific
|
32 |
);
|
33 |
}
|
36 |
$data = array(
|
37 |
trailingslashit( home_url() ) => array(
|
38 |
'priority' => '1.0',
|
39 |
+
'lastmod' => mysql2date( 'c', get_lastpostdate('blog') )
|
40 |
)
|
41 |
);
|
42 |
}
|
43 |
|
|
|
|
|
44 |
return $data;
|
45 |
+
|
46 |
}
|
47 |
|
48 |
/**
|
53 |
* @return array
|
54 |
*/
|
55 |
function xmlsf_do_tags( $type = 'post' ) {
|
56 |
+
|
57 |
$post_types = get_option( 'xmlsf_post_types' );
|
58 |
|
59 |
// make sure it's an array we are returning
|
62 |
is_array($post_types) &&
|
63 |
!empty($post_types[$type]['tags'])
|
64 |
) ? (array) $post_types[$type]['tags'] : array();
|
65 |
+
|
66 |
}
|
67 |
|
68 |
/**
|
70 |
* @return array
|
71 |
*/
|
72 |
function xmlsf_get_frontpages() {
|
73 |
+
|
74 |
if ( null === xmlsf()->frontpages ) :
|
75 |
+
|
76 |
$frontpages = array();
|
77 |
if ( 'page' == get_option('show_on_front') ) {
|
78 |
$frontpage = (int) get_option('page_on_front');
|
79 |
$frontpages = array_merge( (array) $frontpage, xmlsf_get_translations($frontpage) );
|
80 |
}
|
81 |
xmlsf()->frontpages = $frontpages;
|
82 |
+
|
83 |
endif;
|
84 |
|
85 |
return xmlsf()->frontpages;
|
86 |
+
|
87 |
+
}
|
88 |
+
|
89 |
+
/**
|
90 |
+
* Get blog_pages
|
91 |
+
* @return array
|
92 |
+
*/
|
93 |
+
function xmlsf_get_blogpages() {
|
94 |
+
|
95 |
+
if ( null === xmlsf()->blogpages ) :
|
96 |
+
$blogpages = array();
|
97 |
+
if ( 'page' == get_option('show_on_front') ) {
|
98 |
+
$blogpage = (int) get_option('page_for_posts');
|
99 |
+
if ( !empty($blogpage) ) {
|
100 |
+
$blogpages = array_merge( (array) $blogpage, xmlsf_get_translations($blogpage) );
|
101 |
+
}
|
102 |
+
}
|
103 |
+
xmlsf()->blogpages = $blogpages;
|
104 |
+
endif;
|
105 |
+
|
106 |
+
return xmlsf()->blogpages;
|
107 |
+
|
108 |
}
|
109 |
|
110 |
/**
|
115 |
* @return array
|
116 |
*/
|
117 |
function xmlsf_get_translations( $post_id ) {
|
|
|
118 |
|
|
|
119 |
global $sitepress;
|
120 |
+
$translation_ids = array();
|
121 |
+
|
122 |
// Polylang compat
|
123 |
if ( function_exists('pll_get_post_translations') ) {
|
124 |
+
|
125 |
$translations = pll_get_post_translations($post_id);
|
126 |
+
|
127 |
foreach ( $translations as $slug => $id ) {
|
128 |
if ( $post_id != $id ) $translation_ids[] = $id;
|
129 |
}
|
130 |
+
|
131 |
+
// WPML compat
|
132 |
} elseif ( is_object($sitepress) && method_exists($sitepress, 'get_languages') && method_exists($sitepress, 'get_object_id') ) {
|
133 |
+
|
134 |
foreach ( array_keys ( $sitepress->get_languages(false,true) ) as $term ) {
|
135 |
$id = $sitepress->get_object_id($post_id,'page',false,$term);
|
136 |
if ( $post_id != $id ) $translation_ids[] = $id;
|
137 |
}
|
138 |
+
|
139 |
}
|
140 |
|
141 |
return $translation_ids;
|
142 |
+
|
143 |
}
|
144 |
|
145 |
/**
|
146 |
+
* Post Modified
|
147 |
+
*
|
148 |
+
* @return string GMT date
|
149 |
*/
|
150 |
+
function xmlsf_get_post_modified() {
|
151 |
+
|
152 |
+
global $post;
|
153 |
+
|
154 |
+
// if blog or home page then simply look for last post date
|
155 |
+
if ( $post->post_type == 'page' && ( in_array( $post->ID, xmlsf_get_blogpages() ) || in_array( $post->ID, xmlsf_get_frontpages() ) ) ) {
|
156 |
+
|
157 |
+
$lastmod = get_lastpostmodified( 'blog' );
|
158 |
+
|
159 |
+
} else {
|
160 |
+
|
161 |
+
$lastmod = $post->post_modified;
|
162 |
+
|
163 |
+
// make sure lastmod is not older than publication date (happens on scheduled posts)
|
164 |
+
if ( isset( $post->post_date ) && strtotime( $post->post_date ) > strtotime( $lastmod ) ) {
|
165 |
+
$lastmod = $post->post_date;
|
166 |
+
};
|
167 |
+
|
168 |
+
// maybe update lastmod to latest comment
|
169 |
+
$options = (array) get_option( 'xmlsf_post_types', array() );
|
170 |
+
|
171 |
+
if ( !empty($options[$post->post_type]['update_lastmod_on_comments']) ) {
|
172 |
+
// assuming post meta data has been primed here
|
173 |
+
$lastcomment = get_post_meta( $post->ID, '_xmlsf_comment_date', true ); // only get one
|
174 |
+
|
175 |
+
if ( ! empty( $lastcomment ) && strtotime( $lastcomment ) > strtotime( $lastmod ) )
|
176 |
+
$lastmod = $lastcomment;
|
177 |
}
|
|
|
|
|
178 |
|
179 |
+
}
|
180 |
+
|
181 |
+
return ! empty( $lastmod ) ? mysql2date( 'c', $lastmod ) : false;
|
182 |
+
|
183 |
}
|
184 |
|
185 |
/**
|
186 |
+
* Term Modified
|
187 |
*
|
188 |
+
* @param object $term
|
189 |
*
|
190 |
+
* @return string
|
191 |
*/
|
192 |
+
function xmlsf_get_term_modified( $term ) {
|
193 |
+
|
194 |
+
/*
|
195 |
+
* Getting ALL meta here because if checking for single key, we cannot
|
196 |
+
* distiguish between empty value or non-exisiting key as both return ''.
|
197 |
+
*/
|
198 |
+
$meta = get_term_meta( $term->term_id );
|
199 |
+
|
200 |
+
if ( ! array_key_exists( 'term_modified', $meta ) ) {
|
201 |
+
|
202 |
+
// get the latest post in this taxonomy item, to use its post_date as lastmod
|
203 |
+
$posts = get_posts (
|
204 |
+
array(
|
205 |
+
'post_type' => 'any',
|
206 |
+
'post_status' => 'publish',
|
207 |
+
'posts_per_page' => 1,
|
208 |
+
'update_post_meta_cache' => false,
|
209 |
+
'update_post_term_cache' => false,
|
210 |
+
'update_cache' => false,
|
211 |
+
'lang' => '',
|
212 |
+
'has_password' => false,
|
213 |
+
'tax_query' => array(
|
214 |
+
array(
|
215 |
+
'taxonomy' => $term->taxonomy,
|
216 |
+
'field' => 'slug',
|
217 |
+
'terms' => $term->slug
|
218 |
+
)
|
219 |
+
)
|
220 |
+
)
|
221 |
+
);
|
222 |
+
|
223 |
+
$lastmod = isset($posts[0]->post_date) ? $posts[0]->post_date : '';
|
224 |
+
// get post date here, not modified date because we're only
|
225 |
+
// concerned about new entries on the (first) taxonomy page
|
226 |
+
|
227 |
+
add_term_meta( $term->term_id, 'term_modified', $lastmod );
|
228 |
+
|
229 |
+
} else {
|
230 |
+
|
231 |
+
$lastmod = get_term_meta( $term->term_id, 'term_modified', true ); // only get one
|
232 |
+
|
233 |
+
}
|
234 |
+
|
235 |
+
return ! empty( $lastmod ) ? mysql2date( 'c', $lastmod ) : false;
|
236 |
+
|
237 |
}
|
238 |
|
239 |
/**
|
240 |
+
* Taxonmy Modified
|
241 |
*
|
242 |
+
* @param string $taxonomy
|
|
|
243 |
*
|
244 |
* @return string
|
245 |
*/
|
246 |
+
function xmlsf_get_taxonomy_modified( $taxonomy ) {
|
|
|
247 |
|
248 |
+
$obj = get_taxonomy( $taxonomy );
|
|
|
249 |
|
250 |
+
$lastmodified = array();
|
251 |
+
foreach ( (array)$obj->object_type as $object_type ) {
|
252 |
+
$lastmodified[] = get_lastpostdate( 'blog', $object_type );
|
253 |
+
// get last post date here, not modified date because we're only
|
254 |
+
// concerned about new entries on the (first) taxonomy page
|
255 |
+
}
|
256 |
|
257 |
+
sort( $lastmodified );
|
258 |
+
$lastmodified = array_filter( $lastmodified );
|
259 |
+
$lastmod = end( $lastmodified );
|
260 |
|
261 |
+
return mysql2date( 'c', $lastmod );
|
262 |
|
263 |
+
}
|
|
|
|
|
|
|
|
|
|
|
264 |
|
265 |
+
/**
|
266 |
+
* Get post priority
|
267 |
+
*
|
268 |
+
* @return float
|
269 |
+
*/
|
270 |
+
function xmlsf_get_post_priority() {
|
271 |
+
// locale LC_NUMERIC should be set to C for these calculations
|
272 |
+
// it is assumed to be done once at the request filter
|
273 |
+
//setlocale( LC_NUMERIC, 'C' );
|
274 |
|
275 |
+
global $post;
|
276 |
+
$options = get_option( 'xmlsf_post_types' );
|
277 |
+
$priority = isset($options[$post->post_type]['priority']) && is_numeric($options[$post->post_type]['priority']) ? floatval($options[$post->post_type]['priority']) : 0.5;
|
|
|
278 |
|
279 |
+
if ( in_array( $post->ID, xmlsf_get_frontpages() ) ) {
|
280 |
|
281 |
+
$priority = 1;
|
|
|
282 |
|
283 |
+
} elseif ( $priority_meta = get_post_meta( $post->ID, '_xmlsf_priority', true ) ) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
284 |
|
285 |
+
$priority = floatval(str_replace(',','.',$priority_meta));
|
|
|
|
|
286 |
|
287 |
+
} elseif ( !empty($options[$post->post_type]['dynamic_priority']) ) {
|
288 |
|
289 |
+
$post_modified = mysql2date('U',$post->post_modified, false);
|
|
|
|
|
|
|
|
|
|
|
290 |
|
291 |
+
// reduce by age
|
292 |
+
// NOTE : home/blog page gets same treatment as sticky post, i.e. no reduction by age
|
293 |
+
if ( xmlsf()->timespan > 0 && ! is_sticky( $post->ID ) && ! in_array( $post->ID, xmlsf_get_blogpages() ) ) {
|
294 |
+
$priority -= $priority * ( xmlsf()->lastmodified - $post_modified ) / xmlsf()->timespan;
|
295 |
+
}
|
296 |
|
297 |
+
// increase by relative comment count
|
298 |
+
if ( $post->comment_count > 0 && $priority < 1 && xmlsf()->comment_count > 0 ) {
|
299 |
+
$priority += 0.1 + ( 1 - $priority ) * $post->comment_count / xmlsf()->comment_count;
|
300 |
+
}
|
301 |
+
|
302 |
+
}
|
303 |
+
|
304 |
+
$priority = apply_filters( 'xmlsf_post_priority', $priority, $post->ID );
|
305 |
+
|
306 |
+
// a final check for limits and round it
|
307 |
+
return xmlsf_sanitize_priority( $priority, 0.1, 1 );
|
308 |
|
|
|
309 |
}
|
310 |
|
311 |
/**
|
312 |
+
* Get taxonomy priority
|
313 |
*
|
|
|
314 |
* @param WP_Term|string $term
|
315 |
*
|
316 |
+
* @return float
|
317 |
*/
|
318 |
+
function xmlsf_get_term_priority( $term = '' ) {
|
319 |
|
320 |
// locale LC_NUMERIC should be set to C for these calculations
|
321 |
// it is assumed to be done at the request filter
|
322 |
//setlocale( LC_NUMERIC, 'C' );
|
323 |
|
324 |
+
$options = get_option( 'xmlsf_taxonomy_settings' );
|
|
|
|
|
|
|
|
|
|
|
|
|
325 |
|
326 |
+
$priority = isset( $options['priority'] ) && is_numeric( $options['priority'] ) ? floatval( $options['priority'] ) : 0.5 ;
|
|
|
|
|
|
|
327 |
|
328 |
+
if ( !empty($options['dynamic_priority']) && $priority > 0.1 && is_object($term) ) {
|
329 |
+
// set first and highest term post count as maximum
|
330 |
+
if ( null == xmlsf()->taxonomy_termmaxposts ) {
|
331 |
+
xmlsf()->taxonomy_termmaxposts = $term->count;
|
|
|
|
|
|
|
|
|
|
|
|
|
332 |
}
|
333 |
|
334 |
+
$priority -= ( xmlsf()->taxonomy_termmaxposts - $term->count ) * ( $priority - 0.1 ) / xmlsf()->taxonomy_termmaxposts;
|
335 |
+
}
|
|
|
336 |
|
337 |
+
$priority = apply_filters( 'xmlsf_term_priority', $priority, $term->slug );
|
|
|
338 |
|
339 |
+
// a final check for limits and round it
|
340 |
+
return xmlsf_sanitize_priority( $priority, 0.1, 1 );
|
|
|
|
|
|
|
341 |
|
342 |
+
}
|
|
|
|
|
|
|
343 |
|
344 |
+
/**
|
345 |
+
* Get post images
|
346 |
+
*
|
347 |
+
* @param string $which
|
348 |
+
*
|
349 |
+
* @return array
|
350 |
+
*/
|
351 |
+
function xmlsf_get_post_images( $which ) {
|
352 |
+
global $post;
|
353 |
|
354 |
+
// assuming images post meta has been primed here
|
355 |
+
$images = get_post_meta( $post->ID, '_xmlsf_image_'.$which );
|
|
|
|
|
|
|
|
|
|
|
356 |
|
357 |
+
return (array) apply_filters( 'xmlsf_post_images_'.$which, $images );
|
358 |
}
|
359 |
|
360 |
/**
|
406 |
|
407 |
case 'posttype':
|
408 |
|
409 |
+
if ( ! isset( $feed[2] ) ) break;
|
410 |
+
|
411 |
+
// try to raise memory limit, context added for filters
|
412 |
+
wp_raise_memory_limit( 'sitemap-posttype-'.$feed[2] );
|
413 |
|
414 |
+
$options = (array) get_option( 'xmlsf_post_types', array() );
|
415 |
|
416 |
// prepare priority calculation
|
417 |
+
if ( ! empty($options[$feed[2]]['dynamic_priority']) ) {
|
418 |
// last posts or page modified date in Unix seconds
|
419 |
+
xmlsf()->lastmodified = mysql2date( 'U', get_lastpostmodified( 'blog', $feed[2]), false );
|
420 |
+
// calculate time span, uses get_firstpostdate() function defined in xml-sitemap/inc/functions.php !
|
421 |
+
xmlsf()->timespan = xmlsf()->lastmodified - mysql2date( 'U', get_firstpostdate( 'blog', $feed[2]), false );
|
422 |
+
// total post type comment count
|
423 |
+
xmlsf()->comment_count = wp_count_comments($feed[2])->approved;
|
424 |
};
|
425 |
|
426 |
// setup filter
|
428 |
|
429 |
$request['post_type'] = $feed[2];
|
430 |
$request['orderby'] = 'modified';
|
431 |
+
$request['order'] = 'DESC';
|
432 |
$request['is_date'] = false;
|
433 |
|
434 |
break;
|
437 |
|
438 |
if ( !isset( $feed[2] ) ) break;
|
439 |
|
440 |
+
// try to raise memory limit, context added for filters
|
441 |
+
wp_raise_memory_limit( 'sitemap-taxonomy-'.$feed[2] );
|
442 |
+
|
443 |
// WPML compat
|
444 |
global $sitepress;
|
445 |
if ( is_object($sitepress) ) {
|
472 |
* @return array
|
473 |
*/
|
474 |
function xmlsf_cache_get_archives( $query ) {
|
475 |
+
|
476 |
global $wpdb;
|
477 |
|
478 |
$key = md5($query);
|
487 |
}
|
488 |
|
489 |
return $arcresults;
|
|
|
490 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
491 |
}
|
492 |
|
493 |
/* -------------------------------------
|
507 |
*/
|
508 |
if( !function_exists('_get_post_time') ) {
|
509 |
function _get_post_time( $timezone, $field, $post_type = 'any', $which = 'last', $m = '' ) {
|
510 |
+
|
511 |
global $wpdb;
|
512 |
|
513 |
if ( !in_array( $field, array( 'date', 'modified' ) ) ) {
|
561 |
|
562 |
$order = ( $which == 'last' ) ? 'DESC' : 'ASC';
|
563 |
|
564 |
+
/* CODE SUGGESTION BY Frédéric Demarle
|
565 |
+
* to make this language aware:
|
566 |
+
"SELECT post_{$field}_gmt FROM $wpdb->posts" . PLL()->model->post->join_clause()
|
567 |
+
."WHERE post_status = 'publish' AND post_type IN ({$post_types})" . PLL()->model->post->where_clause( $lang )
|
568 |
+
. ORDER BY post_{$field}_gmt DESC LIMIT 1
|
569 |
+
*/
|
570 |
switch ( $timezone ) {
|
571 |
case 'gmt':
|
572 |
$date = $wpdb->get_var("SELECT post_{$field}_gmt FROM $wpdb->posts WHERE $where ORDER BY post_{$field}_gmt $order LIMIT 1");
|
587 |
}
|
588 |
|
589 |
return false;
|
590 |
+
|
591 |
+
}
|
592 |
+
}
|
593 |
+
|
594 |
+
/**
|
595 |
+
* Retrieve the date that the first post/page was published.
|
596 |
+
* Variation of function get_lastpostdate, uses _get_post_time
|
597 |
+
*
|
598 |
+
* The server timezone is the default and is the difference between GMT and
|
599 |
+
* server time. The 'blog' value is the date when the last post was posted. The
|
600 |
+
* 'gmt' is when the last post was posted in GMT formatted date.
|
601 |
+
*
|
602 |
+
* @uses apply_filters() Calls 'get_firstpostdate' filter
|
603 |
+
* @param string $timezone The location to get the time. Can be 'gmt', 'blog', or 'server'.
|
604 |
+
* @param string $post_type Post type to check.
|
605 |
+
* @return string The date of the last post.
|
606 |
+
*/
|
607 |
+
if( !function_exists('get_firstpostdate') ) {
|
608 |
+
function get_firstpostdate($timezone = 'server', $post_type = 'any') {
|
609 |
+
|
610 |
+
return apply_filters( 'get_firstpostdate', _get_post_time( $timezone, 'date', $post_type, 'first' ), $timezone );
|
611 |
+
|
612 |
}
|
613 |
}
|
|
|
|
|
614 |
|
615 |
+
/**
|
616 |
+
* Retrieve last post/page modified date depending on timezone.
|
617 |
+
* Variation of function get_lastpostmodified, uses _get_post_time
|
618 |
+
*
|
619 |
+
* The server timezone is the default and is the difference between GMT and
|
620 |
+
* server time. The 'blog' value is the date when the last post was posted. The
|
621 |
+
* 'gmt' is when the last post was posted in GMT formatted date.
|
622 |
+
*
|
623 |
+
* @uses apply_filters() Calls 'get_lastmodified' filter
|
624 |
+
* @param string $timezone The location to get the time. Can be 'gmt', 'blog', or 'server'.
|
625 |
+
* @return string The date of the oldest modified post.
|
626 |
+
*/
|
627 |
+
if( !function_exists('get_lastmodified') ) {
|
628 |
+
function get_lastmodified( $timezone = 'server', $post_type = 'any', $m = '' ) {
|
629 |
+
|
630 |
+
return apply_filters( 'get_lastmodified', _get_post_time( $timezone, 'modified', $post_type, 'last', $m ), $timezone );
|
631 |
+
|
632 |
+
}
|
633 |
+
}
|
models/{main.php → functions.shared.php}
RENAMED
@@ -9,12 +9,16 @@
|
|
9 |
*/
|
10 |
function xmlsf_filter_request( $request ) {
|
11 |
|
|
|
|
|
|
|
12 |
if ( isset($request['feed']) && strpos($request['feed'],'sitemap') === 0 ) :
|
13 |
|
14 |
// make sure we have the proper locale setting for calculations
|
15 |
setlocale( LC_NUMERIC, 'C' );
|
16 |
|
17 |
-
|
|
|
18 |
|
19 |
// set the sitemap conditional flag
|
20 |
xmlsf()->is_sitemap = true;
|
@@ -22,12 +26,14 @@ function xmlsf_filter_request( $request ) {
|
|
22 |
// REPSONSE HEADERS filtering
|
23 |
add_filter( 'wp_headers', 'xmlsf_headers' );
|
24 |
|
|
|
|
|
|
|
|
|
|
|
25 |
// modify request parameters
|
26 |
$request['post_status'] = 'publish';
|
27 |
-
$request['no_found_rows'] = true;
|
28 |
-
$request['cache_results'] = false;
|
29 |
-
$request['update_post_term_cache'] = false;
|
30 |
-
$request['update_post_meta_cache'] = false;
|
31 |
|
32 |
// PLUGIN COMPATIBILITIES
|
33 |
// Polylang
|
@@ -45,17 +51,17 @@ function xmlsf_filter_request( $request ) {
|
|
45 |
// check for gz request
|
46 |
if ( substr($request['feed'], -3) == '.gz' ) {
|
47 |
$request['feed'] = substr($request['feed'], 0, -3);
|
48 |
-
|
49 |
}
|
50 |
|
51 |
if ( strpos($request['feed'],'sitemap-news') === 0 ) {
|
52 |
// set the news sitemap conditional flag
|
53 |
xmlsf()->is_news = true;
|
54 |
|
55 |
-
|
56 |
$request = xmlsf_sitemap_news_parse_request( $request );
|
57 |
} else {
|
58 |
-
require_once XMLSF_DIR . '/models/public
|
59 |
$request = xmlsf_sitemap_parse_request( $request );
|
60 |
}
|
61 |
|
@@ -85,7 +91,7 @@ function xmlsf_untrailingslash( $request ) {
|
|
85 |
* @param $se google|bing
|
86 |
* @param $sitemap sitemap
|
87 |
* @param $interval seconds
|
88 |
-
* @return string ping response|999 (
|
89 |
*/
|
90 |
function xmlsf_ping( $se, $sitemap, $interval ) {
|
91 |
if ( 'google' == $se ) {
|
@@ -105,15 +111,9 @@ function xmlsf_ping( $se, $sitemap, $interval ) {
|
|
105 |
if ( 200 === $code ) {
|
106 |
set_transient( 'xmlsf_ping_'.$se.'_'.$sitemap, '', $interval );
|
107 |
}
|
108 |
-
|
109 |
-
if ( defined('WP_DEBUG') && WP_DEBUG == true ) {
|
110 |
-
error_log( 'Pinged '. $url .' with response code: ' . $code );
|
111 |
-
}
|
112 |
} else {
|
|
|
113 |
$code = 999;
|
114 |
-
if ( defined('WP_DEBUG') && WP_DEBUG == true ) {
|
115 |
-
error_log( 'Ping '. $se .' skipped.' );
|
116 |
-
}
|
117 |
}
|
118 |
|
119 |
do_action( 'xmlsf_ping', $se, $sitemap, $url, $code );
|
@@ -148,23 +148,24 @@ function xmlsf_nginx_helper_purge_urls( $urls = array(), $redis = false ) {
|
|
148 |
$urls[] = '/sitemap-home.xml';
|
149 |
$urls[] = '/sitemap-custom.xml';
|
150 |
|
151 |
-
require_once XMLSF_DIR . '/models/public/sitemap.php';
|
152 |
-
|
153 |
// add public post types sitemaps
|
154 |
$post_types = get_option( 'xmlsf_post_types' );
|
155 |
-
if ( is_array($post_types) )
|
156 |
foreach ( $post_types as $post_type => $settings ) {
|
157 |
$archive = !empty($settings['archive']) ? $settings['archive'] : '';
|
158 |
-
foreach ( xmlsf_get_archives($post_type,$archive) as $url )
|
159 |
-
|
160 |
-
|
|
|
|
|
161 |
|
162 |
// add public post taxonomies sitemaps
|
163 |
$taxonomies = get_option('xmlsf_taxonomies');
|
164 |
-
if ( is_array($taxonomies) )
|
165 |
foreach ( $taxonomies as $taxonomy ) {
|
166 |
$urls[] = parse_url( xmlsf_get_index_url('taxonomy',$taxonomy), PHP_URL_PATH);
|
167 |
-
}
|
|
|
168 |
}
|
169 |
}
|
170 |
|
9 |
*/
|
10 |
function xmlsf_filter_request( $request ) {
|
11 |
|
12 |
+
// short-circuit if request has already been filtered
|
13 |
+
if ( xmlsf()->request_filtered ) return $request;
|
14 |
+
|
15 |
if ( isset($request['feed']) && strpos($request['feed'],'sitemap') === 0 ) :
|
16 |
|
17 |
// make sure we have the proper locale setting for calculations
|
18 |
setlocale( LC_NUMERIC, 'C' );
|
19 |
|
20 |
+
// include shared functions
|
21 |
+
require_once XMLSF_DIR . '/models/functions.public-shared.php';
|
22 |
|
23 |
// set the sitemap conditional flag
|
24 |
xmlsf()->is_sitemap = true;
|
26 |
// REPSONSE HEADERS filtering
|
27 |
add_filter( 'wp_headers', 'xmlsf_headers' );
|
28 |
|
29 |
+
// Remove filters to prevent stuff like cdn urls for xml stylesheet and images
|
30 |
+
remove_all_filters( 'plugins_url' );
|
31 |
+
remove_all_filters( 'wp_get_attachment_url' );
|
32 |
+
remove_all_filters( 'image_downsize' );
|
33 |
+
|
34 |
// modify request parameters
|
35 |
$request['post_status'] = 'publish';
|
36 |
+
$request['no_found_rows'] = true; // found rows calc is slow and only needed for pagination
|
|
|
|
|
|
|
37 |
|
38 |
// PLUGIN COMPATIBILITIES
|
39 |
// Polylang
|
51 |
// check for gz request
|
52 |
if ( substr($request['feed'], -3) == '.gz' ) {
|
53 |
$request['feed'] = substr($request['feed'], 0, -3);
|
54 |
+
xmlsf_output_compression();
|
55 |
}
|
56 |
|
57 |
if ( strpos($request['feed'],'sitemap-news') === 0 ) {
|
58 |
// set the news sitemap conditional flag
|
59 |
xmlsf()->is_news = true;
|
60 |
|
61 |
+
require_once XMLSF_DIR . '/models/functions.public-sitemap-news.php';
|
62 |
$request = xmlsf_sitemap_news_parse_request( $request );
|
63 |
} else {
|
64 |
+
require_once XMLSF_DIR . '/models/functions.public-sitemap.php';
|
65 |
$request = xmlsf_sitemap_parse_request( $request );
|
66 |
}
|
67 |
|
91 |
* @param $se google|bing
|
92 |
* @param $sitemap sitemap
|
93 |
* @param $interval seconds
|
94 |
+
* @return string ping response|999 (skipped)
|
95 |
*/
|
96 |
function xmlsf_ping( $se, $sitemap, $interval ) {
|
97 |
if ( 'google' == $se ) {
|
111 |
if ( 200 === $code ) {
|
112 |
set_transient( 'xmlsf_ping_'.$se.'_'.$sitemap, '', $interval );
|
113 |
}
|
|
|
|
|
|
|
|
|
114 |
} else {
|
115 |
+
// Skip !
|
116 |
$code = 999;
|
|
|
|
|
|
|
117 |
}
|
118 |
|
119 |
do_action( 'xmlsf_ping', $se, $sitemap, $url, $code );
|
148 |
$urls[] = '/sitemap-home.xml';
|
149 |
$urls[] = '/sitemap-custom.xml';
|
150 |
|
|
|
|
|
151 |
// add public post types sitemaps
|
152 |
$post_types = get_option( 'xmlsf_post_types' );
|
153 |
+
if ( is_array($post_types) ) {
|
154 |
foreach ( $post_types as $post_type => $settings ) {
|
155 |
$archive = !empty($settings['archive']) ? $settings['archive'] : '';
|
156 |
+
foreach ( xmlsf_get_archives($post_type,$archive) as $url ) {
|
157 |
+
$urls[] = parse_url( $url, PHP_URL_PATH);
|
158 |
+
}
|
159 |
+
}
|
160 |
+
}
|
161 |
|
162 |
// add public post taxonomies sitemaps
|
163 |
$taxonomies = get_option('xmlsf_taxonomies');
|
164 |
+
if ( is_array($taxonomies) ) {
|
165 |
foreach ( $taxonomies as $taxonomy ) {
|
166 |
$urls[] = parse_url( xmlsf_get_index_url('taxonomy',$taxonomy), PHP_URL_PATH);
|
167 |
+
}
|
168 |
+
}
|
169 |
}
|
170 |
}
|
171 |
|
models/{sitemap-news.php → functions.sitemap-news.php}
RENAMED
@@ -13,5 +13,5 @@ function xmlsf_news_filter_post_types( $post_types ) {
|
|
13 |
unset( $post_types[$post_type] );
|
14 |
}
|
15 |
|
16 |
-
return array_filter( $post_types );
|
17 |
}
|
13 |
unset( $post_types[$post_type] );
|
14 |
}
|
15 |
|
16 |
+
return array_filter( (array) $post_types );
|
17 |
}
|
models/functions.sitemap.php
ADDED
@@ -0,0 +1,255 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Filter sitemap post types
|
5 |
+
*
|
6 |
+
* @since 5.0
|
7 |
+
* @param $post_types array
|
8 |
+
* @return array
|
9 |
+
*/
|
10 |
+
function xmlsf_filter_post_types( $post_types ) {
|
11 |
+
// Always exclude attachment and reply post types (bbpress)
|
12 |
+
unset( $post_types['attachment'], $post_types['reply'] );
|
13 |
+
|
14 |
+
return array_filter( (array) $post_types );
|
15 |
+
}
|
16 |
+
|
17 |
+
/**
|
18 |
+
* Get index url
|
19 |
+
*
|
20 |
+
* @param string $sitemap
|
21 |
+
* @param string $type
|
22 |
+
* @param string $parm
|
23 |
+
*
|
24 |
+
* @return string
|
25 |
+
*/
|
26 |
+
function xmlsf_get_index_url( $sitemap = 'home', $type = false, $param = false ) {
|
27 |
+
|
28 |
+
if ( xmlsf()->plain_permalinks() ) {
|
29 |
+
$name = '?feed=sitemap-'.$sitemap;
|
30 |
+
$name .= $type ? '-'.$type : '';
|
31 |
+
$name .= $param ? '&m='.$param : '';
|
32 |
+
} else {
|
33 |
+
$name = 'sitemap-'.$sitemap;
|
34 |
+
$name .= $type ? '-'.$type : '';
|
35 |
+
$name .= $param ? '.'.$param : '';
|
36 |
+
$name .= '.xml';
|
37 |
+
}
|
38 |
+
|
39 |
+
return esc_url( trailingslashit( home_url() ) . $name );
|
40 |
+
|
41 |
+
}
|
42 |
+
|
43 |
+
/**
|
44 |
+
* Get archives
|
45 |
+
*
|
46 |
+
* @param string $post_type
|
47 |
+
* @param string $type
|
48 |
+
*
|
49 |
+
* @return array
|
50 |
+
*/
|
51 |
+
function xmlsf_get_archives( $post_type = 'post', $type = '' ) {
|
52 |
+
|
53 |
+
global $wpdb;
|
54 |
+
$return = array();
|
55 |
+
|
56 |
+
if ( 'monthly' == $type ) :
|
57 |
+
|
58 |
+
$query = "SELECT YEAR(post_date) as `year`, LPAD(MONTH(post_date),2,'0') as `month`, count(ID) as posts FROM {$wpdb->posts} WHERE post_type = '{$post_type}' AND post_status = 'publish' GROUP BY YEAR(post_date), MONTH(post_date) ORDER BY post_date DESC";
|
59 |
+
$arcresults = xmlsf_cache_get_archives( $query );
|
60 |
+
|
61 |
+
foreach ( (array) $arcresults as $arcresult ) {
|
62 |
+
$return[$arcresult->year.$arcresult->month] = xmlsf_get_index_url( 'posttype', $post_type, $arcresult->year . $arcresult->month );
|
63 |
+
};
|
64 |
+
|
65 |
+
elseif ( 'yearly' == $type ) :
|
66 |
+
|
67 |
+
$query = "SELECT YEAR(post_date) as `year`, count(ID) as posts FROM {$wpdb->posts} WHERE post_type = '{$post_type}' AND post_status = 'publish' GROUP BY YEAR(post_date) ORDER BY post_date DESC";
|
68 |
+
$arcresults = xmlsf_cache_get_archives( $query );
|
69 |
+
|
70 |
+
foreach ( (array) $arcresults as $arcresult ) {
|
71 |
+
$return[$arcresult->year] = xmlsf_get_index_url( 'posttype', $post_type, $arcresult->year );
|
72 |
+
};
|
73 |
+
|
74 |
+
else :
|
75 |
+
|
76 |
+
$query = "SELECT count(ID) as posts FROM {$wpdb->posts} WHERE post_type = '{$post_type}' AND post_status = 'publish' ORDER BY post_date DESC";
|
77 |
+
$arcresults = xmlsf_cache_get_archives( $query );
|
78 |
+
|
79 |
+
if ( is_object($arcresults[0]) && $arcresults[0]->posts > 0 ) {
|
80 |
+
$return[] = xmlsf_get_index_url( 'posttype', $post_type ); // $sitemap = 'home', $type = false, $param = false
|
81 |
+
};
|
82 |
+
|
83 |
+
endif;
|
84 |
+
|
85 |
+
return $return;
|
86 |
+
|
87 |
+
}
|
88 |
+
|
89 |
+
/**
|
90 |
+
* Get taxonomies
|
91 |
+
* Returns an array of taxonomy names to be included in the index
|
92 |
+
*
|
93 |
+
* @since 5.0
|
94 |
+
* @param void
|
95 |
+
* @return array
|
96 |
+
*/
|
97 |
+
function xmlsf_get_taxonomies() {
|
98 |
+
$taxonomy_settings = get_option('xmlsf_taxonomy_settings');
|
99 |
+
$tax_array = array();
|
100 |
+
if ( !empty( $taxonomy_settings['active'] ) ) {
|
101 |
+
$taxonomies = get_option('xmlsf_taxonomies');
|
102 |
+
if ( is_array($taxonomies) ) {
|
103 |
+
foreach ( $taxonomies as $taxonomy ) {
|
104 |
+
$count = wp_count_terms( $taxonomy, array('hide_empty'=>true) );
|
105 |
+
if ( !is_wp_error($count) && $count > 0 )
|
106 |
+
$tax_array[] = $taxonomy;
|
107 |
+
}
|
108 |
+
} else {
|
109 |
+
foreach ( xmlsf_public_taxonomies() as $name => $label )
|
110 |
+
if ( 0 < wp_count_terms( $name, array('hide_empty'=>true) ) )
|
111 |
+
$tax_array[] = $name;
|
112 |
+
}
|
113 |
+
}
|
114 |
+
return $tax_array;
|
115 |
+
}
|
116 |
+
|
117 |
+
/**
|
118 |
+
* Get all public (and not empty) taxonomies
|
119 |
+
* Returns an array associated taxonomy object names and labels.
|
120 |
+
*
|
121 |
+
* @since 5.0
|
122 |
+
* @param void
|
123 |
+
* @return array
|
124 |
+
*/
|
125 |
+
function xmlsf_public_taxonomies() {
|
126 |
+
|
127 |
+
$tax_array = array();
|
128 |
+
|
129 |
+
foreach ( (array) get_option( 'xmlsf_post_types' ) as $post_type => $settings ) {
|
130 |
+
|
131 |
+
if ( empty($settings['active']) ) continue;
|
132 |
+
|
133 |
+
// check each tax public flag and term count and append name to array
|
134 |
+
foreach ( get_object_taxonomies( $post_type, 'objects' ) as $taxonomy ) {
|
135 |
+
if ( !empty( $taxonomy->public ) && !in_array( $taxonomy->name, xmlsf()->disabled_taxonomies() ) )
|
136 |
+
$tax_array[$taxonomy->name] = $taxonomy->label;
|
137 |
+
}
|
138 |
+
|
139 |
+
}
|
140 |
+
|
141 |
+
return $tax_array;
|
142 |
+
}
|
143 |
+
|
144 |
+
/**
|
145 |
+
* Santize priority value
|
146 |
+
* Expects proper locale setting for calculations: setlocale( LC_NUMERIC, 'C' );
|
147 |
+
*
|
148 |
+
* Returns a float within the set limits.
|
149 |
+
*
|
150 |
+
* @since 5.2
|
151 |
+
* @param float $priority
|
152 |
+
* @param float $min
|
153 |
+
* @param float $max
|
154 |
+
* @return float
|
155 |
+
*/
|
156 |
+
function xmlsf_sanitize_priority( $priority, $min = 0, $max = 1 ) {
|
157 |
+
|
158 |
+
$priority = (float) $priority;
|
159 |
+
$min = (float) $min;
|
160 |
+
$max = (float) $max;
|
161 |
+
|
162 |
+
if ( $priority <= $min ) {
|
163 |
+
return number_format( $min, 1 );
|
164 |
+
} elseif ( $priority >= $max ) {
|
165 |
+
return number_format( $max, 1 );
|
166 |
+
} else {
|
167 |
+
return number_format( $priority, 1 );
|
168 |
+
}
|
169 |
+
}
|
170 |
+
|
171 |
+
/**
|
172 |
+
* Get post attached | featured image(s)
|
173 |
+
*
|
174 |
+
* @param object $post
|
175 |
+
* @param string $which
|
176 |
+
*
|
177 |
+
* @return array
|
178 |
+
*/
|
179 |
+
function xmlsf_images_data( $post, $which ) {
|
180 |
+
$attachments = array();
|
181 |
+
|
182 |
+
if ( 'featured' == $which ) {
|
183 |
+
|
184 |
+
if ( has_post_thumbnail( $post->ID ) ) {
|
185 |
+
$featured = get_post( get_post_thumbnail_id( $post->ID ) );
|
186 |
+
if ( is_object($featured) ) {
|
187 |
+
$attachments[] = $featured;
|
188 |
+
}
|
189 |
+
}
|
190 |
+
|
191 |
+
} elseif ( 'attached' == $which ) {
|
192 |
+
|
193 |
+
$args = array(
|
194 |
+
'post_type' => 'attachment',
|
195 |
+
'post_mime_type' => 'image',
|
196 |
+
'numberposts' => -1,
|
197 |
+
'post_status' =>'inherit',
|
198 |
+
'post_parent' => $post->ID
|
199 |
+
);
|
200 |
+
|
201 |
+
$attachments = get_posts( $args );
|
202 |
+
|
203 |
+
}
|
204 |
+
|
205 |
+
if ( empty( $attachments ) ) return array();
|
206 |
+
|
207 |
+
// gather all data
|
208 |
+
$images_data = array();
|
209 |
+
|
210 |
+
foreach ( $attachments as $attachment ) {
|
211 |
+
|
212 |
+
$url = wp_get_attachment_url( $attachment->ID );
|
213 |
+
|
214 |
+
if ( !empty($url) ) {
|
215 |
+
|
216 |
+
$url = esc_attr( esc_url_raw( $url ) );
|
217 |
+
|
218 |
+
$images_data[$url] = array(
|
219 |
+
'loc' => $url,
|
220 |
+
'title' => apply_filters( 'the_title_xmlsitemap', $attachment->post_title ),
|
221 |
+
'caption' => apply_filters( 'the_title_xmlsitemap', $attachment->post_excerpt )
|
222 |
+
// 'caption' => apply_filters( 'the_title_xmlsitemap', get_post_meta( $attachment->ID, '_wp_attachment_image_alt', true ) )
|
223 |
+
);
|
224 |
+
|
225 |
+
}
|
226 |
+
|
227 |
+
}
|
228 |
+
|
229 |
+
return $images_data;
|
230 |
+
}
|
231 |
+
|
232 |
+
/**
|
233 |
+
* Get instantiated sitemap controller class
|
234 |
+
*
|
235 |
+
* @since 5.2
|
236 |
+
* @global XMLSF_Sitemap $xmlsf_sitemap
|
237 |
+
* @return XMLSF_Sitemap object
|
238 |
+
*/
|
239 |
+
function xmlsf_sitemap( $sitemap = null ) {
|
240 |
+
global $xmlsf_sitemap;
|
241 |
+
|
242 |
+
if ( ! isset( $xmlsf_sitemap ) ) {
|
243 |
+
if ( ! class_exists( 'XMLSF_Sitemap' ) )
|
244 |
+
require XMLSF_DIR . '/controllers/class.xmlsf-sitemap.php';
|
245 |
+
|
246 |
+
if ( empty($sitemap) ) {
|
247 |
+
$sitemaps = get_option( 'xmlsf_sitemaps' );
|
248 |
+
$sitemap = $sitemaps['sitemap'];
|
249 |
+
}
|
250 |
+
|
251 |
+
$xmlsf_sitemap = new XMLSF_Sitemap( $sitemap );
|
252 |
+
}
|
253 |
+
|
254 |
+
return $xmlsf_sitemap;
|
255 |
+
}
|
models/public/shared.php
DELETED
@@ -1,123 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/**
|
4 |
-
* Response headers filter
|
5 |
-
* Does not check if we are really in a sitemap feed.
|
6 |
-
*
|
7 |
-
* @param $headers
|
8 |
-
*
|
9 |
-
* @return array
|
10 |
-
*/
|
11 |
-
function xmlsf_headers( $headers ) {
|
12 |
-
// set noindex
|
13 |
-
$headers['X-Robots-Tag'] = 'noindex, follow';
|
14 |
-
$headers['Content-Type'] = 'text/xml; charset=' . get_bloginfo('charset');
|
15 |
-
return $headers;
|
16 |
-
}
|
17 |
-
|
18 |
-
/**
|
19 |
-
* Get images
|
20 |
-
*
|
21 |
-
* @param string $sitemap
|
22 |
-
*
|
23 |
-
* @return array|bool
|
24 |
-
*/
|
25 |
-
function xmlsf_get_images( $sitemap = '' ) {
|
26 |
-
global $post;
|
27 |
-
$images = array();
|
28 |
-
|
29 |
-
if ( 'news' == $sitemap ) {
|
30 |
-
$options = get_option('xmlsf_news_tags');
|
31 |
-
$which = isset($options['image']) ? $options['image'] : '';
|
32 |
-
} else {
|
33 |
-
$options = get_option('xmlsf_post_types');
|
34 |
-
$which = is_array($options) && isset($options[$post->post_type]['tags']['image']) ? $options[$post->post_type]['tags']['image'] : '';
|
35 |
-
}
|
36 |
-
|
37 |
-
if ( 'attached' == $which ) {
|
38 |
-
$args = array( 'post_type' => 'attachment', 'post_mime_type' => 'image', 'numberposts' => -1, 'post_status' =>'inherit', 'post_parent' => $post->ID );
|
39 |
-
$attachments = get_posts($args);
|
40 |
-
if ( $attachments ) {
|
41 |
-
foreach ( $attachments as $attachment ) {
|
42 |
-
$url = wp_get_attachment_image_url( $attachment->ID, 'full' );
|
43 |
-
$url = xmlsf_get_absolute_url( $url );
|
44 |
-
if ( !empty($url) ) {
|
45 |
-
$images[] = array(
|
46 |
-
'loc' => esc_attr( esc_url_raw( $url ) ),
|
47 |
-
'title' => apply_filters( 'the_title_xmlsitemap', $attachment->post_title ),
|
48 |
-
'caption' => apply_filters( 'the_title_xmlsitemap', $attachment->post_excerpt )
|
49 |
-
// 'caption' => apply_filters( 'the_title_xmlsitemap', get_post_meta( $attachment->ID, '_wp_attachment_image_alt', true ) )
|
50 |
-
);
|
51 |
-
}
|
52 |
-
}
|
53 |
-
}
|
54 |
-
} elseif ( 'featured' == $which ) {
|
55 |
-
if ( has_post_thumbnail( $post->ID ) ) {
|
56 |
-
$attachment = get_post( get_post_thumbnail_id( $post->ID ) );
|
57 |
-
$url = wp_get_attachment_image_url( get_post_thumbnail_id( $post->ID ), 'full' );
|
58 |
-
$url = xmlsf_get_absolute_url( $url );
|
59 |
-
if ( !empty($url) ) {
|
60 |
-
$images[] = array(
|
61 |
-
'loc' => esc_attr( esc_url_raw( $url ) ),
|
62 |
-
'title' => apply_filters( 'the_title_xmlsitemap', $attachment->post_title ),
|
63 |
-
'caption' => apply_filters( 'the_title_xmlsitemap', $attachment->post_excerpt )
|
64 |
-
// 'caption' => apply_filters( 'the_title_xmlsitemap', get_post_meta( $attachment->ID, '_wp_attachment_image_alt', true ) )
|
65 |
-
);
|
66 |
-
}
|
67 |
-
}
|
68 |
-
}
|
69 |
-
|
70 |
-
return $images;
|
71 |
-
}
|
72 |
-
|
73 |
-
/**
|
74 |
-
* Get absolute URL
|
75 |
-
* Converts path or protocol relative URLs to absolute ones.
|
76 |
-
*
|
77 |
-
* @param string $url
|
78 |
-
*
|
79 |
-
* @return string|bool
|
80 |
-
*/
|
81 |
-
function xmlsf_get_absolute_url( $url = false ) {
|
82 |
-
// have a string or return false
|
83 |
-
if ( empty( $url ) || ! is_string( $url ) ) {
|
84 |
-
return false;
|
85 |
-
}
|
86 |
-
|
87 |
-
// check for scheme
|
88 |
-
if ( strpos( $url, 'http' ) !== 0 ) {
|
89 |
-
// check for relative url path
|
90 |
-
if ( strpos( $url, '//' ) !== 0 ) {
|
91 |
-
return ( strpos( $url, '/' ) === 0 ) ? untrailingslashit( home_url() ) . $url : trailingslashit( home_url() ) . $url;
|
92 |
-
}
|
93 |
-
return xmlsf()->scheme() . ':' . $url;
|
94 |
-
}
|
95 |
-
|
96 |
-
return $url;
|
97 |
-
}
|
98 |
-
|
99 |
-
/**
|
100 |
-
* Is allowed domain
|
101 |
-
*
|
102 |
-
* @param $url
|
103 |
-
*
|
104 |
-
* @return mixed|void
|
105 |
-
*/
|
106 |
-
function xmlsf_is_allowed_domain( $url ) {
|
107 |
-
|
108 |
-
$domains = xmlsf()->get_allowed_domains();
|
109 |
-
|
110 |
-
$return = false;
|
111 |
-
$parsed_url = parse_url($url);
|
112 |
-
|
113 |
-
if (isset($parsed_url['host'])) {
|
114 |
-
foreach ( $domains as $domain ) {
|
115 |
-
if ( $parsed_url['host'] == $domain || strpos($parsed_url['host'],'.'.$domain) !== false ) {
|
116 |
-
$return = true;
|
117 |
-
break;
|
118 |
-
}
|
119 |
-
}
|
120 |
-
}
|
121 |
-
|
122 |
-
return apply_filters( 'xmlsf_allowed_domain', $return, $url );
|
123 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
models/sitemap.php
DELETED
@@ -1,68 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/**
|
4 |
-
* Filter sitemap post types
|
5 |
-
*
|
6 |
-
* @since 5.0
|
7 |
-
* @param $post_types array
|
8 |
-
* @return array
|
9 |
-
*/
|
10 |
-
function xmlsf_filter_post_types( $post_types ) {
|
11 |
-
// Always exclude attachment and reply post types (bbpress)
|
12 |
-
unset( $post_types['attachment'], $post_types['reply'] );
|
13 |
-
|
14 |
-
return array_filter( $post_types );
|
15 |
-
}
|
16 |
-
|
17 |
-
/**
|
18 |
-
* Get taxonomies
|
19 |
-
* Returns an array of taxonomy names to be included in the index
|
20 |
-
*
|
21 |
-
* @since 5.0
|
22 |
-
* @param void
|
23 |
-
* @return array
|
24 |
-
*/
|
25 |
-
function xmlsf_get_taxonomies() {
|
26 |
-
$taxonomy_settings = get_option('xmlsf_taxonomy_settings');
|
27 |
-
$tax_array = array();
|
28 |
-
if ( !empty( $taxonomy_settings['active'] ) ) {
|
29 |
-
$taxonomies = get_option('xmlsf_taxonomies');
|
30 |
-
if ( is_array($taxonomies) ) {
|
31 |
-
foreach ( $taxonomies as $taxonomy ) {
|
32 |
-
$count = wp_count_terms( $taxonomy, array('hide_empty'=>true) );
|
33 |
-
if ( !is_wp_error($count) && $count > 0 )
|
34 |
-
$tax_array[] = $taxonomy;
|
35 |
-
}
|
36 |
-
} else {
|
37 |
-
foreach ( xmlsf_public_taxonomies() as $name => $label )
|
38 |
-
if ( 0 < wp_count_terms( $name, array('hide_empty'=>true) ) )
|
39 |
-
$tax_array[] = $name;
|
40 |
-
}
|
41 |
-
}
|
42 |
-
return $tax_array;
|
43 |
-
}
|
44 |
-
|
45 |
-
/**
|
46 |
-
* Get all public (and not empty) taxonomies
|
47 |
-
* Returns an array associated taxonomy object names and labels.
|
48 |
-
*
|
49 |
-
* @since 5.0
|
50 |
-
* @param void
|
51 |
-
* @return array
|
52 |
-
*/
|
53 |
-
function xmlsf_public_taxonomies() {
|
54 |
-
$tax_array = array();
|
55 |
-
|
56 |
-
foreach ( (array) get_option( 'xmlsf_post_types' ) as $post_type => $settings ) {
|
57 |
-
if ( empty($settings['active']) ) continue;
|
58 |
-
|
59 |
-
$taxonomies = get_object_taxonomies( $post_type, 'objects' );
|
60 |
-
// check each tax public flag and term count and append name to array
|
61 |
-
foreach ( $taxonomies as $taxonomy ) {
|
62 |
-
if ( !empty( $taxonomy->public ) && !in_array( $taxonomy->name, xmlsf()->disabled_taxonomies() ) )
|
63 |
-
$tax_array[$taxonomy->name] = $taxonomy->label;
|
64 |
-
}
|
65 |
-
}
|
66 |
-
|
67 |
-
return $tax_array;
|
68 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
readme.txt
CHANGED
@@ -4,14 +4,14 @@ Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=ravan
|
|
4 |
Tags: sitemap, xml sitemap, news sitemap, sitemap.xml, robots.txt, Google, Google News, Yahoo, Bing, Yandex, Baidu, seo, feed, Polylang, WPML, image sitemap
|
5 |
Requires at least: 4.4
|
6 |
Requires PHP: 5.4
|
7 |
-
Tested up to: 5.
|
8 |
-
Stable tag: 5.
|
9 |
|
10 |
XML and Google News Sitemaps to feed the hungry spiders. Multisite, WP Super Cache, Polylang and WPML compatible.
|
11 |
|
12 |
== Description ==
|
13 |
|
14 |
-
This plugin dynamically creates feeds that comply with the **XML Sitemap** and the **Google News Sitemap** protocol. **Multisite**, **Polylang** and **WPML** compatible and there are no files created. There are options to control which sitemaps are enabled, which Post
|
15 |
|
16 |
The main advantage of this plugin over other XML Sitemap plugins is **simplicity**. No need to change file or folder permissions, move files or spend time tweaking difficult plugin options.
|
17 |
|
@@ -42,7 +42,7 @@ Please read the FAQ's for info on how to get your articles listed on Google News
|
|
42 |
* Custom/static sitemaps can be added to the index.
|
43 |
* Works out-of-the-box, even on **Multisite** installations.
|
44 |
* Optionally include Image tags with caption and title for featured images or attached images.
|
45 |
-
* Pings Google, Bing & Yahoo on new post publication.
|
46 |
* Options to define which post types and if taxonomies get included in the sitemap
|
47 |
* Updates Lastmod on post modification or on comments.
|
48 |
* Set Priority per post type, per taxonomy and per individual post.
|
@@ -50,9 +50,11 @@ Please read the FAQ's for info on how to get your articles listed on Google News
|
|
50 |
|
51 |
**Google News Sitemap**
|
52 |
|
53 |
-
*
|
54 |
-
*
|
55 |
-
*
|
|
|
|
|
56 |
|
57 |
= Pro Features =
|
58 |
|
@@ -196,7 +198,7 @@ You can also choose to notify major search engines of your new XML sitemap manua
|
|
196 |
|
197 |
= Can I change the sitemap name/URL? =
|
198 |
|
199 |
-
No. If you have fancy URL's turned ON in WordPress (Permalinks), the sitemap url
|
200 |
|
201 |
= I see no sitemap.xml file in my site root! =
|
202 |
|
@@ -291,7 +293,7 @@ Yes. In fact, it has been designed for it. Tested on WPMU 2.9.2 and WPMS 3+ both
|
|
291 |
|
292 |
= 5.2 =
|
293 |
|
294 |
-
Major query reduction and speed improvements.
|
295 |
|
296 |
|
297 |
== Changelog ==
|
@@ -301,8 +303,16 @@ Major query reduction and speed improvements. Some bugfixes.
|
|
301 |
* Last comment date meta caching
|
302 |
* Lastmod and publication dates in local time
|
303 |
* Removed ignored image tag from news sitemap
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
304 |
* FIX: possible division by zero
|
305 |
* FIX: update_term_modified_meta
|
|
|
306 |
|
307 |
= 5.1.2 =
|
308 |
* FIX: admin notice dismiss button failing
|
4 |
Tags: sitemap, xml sitemap, news sitemap, sitemap.xml, robots.txt, Google, Google News, Yahoo, Bing, Yandex, Baidu, seo, feed, Polylang, WPML, image sitemap
|
5 |
Requires at least: 4.4
|
6 |
Requires PHP: 5.4
|
7 |
+
Tested up to: 5.2
|
8 |
+
Stable tag: 5.2
|
9 |
|
10 |
XML and Google News Sitemaps to feed the hungry spiders. Multisite, WP Super Cache, Polylang and WPML compatible.
|
11 |
|
12 |
== Description ==
|
13 |
|
14 |
+
This plugin dynamically creates feeds that comply with the **XML Sitemap** and the **Google News Sitemap** protocol. **Multisite**, **Polylang** and **WPML** compatible and there are no files created. There are options to control which sitemaps are enabled, which Post types are included, how Priority and Lastmod are calculated, who to ping and a possibility to set additional robots.txt rules from within the WordPress admin.
|
15 |
|
16 |
The main advantage of this plugin over other XML Sitemap plugins is **simplicity**. No need to change file or folder permissions, move files or spend time tweaking difficult plugin options.
|
17 |
|
42 |
* Custom/static sitemaps can be added to the index.
|
43 |
* Works out-of-the-box, even on **Multisite** installations.
|
44 |
* Optionally include Image tags with caption and title for featured images or attached images.
|
45 |
+
* Pings Google, Bing & Yahoo on new post publication, once per hour.
|
46 |
* Options to define which post types and if taxonomies get included in the sitemap
|
47 |
* Updates Lastmod on post modification or on comments.
|
48 |
* Set Priority per post type, per taxonomy and per individual post.
|
50 |
|
51 |
**Google News Sitemap**
|
52 |
|
53 |
+
* Required news sitemap tags: Publication name, language, title and publication date.
|
54 |
+
* Set a News Publication Name or uses site name.
|
55 |
+
* Supports custom post types.
|
56 |
+
* Limit inclusion to certain post categories.
|
57 |
+
* Pings Google on new publications, once per 5 minutes.
|
58 |
|
59 |
= Pro Features =
|
60 |
|
198 |
|
199 |
= Can I change the sitemap name/URL? =
|
200 |
|
201 |
+
No. If you have fancy URL's turned ON in WordPress (Permalinks), the sitemap url is `yourblogurl.tld/sitemap.xml` but if you have the Permalink Default option set the feed is only available via `yourblog.url/?feed=sitemap`.
|
202 |
|
203 |
= I see no sitemap.xml file in my site root! =
|
204 |
|
293 |
|
294 |
= 5.2 =
|
295 |
|
296 |
+
Major DB query reduction and speed improvements. Bugfixes.
|
297 |
|
298 |
|
299 |
== Changelog ==
|
303 |
* Last comment date meta caching
|
304 |
* Lastmod and publication dates in local time
|
305 |
* Removed ignored image tag from news sitemap
|
306 |
+
* Max memory limit for post type and taxonomy term sitemaps
|
307 |
+
* Prevent CDN file urls
|
308 |
+
* Zlib before GZhandler on .gz request
|
309 |
+
* FIX: don't ping for excluded posts
|
310 |
+
* FIX: traditional and simplified Chinese with WPML
|
311 |
+
* FIX: redundant front page url
|
312 |
+
* FIX: array_filter() expects parameter 1 to be array
|
313 |
* FIX: possible division by zero
|
314 |
* FIX: update_term_modified_meta
|
315 |
+
* FIX: rewrite rules on deactivate/uninstall
|
316 |
|
317 |
= 5.1.2 =
|
318 |
* FIX: admin notice dismiss button failing
|
uninstall.php
CHANGED
@@ -32,10 +32,12 @@ class XMLSitemapFeed_Uninstall {
|
|
32 |
global $wpdb;
|
33 |
|
34 |
// check if it is a multisite and if XMLSF_MULTISITE_UNINSTALL constant is defined
|
35 |
-
|
36 |
if ( is_multisite() && defined('XMLSF_MULTISITE_UNINSTALL') && XMLSF_MULTISITE_UNINSTALL ) {
|
37 |
error_log('Clearing XML Sitemap Feeds settings from each site brefore uninstall:');
|
38 |
-
|
|
|
|
|
39 |
switch_to_blog($blog_id);
|
40 |
$this->uninstall($blog_id);
|
41 |
}
|
@@ -52,8 +54,23 @@ class XMLSitemapFeed_Uninstall {
|
|
52 |
*/
|
53 |
function uninstall($blog_id = false)
|
54 |
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
55 |
// remove plugin settings
|
56 |
-
delete_transient('xmlsf_static_files');
|
57 |
delete_option('xmlsf_version');
|
58 |
delete_option('xmlsf_sitemaps');
|
59 |
delete_option('xmlsf_post_types');
|
@@ -65,9 +82,11 @@ class XMLSitemapFeed_Uninstall {
|
|
65 |
delete_option('xmlsf_custom_sitemaps');
|
66 |
delete_option('xmlsf_domains');
|
67 |
delete_option('xmlsf_news_tags');
|
|
|
|
|
68 |
|
69 |
// remove filter and flush rules
|
70 |
-
remove_filter( 'rewrite_rules_array', 'xmlsf_rewrite_rules',
|
71 |
flush_rewrite_rules();
|
72 |
|
73 |
// Kilroy was here
|
32 |
global $wpdb;
|
33 |
|
34 |
// check if it is a multisite and if XMLSF_MULTISITE_UNINSTALL constant is defined
|
35 |
+
// if so, run the uninstall function for each blog id
|
36 |
if ( is_multisite() && defined('XMLSF_MULTISITE_UNINSTALL') && XMLSF_MULTISITE_UNINSTALL ) {
|
37 |
error_log('Clearing XML Sitemap Feeds settings from each site brefore uninstall:');
|
38 |
+
$field = 'blog_id';
|
39 |
+
$table = $wpdb->prefix.'blogs';
|
40 |
+
foreach ( $wpdb->get_col("SELECT {$field} FROM {$table}") as $blog_id ) {
|
41 |
switch_to_blog($blog_id);
|
42 |
$this->uninstall($blog_id);
|
43 |
}
|
54 |
*/
|
55 |
function uninstall($blog_id = false)
|
56 |
{
|
57 |
+
// remove metadata
|
58 |
+
global $wpdb;
|
59 |
+
// posts meta
|
60 |
+
$wpdb->delete( $wpdb->prefix.'postmeta', array( 'meta_key' => '_xmlsf_image_attached' ) );
|
61 |
+
$wpdb->delete( $wpdb->prefix.'postmeta', array( 'meta_key' => '_xmlsf_image_featured' ) );
|
62 |
+
$wpdb->delete( $wpdb->prefix.'postmeta', array( 'meta_key' => '_xmlsf_comment_date' ) );
|
63 |
+
$wpdb->delete( $wpdb->prefix.'postmeta', array( 'meta_key' => '_xmlsf_priority' ) );
|
64 |
+
$wpdb->delete( $wpdb->prefix.'postmeta', array( 'meta_key' => '_xmlsf_exclude' ) );
|
65 |
+
$wpdb->delete( $wpdb->prefix.'postmeta', array( 'meta_key' => '_xmlsf_news_exclude' ) );
|
66 |
+
// terms meta
|
67 |
+
$wpdb->delete( $wpdb->prefix.'termmeta', array( 'meta_key' => 'term_modified' ) );
|
68 |
+
|
69 |
+
// remove transients
|
70 |
+
delete_transient( 'xmlsf_flush_rewrite_rules' );
|
71 |
+
delete_transient( 'xmlsf_check_static_files' );
|
72 |
+
|
73 |
// remove plugin settings
|
|
|
74 |
delete_option('xmlsf_version');
|
75 |
delete_option('xmlsf_sitemaps');
|
76 |
delete_option('xmlsf_post_types');
|
82 |
delete_option('xmlsf_custom_sitemaps');
|
83 |
delete_option('xmlsf_domains');
|
84 |
delete_option('xmlsf_news_tags');
|
85 |
+
delete_option('xmlsf_images_meta_primed');
|
86 |
+
delete_option('xmlsf_comments_meta_primed');
|
87 |
|
88 |
// remove filter and flush rules
|
89 |
+
remove_filter( 'rewrite_rules_array', 'xmlsf_rewrite_rules', 99 );
|
90 |
flush_rewrite_rules();
|
91 |
|
92 |
// Kilroy was here
|
controllers/upgrade.php → upgrade.php
RENAMED
@@ -56,6 +56,8 @@ class XMLSitemapFeed_Upgrade {
|
|
56 |
*/
|
57 |
function upgrade( $db_version )
|
58 |
{
|
|
|
|
|
59 |
if ( version_compare( '4.4', $db_version, '>' ) ) {
|
60 |
// remove robots.txt rules blocking stylesheets
|
61 |
if ( $robot_rules = get_option( 'xmlsf_robots' ) ) {
|
@@ -170,6 +172,11 @@ class XMLSitemapFeed_Upgrade {
|
|
170 |
delete_transient('xmlsf_ping_bing_sitemap');
|
171 |
}
|
172 |
|
|
|
|
|
|
|
|
|
|
|
173 |
if ( defined('WP_DEBUG') && WP_DEBUG ) {
|
174 |
error_log('XML Sitemap Feeds upgraded from '.$db_version.' to '.XMLSF_VERSION);
|
175 |
}
|
56 |
*/
|
57 |
function upgrade( $db_version )
|
58 |
{
|
59 |
+
global $wpdb;
|
60 |
+
|
61 |
if ( version_compare( '4.4', $db_version, '>' ) ) {
|
62 |
// remove robots.txt rules blocking stylesheets
|
63 |
if ( $robot_rules = get_option( 'xmlsf_robots' ) ) {
|
172 |
delete_transient('xmlsf_ping_bing_sitemap');
|
173 |
}
|
174 |
|
175 |
+
if ( version_compare( '5.2', $db_version, '>' ) ) {
|
176 |
+
// remove term meta term_modified_gmt
|
177 |
+
$wpdb->delete( $wpdb->prefix.'termmeta', array( 'meta_key' => 'term_modified_gmt' ) );
|
178 |
+
}
|
179 |
+
|
180 |
if ( defined('WP_DEBUG') && WP_DEBUG ) {
|
181 |
error_log('XML Sitemap Feeds upgraded from '.$db_version.' to '.XMLSF_VERSION);
|
182 |
}
|
views/_generator.php
CHANGED
@@ -1,4 +1,4 @@
|
|
1 |
<!-- generated-on="<?php echo $date; ?>" -->
|
2 |
-
<!-- generator="XML & Google News
|
3 |
<!-- generator-url="https://status301.net/wordpress-plugins/xml-sitemap-feed/" -->
|
4 |
<!-- generator-version="<?php echo XMLSF_VERSION; ?>" -->
|
1 |
<!-- generated-on="<?php echo $date; ?>" -->
|
2 |
+
<!-- generator="XML Sitemap & Google News for WordPress" -->
|
3 |
<!-- generator-url="https://status301.net/wordpress-plugins/xml-sitemap-feed/" -->
|
4 |
<!-- generator-version="<?php echo XMLSF_VERSION; ?>" -->
|
views/_usage.php
CHANGED
@@ -1 +1 @@
|
|
1 |
-
<!-- Queries executed: <?php echo $num; if ( $mem ) { ?> | Peak memory usage: <?php echo $mem; } ?> -->
|
1 |
+
<!-- Queries executed: <?php echo $num; if ( $mem ) { ?> | Peak memory usage: <?php echo $mem; } ?> | Memory limit: <?php echo $limit; ?> -->
|
views/admin/field-news-categories.php
CHANGED
@@ -1,12 +1,12 @@
|
|
1 |
<fieldset>
|
2 |
-
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
<?php echo $cat_list; ?>
|
11 |
</ul>
|
12 |
</fieldset>
|
1 |
<fieldset>
|
2 |
+
<legend class="screen-reader-text">
|
3 |
+
<?php echo translate('Categories'); ?>
|
4 |
+
</legend>
|
5 |
+
<p>
|
6 |
+
<?php _e('Limit to posts in these post categories:','xml-sitemap-feed'); ?>
|
7 |
+
</p>
|
8 |
+
<style type"text/css">ul.children{padding-left:1em}</style>
|
9 |
+
<ul class="cat-checklist">
|
10 |
<?php echo $cat_list; ?>
|
11 |
</ul>
|
12 |
</fieldset>
|
views/admin/field-news-image.php
DELETED
@@ -1,10 +0,0 @@
|
|
1 |
-
<fieldset>
|
2 |
-
<legend class="screen-reader-text"><?php echo translate('Images'); ?></legend>
|
3 |
-
<label><?php _e('Add image tags for','xml-sitemap-feed'); ?>
|
4 |
-
<select name="xmlsf_news_tags[image]">
|
5 |
-
<option value=""><?php echo translate('None'); ?></option>
|
6 |
-
<option value="featured"<?php echo selected( $image == "featured", true, false); ?>><?php echo translate_with_gettext_context('Featured Image','post'); ?></option>
|
7 |
-
<option value="attached"<?php echo selected( $image == "attached", true, false); ?>><?php _e('Attached images','xml-sitemap-feed'); ?></option>
|
8 |
-
</select>
|
9 |
-
</label>
|
10 |
-
</fieldset>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
views/admin/field-sitemap-taxonomies.php
CHANGED
@@ -1,18 +1,22 @@
|
|
1 |
<fieldset id="xmlsf_taxonomies">
|
2 |
-
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
|
|
|
|
|
|
|
|
16 |
<p class="description warning" style="color: red;">
|
17 |
<?php _e( 'No taxonomies available for the currently included post types.', 'xml-sitemap-feed' ); ?>
|
18 |
</p>
|
1 |
<fieldset id="xmlsf_taxonomies">
|
2 |
+
<legend class="screen-reader-text">
|
3 |
+
<?php _e( 'Taxonomies', 'xml-sitemap-feed' ); ?>
|
4 |
+
</legend>
|
5 |
+
<p>
|
6 |
+
<?php _e('Limit to these taxonomies:','xml-sitemap-feed'); ?>
|
7 |
+
</p>
|
8 |
+
<?php if ( !empty( $this->public_taxonomies() ) ) { ?>
|
9 |
+
<ul class="cat-checklist">
|
10 |
+
<?php foreach ( $this->public_taxonomies() as $name => $label ) { ?>
|
11 |
+
<li>
|
12 |
+
<label>
|
13 |
+
<input type="checkbox" name="xmlsf_taxonomies[]" id="xmlsf_taxonomies_'<?php echo $name; ?>" value="<?php echo $name; ?>" <?php checked( in_array( $name, (array) $taxonomies ) ); ?>/>
|
14 |
+
<?php echo $label; ?> (<?php echo wp_count_terms( $name ); ?>)
|
15 |
+
</label>
|
16 |
+
</li>
|
17 |
+
<?php } ?>
|
18 |
+
</ul>
|
19 |
+
<?php } else { ?>
|
20 |
<p class="description warning" style="color: red;">
|
21 |
<?php _e( 'No taxonomies available for the currently included post types.', 'xml-sitemap-feed' ); ?>
|
22 |
</p>
|
views/admin/field-sitemap-taxonomy-settings.php
CHANGED
@@ -1,36 +1,34 @@
|
|
1 |
<fieldset id="xmlsf_taxonomies">
|
2 |
-
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
<
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
<
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
<
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
</p>
|
35 |
-
|
36 |
</fieldset>
|
1 |
<fieldset id="xmlsf_taxonomies">
|
2 |
+
<legend class="screen-reader-text">
|
3 |
+
<?php echo translate( 'General' ); ?>
|
4 |
+
</legend>
|
5 |
+
<p>
|
6 |
+
<label>
|
7 |
+
<input type="checkbox" name="xmlsf_taxonomy_settings[active]" id="xmlsf_taxonomy_active" value="1"<?php checked( !empty( $taxonomy_settings['active'] ), true); ?> />
|
8 |
+
<?php _e( 'Include taxonomies', 'xml-sitemap-feed' ); ?> (<?php echo count( $this->public_taxonomies() ); ?>)
|
9 |
+
</label>
|
10 |
+
<?php if ( ! $this->public_taxonomies() ) { ?>
|
11 |
+
<p class="description warning" style="color: red;">
|
12 |
+
<?php _e( 'No taxonomies available for the currently included post types.', 'xml-sitemap-feed' ); ?>
|
13 |
+
</p>
|
14 |
+
<?php } ?>
|
15 |
+
</p>
|
16 |
+
<p>
|
17 |
+
<label>
|
18 |
+
<?php _e('Priority','xml-sitemap-feed'); ?>
|
19 |
+
<input type="number" step="0.1" min="0.1" max="0.9" name="xmlsf_taxonomy_settings[priority]" id="xmlsf_taxonomy_priority" value="<?php echo ( isset($taxonomy_settings['priority']) ? $taxonomy_settings['priority'] : '' ); ?>" class="small-text" />
|
20 |
+
</label>
|
21 |
+
</p>
|
22 |
+
<p>
|
23 |
+
<label>
|
24 |
+
<input type="checkbox" name="xmlsf_taxonomy_settings[dynamic_priority]" id="xmlsf_taxonomy_dynamic_priority" value="1"<?php echo checked( !empty($taxonomy_settings['dynamic_priority']), true, false ); ?> />
|
25 |
+
<?php _e('Automatic Priority calculation.','xml-sitemap-feed'); ?>
|
26 |
+
</label>
|
27 |
+
</p>
|
28 |
+
<p>
|
29 |
+
<label>
|
30 |
+
<?php _e('Maximum per sitemap','xml-sitemap-feed'); ?>
|
31 |
+
<input type="number" step="100" min="0" max="50000" name="xmlsf_taxonomy_settings[term_limit]" id="xmlsf_taxonomy_term_limit" value="<?php echo ( isset($taxonomy_settings['term_limit']) ? $taxonomy_settings['term_limit'] : '' ); ?>" class="medium-text" />
|
32 |
+
</label>
|
33 |
+
</p>
|
|
|
|
|
34 |
</fieldset>
|
views/admin/help-tab-news-images.php
DELETED
@@ -1,7 +0,0 @@
|
|
1 |
-
<p>
|
2 |
-
<?php _e( 'Google News displays images associated with articles included in their index.', 'xml-sitemap-feed' ); ?>
|
3 |
-
</p>
|
4 |
-
<p>
|
5 |
-
<?php _e( 'Note: Google News prefers at most one image per article in the News Sitemap. If multiple valid images are specified, the crawler will have to pick one arbitrarily. Images in News Sitemaps should be in jpeg or png format.', 'xml-sitemap-feed' ); ?>
|
6 |
-
<?php printf( /* translators: Prevent missing or incorrect images help page */ __( 'Read more on %s.', 'xml-sitemap-feed' ), '<a href="https://support.google.com/news/publisher/answer/13369" target="_blank">'.__( /* translators: PAge title https://support.google.com/news/publisher/answer/13369 */ 'Prevent missing or incorrect images','xml-sitemap-feed').'</a>' ); ?>
|
7 |
-
</p>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
views/admin/meta-box-news.php
CHANGED
@@ -1,7 +1,6 @@
|
|
1 |
<p>
|
2 |
<label>
|
3 |
-
<input type="checkbox" name="xmlsf_news_exclude" id="xmlsf_news_exclude" value="1"<?php
|
4 |
<?php _e('Exclude from Google News Sitemap','xml-sitemap-feed'); ?>
|
5 |
</label>
|
6 |
</p>
|
7 |
-
|
1 |
<p>
|
2 |
<label>
|
3 |
+
<input type="checkbox" name="xmlsf_news_exclude" id="xmlsf_news_exclude" value="1"<?php checked( !empty($exclude) ); disabled( $disabled ); ?> />
|
4 |
<?php _e('Exclude from Google News Sitemap','xml-sitemap-feed'); ?>
|
5 |
</label>
|
6 |
</p>
|
|
views/admin/meta-box.php
CHANGED
@@ -1,15 +1,19 @@
|
|
1 |
<p>
|
2 |
-
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
|
|
|
|
|
|
|
|
8 |
</span>
|
9 |
</p>
|
10 |
<p>
|
11 |
-
|
12 |
-
|
13 |
<?php _e('Exclude from XML Sitemap','xml-sitemap-feed'); ?>
|
14 |
-
|
15 |
</p>
|
1 |
<p>
|
2 |
+
<label>
|
3 |
+
<?php _e('Priority','xml-sitemap-feed'); ?>
|
4 |
+
<input type="number" step="0.1" min="0.1" max="1" name="xmlsf_priority" id="xmlsf_priority" value="<?php echo $priority; ?>" class="small-text"<?php disabled( $disabled )?> />
|
5 |
+
</label>
|
6 |
+
<span class="description">
|
7 |
+
<?php printf(
|
8 |
+
__('Leave empty for automatic Priority as configured on %1$s > %2$s.','xml-sitemap-feed'),
|
9 |
+
translate('Settings'),
|
10 |
+
'<a href="' . admin_url('options-general.php') . '?page=xmlsf">' . __('XML Sitemap','xml-sitemap-feed') . '</a>'
|
11 |
+
); ?>
|
12 |
</span>
|
13 |
</p>
|
14 |
<p>
|
15 |
+
<label>
|
16 |
+
<input type="checkbox" name="xmlsf_exclude" id="xmlsf_exclude" value="1"<?php checked( !empty($exclude) ); disabled( $disabled ); ?> />
|
17 |
<?php _e('Exclude from XML Sitemap','xml-sitemap-feed'); ?>
|
18 |
+
</label>
|
19 |
</p>
|
views/admin/notice-static-files.php
CHANGED
@@ -11,7 +11,7 @@
|
|
11 |
<form action="" method="post">
|
12 |
<?php wp_nonce_field( XMLSF_BASENAME.'-notice', '_xmlsf_notice_nonce' ); ?>
|
13 |
<ul>
|
14 |
-
<?php foreach (
|
15 |
<li>
|
16 |
<label><input type="checkbox" name="xmlsf-delete[]" value="<?php echo $name; ?>" /> <strong><?php echo $name; ?></strong> (<?php echo $file; ?>)</label>
|
17 |
</li>
|
11 |
<form action="" method="post">
|
12 |
<?php wp_nonce_field( XMLSF_BASENAME.'-notice', '_xmlsf_notice_nonce' ); ?>
|
13 |
<ul>
|
14 |
+
<?php foreach ( parent::$static_files as $name => $file) { ?>
|
15 |
<li>
|
16 |
<label><input type="checkbox" name="xmlsf-delete[]" value="<?php echo $name; ?>" /> <strong><?php echo $name; ?></strong> (<?php echo $file; ?>)</label>
|
17 |
</li>
|
views/admin/page-sitemap-news.php
CHANGED
@@ -1,5 +1,5 @@
|
|
1 |
<style type="text/css">
|
2 |
-
<?php include XMLSF_DIR . '/
|
3 |
</style>
|
4 |
<div class="wrap">
|
5 |
|
@@ -47,13 +47,13 @@
|
|
47 |
<form action="" method="post">
|
48 |
<?php wp_nonce_field( XMLSF_BASENAME.'-help', '_xmlsf_help_nonce' ); ?>
|
49 |
<p>
|
50 |
-
<input type="submit" name="xmlsf-
|
51 |
</p>
|
52 |
<p>
|
53 |
<input type="submit" name="xmlsf-flush-rewrite-rules" class="button button-small" value="<?php _e( 'Flush rewrite rules', 'xml-sitemap-feed' ); ?>" />
|
54 |
</p>
|
55 |
<p>
|
56 |
-
<input type="submit" name="xmlsf-
|
57 |
</p>
|
58 |
<p>
|
59 |
<input type="hidden" name="xmlsf-clear-settings" value="sitemap-news" />
|
1 |
<style type="text/css">
|
2 |
+
<?php include XMLSF_DIR . '/assets/styles/admin.css'; ?>
|
3 |
</style>
|
4 |
<div class="wrap">
|
5 |
|
47 |
<form action="" method="post">
|
48 |
<?php wp_nonce_field( XMLSF_BASENAME.'-help', '_xmlsf_help_nonce' ); ?>
|
49 |
<p>
|
50 |
+
<input type="submit" name="xmlsf-ping-sitemap-news" class="button button-small" value="<?php _e( 'Ping Google News', 'xml-sitemap-feed' ); ?>" />
|
51 |
</p>
|
52 |
<p>
|
53 |
<input type="submit" name="xmlsf-flush-rewrite-rules" class="button button-small" value="<?php _e( 'Flush rewrite rules', 'xml-sitemap-feed' ); ?>" />
|
54 |
</p>
|
55 |
<p>
|
56 |
+
<input type="submit" name="xmlsf-check-conflicts" class="button button-small" value="<?php _e( 'Check for conflicts', 'xml-sitemap-feed' ); ?>" />
|
57 |
</p>
|
58 |
<p>
|
59 |
<input type="hidden" name="xmlsf-clear-settings" value="sitemap-news" />
|
views/admin/page-sitemap.php
CHANGED
@@ -1,5 +1,5 @@
|
|
1 |
<style type="text/css">
|
2 |
-
<?php include XMLSF_DIR . '/
|
3 |
</style>
|
4 |
<div class="wrap">
|
5 |
|
@@ -43,13 +43,18 @@
|
|
43 |
<form action="" method="post">
|
44 |
<?php wp_nonce_field( XMLSF_BASENAME.'-help', '_xmlsf_help_nonce' ); ?>
|
45 |
<p>
|
46 |
-
<input type="submit" name="xmlsf-
|
47 |
</p>
|
48 |
<p>
|
49 |
<input type="submit" name="xmlsf-flush-rewrite-rules" class="button button-small" value="<?php _e( 'Flush rewrite rules', 'xml-sitemap-feed' ); ?>" />
|
50 |
</p>
|
51 |
<p>
|
52 |
-
<input type="submit" name="xmlsf-
|
|
|
|
|
|
|
|
|
|
|
53 |
</p>
|
54 |
<p>
|
55 |
<input type="hidden" name="xmlsf-clear-settings" value="sitemap" />
|
1 |
<style type="text/css">
|
2 |
+
<?php include XMLSF_DIR . '/assets/styles/admin.css'; ?>
|
3 |
</style>
|
4 |
<div class="wrap">
|
5 |
|
43 |
<form action="" method="post">
|
44 |
<?php wp_nonce_field( XMLSF_BASENAME.'-help', '_xmlsf_help_nonce' ); ?>
|
45 |
<p>
|
46 |
+
<input type="submit" name="xmlsf-ping-sitemap" class="button button-small" value="<?php _e( 'Ping search engines', 'xml-sitemap-feed' ); ?>" />
|
47 |
</p>
|
48 |
<p>
|
49 |
<input type="submit" name="xmlsf-flush-rewrite-rules" class="button button-small" value="<?php _e( 'Flush rewrite rules', 'xml-sitemap-feed' ); ?>" />
|
50 |
</p>
|
51 |
<p>
|
52 |
+
<input type="submit" name="xmlsf-check-conflicts" class="button button-small" value="<?php _e( 'Check for conflicts', 'xml-sitemap-feed' ); ?>" />
|
53 |
+
</p>
|
54 |
+
<p>
|
55 |
+
<?php //printf( __('%1$s or %2$s all cached Sitemap metadata.'), '<input type="submit" name="xmlsf-prime-meta" class="button button-small" value="'.__( 'Rebuild', 'xml-sitemap-feed' ).'"/>', '<input type="submit" name="xmlsf-clear-meta" class="button button-small" value="'.__( 'Clear', 'xml-sitemap-feed' ).'"/>'); ?>
|
56 |
+
<input type="submit" name="xmlsf-clear-post-meta" class="button button-small" value="<?php _e( 'Clear post meta caches', 'xml-sitemap-feed' ); ?>" />
|
57 |
+
<input type="submit" name="xmlsf-clear-term-meta" class="button button-small" value="<?php _e( 'Clear term meta cache', 'xml-sitemap-feed' ); ?>" />
|
58 |
</p>
|
59 |
<p>
|
60 |
<input type="hidden" name="xmlsf-clear-settings" value="sitemap" />
|
views/feed-sitemap-custom.php
CHANGED
@@ -7,8 +7,9 @@
|
|
7 |
|
8 |
if ( ! defined( 'WPINC' ) ) die;
|
9 |
|
|
|
10 |
echo '<?xml version="1.0" encoding="' . get_bloginfo('charset') . '"?>
|
11 |
-
<?xml-stylesheet type="text/xsl" href="' . plugins_url('
|
12 |
'; ?>
|
13 |
<?php xmlsf_generator(); ?>
|
14 |
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
|
7 |
|
8 |
if ( ! defined( 'WPINC' ) ) die;
|
9 |
|
10 |
+
// do xml tag via echo or SVN parser is going to freak out
|
11 |
echo '<?xml version="1.0" encoding="' . get_bloginfo('charset') . '"?>
|
12 |
+
<?xml-stylesheet type="text/xsl" href="' . plugins_url('assets/styles/sitemap-custom.xsl',XMLSF_BASENAME) . '?ver=' . XMLSF_VERSION . '"?>
|
13 |
'; ?>
|
14 |
<?php xmlsf_generator(); ?>
|
15 |
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
|
views/feed-sitemap-home.php
CHANGED
@@ -7,8 +7,9 @@
|
|
7 |
|
8 |
if ( ! defined( 'WPINC' ) ) die;
|
9 |
|
|
|
10 |
echo '<?xml version="1.0" encoding="' . get_bloginfo('charset') . '"?>
|
11 |
-
<?xml-stylesheet type="text/xsl" href="' . plugins_url('
|
12 |
'; ?>
|
13 |
<?php xmlsf_generator(); ?>
|
14 |
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
|
7 |
|
8 |
if ( ! defined( 'WPINC' ) ) die;
|
9 |
|
10 |
+
// do xml tag via echo or SVN parser is going to freak out
|
11 |
echo '<?xml version="1.0" encoding="' . get_bloginfo('charset') . '"?>
|
12 |
+
<?xml-stylesheet type="text/xsl" href="' . plugins_url('assets/styles/sitemap.xsl',XMLSF_BASENAME) . '?ver=' . XMLSF_VERSION . '"?>
|
13 |
'; ?>
|
14 |
<?php xmlsf_generator(); ?>
|
15 |
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
|
views/feed-sitemap-news.php
CHANGED
@@ -8,30 +8,14 @@
|
|
8 |
if ( ! defined( 'WPINC' ) ) die;
|
9 |
|
10 |
$options = get_option('xmlsf_news_tags');
|
11 |
-
if ( !is_array($options) ) $options = array();
|
12 |
-
|
13 |
-
if ( !empty($options['image']) ) {
|
14 |
-
$image_xmlns = ' xmlns:image="http://www.google.com/schemas/sitemap-image/1.1"'.PHP_EOL;
|
15 |
-
$image_schema = '
|
16 |
-
http://www.google.com/schemas/sitemap-image/1.1
|
17 |
-
http://www.google.com/schemas/sitemap-image/1.1/sitemap-image.xsd';
|
18 |
-
} else {
|
19 |
-
$image_xmlns = '';
|
20 |
-
$image_schema = '';
|
21 |
-
}
|
22 |
|
|
|
23 |
echo '<?xml version="1.0" encoding="' . get_bloginfo('charset') . '"?>
|
24 |
-
<?xml-stylesheet type="text/xsl" href="' . plugins_url('
|
25 |
'; ?>
|
26 |
<?php xmlsf_generator(); ?>
|
27 |
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
|
28 |
-
xmlns:news="http://www.google.com/schemas/sitemap-news/0.9"
|
29 |
-
<?php echo $image_xmlns; ?>
|
30 |
-
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
31 |
-
xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9
|
32 |
-
http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd
|
33 |
-
http://www.google.com/schemas/sitemap-news/0.9
|
34 |
-
http://www.google.com/schemas/sitemap-news/0.9/sitemap-news.xsd<?php echo $image_schema; ?>">
|
35 |
<?php
|
36 |
|
37 |
// set empty news sitemap flag
|
@@ -66,30 +50,12 @@ if ( have_posts() ) :
|
|
66 |
echo apply_filters( 'the_title_xmlsitemap', get_bloginfo('name') ); ?></news:name>
|
67 |
<news:language><?php echo xmlsf_get_language( $post->ID ); ?></news:language>
|
68 |
</news:publication>
|
69 |
-
<news:publication_date><?php
|
70 |
-
echo mysql2date('Y-m-d\TH:i:s+00:00', $post->post_date_gmt, false); ?></news:publication_date>
|
71 |
<news:title><?php echo apply_filters( 'the_title_xmlsitemap', get_the_title() ); ?></news:title>
|
72 |
<news:keywords><?php echo implode( ', ', apply_filters( 'xmlsf_news_keywords', array() ) ); ?></news:keywords>
|
73 |
<news:stock_tickers><?php echo implode( ', ', apply_filters( 'xmlsf_news_stock_tickers', array() ) ); ?></news:stock_tickers>
|
74 |
<?php do_action( 'xmlsf_news_tags_after' ); ?>
|
75 |
</news:news>
|
76 |
-
<?php
|
77 |
-
if ( !empty($options['image']) ) :
|
78 |
-
foreach ( xmlsf_get_images('news') as $image ) {
|
79 |
-
if ( empty($image['loc']) )
|
80 |
-
continue;
|
81 |
-
?>
|
82 |
-
<image:image>
|
83 |
-
<image:loc><?php echo utf8_uri_encode( $image['loc'] ); ?></image:loc>
|
84 |
-
<?php if ( !empty($image['title']) ) { ?>
|
85 |
-
<image:title><![CDATA[<?php echo str_replace(']]>', ']]>', $image['title']); ?>]]></image:title>
|
86 |
-
<?php }
|
87 |
-
if ( !empty($image['caption']) ) { ?>
|
88 |
-
<image:caption><![CDATA[<?php echo str_replace(']]>', ']]>', $image['caption']); ?>]]></image:caption>
|
89 |
-
<?php } ?>
|
90 |
-
</image:image>
|
91 |
-
<?php }
|
92 |
-
endif; ?>
|
93 |
</url>
|
94 |
<?php
|
95 |
endwhile;
|
8 |
if ( ! defined( 'WPINC' ) ) die;
|
9 |
|
10 |
$options = get_option('xmlsf_news_tags');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
11 |
|
12 |
+
// do xml tag via echo or SVN parser is going to freak out
|
13 |
echo '<?xml version="1.0" encoding="' . get_bloginfo('charset') . '"?>
|
14 |
+
<?xml-stylesheet type="text/xsl" href="' . plugins_url('assets/styles/sitemap-news.xsl',XMLSF_BASENAME) . '?ver=' . XMLSF_VERSION . '"?>
|
15 |
'; ?>
|
16 |
<?php xmlsf_generator(); ?>
|
17 |
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
|
18 |
+
xmlns:news="http://www.google.com/schemas/sitemap-news/0.9">
|
|
|
|
|
|
|
|
|
|
|
|
|
19 |
<?php
|
20 |
|
21 |
// set empty news sitemap flag
|
50 |
echo apply_filters( 'the_title_xmlsitemap', get_bloginfo('name') ); ?></news:name>
|
51 |
<news:language><?php echo xmlsf_get_language( $post->ID ); ?></news:language>
|
52 |
</news:publication>
|
53 |
+
<news:publication_date><?php echo mysql2date( 'c', $post->post_date ); ?></news:publication_date>
|
|
|
54 |
<news:title><?php echo apply_filters( 'the_title_xmlsitemap', get_the_title() ); ?></news:title>
|
55 |
<news:keywords><?php echo implode( ', ', apply_filters( 'xmlsf_news_keywords', array() ) ); ?></news:keywords>
|
56 |
<news:stock_tickers><?php echo implode( ', ', apply_filters( 'xmlsf_news_stock_tickers', array() ) ); ?></news:stock_tickers>
|
57 |
<?php do_action( 'xmlsf_news_tags_after' ); ?>
|
58 |
</news:news>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
59 |
</url>
|
60 |
<?php
|
61 |
endwhile;
|
views/feed-sitemap-post_type.php
CHANGED
@@ -9,6 +9,8 @@ if ( ! defined( 'WPINC' ) ) die;
|
|
9 |
|
10 |
extract ( xmlsf_do_tags( get_query_var('post_type') ) );
|
11 |
|
|
|
|
|
12 |
if ( !empty($image) ) {
|
13 |
$image_xmlns = ' xmlns:image="http://www.google.com/schemas/sitemap-image/1.1"'.PHP_EOL;
|
14 |
$image_schema = '
|
@@ -19,8 +21,9 @@ if ( !empty($image) ) {
|
|
19 |
$image_schema = '';
|
20 |
}
|
21 |
|
|
|
22 |
echo '<?xml version="1.0" encoding="' . get_bloginfo('charset') . '"?>
|
23 |
-
<?xml-stylesheet type="text/xsl" href="' . plugins_url('
|
24 |
'; ?>
|
25 |
<?php xmlsf_generator(); ?>
|
26 |
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
|
@@ -35,57 +38,55 @@ $have_posts = false;
|
|
35 |
|
36 |
// loop away!
|
37 |
if ( have_posts() ) :
|
38 |
-
|
39 |
-
|
40 |
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
'xmlsf_excluded',
|
45 |
-
|
46 |
-
|
47 |
-
) || !xmlsf_is_allowed_domain( get_permalink() ) )
|
48 |
-
continue;
|
49 |
|
50 |
-
$
|
51 |
?>
|
52 |
<url>
|
53 |
<loc><?php echo esc_url( get_permalink() ); ?></loc>
|
54 |
-
<priority><?php echo
|
55 |
-
<?php if ( $lastmod =
|
56 |
<lastmod><?php echo $lastmod; ?></lastmod>
|
57 |
<?php } ?>
|
58 |
<?php
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
?>
|
64 |
<image:image>
|
65 |
-
<image:loc><?php echo utf8_uri_encode( $
|
66 |
<?php
|
67 |
-
|
68 |
?>
|
69 |
-
<image:title><![CDATA[<?php echo str_replace(']]>', ']]>', $
|
70 |
<?php
|
71 |
-
|
72 |
-
|
73 |
?>
|
74 |
-
<image:caption><![CDATA[<?php echo str_replace(']]>', ']]>', $
|
75 |
<?php
|
76 |
-
|
77 |
?>
|
78 |
</image:image>
|
79 |
<?php
|
80 |
-
|
81 |
-
|
82 |
?>
|
83 |
</url>
|
84 |
<?php
|
85 |
-
|
86 |
endif;
|
87 |
|
88 |
-
if (
|
89 |
// No posts done? Then do at least the homepage to prevent error message in GWT.
|
90 |
?>
|
91 |
<url>
|
9 |
|
10 |
extract ( xmlsf_do_tags( get_query_var('post_type') ) );
|
11 |
|
12 |
+
xmlsf_sitemap()->prefetch_posts_meta();
|
13 |
+
|
14 |
if ( !empty($image) ) {
|
15 |
$image_xmlns = ' xmlns:image="http://www.google.com/schemas/sitemap-image/1.1"'.PHP_EOL;
|
16 |
$image_schema = '
|
21 |
$image_schema = '';
|
22 |
}
|
23 |
|
24 |
+
// do xml tag via echo or SVN parser is going to freak out
|
25 |
echo '<?xml version="1.0" encoding="' . get_bloginfo('charset') . '"?>
|
26 |
+
<?xml-stylesheet type="text/xsl" href="' . plugins_url('assets/styles/sitemap.xsl',XMLSF_BASENAME) . '?ver=' . XMLSF_VERSION . '"?>
|
27 |
'; ?>
|
28 |
<?php xmlsf_generator(); ?>
|
29 |
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
|
38 |
|
39 |
// loop away!
|
40 |
if ( have_posts() ) :
|
41 |
+
while ( have_posts() ) :
|
42 |
+
the_post();
|
43 |
|
44 |
+
// check if page is in the exclusion list (like front page or post meta)
|
45 |
+
// or if we are dealing with an external URL :: Thanks to Francois Deschenes :)
|
46 |
+
if ( $post->ID == get_option('page_on_front')
|
47 |
+
|| apply_filters( 'xmlsf_excluded', get_post_meta( $post->ID, '_xmlsf_exclude', true ), $post->ID )
|
48 |
+
|| !xmlsf_is_allowed_domain( get_permalink() )
|
49 |
+
) continue;
|
|
|
|
|
50 |
|
51 |
+
$did_posts = true;
|
52 |
?>
|
53 |
<url>
|
54 |
<loc><?php echo esc_url( get_permalink() ); ?></loc>
|
55 |
+
<priority><?php echo xmlsf_get_post_priority(); ?></priority>
|
56 |
+
<?php if ( $lastmod = xmlsf_get_post_modified() ) { ?>
|
57 |
<lastmod><?php echo $lastmod; ?></lastmod>
|
58 |
<?php } ?>
|
59 |
<?php
|
60 |
+
if ( !empty($image) ) :
|
61 |
+
foreach ( get_post_meta( $post->ID, '_xmlsf_image_'.$image ) as $img_data ) {
|
62 |
+
if ( empty($img_data['loc']) )
|
63 |
+
continue;
|
64 |
?>
|
65 |
<image:image>
|
66 |
+
<image:loc><?php echo utf8_uri_encode( $img_data['loc'] ); ?></image:loc>
|
67 |
<?php
|
68 |
+
if ( !empty($img_data['title']) ) {
|
69 |
?>
|
70 |
+
<image:title><![CDATA[<?php echo str_replace(']]>', ']]>', $img_data['title']); ?>]]></image:title>
|
71 |
<?php
|
72 |
+
}
|
73 |
+
if ( !empty($img_data['caption']) ) {
|
74 |
?>
|
75 |
+
<image:caption><![CDATA[<?php echo str_replace(']]>', ']]>', $img_data['caption']); ?>]]></image:caption>
|
76 |
<?php
|
77 |
+
}
|
78 |
?>
|
79 |
</image:image>
|
80 |
<?php
|
81 |
+
}
|
82 |
+
endif;
|
83 |
?>
|
84 |
</url>
|
85 |
<?php
|
86 |
+
endwhile;
|
87 |
endif;
|
88 |
|
89 |
+
if ( empty( $did_posts ) ) :
|
90 |
// No posts done? Then do at least the homepage to prevent error message in GWT.
|
91 |
?>
|
92 |
<url>
|
views/feed-sitemap-taxonomy.php
CHANGED
@@ -7,8 +7,9 @@
|
|
7 |
|
8 |
if ( ! defined( 'WPINC' ) ) die;
|
9 |
|
|
|
10 |
echo '<?xml version="1.0" encoding="' . get_bloginfo('charset') . '"?>
|
11 |
-
<?xml-stylesheet type="text/xsl" href="' . plugins_url('
|
12 |
'; ?>
|
13 |
<?php xmlsf_generator(); ?>
|
14 |
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
|
@@ -23,8 +24,8 @@ if ( is_array($terms) ) :
|
|
23 |
?>
|
24 |
<url>
|
25 |
<loc><?php echo get_term_link( $term ); ?></loc>
|
26 |
-
<priority><?php echo
|
27 |
-
<?php if ( $lastmod =
|
28 |
<lastmod><?php echo $lastmod; ?></lastmod>
|
29 |
<?php } ?>
|
30 |
</url>
|
7 |
|
8 |
if ( ! defined( 'WPINC' ) ) die;
|
9 |
|
10 |
+
// do xml tag via echo or SVN parser is going to freak out
|
11 |
echo '<?xml version="1.0" encoding="' . get_bloginfo('charset') . '"?>
|
12 |
+
<?xml-stylesheet type="text/xsl" href="' . plugins_url('assets/styles/sitemap-taxonomy.xsl',XMLSF_BASENAME) . '?ver=' . XMLSF_VERSION . '"?>
|
13 |
'; ?>
|
14 |
<?php xmlsf_generator(); ?>
|
15 |
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
|
24 |
?>
|
25 |
<url>
|
26 |
<loc><?php echo get_term_link( $term ); ?></loc>
|
27 |
+
<priority><?php echo xmlsf_get_term_priority( $term ); ?></priority>
|
28 |
+
<?php if ( $lastmod = xmlsf_get_term_modified( $term ) ) { ?>
|
29 |
<lastmod><?php echo $lastmod; ?></lastmod>
|
30 |
<?php } ?>
|
31 |
</url>
|
views/feed-sitemap.php
CHANGED
@@ -7,8 +7,9 @@
|
|
7 |
|
8 |
if ( ! defined( 'WPINC' ) ) die;
|
9 |
|
|
|
10 |
echo '<?xml version="1.0" encoding="' . get_bloginfo('charset') . '"?>
|
11 |
-
<?xml-stylesheet type="text/xsl" href="' . plugins_url('
|
12 |
'; ?>
|
13 |
<?php xmlsf_generator(); ?>
|
14 |
<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
|
@@ -17,11 +18,11 @@ echo '<?xml version="1.0" encoding="' . get_bloginfo('charset') . '"?>
|
|
17 |
http://www.sitemaps.org/schemas/sitemap/0.9/siteindex.xsd">
|
18 |
<sitemap>
|
19 |
<loc><?php echo xmlsf_get_index_url('home'); ?></loc>
|
20 |
-
<lastmod><?php echo mysql2date('
|
21 |
</sitemap>
|
22 |
<?php
|
23 |
// add rules for public post types
|
24 |
-
$post_types = apply_filters( 'xmlsf_post_types', get_option( 'xmlsf_post_types' ) );
|
25 |
if ( is_array($post_types) ) :
|
26 |
foreach ( $post_types as $post_type => $settings ) {
|
27 |
if ( empty($settings['active']) || ! post_type_exists( $post_type ) )
|
@@ -33,7 +34,7 @@ if ( is_array($post_types) ) :
|
|
33 |
?>
|
34 |
<sitemap>
|
35 |
<loc><?php echo $url; ?></loc>
|
36 |
-
<lastmod><?php echo mysql2date('
|
37 |
</sitemap>
|
38 |
<?php
|
39 |
}
|
@@ -44,7 +45,7 @@ endif;
|
|
44 |
foreach ( xmlsf_get_taxonomies() as $taxonomy ) : ?>
|
45 |
<sitemap>
|
46 |
<loc><?php echo xmlsf_get_index_url('taxonomy',$taxonomy); ?></loc>
|
47 |
-
<?php if ( $lastmod =
|
48 |
<lastmod><?php echo $lastmod; ?></lastmod>
|
49 |
<?php } ?>
|
50 |
</sitemap>
|
7 |
|
8 |
if ( ! defined( 'WPINC' ) ) die;
|
9 |
|
10 |
+
// do xml tag via echo or SVN parser is going to freak out
|
11 |
echo '<?xml version="1.0" encoding="' . get_bloginfo('charset') . '"?>
|
12 |
+
<?xml-stylesheet type="text/xsl" href="' . plugins_url('assets/styles/sitemap-index.xsl',XMLSF_BASENAME) . '?ver=' . XMLSF_VERSION . '"?>
|
13 |
'; ?>
|
14 |
<?php xmlsf_generator(); ?>
|
15 |
<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
|
18 |
http://www.sitemaps.org/schemas/sitemap/0.9/siteindex.xsd">
|
19 |
<sitemap>
|
20 |
<loc><?php echo xmlsf_get_index_url('home'); ?></loc>
|
21 |
+
<lastmod><?php echo mysql2date( 'c', get_lastpostdate( 'blog' ) ); ?></lastmod>
|
22 |
</sitemap>
|
23 |
<?php
|
24 |
// add rules for public post types
|
25 |
+
$post_types = apply_filters( 'xmlsf_post_types', (array) get_option( 'xmlsf_post_types', array() ) );
|
26 |
if ( is_array($post_types) ) :
|
27 |
foreach ( $post_types as $post_type => $settings ) {
|
28 |
if ( empty($settings['active']) || ! post_type_exists( $post_type ) )
|
34 |
?>
|
35 |
<sitemap>
|
36 |
<loc><?php echo $url; ?></loc>
|
37 |
+
<lastmod><?php echo mysql2date( 'c', get_lastmodified( 'blog', $post_type, $m ) ); ?></lastmod>
|
38 |
</sitemap>
|
39 |
<?php
|
40 |
}
|
45 |
foreach ( xmlsf_get_taxonomies() as $taxonomy ) : ?>
|
46 |
<sitemap>
|
47 |
<loc><?php echo xmlsf_get_index_url('taxonomy',$taxonomy); ?></loc>
|
48 |
+
<?php if ( $lastmod = xmlsf_get_taxonomy_modified( $taxonomy ) ) { ?>
|
49 |
<lastmod><?php echo $lastmod; ?></lastmod>
|
50 |
<?php } ?>
|
51 |
</sitemap>
|
xml-sitemap.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
Plugin Name: XML Sitemap & Google News
|
4 |
Plugin URI: http://status301.net/wordpress-plugins/xml-sitemap-feed/
|
5 |
Description: Feed the hungry spiders in compliance with the XML Sitemap and Google News protocols. Happy with the results? Please leave me a <strong><a href="https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=ravanhagen%40gmail%2ecom&item_name=XML%20Sitemap%20Feed">tip</a></strong> for continued development and support. Thanks :)
|
6 |
-
Version: 5.
|
7 |
Text Domain: xml-sitemap-feed
|
8 |
Requires at least: 4.6
|
9 |
Requires PHP: 5.4
|
@@ -11,7 +11,7 @@ Author: RavanH
|
|
11 |
Author URI: http://status301.net/
|
12 |
*/
|
13 |
|
14 |
-
define( 'XMLSF_VERSION', '5.
|
15 |
|
16 |
/* Copyright 2019 RavanH
|
17 |
http://status301.net/
|
@@ -82,9 +82,13 @@ define( 'XMLSF_DIR', dirname(__FILE__) );
|
|
82 |
|
83 |
define( 'XMLSF_BASENAME', plugin_basename(__FILE__) );
|
84 |
|
85 |
-
require XMLSF_DIR . '/models/
|
86 |
|
87 |
-
require XMLSF_DIR . '/controllers/
|
|
|
|
|
|
|
|
|
88 |
|
89 |
// main plugin init
|
90 |
add_action( 'init', 'xmlsf_init' );
|
3 |
Plugin Name: XML Sitemap & Google News
|
4 |
Plugin URI: http://status301.net/wordpress-plugins/xml-sitemap-feed/
|
5 |
Description: Feed the hungry spiders in compliance with the XML Sitemap and Google News protocols. Happy with the results? Please leave me a <strong><a href="https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=ravanhagen%40gmail%2ecom&item_name=XML%20Sitemap%20Feed">tip</a></strong> for continued development and support. Thanks :)
|
6 |
+
Version: 5.2
|
7 |
Text Domain: xml-sitemap-feed
|
8 |
Requires at least: 4.6
|
9 |
Requires PHP: 5.4
|
11 |
Author URI: http://status301.net/
|
12 |
*/
|
13 |
|
14 |
+
define( 'XMLSF_VERSION', '5.2' );
|
15 |
|
16 |
/* Copyright 2019 RavanH
|
17 |
http://status301.net/
|
82 |
|
83 |
define( 'XMLSF_BASENAME', plugin_basename(__FILE__) );
|
84 |
|
85 |
+
require XMLSF_DIR . '/models/functions.php';
|
86 |
|
87 |
+
require XMLSF_DIR . '/controllers/functions.php';
|
88 |
+
|
89 |
+
if ( is_admin() ) {
|
90 |
+
require XMLSF_DIR . '/controllers/class.xmlsf-admin.php';
|
91 |
+
}
|
92 |
|
93 |
// main plugin init
|
94 |
add_action( 'init', 'xmlsf_init' );
|