XML Sitemap & Google News feeds - Version 5.3.2

Version Description

Fix Bing ping 410 error response and help links.

=

Download this release

Release Info

Developer RavanH
Plugin Icon 128x128 XML Sitemap & Google News feeds
Version 5.3.2
Comparing to
See all releases

Code changes from version 5.2.7 to 5.3.2

Files changed (96) hide show
  1. LICENSE +0 -0
  2. README.md +0 -6
  3. assets/admin.css +19 -0
  4. assets/sitemap-author.xsl +44 -0
  5. assets/sitemap-custom.xsl +41 -0
  6. assets/sitemap-news.xsl +50 -0
  7. assets/sitemap-posttype.xsl +46 -0
  8. assets/sitemap-root.xsl +46 -0
  9. assets/sitemap-taxonomy.xsl +43 -0
  10. assets/sitemap.xsl +43 -0
  11. assets/sitemapxml.gif +0 -0
  12. controllers/class.xmlsf-admin-sitemap-news.php +182 -124
  13. controllers/class.xmlsf-admin-sitemap.php +216 -103
  14. controllers/class.xmlsf-admin.php +66 -30
  15. controllers/class.xmlsf-sitemap-news.php +31 -18
  16. controllers/class.xmlsf-sitemap.php +69 -75
  17. controllers/functions.shared.php +118 -4
  18. models/class-xmlsitemapfeed.php +14 -5
  19. models/class.xmlsf-admin-sitemap-news-sanitize.php +0 -0
  20. models/class.xmlsf-admin-sitemap-sanitize.php +27 -3
  21. models/functions.admin.php +13 -15
  22. models/functions.public-shared.php +79 -3
  23. models/functions.public-sitemap-news.php +66 -43
  24. models/functions.public-sitemap.php +146 -194
  25. models/functions.shared.php +69 -52
  26. models/functions.sitemap-news.php +1 -2
  27. models/functions.sitemap.php +211 -40
  28. readme.txt +24 -13
  29. uninstall.php +28 -27
  30. upgrade.php +23 -17
  31. views/_generator.php +0 -0
  32. views/_usage.php +4 -1
  33. views/admin/field-news-categories.php +0 -0
  34. views/admin/field-news-keywords.php +0 -0
  35. views/admin/field-news-labels.php +1 -1
  36. views/admin/field-news-name.php +0 -0
  37. views/admin/field-news-ping-log.php +0 -0
  38. views/admin/field-news-post-type.php +2 -2
  39. views/admin/field-news-stocktickers.php +0 -0
  40. views/admin/field-ping.php +0 -0
  41. views/admin/field-robots.php +0 -0
  42. views/admin/field-sitemap-author-settings.php +34 -0
  43. views/admin/field-sitemap-custom.php +3 -3
  44. views/admin/field-sitemap-domains.php +0 -0
  45. views/admin/field-sitemap-name.php +16 -0
  46. views/admin/field-sitemap-post-type.php +67 -64
  47. views/admin/field-sitemap-taxonomies.php +0 -0
  48. views/admin/field-sitemap-taxonomy-settings.php +1 -1
  49. views/admin/field-sitemap-urls.php +0 -0
  50. views/admin/field-sitemaps.php +27 -27
  51. views/admin/help-tab-advanced.php +0 -0
  52. views/admin/help-tab-allowed-domains.php +0 -0
  53. views/admin/help-tab-authors.php +27 -0
  54. views/admin/help-tab-news-categories.php +0 -0
  55. views/admin/help-tab-news-keywords.php +0 -0
  56. views/admin/help-tab-news-labels.php +2 -2
  57. views/admin/help-tab-news-name.php +0 -0
  58. views/admin/help-tab-news-sidebar.php +13 -11
  59. views/admin/help-tab-news-stocktickers.php +0 -0
  60. views/admin/help-tab-news.php +18 -2
  61. views/admin/help-tab-ping.php +0 -0
  62. views/admin/help-tab-post-types.php +24 -1
  63. views/admin/help-tab-robots.php +0 -0
  64. views/admin/help-tab-sidebar.php +14 -3
  65. views/admin/help-tab-sitemaps.php +8 -0
  66. views/admin/help-tab-support.php +0 -0
  67. views/admin/help-tab-taxonomies.php +10 -0
  68. views/admin/meta-box-news.php +0 -0
  69. views/admin/meta-box.php +0 -0
  70. views/admin/notice-aioseop-sitemap.php +25 -0
  71. views/admin/notice-catchbox-feed-redirect.php +0 -0
  72. views/admin/notice-seoframework-sitemap.php +25 -0
  73. views/admin/notice-seopress-date-redirect.php +0 -0
  74. views/admin/notice-seopress-sitemap.php +0 -0
  75. views/admin/notice-static-files.php +12 -9
  76. views/admin/notice-wpseo-date-redirect.php +0 -0
  77. views/admin/notice-wpseo-sitemap.php +0 -0
  78. views/admin/notice-xmlsf-advanced-news.php +11 -0
  79. views/admin/page-sitemap-news.php +10 -4
  80. views/admin/page-sitemap.php +9 -7
  81. views/admin/section-advanced-compat-message.php +7 -0
  82. views/admin/section-advanced-intro.php +0 -0
  83. views/admin/sidebar-contribute.php +0 -0
  84. views/admin/sidebar-help.php +3 -3
  85. views/admin/sidebar-links.php +5 -5
  86. views/admin/sidebar-news-links.php +1 -1
  87. views/feed-sitemap-author.php +38 -0
  88. views/feed-sitemap-custom.php +3 -4
  89. views/feed-sitemap-home.php +0 -0
  90. views/feed-sitemap-news.php +27 -25
  91. views/feed-sitemap-post_type.php +0 -0
  92. views/feed-sitemap-posttype.php +95 -0
  93. views/feed-sitemap-root.php +34 -0
  94. views/feed-sitemap-taxonomy.php +4 -4
  95. views/feed-sitemap.php +29 -20
  96. xml-sitemap.php +310 -59
LICENSE CHANGED
File without changes
README.md DELETED
@@ -1,6 +0,0 @@
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
-
 
 
 
 
 
 
assets/admin.css ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ div.main {
2
+ width: 68%;
3
+ float: left;
4
+ }
5
+ div.sidebar {
6
+ width: 29%;
7
+ padding: .9em 0 2em 2%;
8
+ border-left: 1px solid #ccc;
9
+ float: right;
10
+ background: linear-gradient(to right, rgba(255,255,255,1) 0%,rgba(255,255,255,0) 100%);
11
+ }
12
+ @media screen and (max-width: 600px) {
13
+ div.main, div.sidebar {
14
+ width: 100%;
15
+ float: none;
16
+ border: none;
17
+ padding: 0
18
+ }
19
+ }
assets/sitemap-author.xsl ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <xsl:stylesheet version="1.1"
2
+ xmlns:sitemap="http://www.sitemaps.org/schemas/sitemap/0.9"
3
+ xmlns:image="http://www.google.com/schemas/sitemap-image/1.1"
4
+ xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
5
+ <xsl:output method="html" version="1.0" encoding="UTF-8" indent="yes"/>
6
+ <xsl:template match="/">
7
+ <html xmlns="http://www.w3.org/1999/xhtml">
8
+ <head>
9
+ <title>XML Sitemap — Authors</title>
10
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
11
+ <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>
12
+ </head>
13
+ <body>
14
+ <h1>XML Sitemap — Authors</h1>
15
+ <div id="header">
16
+ <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>
17
+ </div>
18
+ <div id="content">
19
+ <table cellpadding="5">
20
+ <tr class="high">
21
+ <th>#</th>
22
+ <th>URL</th>
23
+ <th>Priority</th>
24
+ <th>Last Modified</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:if test="sitemap:priority"><xsl:value-of select="concat(sitemap:priority*100,'%')"/></xsl:if></td>
33
+ <td><xsl:if test="sitemap:lastmod"><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)"/>)</xsl:if></td>
34
+ </tr>
35
+ </xsl:for-each>
36
+ </table>
37
+ </div>
38
+ <div id="footer">
39
+ <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 &amp; Google News</a> for <a href="https://wordpress.org/">WordPress</a>.</p>
40
+ </div>
41
+ </body>
42
+ </html>
43
+ </xsl:template>
44
+ </xsl:stylesheet>
assets/sitemap-custom.xsl ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <xsl:stylesheet version="1.1"
2
+ xmlns:sitemap="http://www.sitemaps.org/schemas/sitemap/0.9"
3
+ xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
4
+ <xsl:output method="html" version="1.0" encoding="UTF-8" indent="yes"/>
5
+ <xsl:template match="/">
6
+ <html xmlns="http://www.w3.org/1999/xhtml">
7
+ <head>
8
+ <title>XML Sitemap — Additional URLs</title>
9
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
10
+ <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>
11
+ </head>
12
+ <body>
13
+ <h1>XML Sitemap — Additional URLs</h1>
14
+ <div id="header">
15
+ <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>
16
+ </div>
17
+ <div id="content">
18
+ <table cellpadding="5">
19
+ <tr class="high">
20
+ <th>#</th>
21
+ <th>URL</th>
22
+ <th>Priority</th>
23
+ </tr>
24
+ <xsl:variable name="lower" select="'abcdefghijklmnopqrstuvwxyz'"/>
25
+ <xsl:variable name="upper" select="'ABCDEFGHIJKLMNOPQRSTUVWXYZ'"/>
26
+ <xsl:for-each select="sitemap:urlset/sitemap:url">
27
+ <tr><xsl:if test="position() mod 2 != 1"><xsl:attribute name="class">high</xsl:attribute></xsl:if>
28
+ <td><xsl:value-of select="position()"/></td>
29
+ <td><xsl:variable name="itemURL"><xsl:value-of select="sitemap:loc"/></xsl:variable><a href="{$itemURL}"><xsl:value-of select="sitemap:loc"/></a></td>
30
+ <td><xsl:if test="sitemap:priority"><xsl:value-of select="concat(sitemap:priority*100,'%')"/></xsl:if></td>
31
+ </tr>
32
+ </xsl:for-each>
33
+ </table>
34
+ </div>
35
+ <div id="footer">
36
+ <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 &amp; Google News</a> for <a href="https://wordpress.org/">WordPress</a>.</p>
37
+ </div>
38
+ </body>
39
+ </html>
40
+ </xsl:template>
41
+ </xsl:stylesheet>
assets/sitemap-news.xsl ADDED
@@ -0,0 +1,50 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <xsl:stylesheet version="1.1"
2
+ xmlns:sitemap="http://www.sitemaps.org/schemas/sitemap/0.9"
3
+ xmlns:news="http://www.google.com/schemas/sitemap-news/0.9"
4
+ xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
5
+ <xsl:output method="html" version="1.0" encoding="UTF-8" indent="yes"/>
6
+ <xsl:template match="/">
7
+ <html xmlns="http://www.w3.org/1999/xhtml">
8
+ <head>
9
+ <title>Google News Sitemap</title>
10
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
11
+ <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>
12
+ </head>
13
+ <body>
14
+ <h1>Google News Sitemap</h1>
15
+ <div id="header">
16
+ <p>This is a <a href="https://support.google.com/news/publisher/answer/75717" target="_blank">Google News Sitemap</a> to aid <a href="https://news.google.com" target="_blank">Google News</a> finding news on your website. Please note that <strong><em>only posts from the last 48 hours</em></strong> will be processed by Google News.</p>
17
+ </div>
18
+ <div id="content">
19
+ <table cellpadding="5">
20
+ <tr class="high">
21
+ <th>#</th>
22
+ <th>Title</th>
23
+ <th>Language</th>
24
+ <th>Keyword(s)</th>
25
+ <th>Stock(s)</th>
26
+ <th>Publication Date</th>
27
+ </tr>
28
+ <xsl:variable name="lower" select="'abcdefghijklmnopqrstuvwxyz'"/>
29
+ <xsl:variable name="upper" select="'ABCDEFGHIJKLMNOPQRSTUVWXYZ'"/>
30
+ <xsl:for-each select="sitemap:urlset/sitemap:url">
31
+ <tr><xsl:if test="position() mod 2 != 1"><xsl:attribute name="class">high</xsl:attribute></xsl:if>
32
+ <td><xsl:value-of select="position()"/></td>
33
+ <td><xsl:variable name="itemURL"><xsl:value-of select="sitemap:loc"/></xsl:variable>
34
+ <a href="{$itemURL}"><xsl:value-of select="news:news/news:title"/></a>
35
+ </td>
36
+ <td><xsl:value-of select="news:news/news:publication/news:language"/></td>
37
+ <td><xsl:value-of select="news:news/news:keywords"/></td>
38
+ <td><xsl:value-of select="news:news/news:stock_tickers"/></td>
39
+ <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>
40
+ </tr>
41
+ </xsl:for-each>
42
+ </table>
43
+ </div>
44
+ <div id="footer">
45
+ <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 &amp; Google News</a> for <a href="https://wordpress.org/">WordPress</a>.</p>
46
+ </div>
47
+ </body>
48
+ </html>
49
+ </xsl:template>
50
+ </xsl:stylesheet>
assets/sitemap-posttype.xsl ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <xsl:stylesheet version="1.1"
2
+ xmlns:sitemap="http://www.sitemaps.org/schemas/sitemap/0.9"
3
+ xmlns:image="http://www.google.com/schemas/sitemap-image/1.1"
4
+ xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
5
+ <xsl:output method="html" version="1.0" encoding="UTF-8" indent="yes"/>
6
+ <xsl:template match="/">
7
+ <html xmlns="http://www.w3.org/1999/xhtml">
8
+ <head>
9
+ <title>XML Sitemap — Post Type</title>
10
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
11
+ <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>
12
+ </head>
13
+ <body>
14
+ <h1>XML Sitemap — Post Type</h1>
15
+ <div id="header">
16
+ <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>
17
+ </div>
18
+ <div id="content">
19
+ <table cellpadding="5">
20
+ <tr class="high">
21
+ <th>#</th>
22
+ <th>URL</th>
23
+ <th># Images</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'"/>
29
+ <xsl:for-each select="sitemap:urlset/sitemap:url">
30
+ <tr><xsl:if test="position() mod 2 != 1"><xsl:attribute name="class">high</xsl:attribute></xsl:if>
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:if test="image:image"><xsl:value-of select="count(image:image)"/></xsl:if></td>
34
+ <td><xsl:if test="sitemap:priority"><xsl:value-of select="concat(sitemap:priority*100,'%')"/></xsl:if></td>
35
+ <td><xsl:if test="sitemap:lastmod"><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)"/>)</xsl:if></td>
36
+ </tr>
37
+ </xsl:for-each>
38
+ </table>
39
+ </div>
40
+ <div id="footer">
41
+ <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 &amp; Google News</a> for <a href="https://wordpress.org/">WordPress</a>.</p>
42
+ </div>
43
+ </body>
44
+ </html>
45
+ </xsl:template>
46
+ </xsl:stylesheet>
assets/sitemap-root.xsl ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <xsl:stylesheet version="1.1"
2
+ xmlns:sitemap="http://www.sitemaps.org/schemas/sitemap/0.9"
3
+ xmlns:image="http://www.google.com/schemas/sitemap-image/1.1"
4
+ xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
5
+ <xsl:output method="html" version="1.0" encoding="UTF-8" indent="yes"/>
6
+ <xsl:template match="/">
7
+ <html xmlns="http://www.w3.org/1999/xhtml">
8
+ <head>
9
+ <title>XML Sitemap — Root pages</title>
10
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
11
+ <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>
12
+ </head>
13
+ <body>
14
+ <h1>XML Sitemap — Root pages</h1>
15
+ <div id="header">
16
+ <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>
17
+ </div>
18
+ <div id="content">
19
+ <table cellpadding="5">
20
+ <tr class="high">
21
+ <th>#</th>
22
+ <th>URL</th>
23
+ <th># Images</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'"/>
29
+ <xsl:for-each select="sitemap:urlset/sitemap:url">
30
+ <tr><xsl:if test="position() mod 2 != 1"><xsl:attribute name="class">high</xsl:attribute></xsl:if>
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:if test="image:image"><xsl:value-of select="count(image:image)"/></xsl:if></td>
34
+ <td><xsl:if test="sitemap:priority"><xsl:value-of select="concat(sitemap:priority*100,'%')"/></xsl:if></td>
35
+ <td><xsl:if test="sitemap:lastmod"><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)"/>)</xsl:if></td>
36
+ </tr>
37
+ </xsl:for-each>
38
+ </table>
39
+ </div>
40
+ <div id="footer">
41
+ <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 &amp; Google News</a> for <a href="https://wordpress.org/">WordPress</a>.</p>
42
+ </div>
43
+ </body>
44
+ </html>
45
+ </xsl:template>
46
+ </xsl:stylesheet>
assets/sitemap-taxonomy.xsl ADDED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <xsl:stylesheet version="1.1"
2
+ xmlns:sitemap="http://www.sitemaps.org/schemas/sitemap/0.9"
3
+ xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
4
+ <xsl:output method="html" version="1.0" encoding="UTF-8" indent="yes"/>
5
+ <xsl:template match="/">
6
+ <html xmlns="http://www.w3.org/1999/xhtml">
7
+ <head>
8
+ <title>XML Sitemap — Taxonomy</title>
9
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
10
+ <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>
11
+ </head>
12
+ <body>
13
+ <h1>XML Sitemap — Taxonomy</h1>
14
+ <div id="header">
15
+ <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>
16
+ </div>
17
+ <div id="content">
18
+ <table cellpadding="5">
19
+ <tr class="high">
20
+ <th>#</th>
21
+ <th>URL</th>
22
+ <th>Priority</th>
23
+ <th>Last Modified</th>
24
+ </tr>
25
+ <xsl:variable name="lower" select="'abcdefghijklmnopqrstuvwxyz'"/>
26
+ <xsl:variable name="upper" select="'ABCDEFGHIJKLMNOPQRSTUVWXYZ'"/>
27
+ <xsl:for-each select="sitemap:urlset/sitemap:url">
28
+ <tr><xsl:if test="position() mod 2 != 1"><xsl:attribute name="class">high</xsl:attribute></xsl:if>
29
+ <td><xsl:value-of select="position()"/></td>
30
+ <td><xsl:variable name="itemURL"><xsl:value-of select="sitemap:loc"/></xsl:variable><a href="{$itemURL}"><xsl:value-of select="sitemap:loc"/></a></td>
31
+ <td><xsl:if test="sitemap:priority"><xsl:value-of select="concat(sitemap:priority*100,'%')"/></xsl:if></td>
32
+ <td><xsl:if test="sitemap:lastmod"><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)"/>)</xsl:if></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 &amp; Google News</a> for <a href="https://wordpress.org/">WordPress</a>.</p>
39
+ </div>
40
+ </body>
41
+ </html>
42
+ </xsl:template>
43
+ </xsl:stylesheet>
assets/sitemap.xsl ADDED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <xsl:stylesheet version="1.1"
2
+ xmlns:sitemap="http://www.sitemaps.org/schemas/sitemap/0.9"
3
+ xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
4
+ <xsl:output method="html" version="1.0" encoding="UTF-8" indent="yes"/>
5
+ <xsl:template match="/">
6
+ <html xmlns="http://www.w3.org/1999/xhtml">
7
+ <head>
8
+ <title>XML Sitemap — Index</title>
9
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
10
+ <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>
11
+ </head>
12
+ <body>
13
+ <h1>XML Sitemap — Index</h1>
14
+ <div id="header">
15
+ <p>This is the XML Sitemap Index 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>
16
+ </div>
17
+ <div id="content">
18
+ <table cellpadding="5">
19
+ <tr class="high">
20
+ <th>#</th>
21
+ <th>XML Sitemap</th>
22
+ <th>Last Modified</th>
23
+ </tr>
24
+ <xsl:variable name="lower" select="'abcdefghijklmnopqrstuvwxyz'"/>
25
+ <xsl:variable name="upper" select="'ABCDEFGHIJKLMNOPQRSTUVWXYZ'"/>
26
+ <xsl:for-each select="sitemap:sitemapindex/sitemap:sitemap">
27
+ <tr><xsl:if test="position() mod 2 != 1"><xsl:attribute name="class">high</xsl:attribute></xsl:if>
28
+ <td><xsl:value-of select="position()"/></td>
29
+ <td><xsl:variable name="itemURL"><xsl:value-of select="sitemap:loc"/></xsl:variable>
30
+ <a href="{$itemURL}"><xsl:value-of select="sitemap:loc"/></a>
31
+ </td>
32
+ <td><xsl:if test="sitemap:lastmod"><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)"/>)</xsl:if></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 &amp; Google News</a> for <a href="https://wordpress.org/">WordPress</a>.</p>
39
+ </div>
40
+ </body>
41
+ </html>
42
+ </xsl:template>
43
+ </xsl:stylesheet>
assets/sitemapxml.gif ADDED
Binary file
controllers/class.xmlsf-admin-sitemap-news.php CHANGED
@@ -3,15 +3,15 @@
3
  class XMLSF_Admin_Sitemap_News extends XMLSF_Admin
4
  {
5
  /**
6
- * Holds the values to be used in the fields callbacks
7
- */
8
- private $options;
9
-
10
- /**
11
- * Start up
12
- */
13
- public function __construct()
14
- {
15
  // META
16
  add_action( 'add_meta_boxes', array( $this, 'add_meta_box' ) );
17
  add_action( 'save_post', array( $this, 'save_metadata' ) );
@@ -24,17 +24,17 @@ class XMLSF_Admin_Sitemap_News extends XMLSF_Admin
24
  add_action( 'xmlsf_news_add_settings', array( $this, 'add_settings' ) );
25
 
26
  // TOOLS ACTIONS
27
- add_action( 'admin_init', array( $this, 'tools_actions' ) );
28
- }
29
 
30
  /**
31
  * TOOLS ACTIONS
32
  */
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 );
@@ -103,11 +103,11 @@ class XMLSF_Admin_Sitemap_News extends XMLSF_Admin
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']) )
@@ -121,91 +121,156 @@ class XMLSF_Admin_Sitemap_News extends XMLSF_Admin
121
  */
122
 
123
  /**
124
- * Add options page
125
- */
126
- public function add_settings_page()
127
  {
128
- // This page will be under "Settings"
129
- $screen_id = add_options_page(
130
- __('Google News Sitemap','xml-sitemap-feed'),
131
- __('Google News','xml-sitemap-feed'),
132
- 'manage_options',
133
- 'xmlsf_news',
134
- array( $this, 'settings_page' )
135
- );
136
-
137
- // Help tab
138
- add_action( 'load-'.$screen_id, array( $this, 'help_tab' ) );
139
- }
140
-
141
- /**
142
- * Options page callback
143
- */
144
- public function settings_page()
145
- {
146
- $this->options = (array) get_option( 'xmlsf_news_tags', array() );
147
 
148
- $sitemaps = (array) get_option( 'xmlsf_sitemaps', array() );
149
- $url = trailingslashit(get_bloginfo('url')) . ( xmlsf()->plain_permalinks() || empty($sitemaps['sitemap-news']) ? '?feed=sitemap-news' : $sitemaps['sitemap-news'] );
 
 
 
 
150
 
151
  $active_tab = isset( $_GET[ 'tab' ] ) ? $_GET[ 'tab' ] : 'general';
152
 
153
- do_action( 'xmlsf_news_add_settings', $active_tab );
 
 
 
 
 
 
 
 
 
 
154
 
155
  include XMLSF_DIR . '/views/admin/page-sitemap-news.php';
156
  }
157
 
158
- /**
159
- * Add advanced settings
160
- */
161
- public function add_settings( $active_tab = '' )
162
  {
163
- if ( 'advanced' == $active_tab ) {
164
- // ADVANCED SECTION
165
- add_settings_section( 'news_sitemap_advanced_section', /* '<a name="xmlnf"></a>'.__('Google News Sitemap','xml-sitemap-feed') */ '', '', 'xmlsf_news_advanced' );
166
-
167
- // Hierarchical post types
168
- add_settings_field( 'xmlsf_news_hierarchical', __( 'Hierarchical post types', 'xml-sitemap-feed' ), array( $this,'hierarchical_field' ), 'xmlsf_news_advanced', 'news_sitemap_advanced_section' );
169
-
170
- // Keywords
171
- add_settings_field( 'xmlsf_news_keywords', __( 'Keywords', 'xml-sitemap-feed' ), array( $this,'keywords_field' ), 'xmlsf_news_advanced', 'news_sitemap_advanced_section' );
172
-
173
- // Stock tickers
174
- add_settings_field( 'xmlsf_news_stock_tickers', __( 'Stock tickers', 'xml-sitemap-feed' ), array( $this,'stock_tickers_field' ), 'xmlsf_news_advanced', 'news_sitemap_advanced_section' );
175
-
176
- // Ping log
177
- add_settings_field( 'xmlsf_news_ping_log', __( 'Ping log', 'xml-sitemap-feed' ), array( $this,'ping_log_field' ), 'xmlsf_news_advanced', 'news_sitemap_advanced_section' );
178
- } else {
179
- // GENERAL SECTION
180
- add_settings_section( 'news_sitemap_general_section', /* '<a name="xmlnf"></a>'.__('Google News Sitemap','xml-sitemap-feed') */ '', '', 'xmlsf_news_general' );
181
-
182
- // SETTINGS
183
- add_settings_field( 'xmlsf_news_name', '<label for="xmlsf_news_name">'.__('Publication name','xml-sitemap-feed').'</label>', array($this,'name_field'), 'xmlsf_news_general', 'news_sitemap_general_section' );
184
- add_settings_field( 'xmlsf_news_post_type', __('Post type','xml-sitemap-feed'), array($this,'post_type_field'), 'xmlsf_news_general', 'news_sitemap_general_section' );
185
-
186
- global $wp_taxonomies;
187
- $news_post_type = isset( $this->options['post_type'] ) && !empty( $this->options['post_type'] ) ? (array) $this->options['post_type'] : array('post');
188
- $post_types = ( isset( $wp_taxonomies['category'] ) ) ? $wp_taxonomies['category']->object_type : array();
189
-
190
- foreach ( $news_post_type as $post_type ) {
191
- if ( in_array( $post_type, $post_types ) ) {
192
- add_settings_field( 'xmlsf_news_categories', translate('Categories'), array($this,'categories_field'), 'xmlsf_news_general', 'news_sitemap_general_section' );
193
- break;
194
- }
195
- }
196
-
197
- // Source labels - deprecated
198
- add_settings_field( 'xmlsf_news_labels', __('Source labels', 'xml-sitemap-feed' ), array($this,'labels_field'), 'xmlsf_news_general', 'news_sitemap_general_section' );
199
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
200
  }
201
 
202
  /**
203
- * Register settings
204
- */
205
  public function register_settings()
206
- {
207
- register_setting( 'xmlsf_news_general', 'xmlsf_news_tags', array('XMLSF_Admin_Sitemap_News_Sanitize','news_tags_settings') );
208
- }
 
 
 
 
209
 
210
  /**
211
  * GOOGLE NEWS SITEMAP SECTION
@@ -220,7 +285,7 @@ class XMLSF_Admin_Sitemap_News extends XMLSF_Admin
220
  $content = ob_get_clean();
221
 
222
  $screen->add_help_tab( array(
223
- 'id' => 'sitemap-news-settings',
224
  'title' => __( 'Google News Sitemap', 'xml-sitemap-feed' ),
225
  'content' => $content
226
  ) );
@@ -231,7 +296,7 @@ class XMLSF_Admin_Sitemap_News extends XMLSF_Admin
231
  $content = ob_get_clean();
232
 
233
  $screen->add_help_tab( array(
234
- 'id' => 'sitemap-news-name',
235
  'title' => __( 'Publication name', 'xml-sitemap-feed' ),
236
  'content' => $content
237
  ) );
@@ -242,7 +307,7 @@ class XMLSF_Admin_Sitemap_News extends XMLSF_Admin
242
  $content = ob_get_clean();
243
 
244
  $screen->add_help_tab( array(
245
- 'id' => 'sitemap-news-categories',
246
  'title' => translate('Categories'),
247
  'content' => $content
248
  ) );
@@ -253,7 +318,7 @@ class XMLSF_Admin_Sitemap_News extends XMLSF_Admin
253
  $content = ob_get_clean();
254
 
255
  $screen->add_help_tab( array(
256
- 'id' => 'sitemap-news-keywords',
257
  'title' => __( 'Keywords', 'xml-sitemap-feed' ),
258
  'content' => $content
259
  ) );
@@ -264,7 +329,7 @@ class XMLSF_Admin_Sitemap_News extends XMLSF_Admin
264
  $content = ob_get_clean();
265
 
266
  $screen->add_help_tab( array(
267
- 'id' => 'sitemap-news-stocktickers',
268
  'title' => __( 'Stock tickers', 'xml-sitemap-feed' ),
269
  'content' => $content
270
  ) );
@@ -275,7 +340,7 @@ class XMLSF_Admin_Sitemap_News extends XMLSF_Admin
275
  $content = ob_get_clean();
276
 
277
  $screen->add_help_tab( array(
278
- 'id' => 'sitemap-news-labels',
279
  'title' => __( 'Source labels', 'xml-sitemap-feed' ),
280
  'content' => $content
281
  ) );
@@ -298,6 +363,7 @@ class XMLSF_Admin_Sitemap_News extends XMLSF_Admin
298
  public function post_type_field()
299
  {
300
  global $wp_taxonomies;
 
301
  $post_types = apply_filters( 'xmlsf_news_post_types', get_post_types( array( 'public' => true, 'hierarchical' => false ) /*,'objects'*/) );
302
 
303
  if ( is_array($post_types) && !empty($post_types) ) :
@@ -320,44 +386,36 @@ class XMLSF_Admin_Sitemap_News extends XMLSF_Admin
320
  endif;
321
  }
322
 
323
- public function categories_field()
324
  {
325
- $selected_categories = isset( $this->options['categories'] ) && is_array( $this->options['categories'] ) ? $this->options['categories'] : array();
326
-
327
- $cat_list = str_replace('name="post_category[]"','name="'.'xmlsf_news_tags[categories][]"', wp_terms_checklist( null, array( 'taxonomy' => 'category', 'selected_cats' => $selected_categories, 'echo' => false ) ) );
 
 
328
 
329
- // The actual fields for data entry
330
- include XMLSF_DIR . '/views/admin/field-news-categories.php';
331
  }
332
 
333
- public function keywords_field()
334
- {
335
- // The actual fields for data entry
336
- include XMLSF_DIR . '/views/admin/field-news-keywords.php';
337
- }
338
 
339
- public function hierarchical_field()
340
- {
341
- // The actual fields for data entry
342
- include XMLSF_DIR . '/views/admin/field-news-hierarchical.php';
343
- }
344
 
345
- public function stock_tickers_field()
346
- {
347
- // The actual fields for data entry
348
- include XMLSF_DIR . '/views/admin/field-news-stocktickers.php';
349
- }
 
350
 
351
- public function ping_log_field()
352
- {
353
- // The actual fields for data entry
354
- include XMLSF_DIR . '/views/admin/field-news-ping-log.php';
355
- }
356
 
357
- public function labels_field()
358
- {
359
  // The actual fields for data entry
360
- include XMLSF_DIR . '/views/admin/field-news-labels.php';
361
  }
362
 
363
  }
3
  class XMLSF_Admin_Sitemap_News extends XMLSF_Admin
4
  {
5
  /**
6
+ * Holds the values to be used in the fields callbacks
7
+ */
8
+ private $options;
9
+
10
+ /**
11
+ * Start up
12
+ */
13
+ public function __construct()
14
+ {
15
  // META
16
  add_action( 'add_meta_boxes', array( $this, 'add_meta_box' ) );
17
  add_action( 'save_post', array( $this, 'save_metadata' ) );
24
  add_action( 'xmlsf_news_add_settings', array( $this, 'add_settings' ) );
25
 
26
  // TOOLS ACTIONS
27
+ add_action( 'admin_init', array( $this, 'ping_sitemap' ) );
28
+ }
29
 
30
  /**
31
  * TOOLS ACTIONS
32
  */
33
 
34
+ public function ping_sitemap()
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 );
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']) )
121
  */
122
 
123
  /**
124
+ * Add options page
125
+ */
126
+ public function add_settings_page()
127
  {
128
+ // This page will be under "Settings"
129
+ $screen_id = add_options_page(
130
+ __('Google News Sitemap','xml-sitemap-feed'),
131
+ __('Google News','xml-sitemap-feed'),
132
+ 'manage_options',
133
+ 'xmlsf_news',
134
+ array( $this, 'settings_page' )
135
+ );
136
+
137
+ // Help tab
138
+ add_action( 'load-'.$screen_id, array( $this, 'help_tab' ) );
139
+ }
 
 
 
 
 
 
 
140
 
141
+ /**
142
+ * Options page callback
143
+ */
144
+ public function settings_page()
145
+ {
146
+ $this->options = (array) get_option( 'xmlsf_news_tags', array() );
147
 
148
  $active_tab = isset( $_GET[ 'tab' ] ) ? $_GET[ 'tab' ] : 'general';
149
 
150
+ do_action( 'xmlsf_news_add_settings', $active_tab );
151
+
152
+ // prepare sitemap link url
153
+ $sitemaps = (array) get_option( 'xmlsf_sitemaps', array() );
154
+
155
+ $sitemap = xmlsf()->plain_permalinks() ? '?feed=sitemap-news' : $sitemaps['sitemap-news'];
156
+
157
+ // remove WPML home url filter
158
+ global $wpml_url_filters;
159
+ if ( is_object($wpml_url_filters) )
160
+ remove_filter( 'home_url', array( $wpml_url_filters, 'home_url_filter' ), - 10 );
161
 
162
  include XMLSF_DIR . '/views/admin/page-sitemap-news.php';
163
  }
164
 
165
+ /**
166
+ * Add advanced settings
167
+ */
168
+ public function add_settings( $active_tab = '' )
169
  {
170
+ if ( 'advanced' == $active_tab ) {
171
+ // ADVANCED SECTION
172
+ add_settings_section(
173
+ 'news_sitemap_advanced_section',
174
+ /* '<a name="xmlnf"></a>'.__('Google News Sitemap','xml-sitemap-feed') */
175
+ '',
176
+ '',
177
+ 'xmlsf_news_advanced'
178
+ );
179
+
180
+ // Hierarchical post types
181
+ add_settings_field(
182
+ 'xmlsf_news_hierarchical',
183
+ __( 'Hierarchical post types', 'xml-sitemap-feed' ),
184
+ function() { include XMLSF_DIR . '/views/admin/field-news-hierarchical.php'; },
185
+ 'xmlsf_news_advanced',
186
+ 'news_sitemap_advanced_section'
187
+ );
188
+
189
+ // Keywords
190
+ add_settings_field(
191
+ 'xmlsf_news_keywords',
192
+ __( 'Keywords', 'xml-sitemap-feed' ),
193
+ function() { include XMLSF_DIR . '/views/admin/field-news-keywords.php'; },
194
+ 'xmlsf_news_advanced',
195
+ 'news_sitemap_advanced_section'
196
+ );
197
+
198
+ // Stock tickers
199
+ add_settings_field(
200
+ 'xmlsf_news_stock_tickers',
201
+ __( 'Stock tickers', 'xml-sitemap-feed' ),
202
+ function() { include XMLSF_DIR . '/views/admin/field-news-stocktickers.php'; },
203
+ 'xmlsf_news_advanced',
204
+ 'news_sitemap_advanced_section'
205
+ );
206
+
207
+ // Ping log
208
+ add_settings_field(
209
+ 'xmlsf_news_ping_log',
210
+ __( 'Ping log', 'xml-sitemap-feed' ),
211
+ function() { include XMLSF_DIR . '/views/admin/field-news-ping-log.php'; },
212
+ 'xmlsf_news_advanced',
213
+ 'news_sitemap_advanced_section'
214
+ );
215
+ } else {
216
+ // GENERAL SECTION
217
+ add_settings_section(
218
+ 'news_sitemap_general_section',
219
+ /* '<a name="xmlnf"></a>'.__('Google News Sitemap','xml-sitemap-feed') */
220
+ '',
221
+ '',
222
+ 'xmlsf_news_general'
223
+ );
224
+
225
+ // SETTINGS
226
+ add_settings_field(
227
+ 'xmlsf_news_name',
228
+ '<label for="xmlsf_news_name">'.__('Publication name','xml-sitemap-feed').'</label>',
229
+ array( $this, 'name_field' ),
230
+ 'xmlsf_news_general',
231
+ 'news_sitemap_general_section'
232
+ );
233
+ add_settings_field(
234
+ 'xmlsf_news_post_type',
235
+ __( 'Post type', 'xml-sitemap-feed' ),
236
+ array( $this, 'post_type_field' ),
237
+ 'xmlsf_news_general',
238
+ 'news_sitemap_general_section'
239
+ );
240
+
241
+ global $wp_taxonomies;
242
+ $news_post_type = isset( $this->options['post_type'] ) && !empty( $this->options['post_type'] ) ? (array) $this->options['post_type'] : array('post');
243
+ $post_types = ( isset( $wp_taxonomies['category'] ) ) ? $wp_taxonomies['category']->object_type : array();
244
+
245
+ foreach ( $news_post_type as $post_type ) {
246
+ if ( in_array( $post_type, $post_types ) ) {
247
+ add_settings_field( 'xmlsf_news_categories', translate('Categories'), array($this,'categories_field'), 'xmlsf_news_general', 'news_sitemap_general_section' );
248
+ break;
249
+ }
250
+ }
251
+
252
+ // Source labels - deprecated
253
+ add_settings_field(
254
+ 'xmlsf_news_labels',
255
+ __('Source labels', 'xml-sitemap-feed' ),
256
+ function() { include XMLSF_DIR . '/views/admin/field-news-labels.php'; },
257
+ 'xmlsf_news_general',
258
+ 'news_sitemap_general_section'
259
+ );
260
+ }
261
  }
262
 
263
  /**
264
+ * Register settings
265
+ */
266
  public function register_settings()
267
+ {
268
+ register_setting(
269
+ 'xmlsf_news_general',
270
+ 'xmlsf_news_tags',
271
+ array( 'XMLSF_Admin_Sitemap_News_Sanitize', 'news_tags_settings' )
272
+ );
273
+ }
274
 
275
  /**
276
  * GOOGLE NEWS SITEMAP SECTION
285
  $content = ob_get_clean();
286
 
287
  $screen->add_help_tab( array(
288
+ 'id' => 'sitemap-news-settings',
289
  'title' => __( 'Google News Sitemap', 'xml-sitemap-feed' ),
290
  'content' => $content
291
  ) );
296
  $content = ob_get_clean();
297
 
298
  $screen->add_help_tab( array(
299
+ 'id' => 'sitemap-news-name',
300
  'title' => __( 'Publication name', 'xml-sitemap-feed' ),
301
  'content' => $content
302
  ) );
307
  $content = ob_get_clean();
308
 
309
  $screen->add_help_tab( array(
310
+ 'id' => 'sitemap-news-categories',
311
  'title' => translate('Categories'),
312
  'content' => $content
313
  ) );
318
  $content = ob_get_clean();
319
 
320
  $screen->add_help_tab( array(
321
+ 'id' => 'sitemap-news-keywords',
322
  'title' => __( 'Keywords', 'xml-sitemap-feed' ),
323
  'content' => $content
324
  ) );
329
  $content = ob_get_clean();
330
 
331
  $screen->add_help_tab( array(
332
+ 'id' => 'sitemap-news-stocktickers',
333
  'title' => __( 'Stock tickers', 'xml-sitemap-feed' ),
334
  'content' => $content
335
  ) );
340
  $content = ob_get_clean();
341
 
342
  $screen->add_help_tab( array(
343
+ 'id' => 'sitemap-news-labels',
344
  'title' => __( 'Source labels', 'xml-sitemap-feed' ),
345
  'content' => $content
346
  ) );
363
  public function post_type_field()
364
  {
365
  global $wp_taxonomies;
366
+
367
  $post_types = apply_filters( 'xmlsf_news_post_types', get_post_types( array( 'public' => true, 'hierarchical' => false ) /*,'objects'*/) );
368
 
369
  if ( is_array($post_types) && !empty($post_types) ) :
386
  endif;
387
  }
388
 
389
+ public function terms_checklist_language_filter( $args )
390
  {
391
+ if ( function_exists('pll_languages_list') ) {
392
+ $args['lang'] = implode( ',', pll_languages_list() );
393
+ } else {
394
+ $args['lang'] = '';
395
+ }
396
 
397
+ return $args;
 
398
  }
399
 
400
+ public function categories_field()
401
+ {
402
+ $selected_categories = isset( $this->options['categories'] ) && is_array( $this->options['categories'] ) ? $this->options['categories'] : array();
 
 
403
 
404
+ if ( function_exists('pll_languages_list') ) {
405
+ add_filter( 'get_terms_args', function( $args ){ $args['lang'] = implode( ',', pll_languages_list() ); return $args; }/*array( $this, 'terms_checklist_language_filter' )*/ );
406
+ }
 
 
407
 
408
+ global $sitepress;
409
+ if ( $sitepress ) {
410
+ remove_filter( 'get_terms_args', array( $sitepress, 'get_terms_args_filter' ) );
411
+ remove_filter( 'get_term', array( $sitepress, 'get_term_adjust_id' ), 1 );
412
+ remove_filter( 'terms_clauses', array( $sitepress, 'terms_clauses' ) );
413
+ }
414
 
415
+ $cat_list = str_replace('name="post_category[]"','name="'.'xmlsf_news_tags[categories][]"', wp_terms_checklist( null, array( 'taxonomy' => 'category', 'selected_cats' => $selected_categories, 'echo' => false ) ) );
 
 
 
 
416
 
 
 
417
  // The actual fields for data entry
418
+ include XMLSF_DIR . '/views/admin/field-news-categories.php';
419
  }
420
 
421
  }
controllers/class.xmlsf-admin-sitemap.php CHANGED
@@ -2,33 +2,39 @@
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_conflicts' ), 11 );
23
  add_action( 'admin_init', array( $this, 'register_settings' ) );
24
  add_action( 'add_meta_boxes', array( $this, 'add_meta_box' ) );
25
  add_action( 'save_post', array( $this, 'save_metadata' ) );
 
 
 
26
  }
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
 
@@ -68,33 +74,36 @@ class XMLSF_Admin_Sitemap extends XMLSF_Admin
68
  */
69
  public function check_conflicts()
70
  {
71
- if ( wp_doing_ajax() || ! current_user_can( 'manage_options' ) ) return;
72
 
73
  // TODO:
74
- // W3TC static files 404 exclusion rules ? Said to be fixed in W3TC next version...
75
- // Google (XML) Sitemaps Generator Plugin for WordPress and Google News sitemap incompatibility
76
 
77
  // WP SEO conflict notices
78
  if ( is_plugin_active('wordpress-seo/wp-seo.php') ) {
79
  // check date archive redirection
80
- //if ( !in_array( 'wpseo_date_redirect', parent::$dismissed ) ) {
81
- $wpseo_titles = get_option( 'wpseo_titles' );
82
- if ( !empty( $wpseo_titles['disable-date'] ) ) {
83
- // check if Split by option is set anywhere
84
- foreach ( (array) get_option( 'xmlsf_post_types', array() ) as $type => $settings ) {
85
- if ( !empty( $settings['active'] ) && !empty( $settings['archive'] ) ) {
86
- add_action( 'admin_notices', array( 'XMLSF_Admin_Notices', 'notice_wpseo_date_redirect' ) );
87
- break;
88
- }
 
89
  }
90
  }
91
- //}
92
 
93
  // check wpseo sitemap option
94
  if ( !in_array( 'wpseo_sitemap', parent::$dismissed ) ) {
95
  $wpseo = get_option( 'wpseo' );
96
  if ( !empty( $wpseo['enable_xml_sitemap'] ) ) {
97
- add_action( 'admin_notices', array( 'XMLSF_Admin_Notices', 'notice_wpseo_sitemap' ) );
 
 
 
98
  }
99
  }
100
  }
@@ -104,50 +113,94 @@ class XMLSF_Admin_Sitemap extends XMLSF_Admin
104
 
105
  // check date archive redirection
106
  $seopress_toggle = get_option( 'seopress_toggle' );
107
- //if ( !in_array( 'seopress_date_redirect', parent::$dismissed ) ) {
108
- $seopress_titles = get_option( 'seopress_titles_option_name' );
109
- if ( ! empty( $seopress_toggle['toggle-titles'] ) && ! empty( $seopress_titles['seopress_titles_archives_date_disable'] ) ) {
110
- // check if Split by option is set anywhere
111
- foreach ( (array) get_option( 'xmlsf_post_types', array() ) as $type => $settings ) {
112
- if ( !empty( $settings['active'] ) && !empty( $settings['archive'] ) ) {
113
- add_action( 'admin_notices', array( 'XMLSF_Admin_Notices', 'notice_seopress_date_redirect' ) );
114
- break;
115
- }
 
 
116
  }
117
  }
118
- //}
 
119
 
120
  // check seopress sitemap option
121
  if ( !in_array( 'seopress_sitemap', parent::$dismissed ) ) {
122
  $seopress_xml_sitemap = get_option( 'seopress_xml_sitemap_option_name' );
123
  if ( ! empty( $seopress_toggle['toggle-xml-sitemap'] ) && !empty( $seopress_xml_sitemap['seopress_xml_sitemap_general_enable'] ) ) {
124
- add_action( 'admin_notices', array( 'XMLSF_Admin_Notices', 'notice_seopress_sitemap' ) );
 
 
 
125
  }
126
  }
127
  }
128
 
129
- // Rank Math conflict notices
130
  if ( is_plugin_active('seo-by-rank-math/rank-math.php') ) {
131
 
132
  // check date archive redirection
133
- //if ( !in_array( 'rankmath_date_redirect', parent::$dismissed ) ) {
134
- $rankmath_titles = get_option( 'rank-math-options-titles' );
135
- if ( ! empty( $rankmath_titles['disable_date_archives'] ) && $rankmath_titles['disable_date_archives'] == 'on' ) {
136
- // check if Split by option is set anywhere
137
- foreach ( (array) get_option( 'xmlsf_post_types', array() ) as $type => $settings ) {
138
- if ( !empty( $settings['active'] ) && !empty( $settings['archive'] ) ) {
139
- add_action( 'admin_notices', array( 'XMLSF_Admin_Notices', 'notice_rankmath_date_redirect' ) );
140
- break;
141
- }
 
142
  }
143
  }
144
- //}
145
 
146
  // check rank math sitemap option
147
  if ( !in_array( 'rankmath_sitemap', parent::$dismissed ) ) {
148
  $rankmath_modules = (array) get_option( 'rank_math_modules' );
149
  if ( in_array( 'sitemap', $rankmath_modules ) ) {
150
- add_action( 'admin_notices', array( 'XMLSF_Admin_Notices', 'notice_rankmath_sitemap' ) );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
151
  }
152
  }
153
  }
@@ -188,12 +241,8 @@ class XMLSF_Admin_Sitemap extends XMLSF_Admin
188
  $priority = get_post_meta( $post->ID, '_xmlsf_priority', true );
189
  $disabled = false;
190
 
191
- // priority value precheck to prevent "invalid form control not focusable" when meta box is hidden
192
- if ( !empty($priority) && is_numeric($priority) ) {
193
- $priority = xmlsf_sanitize_priority( $priority );
194
- } else {
195
- $priority = '';
196
- }
197
 
198
  // disable options and (visibly) set excluded to true for private posts
199
  if ( 'private' == $post->post_status ) {
@@ -222,17 +271,17 @@ class XMLSF_Admin_Sitemap extends XMLSF_Admin
222
  public function save_metadata( $post_id )
223
  {
224
  if (
225
- // verify nonce
226
- ! isset($_POST['_xmlsf_nonce']) || ! wp_verify_nonce($_POST['_xmlsf_nonce'], XMLSF_BASENAME) ||
227
- // user not allowed
228
- ! current_user_can( 'edit_post', $post_id )
229
- ) return;
230
 
231
  // _xmlsf_priority
232
  if ( empty($_POST['xmlsf_priority']) || ! is_numeric($_POST['xmlsf_priority']) )
233
  delete_post_meta($post_id, '_xmlsf_priority');
234
  else
235
- update_post_meta($post_id, '_xmlsf_priority', xmlsf_sanitize_priority( $_POST['xmlsf_priority'] ) );
236
 
237
  // _xmlsf_exclude
238
  if ( empty($_POST['xmlsf_exclude']) )
@@ -242,9 +291,9 @@ class XMLSF_Admin_Sitemap extends XMLSF_Admin
242
  }
243
 
244
  /**
245
- * Gets public taxonomies
246
- */
247
- public function public_taxonomies()
248
  {
249
  if ( !isset( $this->public_taxonomies ) ) {
250
  $this->public_taxonomies = xmlsf_public_taxonomies();
@@ -254,27 +303,30 @@ class XMLSF_Admin_Sitemap extends XMLSF_Admin
254
  }
255
 
256
  /**
257
- * Add options page
258
- */
259
- public function add_settings_page()
260
  {
261
- // This page will be under "Settings"
262
- $this->screen_id = add_options_page(
263
- __('XML Sitemap','xml-sitemap-feed'),
264
- __('XML Sitemap','xml-sitemap-feed'),
265
- 'manage_options',
266
- 'xmlsf',
267
- array( $this, 'settings_page' )
268
- );
269
- }
270
-
271
- /**
272
- * Options page callback
273
- */
274
- public function settings_page()
275
- {
276
- // SECTIONS & SETTINGS
277
- // post_types
 
 
 
278
  add_settings_section( 'xml_sitemap_post_types_section', /*'<a name="xmlsf"></a>'.__('XML Sitemap','xml-sitemap-feed')*/ '', '', 'xmlsf_post_types' );
279
  $post_types = apply_filters( 'xmlsf_post_types', get_post_types( array( 'public' => true ) /*,'objects'*/) );
280
 
@@ -288,12 +340,19 @@ class XMLSF_Admin_Sitemap extends XMLSF_Admin
288
  }
289
  endif;
290
 
291
- // taxonomies
292
  add_settings_section( 'xml_sitemap_taxonomies_section', /*'<a name="xmlsf"></a>'.__('XML Sitemap','xml-sitemap-feed')*/ '', '', 'xmlsf_taxonomies' );
293
  add_settings_field( 'xmlsf_taxonomy_settings', translate('General'), array($this,'taxonomy_settings_field'), 'xmlsf_taxonomies', 'xml_sitemap_taxonomies_section' );
294
- add_settings_field( 'xmlsf_taxonomies', __('Taxonomies','xml-sitemap-feed'), array($this,'taxonomies_field'), 'xmlsf_taxonomies', 'xml_sitemap_taxonomies_section' );
295
 
 
 
 
 
 
296
  add_settings_section( 'xml_sitemap_advanced_section', /*'<a name="xmlsf"></a>'.__('XML Sitemap','xml-sitemap-feed')*/ '', '', 'xmlsf_advanced' );
 
 
297
  // custom urls
298
  add_settings_field( 'xmlsf_urls', __('External web pages','xml-sitemap-feed'), array($this,'urls_settings_field'), 'xmlsf_advanced', 'xml_sitemap_advanced_section' );
299
  // custom sitemaps
@@ -301,17 +360,26 @@ class XMLSF_Admin_Sitemap extends XMLSF_Admin
301
 
302
  $active_tab = isset( $_GET[ 'tab' ] ) ? $_GET[ 'tab' ] : 'post_types';
303
 
 
 
 
304
  $sitemaps = (array) get_option( 'xmlsf_sitemaps', array() );
305
- $url = trailingslashit(get_bloginfo('url')) . ( xmlsf()->plain_permalinks() || empty($sitemaps['sitemap']) ? '?feed=sitemap' : $sitemaps['sitemap'] );
 
 
 
 
 
 
306
 
307
  include XMLSF_DIR . '/views/admin/page-sitemap.php';
308
- }
309
 
310
- /**
311
- * Register and add settings
312
- */
313
- public function register_settings()
314
- {
315
  // Help tab
316
  add_action( 'load-'.$this->screen_id, array($this,'help_tab') );
317
 
@@ -320,11 +388,13 @@ class XMLSF_Admin_Sitemap extends XMLSF_Admin
320
  // taxonomies
321
  register_setting( 'xmlsf_taxonomies', 'xmlsf_taxonomy_settings', array('XMLSF_Admin_Sitemap_Sanitize','taxonomy_settings') );
322
  register_setting( 'xmlsf_taxonomies', 'xmlsf_taxonomies', array('XMLSF_Admin_Sitemap_Sanitize','taxonomies') );
 
 
323
  // custom urls
324
  register_setting( 'xmlsf_advanced', 'xmlsf_urls', array('XMLSF_Admin_Sitemap_Sanitize','custom_urls_settings') );
325
  // custom sitemaps
326
  register_setting( 'xmlsf_advanced', 'xmlsf_custom_sitemaps', array('XMLSF_Admin_Sitemap_Sanitize','custom_sitemaps_settings') );
327
- }
328
 
329
  /**
330
  * XML SITEMAP SECTION
@@ -340,7 +410,7 @@ class XMLSF_Admin_Sitemap extends XMLSF_Admin
340
  $content = ob_get_clean();
341
 
342
  $screen->add_help_tab( array(
343
- 'id' => 'sitemap-settings',
344
  'title' => __( 'XML Sitemap', 'xml-sitemap-feed' ),
345
  'content' => $content
346
  ) );
@@ -350,7 +420,7 @@ class XMLSF_Admin_Sitemap extends XMLSF_Admin
350
  $content = ob_get_clean();
351
 
352
  $screen->add_help_tab( array(
353
- 'id' => 'sitemap-settings-post-types',
354
  'title' => __( 'Post types', 'xml-sitemap-feed' ),
355
  'content' => $content
356
  ) );
@@ -360,17 +430,27 @@ class XMLSF_Admin_Sitemap extends XMLSF_Admin
360
  $content = ob_get_clean();
361
 
362
  $screen->add_help_tab( array(
363
- 'id' => 'sitemap-settings-taxonomies',
364
  'title' => __( 'Taxonomies', 'xml-sitemap-feed' ),
365
  'content' => $content,
366
  ) );
367
 
 
 
 
 
 
 
 
 
 
 
368
  ob_start();
369
  include XMLSF_DIR . '/views/admin/help-tab-advanced.php';
370
  $content = ob_get_clean();
371
 
372
  $screen->add_help_tab( array(
373
- 'id' => 'sitemap-settings-advanced',
374
  'title' => translate( 'Advanced' ),
375
  'content' => $content
376
  ) );
@@ -411,6 +491,31 @@ class XMLSF_Admin_Sitemap extends XMLSF_Admin
411
  include XMLSF_DIR . '/views/admin/field-sitemap-taxonomies.php';
412
  }
413
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
414
  public function custom_sitemaps_settings_field()
415
  {
416
  $custom_sitemaps = get_option( 'xmlsf_custom_sitemaps' );
@@ -421,7 +526,7 @@ class XMLSF_Admin_Sitemap extends XMLSF_Admin
421
  }
422
 
423
  public function urls_settings_field()
424
- {
425
  $urls = get_option( 'xmlsf_urls' );
426
  $lines = array();
427
 
@@ -436,6 +541,14 @@ class XMLSF_Admin_Sitemap extends XMLSF_Admin
436
  include XMLSF_DIR . '/views/admin/field-sitemap-urls.php';
437
  }
438
 
 
 
 
 
 
 
 
 
439
  }
440
 
441
  new XMLSF_Admin_Sitemap();
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, 'ping_sitemap' ) );
22
  add_action( 'admin_init', array( $this, 'check_conflicts' ), 11 );
23
  add_action( 'admin_init', array( $this, 'register_settings' ) );
24
  add_action( 'add_meta_boxes', array( $this, 'add_meta_box' ) );
25
  add_action( 'save_post', array( $this, 'save_metadata' ) );
26
+
27
+ // placeholders for advanced options
28
+ add_action( 'xmlsf_posttype_archive_field_options', array( $this, 'advanced_archive_field_options' ) );
29
  }
30
 
31
+ /**
32
+ * Ping sitemaps
33
+ */
34
+ public function ping_sitemap()
35
  {
36
  if ( ! isset( $_POST['xmlsf-ping-sitemap'] ) || ! xmlsf_verify_nonce('help') )
37
+ return;
38
 
39
  $sitemaps = get_option( 'xmlsf_sitemaps' );
40
 
74
  */
75
  public function check_conflicts()
76
  {
77
+ if ( wp_doing_ajax() || ! current_user_can( 'manage_options' ) ) return;
78
 
79
  // TODO:
80
+ // Google (XML) Sitemaps Generator Plugin for WordPress and Google News Sitemap incompatibility
 
81
 
82
  // WP SEO conflict notices
83
  if ( is_plugin_active('wordpress-seo/wp-seo.php') ) {
84
  // check date archive redirection
85
+ $wpseo_titles = get_option( 'wpseo_titles' );
86
+ if ( !empty( $wpseo_titles['disable-date'] ) ) {
87
+ // check if Split by option is set anywhere
88
+ foreach ( (array) get_option( 'xmlsf_post_types', array() ) as $type => $settings ) {
89
+ if ( !empty( $settings['active'] ) && !empty( $settings['archive'] ) ) {
90
+ add_action(
91
+ 'admin_notices',
92
+ function() { include XMLSF_DIR . '/views/admin/notice-wpseo-date-redirect.php'; }
93
+ );
94
+ break;
95
  }
96
  }
97
+ }
98
 
99
  // check wpseo sitemap option
100
  if ( !in_array( 'wpseo_sitemap', parent::$dismissed ) ) {
101
  $wpseo = get_option( 'wpseo' );
102
  if ( !empty( $wpseo['enable_xml_sitemap'] ) ) {
103
+ add_action(
104
+ 'admin_notices',
105
+ function() { include XMLSF_DIR . '/views/admin/notice-wpseo-sitemap.php'; }
106
+ );
107
  }
108
  }
109
  }
113
 
114
  // check date archive redirection
115
  $seopress_toggle = get_option( 'seopress_toggle' );
116
+
117
+ $seopress_titles = get_option( 'seopress_titles_option_name' );
118
+ if ( ! empty( $seopress_toggle['toggle-titles'] ) && ! empty( $seopress_titles['seopress_titles_archives_date_disable'] ) ) {
119
+ // check if Split by option is set anywhere
120
+ foreach ( (array) get_option( 'xmlsf_post_types', array() ) as $type => $settings ) {
121
+ if ( !empty( $settings['active'] ) && !empty( $settings['archive'] ) ) {
122
+ add_action(
123
+ 'admin_notices',
124
+ function() { include XMLSF_DIR . '/views/admin/notice-seopress-date-redirect.php'; }
125
+ );
126
+ break;
127
  }
128
  }
129
+ }
130
+
131
 
132
  // check seopress sitemap option
133
  if ( !in_array( 'seopress_sitemap', parent::$dismissed ) ) {
134
  $seopress_xml_sitemap = get_option( 'seopress_xml_sitemap_option_name' );
135
  if ( ! empty( $seopress_toggle['toggle-xml-sitemap'] ) && !empty( $seopress_xml_sitemap['seopress_xml_sitemap_general_enable'] ) ) {
136
+ add_action(
137
+ 'admin_notices',
138
+ function() { include XMLSF_DIR . '/views/admin/notice-seopress-sitemap.php'; }
139
+ );
140
  }
141
  }
142
  }
143
 
144
+ // Rank Math conflict notices
145
  if ( is_plugin_active('seo-by-rank-math/rank-math.php') ) {
146
 
147
  // check date archive redirection
148
+ $rankmath_titles = get_option( 'rank-math-options-titles' );
149
+ if ( ! empty( $rankmath_titles['disable_date_archives'] ) && $rankmath_titles['disable_date_archives'] == 'on' ) {
150
+ // check if Split by option is set anywhere
151
+ foreach ( (array) get_option( 'xmlsf_post_types', array() ) as $type => $settings ) {
152
+ if ( !empty( $settings['active'] ) && !empty( $settings['archive'] ) ) {
153
+ add_action(
154
+ 'admin_notices',
155
+ function() { include XMLSF_DIR . '/views/admin/notice-rankmath-date-redirect.php'; }
156
+ );
157
+ break;
158
  }
159
  }
160
+ }
161
 
162
  // check rank math sitemap option
163
  if ( !in_array( 'rankmath_sitemap', parent::$dismissed ) ) {
164
  $rankmath_modules = (array) get_option( 'rank_math_modules' );
165
  if ( in_array( 'sitemap', $rankmath_modules ) ) {
166
+ add_action(
167
+ 'admin_notices',
168
+ function() { include XMLSF_DIR . '/views/admin/notice-rankmath-sitemap.php'; }
169
+ );
170
+ }
171
+ }
172
+ }
173
+
174
+ // All in One SEO Pack conflict notices
175
+ if ( is_plugin_active('all-in-one-seo-pack/all_in_one_seo_pack.php') ) {
176
+ // check aioseop sitemap module
177
+ if ( !in_array( 'aioseop_sitemap', parent::$dismissed ) ) {
178
+ $aioseop_options = (array) get_option( 'aioseop_options' );
179
+
180
+ if ( isset( $aioseop_options['modules']['aiosp_feature_manager_options']['aiosp_feature_manager_enable_sitemap'] ) && "on" === $aioseop_options['modules']['aiosp_feature_manager_options']['aiosp_feature_manager_enable_sitemap'] ) {
181
+ // sitemap module on
182
+ add_action(
183
+ 'admin_notices',
184
+ function() { include XMLSF_DIR . '/views/admin/notice-aioseop-sitemap.php'; }
185
+ );
186
+ }
187
+ }
188
+ }
189
+
190
+ // SEO Framework conflict notices
191
+ //autodescription-site-settings[sitemaps_output]
192
+ //
193
+ if ( is_plugin_active('autodescription/autodescription.php') ) {
194
+ // check sfw sitemap module
195
+ if ( !in_array( 'seoframework_sitemap', parent::$dismissed ) ) {
196
+ $sfw_options = (array) get_option( 'autodescription-site-settings' );
197
+
198
+ if ( ! empty( $sfw_options['sitemaps_output'] ) ) {
199
+ // sitemap module on
200
+ add_action(
201
+ 'admin_notices',
202
+ function() { include XMLSF_DIR . '/views/admin/notice-seoframework-sitemap.php'; }
203
+ );
204
  }
205
  }
206
  }
241
  $priority = get_post_meta( $post->ID, '_xmlsf_priority', true );
242
  $disabled = false;
243
 
244
+ // value prechecks to prevent "invalid form control not focusable" when meta box is hidden
245
+ $priority = is_numeric($priority) ? xmlsf_sanitize_priority( $priority ): '';
 
 
 
 
246
 
247
  // disable options and (visibly) set excluded to true for private posts
248
  if ( 'private' == $post->post_status ) {
271
  public function save_metadata( $post_id )
272
  {
273
  if (
274
+ // verify nonce
275
+ ! isset($_POST['_xmlsf_nonce']) || ! wp_verify_nonce($_POST['_xmlsf_nonce'], XMLSF_BASENAME) ||
276
+ // user not allowed
277
+ ! current_user_can( 'edit_post', $post_id )
278
+ ) return;
279
 
280
  // _xmlsf_priority
281
  if ( empty($_POST['xmlsf_priority']) || ! is_numeric($_POST['xmlsf_priority']) )
282
  delete_post_meta($post_id, '_xmlsf_priority');
283
  else
284
+ update_post_meta($post_id, '_xmlsf_priority', xmlsf_sanitize_priority( $_POST['xmlsf_priority'] ) );
285
 
286
  // _xmlsf_exclude
287
  if ( empty($_POST['xmlsf_exclude']) )
291
  }
292
 
293
  /**
294
+ * Gets public taxonomies
295
+ */
296
+ public function public_taxonomies()
297
  {
298
  if ( !isset( $this->public_taxonomies ) ) {
299
  $this->public_taxonomies = xmlsf_public_taxonomies();
303
  }
304
 
305
  /**
306
+ * Add options page
307
+ */
308
+ public function add_settings_page()
309
  {
310
+ // This page will be under "Settings"
311
+ $this->screen_id = add_options_page(
312
+ __('XML Sitemap','xml-sitemap-feed'),
313
+ __('XML Sitemap','xml-sitemap-feed'),
314
+ 'manage_options',
315
+ 'xmlsf',
316
+ array( $this, 'settings_page' )
317
+ );
318
+ }
319
+
320
+ /**
321
+ * Options page callback
322
+ */
323
+ public function settings_page()
324
+ {
325
+ /**
326
+ * SECTIONS & SETTINGS
327
+ */
328
+
329
+ /** POST TYPES */
330
  add_settings_section( 'xml_sitemap_post_types_section', /*'<a name="xmlsf"></a>'.__('XML Sitemap','xml-sitemap-feed')*/ '', '', 'xmlsf_post_types' );
331
  $post_types = apply_filters( 'xmlsf_post_types', get_post_types( array( 'public' => true ) /*,'objects'*/) );
332
 
340
  }
341
  endif;
342
 
343
+ /** TAXONOMIES */
344
  add_settings_section( 'xml_sitemap_taxonomies_section', /*'<a name="xmlsf"></a>'.__('XML Sitemap','xml-sitemap-feed')*/ '', '', 'xmlsf_taxonomies' );
345
  add_settings_field( 'xmlsf_taxonomy_settings', translate('General'), array($this,'taxonomy_settings_field'), 'xmlsf_taxonomies', 'xml_sitemap_taxonomies_section' );
346
+ add_settings_field( 'xmlsf_taxonomies', __('Taxonomies','xml-sitemap-feed'), array($this,'taxonomies_field'), 'xmlsf_taxonomies', 'xml_sitemap_taxonomies_section' );
347
 
348
+ /** AUTHORS */
349
+ add_settings_section( 'xml_sitemap_authors_section', /*'<a name="xmlsf"></a>'.__('XML Sitemap','xml-sitemap-feed')*/ '', '', 'xmlsf_authors' );
350
+ add_settings_field( 'xmlsf_author_settings', translate('General'), array($this,'author_settings_field'), 'xmlsf_authors', 'xml_sitemap_authors_section' );
351
+
352
+ /** ADVANCED */
353
  add_settings_section( 'xml_sitemap_advanced_section', /*'<a name="xmlsf"></a>'.__('XML Sitemap','xml-sitemap-feed')*/ '', '', 'xmlsf_advanced' );
354
+ // custom name
355
+ add_settings_field( 'xmlsf_sitemap_name', '<label for="xmlsf_sitemap_name">' . __('XML Sitemap URL','xml-sitemap-feed') . '</label>', array($this,'xmlsf_sitemap_name_field'), 'xmlsf_advanced', 'xml_sitemap_advanced_section' );
356
  // custom urls
357
  add_settings_field( 'xmlsf_urls', __('External web pages','xml-sitemap-feed'), array($this,'urls_settings_field'), 'xmlsf_advanced', 'xml_sitemap_advanced_section' );
358
  // custom sitemaps
360
 
361
  $active_tab = isset( $_GET[ 'tab' ] ) ? $_GET[ 'tab' ] : 'post_types';
362
 
363
+ do_action( 'xmlsf_add_settings', $active_tab );
364
+
365
+ // prepare sitemap link url
366
  $sitemaps = (array) get_option( 'xmlsf_sitemaps', array() );
367
+
368
+ $sitemap = xmlsf()->plain_permalinks() ? '?feed=sitemap' : $sitemaps['sitemap'];
369
+
370
+ // remove WPML home url filter
371
+ global $wpml_url_filters;
372
+ if ( is_object($wpml_url_filters) )
373
+ remove_filter( 'home_url', array( $wpml_url_filters, 'home_url_filter' ), - 10 );
374
 
375
  include XMLSF_DIR . '/views/admin/page-sitemap.php';
376
+ }
377
 
378
+ /**
379
+ * Register and add settings
380
+ */
381
+ public function register_settings()
382
+ {
383
  // Help tab
384
  add_action( 'load-'.$this->screen_id, array($this,'help_tab') );
385
 
388
  // taxonomies
389
  register_setting( 'xmlsf_taxonomies', 'xmlsf_taxonomy_settings', array('XMLSF_Admin_Sitemap_Sanitize','taxonomy_settings') );
390
  register_setting( 'xmlsf_taxonomies', 'xmlsf_taxonomies', array('XMLSF_Admin_Sitemap_Sanitize','taxonomies') );
391
+ // authors
392
+ register_setting( 'xmlsf_authors', 'xmlsf_author_settings', array('XMLSF_Admin_Sitemap_Sanitize','author_settings') );
393
  // custom urls
394
  register_setting( 'xmlsf_advanced', 'xmlsf_urls', array('XMLSF_Admin_Sitemap_Sanitize','custom_urls_settings') );
395
  // custom sitemaps
396
  register_setting( 'xmlsf_advanced', 'xmlsf_custom_sitemaps', array('XMLSF_Admin_Sitemap_Sanitize','custom_sitemaps_settings') );
397
+ }
398
 
399
  /**
400
  * XML SITEMAP SECTION
410
  $content = ob_get_clean();
411
 
412
  $screen->add_help_tab( array(
413
+ 'id' => 'sitemap-settings',
414
  'title' => __( 'XML Sitemap', 'xml-sitemap-feed' ),
415
  'content' => $content
416
  ) );
420
  $content = ob_get_clean();
421
 
422
  $screen->add_help_tab( array(
423
+ 'id' => 'sitemap-settings-post-types',
424
  'title' => __( 'Post types', 'xml-sitemap-feed' ),
425
  'content' => $content
426
  ) );
430
  $content = ob_get_clean();
431
 
432
  $screen->add_help_tab( array(
433
+ 'id' => 'sitemap-settings-taxonomies',
434
  'title' => __( 'Taxonomies', 'xml-sitemap-feed' ),
435
  'content' => $content,
436
  ) );
437
 
438
+ ob_start();
439
+ include XMLSF_DIR . '/views/admin/help-tab-authors.php';
440
+ $content = ob_get_clean();
441
+
442
+ $screen->add_help_tab( array(
443
+ 'id' => 'sitemap-settings-authors',
444
+ 'title' => __( 'Authors', 'xml-sitemap-feed' ),
445
+ 'content' => $content,
446
+ ) );
447
+
448
  ob_start();
449
  include XMLSF_DIR . '/views/admin/help-tab-advanced.php';
450
  $content = ob_get_clean();
451
 
452
  $screen->add_help_tab( array(
453
+ 'id' => 'sitemap-settings-advanced',
454
  'title' => translate( 'Advanced' ),
455
  'content' => $content
456
  ) );
491
  include XMLSF_DIR . '/views/admin/field-sitemap-taxonomies.php';
492
  }
493
 
494
+ public function author_settings_field()
495
+ {
496
+ $author_settings = get_option( 'xmlsf_author_settings' );
497
+
498
+ // The actual fields for data entry
499
+ include XMLSF_DIR . '/views/admin/field-sitemap-author-settings.php';
500
+ }
501
+
502
+ public function authors_field()
503
+ {
504
+ include XMLSF_DIR . '/views/admin/field-sitemap-authors.php';
505
+ }
506
+
507
+ // Advanced tab fields
508
+ public function xmlsf_sitemap_name_field()
509
+ {
510
+ $sitemaps = (array) get_option( 'xmlsf_sitemaps' );
511
+ $default = apply_filters( 'xmlsf_sitemap_filename', 'sitemap.xml' );
512
+
513
+ $name = !empty( $sitemaps['sitemap'] ) && $sitemaps['sitemap'] != $default ? $sitemaps['sitemap'] : '';
514
+
515
+ // The actual fields for data entry
516
+ include XMLSF_DIR . '/views/admin/field-sitemap-name.php';
517
+ }
518
+
519
  public function custom_sitemaps_settings_field()
520
  {
521
  $custom_sitemaps = get_option( 'xmlsf_custom_sitemaps' );
526
  }
527
 
528
  public function urls_settings_field()
529
+ {
530
  $urls = get_option( 'xmlsf_urls' );
531
  $lines = array();
532
 
541
  include XMLSF_DIR . '/views/admin/field-sitemap-urls.php';
542
  }
543
 
544
+ public function advanced_archive_field_options()
545
+ {
546
+ ?>
547
+ <option value=""<?php echo disabled( true ); ?>>
548
+ <?php echo __('Week','xml-sitemap-feed'); ?>
549
+ </option>
550
+ <?php
551
+ }
552
  }
553
 
554
  new XMLSF_Admin_Sitemap();
controllers/class.xmlsf-admin.php CHANGED
@@ -24,13 +24,17 @@ class XMLSF_Admin
24
  public static $dismissed = 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
 
@@ -48,11 +52,12 @@ class XMLSF_Admin
48
  add_filter( 'plugin_action_links_' . XMLSF_BASENAME, 'xmlsf_add_action_link' );
49
  add_filter( 'plugin_row_meta', 'xmlsf_plugin_meta_links', 10, 2);
50
 
51
- add_action( 'admin_init', array( $this, 'notices_actions' ) );
52
- add_action( 'admin_init', array( $this, 'transients_actions' ) );
53
  add_action( 'admin_init', array( $this, 'register_settings' ), 0 );
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_conflicts' ), 11 );
@@ -96,7 +101,9 @@ class XMLSF_Admin
96
  }
97
  }
98
 
99
- /* SITEMAPS */
 
 
100
 
101
  public function xml_sitemaps_help()
102
  {
@@ -168,7 +175,9 @@ class XMLSF_Admin
168
  include XMLSF_DIR . '/views/admin/field-sitemap-domains.php';
169
  }
170
 
171
- /* ROBOTS */
 
 
172
 
173
  public function robots_settings_field()
174
  {
@@ -176,7 +185,9 @@ class XMLSF_Admin
176
  include XMLSF_DIR . '/views/admin/field-robots.php';
177
  }
178
 
179
- /* PING SETTINGS */
 
 
180
 
181
  public function ping_settings_help()
182
  {
@@ -224,7 +235,6 @@ class XMLSF_Admin
224
  /**
225
  * Delete static sitemap files
226
  */
227
-
228
  public function delete_static_files()
229
  {
230
  if ( empty($_POST['xmlsf-delete']) ) {
@@ -234,7 +244,10 @@ class XMLSF_Admin
234
 
235
  $allowed_files = array('sitemap.xml','sitemap-news.xml','robots.txt');
236
 
237
- $this->static_files();
 
 
 
238
 
239
  foreach ( $_POST['xmlsf-delete'] as $name ) {
240
  if ( !in_array($name,$allowed_files) ) {
@@ -270,7 +283,10 @@ class XMLSF_Admin
270
  self::$static_files = get_transient( 'xmlsf_static_files' );
271
 
272
  if ( !empty(self::$static_files) && !in_array( 'static_files', self::$dismissed ) ) {
273
- add_action( 'admin_notices', array( 'XMLSF_Admin_Notices', 'notice_static_files' ) );
 
 
 
274
  }
275
  }
276
 
@@ -305,22 +321,44 @@ class XMLSF_Admin
305
 
306
  public function check_conflicts()
307
  {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
308
  // Catch Box Pro feed redirect
309
  if ( /*!in_array( 'catchbox_feed_redirect', self::$dismissed ) &&*/ function_exists( 'catchbox_is_feed_url_present' ) && catchbox_is_feed_url_present(null) ) {
310
- add_action( 'admin_notices', array( 'XMLSF_Admin_Notices', 'notice_catchbox_feed_redirect' ) );
 
 
 
311
  }
312
 
313
  // Ad Inserter XML setting incompatibility warning
314
- if ( /*!in_array( 'ad_inserter_feed', parent::$dismissed ) &&*/ is_plugin_active('ad-inserter/ad-inserter.php') ) {
315
- $adsettings = get_option( 'ad_inserter' );
316
  if ( is_array($adsettings) && !empty($adsettings) ) {
317
- foreach ( $adsettings as $ad => $settings ) {
318
  // check rss feed setting
319
- if ( !empty( $settings['code'] ) && empty( $settings['disable_insertion'] ) && !empty( $settings['enable_feed'] ) ) {
320
- add_action( 'admin_notices', array( 'XMLSF_Admin_Notices', 'notice_ad_inserter_feed' ) );
321
- break;
322
- }
323
- }
 
 
 
324
  }
325
  }
326
  }
@@ -333,12 +371,6 @@ class XMLSF_Admin
333
  }
334
  }
335
 
336
- if ( isset( $_POST['xmlsf-delete-submit'] ) ) {
337
- if ( xmlsf_verify_nonce('help') ) {
338
- $this->delete_static_files();
339
- }
340
- }
341
-
342
  if ( isset( $_POST['xmlsf-check-conflicts'] ) ) {
343
  if ( xmlsf_verify_nonce('help') ) {
344
  // reset ignored warnings
@@ -374,11 +406,11 @@ class XMLSF_Admin
374
  // remove metadata
375
  global $wpdb;
376
  // images meta
377
- $wpdb->delete( $wpdb->prefix.'postmeta', array( 'meta_key' => '_xmlsf_image_attached' ) );
378
- $wpdb->delete( $wpdb->prefix.'postmeta', array( 'meta_key' => '_xmlsf_image_featured' ) );
379
  update_option( 'xmlsf_images_meta_primed', array() );
380
  // comments meta
381
- $wpdb->delete( $wpdb->prefix.'postmeta', array( 'meta_key' => '_xmlsf_comment_date' ) );
382
  update_option( 'xmlsf_comments_meta_primed', array() );
383
 
384
  add_settings_error( 'clear_meta_notice', 'clear_meta_notice', __('Sitemap post meta caches have been cleared.','xml-sitemap-feed'), 'updated' );
@@ -391,6 +423,12 @@ class XMLSF_Admin
391
  {
392
  self::$dismissed = (array) get_user_meta( get_current_user_id(), 'xmlsf_dismissed' );
393
 
 
 
 
 
 
 
394
  if ( isset( $_POST['xmlsf-dismiss-submit'] ) && isset( $_POST['xmlsf-dismiss'] ) ) {
395
  if ( xmlsf_verify_nonce('notice') ) {
396
  add_user_meta( get_current_user_id(), 'xmlsf_dismissed', $_POST['xmlsf-dismiss'], false );
@@ -409,5 +447,3 @@ class XMLSF_Admin
409
  }
410
 
411
  }
412
-
413
- new XMLSF_Admin();
24
  public static $dismissed = array();
25
 
26
  /**
27
+ * Minimal compatible pro version
28
+ * @var float
29
  */
30
+ public static $compat_pro_min = '1.2';
31
 
32
+ /**
33
+ * CONSTRUCTOR
34
+ */
35
  function __construct()
36
  {
37
  require XMLSF_DIR . '/models/functions.admin.php';
 
38
 
39
  $this->sitemaps = (array) get_option( 'xmlsf_sitemaps', array() );
40
 
52
  add_filter( 'plugin_action_links_' . XMLSF_BASENAME, 'xmlsf_add_action_link' );
53
  add_filter( 'plugin_row_meta', 'xmlsf_plugin_meta_links', 10, 2);
54
 
55
+ // REGISTER SETTINGS
 
56
  add_action( 'admin_init', array( $this, 'register_settings' ), 0 );
57
 
58
  // ACTIONS & CHECKS
59
+ add_action( 'admin_init', array( $this, 'notices_actions' ) );
60
+ add_action( 'admin_init', array( $this, 'transients_actions' ) );
61
  add_action( 'admin_init', array( $this, 'tools_actions' ) );
62
  add_action( 'admin_init', array( $this, 'static_files' ) );
63
  add_action( 'admin_init', array( $this, 'check_conflicts' ), 11 );
101
  }
102
  }
103
 
104
+ /**
105
+ * SITEMAPS
106
+ */
107
 
108
  public function xml_sitemaps_help()
109
  {
175
  include XMLSF_DIR . '/views/admin/field-sitemap-domains.php';
176
  }
177
 
178
+ /**
179
+ * ROBOTS
180
+ */
181
 
182
  public function robots_settings_field()
183
  {
185
  include XMLSF_DIR . '/views/admin/field-robots.php';
186
  }
187
 
188
+ /**
189
+ * PING SETTINGS
190
+ */
191
 
192
  public function ping_settings_help()
193
  {
235
  /**
236
  * Delete static sitemap files
237
  */
 
238
  public function delete_static_files()
239
  {
240
  if ( empty($_POST['xmlsf-delete']) ) {
244
 
245
  $allowed_files = array('sitemap.xml','sitemap-news.xml','robots.txt');
246
 
247
+ if ( null === self::$static_files ) {
248
+ self::$static_files = get_transient( 'xmlsf_static_files' );
249
+ delete_transient( 'xmlsf_static_files' );
250
+ }
251
 
252
  foreach ( $_POST['xmlsf-delete'] as $name ) {
253
  if ( !in_array($name,$allowed_files) ) {
283
  self::$static_files = get_transient( 'xmlsf_static_files' );
284
 
285
  if ( !empty(self::$static_files) && !in_array( 'static_files', self::$dismissed ) ) {
286
+ add_action(
287
+ 'admin_notices',
288
+ function() { include XMLSF_DIR . '/views/admin/notice-static-files.php'; }
289
+ );
290
  }
291
  }
292
 
321
 
322
  public function check_conflicts()
323
  {
324
+ // Google News Advanced incompatibility notice
325
+ if ( is_plugin_active('xml-sitemap-feed-advanced-news/xml-sitemap-advanced-news.php') ) {
326
+ // check version
327
+ if ( !in_array( 'xmlsf_advanced_news', self::$dismissed ) ) {
328
+ if (
329
+ ! defined( 'XMLSF_NEWS_ADV_VERSION' ) ||
330
+ version_compare( XMLSF_NEWS_ADV_VERSION, self::$compat_pro_min, '<' )
331
+ ) {
332
+ add_action(
333
+ 'admin_notices',
334
+ function() { include XMLSF_DIR . '/views/admin/notice-xmlsf-advanced-news.php'; }
335
+ );
336
+ }
337
+ }
338
+ }
339
+
340
  // Catch Box Pro feed redirect
341
  if ( /*!in_array( 'catchbox_feed_redirect', self::$dismissed ) &&*/ function_exists( 'catchbox_is_feed_url_present' ) && catchbox_is_feed_url_present(null) ) {
342
+ add_action(
343
+ 'admin_notices',
344
+ function() { include XMLSF_DIR . '/views/admin/notice-catchbox-feed-redirect.php'; }
345
+ );
346
  }
347
 
348
  // Ad Inserter XML setting incompatibility warning
349
+ if ( /*!in_array( 'ad_inserter_feed', parent::$dismissed ) &&*/ is_plugin_active('ad-inserter/ad-inserter.php') ) {
350
+ $adsettings = get_option( 'ad_inserter' );
351
  if ( is_array($adsettings) && !empty($adsettings) ) {
352
+ foreach ( $adsettings as $ad => $settings ) {
353
  // check rss feed setting
354
+ if ( !empty( $settings['code'] ) && empty( $settings['disable_insertion'] ) && !empty( $settings['enable_feed'] ) ) {
355
+ add_action(
356
+ 'admin_notices',
357
+ function() { include XMLSF_DIR . '/views/admin/notice-ad-insterter-feed.php'; }
358
+ );
359
+ break;
360
+ }
361
+ }
362
  }
363
  }
364
  }
371
  }
372
  }
373
 
 
 
 
 
 
 
374
  if ( isset( $_POST['xmlsf-check-conflicts'] ) ) {
375
  if ( xmlsf_verify_nonce('help') ) {
376
  // reset ignored warnings
406
  // remove metadata
407
  global $wpdb;
408
  // images meta
409
+ $wpdb->delete( $wpdb->prefix.'postmeta', array( 'meta_key' => '_xmlsf_image_attached' ) );
410
+ $wpdb->delete( $wpdb->prefix.'postmeta', array( 'meta_key' => '_xmlsf_image_featured' ) );
411
  update_option( 'xmlsf_images_meta_primed', array() );
412
  // comments meta
413
+ $wpdb->delete( $wpdb->prefix.'postmeta', array( 'meta_key' => '_xmlsf_comment_date_gmt' ) );
414
  update_option( 'xmlsf_comments_meta_primed', array() );
415
 
416
  add_settings_error( 'clear_meta_notice', 'clear_meta_notice', __('Sitemap post meta caches have been cleared.','xml-sitemap-feed'), 'updated' );
423
  {
424
  self::$dismissed = (array) get_user_meta( get_current_user_id(), 'xmlsf_dismissed' );
425
 
426
+ if ( isset( $_POST['xmlsf-delete-submit'] ) ) {
427
+ if ( xmlsf_verify_nonce('notice') ) {
428
+ $this->delete_static_files();
429
+ }
430
+ }
431
+
432
  if ( isset( $_POST['xmlsf-dismiss-submit'] ) && isset( $_POST['xmlsf-dismiss'] ) ) {
433
  if ( xmlsf_verify_nonce('notice') ) {
434
  add_user_meta( get_current_user_id(), 'xmlsf_dismissed', $_POST['xmlsf-dismiss'], false );
447
  }
448
 
449
  }
 
 
controllers/class.xmlsf-sitemap-news.php CHANGED
@@ -17,6 +17,15 @@ class XMLSF_Sitemap_News
17
  */
18
  private $post_types;
19
 
 
 
 
 
 
 
 
 
 
20
  /**
21
  * CONSTRUCTOR
22
  * Runs on init
@@ -24,15 +33,31 @@ class XMLSF_Sitemap_News
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
  *
@@ -45,11 +70,6 @@ class XMLSF_Sitemap_News
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
 
@@ -58,7 +78,7 @@ class XMLSF_Sitemap_News
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 ( get_post_meta( $post->ID, '_xmlsf_news_exclude' ) ) return;
63
  }
64
 
@@ -79,10 +99,3 @@ class XMLSF_Sitemap_News
79
  }
80
 
81
  }
82
-
83
- /**
84
- * set up the news sitemap template
85
- */
86
- function xmlsf_news_load_template() {
87
- load_template( XMLSF_DIR . '/views/feed-sitemap-news.php' );
88
- }
17
  */
18
  private $post_types;
19
 
20
+ /**
21
+ * Rewrite rules
22
+ * @var array
23
+ */
24
+ public $rewrite_rules = array(
25
+ 'regex' => 'sitemap-news\.xml(\.gz)?$',
26
+ 'query' => '?feed=sitemap-news$matches[1]'
27
+ );
28
+
29
  /**
30
  * CONSTRUCTOR
31
  * Runs on init
33
 
34
  function __construct( $sitemap )
35
  {
36
+ if ( $sitemap ) $this->sitemap = $sitemap;
37
 
38
+ // Rewrite rules filter.
39
+ add_filter( 'rewrite_rules_array', array( $this, 'rewrite_rules' ), 99, 1 );
40
 
41
+ // PINGING
42
+ add_action( 'transition_post_status', array( $this, 'do_ping' ), 999, 3 );
43
  }
44
 
45
+ /**
46
+ * Add sitemap rewrite rules
47
+ *
48
+ * Hooked into rewrite_rules_array filter
49
+ *
50
+ * @param array $rewrite_rules
51
+ * @return array $rewrite_rules
52
+ */
53
+ public function rewrite_rules( $rewrite_rules ) {
54
+ global $wp_rewrite;
55
+
56
+ $rewrite_rules = array_merge( array( $this->rewrite_rules['regex'] => $wp_rewrite->index . $this->rewrite_rules['query'] ), $rewrite_rules );
57
+
58
+ return $rewrite_rules;
59
+ }
60
+
61
  /**
62
  * Do pings, hooked to transition post status
63
  *
70
  // bail out when already published or not publishing
71
  if ( $old_status == 'publish' || $new_status != 'publish' ) return;
72
 
 
 
 
 
 
73
  // bail out when Google ping not checked
74
  if ( ! in_array( 'google', (array) get_option( 'xmlsf_ping' ) ) ) return;
75
 
78
  // bail out when exclude field is checked
79
  if ( ! empty( $_POST['_xmlsf_news_exclude'] ) ) return;
80
  } else {
81
+ // fall back on exclude meta data from DB which may be outdated (see bug)
82
  if ( get_post_meta( $post->ID, '_xmlsf_news_exclude' ) ) return;
83
  }
84
 
99
  }
100
 
101
  }
 
 
 
 
 
 
 
controllers/class.xmlsf-sitemap.php CHANGED
@@ -18,6 +18,15 @@ class XMLSF_Sitemap
18
  */
19
  private $post_types = array();
20
 
 
 
 
 
 
 
 
 
 
21
  /**
22
  * CONSTRUCTOR
23
  * Runs on init
@@ -25,43 +34,60 @@ class XMLSF_Sitemap
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
  /**
@@ -82,7 +108,7 @@ class XMLSF_Sitemap
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 ) && ! empty( $_POST['action'] ) && 'editpost' == $_POST['action'] ) {
@@ -112,7 +138,7 @@ class XMLSF_Sitemap
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
@@ -224,12 +250,16 @@ class XMLSF_Sitemap
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
  *
@@ -250,7 +280,7 @@ class XMLSF_Sitemap
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
  /**
@@ -261,12 +291,15 @@ class XMLSF_Sitemap
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' );
@@ -368,47 +401,8 @@ class XMLSF_Sitemap
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
- }
18
  */
19
  private $post_types = array();
20
 
21
+ /**
22
+ * Rewrite rules
23
+ * @var array
24
+ */
25
+ public $rewrite_rules = array(
26
+ 'regex' => 'sitemap(?:_index)?(-[a-z0-9\-_]+)?(?:\.([0-9]{4,8}))?(?:\.([0-9]{1,2}))?\.xml(\.gz)?$',
27
+ 'query' => '?feed=sitemap$matches[1]$matches[4]&m=$matches[2]&w=$matches[3]'
28
+ );
29
+
30
  /**
31
  * CONSTRUCTOR
32
  * Runs on init
34
 
35
  function __construct( $sitemap )
36
  {
37
+ if ( $sitemap ) $this->sitemap = $sitemap;
38
 
39
+ $this->post_types = (array) get_option( 'xmlsf_post_types', array() );
 
40
 
41
+ // Rewrite rules filter.
42
+ add_filter( 'rewrite_rules_array', array( $this, 'rewrite_rules' ), 99, 1 );
43
 
44
+ // Redirect wp-sitemap requests.
45
+ add_action( 'template_redirect', array( $this, 'redirect'), 0 );
46
 
47
+ // Cache clearance.
48
+ add_action( 'clean_post_cache', array( $this, 'clean_post_cache'), 99, 2 );
49
+
50
+ // Update term meta lastmod date.
51
+ add_action( 'transition_post_status', array( $this, 'update_term_modified_meta' ), 10, 3 );
52
+
53
+ // Update images post meta.
54
+ add_action( 'transition_post_status', array( $this, 'update_post_images_meta' ), 10, 3 );
55
+
56
+ // Update last comment date post meta.
57
+ add_action( 'transition_comment_status', array( $this, 'update_post_comment_meta' ), 10, 3 );
58
+ add_action( 'comment_post', array( $this, 'update_post_comment_meta_cp' ), 10, 3 ); // when comment is not held for moderation
59
 
60
  // PINGING
61
+ add_action( 'transition_post_status', array( $this, 'do_pings' ), 10, 3 );
62
+
63
+ }
64
 
65
+ /**
66
+ * Add sitemap rewrite rules
67
+ *
68
+ * Hooked into rewrite_rules_array filter
69
+ *
70
+ * @param array $rewrite_rules
71
+ * @return array $rewrite_rules
72
+ */
73
+ public function rewrite_rules( $rewrite_rules ) {
74
+ global $wp_rewrite;
75
 
76
+ $rewrite_rules = array_merge( array( $this->rewrite_rules['regex'] => $wp_rewrite->index . $this->rewrite_rules['query'] ), $rewrite_rules );
77
 
78
+ return $rewrite_rules;
79
+ }
 
 
 
 
 
80
 
81
+ /**
82
+ * Do WP core sitemap index redirect
83
+ *
84
+ * @uses wp_redirect()
85
+ */
86
+ public function redirect() {
87
+ if ( ! empty( $_SERVER['REQUEST_URI'] ) && substr( $_SERVER['REQUEST_URI'], 0, 15) === '/wp-sitemap.xml' ) {
88
+ wp_redirect( home_url( $this->sitemap ), 301, 'XML Sitemap & Google News for WordPress' );
89
+ exit();
90
+ }
91
  }
92
 
93
  /**
108
  //if ( defined( 'REST_REQUEST' ) && REST_REQUEST ) return;
109
 
110
  // bail out when inactive post type
111
+ if ( ! array_key_exists( $post->post_type, $this->post_types ) ) return;
112
 
113
  // we're saving from post edit screen (f.e. 'inline-save' would be from quick edit)
114
  if ( ! empty( $_POST ) && ! empty( $_POST['action'] ) && 'editpost' == $_POST['action'] ) {
138
  wp_cache_delete( 'xmlsf_get_archives', 'general' );
139
 
140
  // TODO get year / month here to delete specific keys too !!!!
141
+ $m = get_date_from_gmt( $post->post_date_gmt, 'Ym' );
142
  $y = substr( $m, 0, 4 );
143
 
144
  // clear possible last post modified cache keys
250
  || empty( $this->post_types[$post_type]['update_lastmod_on_comments'] ) // comments date irrelevant
251
  ) return;
252
 
253
+ $tz = date_default_timezone_get();
254
+ date_default_timezone_set('UTC');
255
+ update_post_meta( $comment->comment_post_ID, '_xmlsf_comment_date_gmt', date('Y-m-d H:i:s') );
256
+ date_default_timezone_set($tz);
257
+
258
  // update comment meta data
 
259
  }
260
 
261
  /**
262
+ * Update post comment meta, hooked to comment post
263
  *
264
  * @since 5.2
265
  *
280
  ) return;
281
 
282
  // update comment meta data
283
+ update_post_meta( $commentdata['comment_post_ID'], '_xmlsf_comment_date_gmt', $commentdata['comment_date_gmt'] );
284
  }
285
 
286
  /**
291
  */
292
  public function prefetch_posts_meta()
293
  {
 
 
294
  global $wp_query;
295
 
296
  $post_type = $wp_query->get( 'post_type' );
297
 
298
+ if ( empty($post_type) || ! is_string($post_type) ) {
299
+ set_transient( 'xmlsf_prefetch_post_meta_failed', 'Unexpected post type in WP_Query: '.print_r($post_type, true) );
300
+ };
301
+
302
+ // bail if post type not set
303
  if ( ! isset($this->post_types[$post_type]) ) return;
304
 
305
  $y = $wp_query->get( 'year' );
401
  'post_id' => $post->ID,
402
  ) );
403
 
404
+ if ( isset( $comments[0]->comment_date_gmt ) )
405
+ update_post_meta( $post->ID, '_xmlsf_comment_date_gmt', $comments[0]->comment_date_gmt );
406
  }
407
 
408
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
controllers/functions.shared.php CHANGED
@@ -6,10 +6,52 @@
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
  /**
@@ -25,10 +67,25 @@ function xmlsf_generator() {
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
  }
@@ -71,3 +128,60 @@ function xmlsf_debug_ping( $se, $sitemap, $ping_url, $response_code ) {
71
  }
72
  }
73
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6
  */
7
  function xmlsf_wpml_language_switcher() {
8
  global $sitepress, $post;
9
+
10
+ $language = apply_filters( 'wpml_element_language_code', NULL, array( 'element_id' => $post->ID, 'element_type' => $post->post_type ) );
11
+ $sitepress->switch_lang( $language );
12
+ }
13
+ global $sitepress;
14
+ if ( is_object( $sitepress ) ) {
15
+ add_action( 'xmlsf_url', 'xmlsf_wpml_language_switcher' );
16
+ add_action( 'xmlsf_news_url', 'xmlsf_wpml_language_switcher' );
17
+ }
18
+
19
+ /**
20
+ * XML Stylesheet
21
+ */
22
+ function xmlsf_xml_stylesheet( $sitemap = false ) {
23
+
24
+ /**
25
+ * GET STYLESHEET URL
26
+ *
27
+ * DEVELOPERS: a custom stylesheet file in the active (parent or child) theme /assets subdirectory, will be used when found there
28
+ *
29
+ * Must start with 'sitemap', optionally followed by another designator, serparated by a hyphen.
30
+ * It should always end with the xsl extension.
31
+ *
32
+ * Examples:
33
+ * assets/sitemap.xsl
34
+ * assets/sitemap-root.xsl
35
+ * assets/sitemap-posttype.xsl
36
+ * assets/sitemap-taxonomy.xsl
37
+ * assets/sitemap-authors.xsl
38
+ * assets/sitemap-custom.xsl
39
+ * assets/sitemap-news.xsl
40
+ * assets/sitemap-[custom_sitemap_name].xsl
41
+ **/
42
+
43
+ $file = $sitemap ? 'assets/sitemap-'.$sitemap.'.xsl' : 'assets/sitemap.xsl';
44
+
45
+ // find theme stylesheet file
46
+ if ( file_exists( get_stylesheet_directory() . '/' . $file ) ) {
47
+ $url = get_stylesheet_directory_uri() . '/' . $file;
48
+ } elseif ( file_exists( get_template_directory() . '/' . $file ) ) {
49
+ $url = get_template_directory_uri() . '/' . $file;
50
+ } else {
51
+ $url = plugins_url( $file, XMLSF_BASENAME );
52
  }
53
+
54
+ echo '<?xml-stylesheet type="text/xsl" href="' . wp_make_link_relative( $url ) . '?ver=' . XMLSF_VERSION . '"?>' . PHP_EOL;
55
  }
56
 
57
  /**
67
  * Usage info for debugging
68
  */
69
  function xmlsf_usage() {
70
+ if ( defined('WP_DEBUG') && WP_DEBUG ) {
71
+ global $wpdb, $EZSQL_ERROR;
72
  $num = get_num_queries();
73
  $mem = function_exists('memory_get_peak_usage') ? round( memory_get_peak_usage()/1024/1024, 2 ) . 'M' : false;
74
  $limit = ini_get('memory_limit');
75
+ // query errors
76
+ $errors = '';
77
+ if ( is_array($EZSQL_ERROR) && count($EZSQL_ERROR) ) {
78
+ $i = 1;
79
+ foreach ( $EZSQL_ERROR AS $e ) {
80
+ $errors .= PHP_EOL . $i . ': ' . implode(PHP_EOL, $e) . PHP_EOL;
81
+ $i += 1;
82
+ }
83
+ }
84
+ // saved queries
85
+ $saved = '';
86
+ if ( defined('SAVEQUERIES') && SAVEQUERIES ) {
87
+ $saved .= PHP_EOL . print_r($wpdb->queries, true);
88
+ }
89
 
90
  require XMLSF_DIR . '/views/_usage.php';
91
  }
128
  }
129
  }
130
  }
131
+
132
+ /**
133
+ * Load feed template
134
+ *
135
+ * Hooked into do_feed_{sitemap...}. First checks for a child/parent theme template file, then falls back to plugin template
136
+ *
137
+ * @since 5.3
138
+ *
139
+ * @param bool $is_comment_feed unused
140
+ * @param string $feed feed type
141
+ */
142
+ function xmlsf_load_template( $is_comment_feed, $feed ) {
143
+
144
+ /**
145
+ * GET TEMPLATE FILE
146
+ *
147
+ * DEVELOPERS: a custom template file in the active (parent or child) theme directory will be used when found there
148
+ *
149
+ * Must start with 'sitemap', optionally folowed by other designators, serperated by hyphens.
150
+ * It should always end with the php extension.
151
+ *
152
+ * Examples:
153
+ * sitemap.php
154
+ * sitemap-root.php
155
+ * sitemap-posttype.php
156
+ * * sitemap-posttype-post.php
157
+ * * sitemap-posttype-page.php
158
+ * * sitemap-posttype-[custom_post_type].php
159
+ * sitemap-taxonomy.php
160
+ * * sitemap-taxonomy-category.php
161
+ * * sitemap-taxonomy-post_tag.php
162
+ * * sitemap-taxonomy-[custom_taxonomy].php
163
+ * sitemap-authors.php
164
+ * sitemap-custom.php
165
+ * sitemap-news.php
166
+ * sitemap-[custom_sitemap_name].php
167
+ **/
168
+
169
+ $parts = explode( '-' , $feed, 3 );
170
+
171
+ // possible theme template file names
172
+ $templates = array();
173
+ if ( ! empty( $parts[1] ) ) {
174
+ if ( ! empty( $parts[2] ) ) {
175
+ $templates[] = "{$parts[0]}-{$parts[1]}-{$parts[2]}.php";
176
+ }
177
+ $templates[] = "{$parts[0]}-{$parts[1]}.php";
178
+ } else {
179
+ $templates[] = "{$parts[0]}.php";
180
+ }
181
+
182
+ // find theme template file and load that
183
+ locate_template( $templates, true );
184
+
185
+ // still here, then fall back on plugin template file
186
+ load_template( XMLSF_DIR . '/views/feed-' . implode( '-', array_slice( $parts, 0, 2 ) ) . '.php' );
187
+ }
models/class-xmlsitemapfeed.php CHANGED
@@ -76,7 +76,10 @@ class XMLSitemapFeed {
76
  * post format taxonomy is disabled
77
  * @var array
78
  */
79
- private $disabled_taxonomies = array('post_format','product_shipping_class');
 
 
 
80
 
81
  /**
82
  * Maximum number of posts in any taxonomy term
@@ -121,7 +124,7 @@ class XMLSitemapFeed {
121
  * Constructor
122
  * @return void
123
  */
124
- function __construct() {}
125
 
126
  /**
127
  * Default options
@@ -145,7 +148,7 @@ class XMLSitemapFeed {
145
  'active' => '1',
146
  'archive' => 'yearly',
147
  'priority' => '0.7',
148
- 'dynamic_priority' => '1',
149
  'tags' => array(
150
  'image' => 'featured'
151
  /*'video' => ''*/
@@ -165,8 +168,14 @@ class XMLSitemapFeed {
165
  'taxonomy_settings' => array(
166
  'active' => '',
167
  'priority' => '0.3',
168
- 'dynamic_priority' => '1',
169
- 'term_limit' => '5000'
 
 
 
 
 
 
170
  ),
171
  'ping' => array(
172
  'google',
76
  * post format taxonomy is disabled
77
  * @var array
78
  */
79
+ private $disabled_taxonomies = array(
80
+ 'post_format',
81
+ 'product_shipping_class'
82
+ );
83
 
84
  /**
85
  * Maximum number of posts in any taxonomy term
124
  * Constructor
125
  * @return void
126
  */
127
+ function __construct() {}
128
 
129
  /**
130
  * Default options
148
  'active' => '1',
149
  'archive' => 'yearly',
150
  'priority' => '0.7',
151
+ 'dynamic_priority' => '',
152
  'tags' => array(
153
  'image' => 'featured'
154
  /*'video' => ''*/
168
  'taxonomy_settings' => array(
169
  'active' => '',
170
  'priority' => '0.3',
171
+ 'dynamic_priority' => '',
172
+ 'term_limit' => '3000'
173
+ ),
174
+ 'authors' => '',
175
+ 'author_settings' => array(
176
+ 'active' => '1',
177
+ 'priority' => '0.3',
178
+ 'term_limit' => '1000'
179
  ),
180
  'ping' => array(
181
  'google',
models/class.xmlsf-admin-sitemap-news-sanitize.php CHANGED
File without changes
models/class.xmlsf-admin-sitemap-sanitize.php CHANGED
@@ -22,7 +22,7 @@ class XMLSF_Admin_Sitemap_Sanitize
22
  $sanitized = array();
23
 
24
  $sanitized['active'] = !empty($new['active']) ? '1' : '';
25
- $sanitized['priority'] = isset($new['priority']) ? xmlsf_sanitize_priority( str_replace( ',', '.', $new['priority'] ), '0.1', '0.9' ) : '0.3';
26
  $sanitized['dynamic_priority'] = !empty($new['dynamic_priority']) ? '1' : '';
27
  $sanitized['term_limit'] = isset($new['term_limit']) ? intval($new['term_limit']) : 5000;
28
  if ( $sanitized['term_limit'] < 1 || $sanitized['term_limit'] > 50000 ) $sanitized['term_limit'] = 50000;
@@ -39,6 +39,30 @@ class XMLSF_Admin_Sitemap_Sanitize
39
  return $sanitized;
40
  }
41
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
42
  public static function post_types_settings( $new = array() )
43
  {
44
  $sanitized = is_array($new) ? $new : array();
@@ -49,7 +73,7 @@ class XMLSF_Admin_Sitemap_Sanitize
49
 
50
  foreach ( $sanitized as $post_type => $settings ) {
51
  setlocale( LC_NUMERIC, 'C' );
52
- $sanitized[$post_type]['priority'] = isset($settings['priority']) ? xmlsf_sanitize_priority( str_replace( ',', '.', $settings['priority'] ), '0.1', '0.9' ) : '0.5';
53
 
54
  // poll for changes that warrant clearing meta data
55
  if ( isset($old[$post_type]) && is_array($old[$post_type]) ) {
@@ -82,7 +106,7 @@ class XMLSF_Admin_Sitemap_Sanitize
82
 
83
  // clear comments meta caches...
84
  if ( $clear_comments ) {
85
- $wpdb->delete( $wpdb->prefix.'postmeta', array( 'meta_key' => '_xmlsf_comment_date' ) );
86
  update_option( 'xmlsf_comments_meta_primed', array() );
87
  }
88
 
22
  $sanitized = array();
23
 
24
  $sanitized['active'] = !empty($new['active']) ? '1' : '';
25
+ $sanitized['priority'] = isset($new['priority']) ? xmlsf_sanitize_priority( str_replace( ',', '.', $new['priority'] ), .1, .9 ) : '0.3';
26
  $sanitized['dynamic_priority'] = !empty($new['dynamic_priority']) ? '1' : '';
27
  $sanitized['term_limit'] = isset($new['term_limit']) ? intval($new['term_limit']) : 5000;
28
  if ( $sanitized['term_limit'] < 1 || $sanitized['term_limit'] > 50000 ) $sanitized['term_limit'] = 50000;
39
  return $sanitized;
40
  }
41
 
42
+ public static function author_settings( $new )
43
+ {
44
+ setlocale( LC_NUMERIC, 'C' );
45
+
46
+ $sanitized = array();
47
+
48
+ $sanitized['active'] = !empty($new['active']) ? '1' : '';
49
+ $sanitized['priority'] = isset($new['priority']) ? xmlsf_sanitize_priority( str_replace( ',', '.', $new['priority'] ), .1, .9 ) : '0.3';
50
+ $sanitized['dynamic_priority'] = !empty($new['dynamic_priority']) ? '1' : '';
51
+ $sanitized['term_limit'] = isset($new['term_limit']) ? intval($new['term_limit']) : 5000;
52
+ if ( $sanitized['term_limit'] < 1 || $sanitized['term_limit'] > 50000 ) $sanitized['term_limit'] = 50000;
53
+
54
+ // clear user meta cache if deactivating...
55
+ /* if ( empty($sanitized['active']) ) {
56
+ $old = (array) get_option( 'xmlsf_taxonomy_settings', array() );
57
+ if ( ! empty($old['active']) ) {
58
+ global $wpdb;
59
+ $wpdb->delete( $wpdb->prefix.'usermeta', array( 'meta_key' => 'last_published_date_gmt' ) );
60
+ }
61
+ }
62
+ */
63
+ return $sanitized;
64
+ }
65
+
66
  public static function post_types_settings( $new = array() )
67
  {
68
  $sanitized = is_array($new) ? $new : array();
73
 
74
  foreach ( $sanitized as $post_type => $settings ) {
75
  setlocale( LC_NUMERIC, 'C' );
76
+ $sanitized[$post_type]['priority'] = isset($settings['priority']) ? xmlsf_sanitize_priority( str_replace( ',', '.', $settings['priority'] ), .1, .9 ) : '0.5';
77
 
78
  // poll for changes that warrant clearing meta data
79
  if ( isset($old[$post_type]) && is_array($old[$post_type]) ) {
106
 
107
  // clear comments meta caches...
108
  if ( $clear_comments ) {
109
+ $wpdb->delete( $wpdb->prefix.'postmeta', array( 'meta_key' => '_xmlsf_comment_date_gmt' ) );
110
  update_option( 'xmlsf_comments_meta_primed', array() );
111
  }
112
 
models/functions.admin.php CHANGED
@@ -9,24 +9,22 @@ function xmlsf_add_action_link( $links ) {
9
  }
10
 
11
  function xmlsf_plugin_meta_links( $links, $file ) {
12
- $support_link = '<a target="_blank" href="https://wordpress.org/support/plugin/xml-sitemap-feed/">' . __('Support','xml-sitemap-feed') . '</a>';
13
- $rate_link = '<a target="_blank" href="https://wordpress.org/support/plugin/xml-sitemap-feed/reviews/?filter=5#new-post">' . __('Rate ★★★★★','xml-sitemap-feed') . '</a>';
14
-
15
- if ( $file == XMLSF_BASENAME ) {
16
- $links[] = $support_link;
17
- $links[] = $rate_link;
18
- }
19
-
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
  }
@@ -38,7 +36,7 @@ class XMLSF_Admin_Sanitize
38
 
39
  public static function sitemaps_settings( $new )
40
  {
41
- if ( '1' !== get_option('blog_public') ) {
42
  return '';
43
  }
44
 
@@ -76,8 +74,8 @@ class XMLSF_Admin_Sanitize
76
 
77
  // clean up input
78
  if(is_array($new)) {
79
- $new = array_filter($new);
80
- $new = reset($new);
81
  }
82
  $input = $new ? explode( PHP_EOL, strip_tags( $new ) ) : array();
83
 
@@ -115,8 +113,8 @@ class XMLSF_Admin_Sanitize
115
 
116
  // clean up input
117
  if ( is_array( $new ) ) {
118
- $new = array_filter( $new );
119
- $new = reset( $new );
120
  }
121
 
122
  if ( empty($old) && !empty($new) )
9
  }
10
 
11
  function xmlsf_plugin_meta_links( $links, $file ) {
12
+ if ( $file == XMLSF_BASENAME ) {
13
+ $links[] = '<a target="_blank" href="https://wordpress.org/support/plugin/xml-sitemap-feed/">' . __('Support','xml-sitemap-feed') . '</a>';
14
+ $links[] = '<a target="_blank" href="https://wordpress.org/support/plugin/xml-sitemap-feed/reviews/?filter=5#new-post">' . __('Rate ★★★★★','xml-sitemap-feed') . '</a>';
15
+ }
16
+ return $links;
 
 
 
 
17
  }
18
 
19
+ // verification
20
+
21
  function xmlsf_verify_nonce( $context ) {
22
 
23
  if ( isset( $_POST['_xmlsf_'.$context.'_nonce'] ) && wp_verify_nonce( $_POST['_xmlsf_'.$context.'_nonce'], XMLSF_BASENAME.'-'.$context ) )
24
  return true;
25
 
26
  // Still here? Then add security check failed error message and return false.
27
+ add_settings_error( 'security_check_failed', 'security_check_failed', translate('Security check failed.') /* . ' Context: '. $context */ );
28
 
29
  return false;
30
  }
36
 
37
  public static function sitemaps_settings( $new )
38
  {
39
+ if ( '1' !== get_option('blog_public') ) {
40
  return '';
41
  }
42
 
74
 
75
  // clean up input
76
  if(is_array($new)) {
77
+ $new = array_filter($new);
78
+ $new = reset($new);
79
  }
80
  $input = $new ? explode( PHP_EOL, strip_tags( $new ) ) : array();
81
 
113
 
114
  // clean up input
115
  if ( is_array( $new ) ) {
116
+ $new = array_filter( $new );
117
+ $new = reset( $new );
118
  }
119
 
120
  if ( empty($old) && !empty($new) )
models/functions.public-shared.php CHANGED
@@ -9,10 +9,17 @@
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
  /**
@@ -66,3 +73,72 @@ function xmlsf_is_allowed_domain( $url ) {
66
 
67
  return apply_filters( 'xmlsf_allowed_domain', $return, $url );
68
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9
  * @return array
10
  */
11
  function xmlsf_headers( $headers ) {
12
+ // Force status 200.
13
+ $headers['Status'] = '200';
14
+
15
+ // Set noindex.
16
  $headers['X-Robots-Tag'] = 'noindex, follow';
17
+
18
+ // Force content type
19
+ $headers['Content-Type'] = 'application/xml; charset=' . get_bloginfo('charset');
20
+
21
+ // And return, merged with nocache headers
22
+ return array_merge( $headers, wp_get_nocache_headers() );
23
  }
24
 
25
  /**
73
 
74
  return apply_filters( 'xmlsf_allowed_domain', $return, $url );
75
  }
76
+
77
+
78
+ /**
79
+ * Polylang compatibility hooked into xml request filter
80
+ *
81
+ * @param array $request
82
+ *
83
+ * @return array
84
+ */
85
+ function xmlsf_polylang_request( $request ) {
86
+
87
+ if ( function_exists('pll_languages_list') ) {
88
+ $request['lang'] = 'all'; // | 'all' | implode( ',', pll_languages_list() );
89
+ // prevent language redirections
90
+ add_filter( 'pll_check_canonical_url', '__return_false' );
91
+ }
92
+
93
+ return $request;
94
+ }
95
+ add_filter( 'xmlsf_request', 'xmlsf_polylang_request' );
96
+ add_filter( 'xmlsf_news_request', 'xmlsf_polylang_request' );
97
+
98
+ /**
99
+ * WPML compatibility hooked into xml request filter
100
+ *
101
+ * @param array $request
102
+ *
103
+ * @return array
104
+ */
105
+ function xmlsf_wpml_request( $request ) {
106
+ global $sitepress, $wpml_query_filter;
107
+
108
+ if ( is_object($sitepress) ) {
109
+ // remove filters for tax queries
110
+ remove_filter( 'get_terms_args', array($sitepress,'get_terms_args_filter') );
111
+ remove_filter( 'get_term', array($sitepress,'get_term_adjust_id'), 1 );
112
+ remove_filter( 'terms_clauses', array($sitepress,'terms_clauses') );
113
+ // set language to all
114
+ $sitepress->switch_lang('all');
115
+ }
116
+
117
+ if ( $wpml_query_filter ) {
118
+ // remove query filters
119
+ remove_filter( 'posts_join', array( $wpml_query_filter, 'posts_join_filter' ), 10, 2 );
120
+ remove_filter( 'posts_where', array( $wpml_query_filter, 'posts_where_filter' ), 10, 2 );
121
+ }
122
+
123
+ $request['lang'] = ''; // strip off potential lang url parameter
124
+
125
+ return $request;
126
+ }
127
+ add_filter( 'xmlsf_request', 'xmlsf_wpml_request' );
128
+ add_filter( 'xmlsf_news_request', 'xmlsf_wpml_request' );
129
+
130
+ /**
131
+ * BBPress compatibility hooked into xml request filter
132
+ *
133
+ * @param array $request
134
+ *
135
+ * @return array
136
+ */
137
+ function xmlsf_bbpress_request( $request ) {
138
+
139
+ remove_filter( 'bbp_request', 'bbp_request_feed_trap' );
140
+
141
+ return $request;
142
+ }
143
+ add_filter( 'xmlsf_request', 'xmlsf_bbpress_request' );
144
+ add_filter( 'xmlsf_news_request', 'xmlsf_bbpress_request' );
models/functions.public-sitemap-news.php CHANGED
@@ -1,43 +1,56 @@
1
  <?php
2
 
3
  /**
4
- * Filter news WHERE
5
- * only posts from the last 48 hours
6
  *
7
- * @param string $where
8
  *
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
- /**
16
- * Filter news limits
17
- * override default feed limit for GN
18
- * @return string
19
- */
20
- function xmlsf_news_filter_limits( $limits ) {
21
- return 'LIMIT 0, 1000';
22
  }
23
 
24
  /**
25
- * Filter no news limits
26
- * in case there is no news, just take the latest post
 
 
 
27
  * @return string
28
  */
29
- function xmlsf_news_filter_no_news_limits( $limits ) {
30
- return 'LIMIT 0, 1';
31
  }
32
 
33
  /**
34
- * Filter request
35
  *
36
  * @param $request
37
  *
38
  * @return mixed
39
  */
40
- function xmlsf_sitemap_news_parse_request( $request ) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
41
 
42
  // prepare for news and return modified request
43
  $options = get_option( 'xmlsf_news_tags' );
@@ -51,7 +64,7 @@ function xmlsf_sitemap_news_parse_request( $request ) {
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;
@@ -59,10 +72,10 @@ function xmlsf_sitemap_news_parse_request( $request ) {
59
  }
60
 
61
  if ( $live ) {
62
- add_filter( 'post_limits', 'xmlsf_news_filter_limits' );
63
  add_filter( 'posts_where', 'xmlsf_news_filter_where', 10, 1 );
64
  } else {
65
- add_filter( 'post_limits', 'xmlsf_news_filter_no_news_limits' );
66
  }
67
 
68
  // post type
@@ -124,34 +137,42 @@ function xmlsf_news_get_images( $which ) {
124
  */
125
 
126
  /**
127
- * Get language used in News Sitemap
128
  *
 
129
  * @param $post_id
130
  *
131
  * @return string
132
  */
133
- function xmlsf_get_language( $post_id ) {
134
-
135
- $language = xmlsf()->blog_language();
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
  }
 
155
 
156
  /**
157
  * Parse language string
@@ -161,6 +182,7 @@ function xmlsf_get_language( $post_id ) {
161
  * @return string
162
  */
163
  function xmlsf_parse_language_string( $lang ) {
 
164
  $lang = convert_chars( strtolower( strip_tags( $lang ) ) );
165
 
166
  // no underscores
@@ -177,3 +199,4 @@ function xmlsf_parse_language_string( $lang ) {
177
 
178
  return !empty($lang) ? $lang : 'en';
179
  }
 
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_news_nocache_headers( $headers ) {
12
+ // prevent proxy caches serving a cached news sitemap
13
+ $headers['Cache-Control'] .= ', no-store';
14
 
15
+ return $headers;
 
 
 
 
 
 
16
  }
17
 
18
  /**
19
+ * Filter news WHERE
20
+ * only posts from the last 48 hours
21
+ *
22
+ * @param string $where
23
+ *
24
  * @return string
25
  */
26
+ function xmlsf_news_filter_where( $where = '' ) {
27
+ return $where . ' AND post_date_gmt > \'' . gmdate( 'Y-m-d H:i:s', strtotime('-48 hours') ) . '\'';
28
  }
29
 
30
  /**
31
+ * Filter request for news sitemap
32
  *
33
  * @param $request
34
  *
35
  * @return mixed
36
  */
37
+ function xmlsf_sitemap_news_filter_request( $request ) {
38
+
39
+ // REPSONSE HEADERS filtering
40
+ add_filter( 'nocache_headers', 'xmlsf_news_nocache_headers' );
41
+
42
+ /** FILTER HOOK FOR PLUGIN COMPATIBILITIES */
43
+ $request = apply_filters( 'xmlsf_news_request', $request );
44
+ /**
45
+ * Developers: add your actions that should run when a news sitemap request is found with:
46
+ *
47
+ * add_filter( 'xmlsf_news_request', 'your_filter_function' );
48
+ *
49
+ * Filters hooked here already:
50
+ * xmlsf_polylang_request - Polylang compatibility
51
+ * xmlsf_wpml_request - WPML compatibility
52
+ * xmlsf_bbpress_request - bbPress compatibility
53
+ */
54
 
55
  // prepare for news and return modified request
56
  $options = get_option( 'xmlsf_news_tags' );
64
 
65
  // set up query filters
66
  $live = false;
67
+ foreach ( $post_types as $post_type ) {
68
  if ( strtotime( get_lastpostdate( 'gmt', $post_type ) ) > strtotime( gmdate( 'Y-m-d H:i:s', strtotime('-48 hours') ) ) ) {
69
  $live = true;
70
  break;
72
  }
73
 
74
  if ( $live ) {
75
+ add_filter( 'post_limits', function() { return 'LIMIT 0, 1000'; } );
76
  add_filter( 'posts_where', 'xmlsf_news_filter_where', 10, 1 );
77
  } else {
78
+ add_filter( 'post_limits', function() { return 'LIMIT 0, 1'; } );
79
  }
80
 
81
  // post type
137
  */
138
 
139
  /**
140
+ * Post language filter for Polylang
141
  *
142
+ * @param $language
143
  * @param $post_id
144
  *
145
  * @return string
146
  */
147
+ function xmlsf_polylang_post_language_filter( $language, $post_id ) {
148
+
149
+ if ( function_exists('pll_get_post_language') ) {
150
+ $language = pll_get_post_language( $post_id, 'slug' );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
151
  }
152
 
153
+ return $language;
154
+ }
155
+ add_filter( 'xmlsf_news_language', 'xmlsf_polylang_post_language_filter', 10, 2 );
156
+
157
+ /**
158
+ * Post language filter for WPML
159
+ *
160
+ * @param $language
161
+ * @param $post_id
162
+ * @param $post_type
163
+ *
164
+ * @return string
165
+ */
166
+ function xmlsf_wpml_post_language_filter( $language, $post_id, $post_type = 'post' ) {
167
+
168
+ global $sitepress;
169
+
170
+ if ( $sitepress )
171
+ $language = apply_filters( 'wpml_element_language_code', $language, array( 'element_id' => $post_id, 'element_type' => $post_type ) );
172
+
173
+ return $language;
174
  }
175
+ add_filter( 'xmlsf_news_language', 'xmlsf_wpml_post_language_filter', 10, 3 );
176
 
177
  /**
178
  * Parse language string
182
  * @return string
183
  */
184
  function xmlsf_parse_language_string( $lang ) {
185
+
186
  $lang = convert_chars( strtolower( strip_tags( $lang ) ) );
187
 
188
  // no underscores
199
 
200
  return !empty($lang) ? $lang : 'en';
201
  }
202
+ add_filter( 'xmlsf_news_language', 'xmlsf_parse_language_string', 99 );
models/functions.public-sitemap.php CHANGED
@@ -11,13 +11,13 @@ function xmlsf_get_root_data() {
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 ) );
15
  if ( is_array($languages) ) {
16
  foreach ( $languages as $language ) {
17
- $url = pll_home_url( $language['slug'] );
18
  $data[$url] = array(
19
  'priority' => '1.0',
20
- 'lastmod' => mysql2date( DATE_W3C, get_lastpostdate('blog') )
21
  // TODO make lastmod date language specific
22
  );
23
  }
@@ -27,7 +27,7 @@ function xmlsf_get_root_data() {
27
  $url = $sitepress->language_url($term);
28
  $data[$url] = array(
29
  'priority' => '1.0',
30
- 'lastmod' => mysql2date( DATE_W3C, get_lastpostdate('blog') )
31
  // TODO make lastmod date language specific
32
  );
33
  }
@@ -36,12 +36,76 @@ function xmlsf_get_root_data() {
36
  $data = array(
37
  trailingslashit( home_url() ) => array(
38
  'priority' => '1.0',
39
- 'lastmod' => mysql2date( DATE_W3C, get_lastpostdate('blog') )
40
  )
41
  );
42
  }
43
 
44
- return $data;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
45
 
46
  }
47
 
@@ -65,6 +129,18 @@ function xmlsf_do_tags( $type = 'post' ) {
65
 
66
  }
67
 
 
 
 
 
 
 
 
 
 
 
 
 
68
  /**
69
  * Get front pages
70
  * @return array
@@ -154,15 +230,15 @@ function xmlsf_get_post_modified() {
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
@@ -170,7 +246,7 @@ function xmlsf_get_post_modified() {
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;
@@ -178,7 +254,7 @@ function xmlsf_get_post_modified() {
178
 
179
  }
180
 
181
- return ! empty( $lastmod ) ? mysql2date( DATE_W3C, $lastmod ) : false;
182
 
183
  }
184
 
@@ -232,7 +308,7 @@ function xmlsf_get_term_modified( $term ) {
232
 
233
  }
234
 
235
- return ! empty( $lastmod ) ? mysql2date( DATE_W3C, $lastmod ) : false;
236
 
237
  }
238
 
@@ -249,7 +325,7 @@ function xmlsf_get_taxonomy_modified( $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
  }
@@ -258,7 +334,7 @@ function xmlsf_get_taxonomy_modified( $taxonomy ) {
258
  $lastmodified = array_filter( $lastmodified );
259
  $lastmod = end( $lastmodified );
260
 
261
- return mysql2date( DATE_W3C, $lastmod );
262
 
263
  }
264
 
@@ -286,7 +362,7 @@ function xmlsf_get_post_priority() {
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
@@ -304,7 +380,7 @@ function xmlsf_get_post_priority() {
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
 
@@ -337,7 +413,7 @@ function xmlsf_get_term_priority( $term = '' ) {
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
 
@@ -357,15 +433,6 @@ function xmlsf_get_post_images( $which ) {
357
  return (array) apply_filters( 'xmlsf_post_images_'.$which, $images );
358
  }
359
 
360
- /**
361
- * Filter limits
362
- * override default feed limit
363
- * @return string
364
- */
365
- function xmlsf_filter_limits( $limit ) {
366
- return 'LIMIT 0, 50000';
367
- }
368
-
369
  /**
370
  * Terms arguments filter
371
  * Does not check if we are really in a sitemap feed.
@@ -376,9 +443,11 @@ function xmlsf_filter_limits( $limit ) {
376
  */
377
  function xmlsf_set_terms_args( $args ) {
378
  // https://developer.wordpress.org/reference/classes/wp_term_query/__construct/
 
379
  $options = get_option('xmlsf_taxonomy_settings');
380
  $args['number'] = isset($options['term_limit']) ? intval($options['term_limit']) : 5000;
381
  if ( $args['number'] < 1 || $args['number'] > 50000 ) $args['number'] = 50000;
 
382
  $args['order'] = 'DESC';
383
  $args['orderby'] = 'count';
384
  $args['pad_counts'] = true;
@@ -390,19 +459,31 @@ function xmlsf_set_terms_args( $args ) {
390
  }
391
 
392
  /**
393
- * Filter request
394
  *
395
- * @param $request
 
396
  *
397
- * @return mixed
398
  */
399
- function xmlsf_sitemap_parse_request( $request ) {
400
 
401
- $feed = explode( '-' ,$request['feed'], 3 );
 
 
 
 
 
 
 
 
 
 
 
402
 
403
- if ( !isset( $feed[1] ) ) return $request;
404
 
405
- switch( $feed[1] ) {
406
 
407
  case 'posttype':
408
 
@@ -415,21 +496,37 @@ function xmlsf_sitemap_parse_request( $request ) {
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
427
- add_filter( 'post_limits', 'xmlsf_filter_limits' );
428
 
 
429
  $request['post_type'] = $feed[2];
430
  $request['orderby'] = 'modified';
431
  $request['order'] = 'DESC';
432
- $request['is_date'] = false;
 
 
 
 
 
 
 
 
 
433
 
434
  break;
435
 
@@ -440,167 +537,22 @@ function xmlsf_sitemap_parse_request( $request ) {
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) ) {
446
- remove_filter( 'get_terms_args', array($sitepress,'get_terms_args_filter') );
447
- remove_filter( 'get_term', array($sitepress,'get_term_adjust_id'), 1 );
448
- remove_filter( 'terms_clauses', array($sitepress,'terms_clauses') );
449
- $sitepress->switch_lang('all');
450
- }
451
 
 
452
  add_filter( 'get_terms_args', 'xmlsf_set_terms_args' );
453
 
454
- // pass on taxonomy name via request
455
- $request['taxonomy'] = $feed[2];
456
 
457
  break;
458
 
459
  default:
460
- // do nothing
461
- }
462
-
463
- return $request;
464
- }
465
-
466
- /* -------------------------------------
467
- * MISSING WORDPRESS FUNCTIONS
468
- * ------------------------------------- */
469
-
470
- /**
471
- * Retrieve first or last post type date data based on timezone.
472
- * Variation of function _get_last_post_time
473
- *
474
- * @param string $timezone The location to get the time. Can be 'gmt', 'blog', or 'server'.
475
- * @param string $field Field to check. Can be 'date' or 'modified'.
476
- * @param string $post_type Post type to check. Defaults to 'any'.
477
- * @param string $which Which to check. Can be 'first' or 'last'. Defaults to 'last'.
478
- * @param string $m year, month or day period. Can be empty or integer.
479
- * @return string The date.
480
- */
481
- if( !function_exists('_get_post_time') ) {
482
- function _get_post_time( $timezone, $field, $post_type = 'any', $which = 'last', $m = '' ) {
483
-
484
- global $wpdb;
485
-
486
- if ( !in_array( $field, array( 'date', 'modified' ) ) ) {
487
- return false;
488
- }
489
-
490
- $timezone = strtolower( $timezone );
491
-
492
- $m = preg_replace('|[^0-9]|', '', $m);
493
-
494
- $key = "{$which}post{$field}{$m}:$timezone";
495
 
496
- if ( 'any' !== $post_type ) {
497
- $key .= ':' . sanitize_key( $post_type );
498
- }
499
-
500
- $date = wp_cache_get( $key, 'timeinfo' );
501
- if ( false !== $date ) {
502
- return $date;
503
- }
504
 
505
- if ( $post_type === 'any' ) {
506
- $post_types = get_post_types( array( 'public' => true ) );
507
- array_walk( $post_types, array( &$wpdb, 'escape_by_ref' ) );
508
- $post_types = "'" . implode( "', '", $post_types ) . "'";
509
- } elseif ( is_array($post_type) ) {
510
- $types = get_post_types( array( 'public' => true ) );
511
- foreach ( $post_type as $type )
512
- if ( !in_array( $type, $types ) )
513
- return false;
514
- array_walk( $post_type, array( &$wpdb, 'escape_by_ref' ) );
515
- $post_types = "'" . implode( "', '", $post_type ) . "'";
516
- } else {
517
- if ( !in_array( $post_type, get_post_types( array( 'public' => true ) ) ) )
518
- return false;
519
- $post_types = "'" . addslashes($post_type) . "'";
520
- }
521
-
522
- $where = "post_status='publish' AND post_type IN ({$post_types}) AND post_date_gmt";
523
-
524
- // If a period is specified in the querystring, add that to the query
525
- if ( !empty($m) ) {
526
- $where .= " AND YEAR(post_date)=" . substr($m, 0, 4);
527
- if ( strlen($m) > 5 ) {
528
- $where .= " AND MONTH(post_date)=" . substr($m, 4, 2);
529
- if ( strlen($m) > 7 ) {
530
- $where .= " AND DAY(post_date)=" . substr($m, 6, 2);
531
- }
532
- }
533
  }
534
 
535
- $order = ( $which == 'last' ) ? 'DESC' : 'ASC';
536
-
537
- /* CODE SUGGESTION BY Frédéric Demarle
538
- * to make this language aware:
539
- "SELECT post_{$field}_gmt FROM $wpdb->posts" . PLL()->model->post->join_clause()
540
- ."WHERE post_status = 'publish' AND post_type IN ({$post_types})" . PLL()->model->post->where_clause( $lang )
541
- . ORDER BY post_{$field}_gmt DESC LIMIT 1
542
- */
543
- switch ( $timezone ) {
544
- case 'gmt':
545
- $date = $wpdb->get_var("SELECT post_{$field}_gmt FROM $wpdb->posts WHERE $where ORDER BY post_{$field}_gmt $order LIMIT 1");
546
- break;
547
- case 'blog':
548
- $date = $wpdb->get_var("SELECT post_{$field} FROM $wpdb->posts WHERE $where ORDER BY post_{$field}_gmt $order LIMIT 1");
549
- break;
550
- case 'server':
551
- $add_seconds_server = date('Z');
552
- $date = $wpdb->get_var("SELECT DATE_ADD(post_{$field}_gmt, INTERVAL '$add_seconds_server' SECOND) FROM $wpdb->posts WHERE $where ORDER BY post_{$field}_gmt $order LIMIT 1");
553
- break;
554
- }
555
-
556
- if ( $date ) {
557
- wp_cache_set( $key, $date, 'timeinfo' );
558
-
559
- return $date;
560
- }
561
-
562
- return false;
563
-
564
- }
565
- }
566
-
567
- /**
568
- * Retrieve the date that the first post/page was published.
569
- * Variation of function get_lastpostdate, uses _get_post_time
570
- *
571
- * The server timezone is the default and is the difference between GMT and
572
- * server time. The 'blog' value is the date when the last post was posted. The
573
- * 'gmt' is when the last post was posted in GMT formatted date.
574
- *
575
- * @uses apply_filters() Calls 'get_firstpostdate' filter
576
- * @param string $timezone The location to get the time. Can be 'gmt', 'blog', or 'server'.
577
- * @param string $post_type Post type to check.
578
- * @return string The date of the last post.
579
- */
580
- if( !function_exists('get_firstpostdate') ) {
581
- function get_firstpostdate($timezone = 'server', $post_type = 'any') {
582
-
583
- return apply_filters( 'get_firstpostdate', _get_post_time( $timezone, 'date', $post_type, 'first' ), $timezone );
584
-
585
- }
586
- }
587
-
588
- /**
589
- * Retrieve last post/page modified date depending on timezone.
590
- * Variation of function get_lastpostmodified, uses _get_post_time
591
- *
592
- * The server timezone is the default and is the difference between GMT and
593
- * server time. The 'blog' value is the date when the last post was posted. The
594
- * 'gmt' is when the last post was posted in GMT formatted date.
595
- *
596
- * @uses apply_filters() Calls 'get_lastmodified' filter
597
- * @param string $timezone The location to get the time. Can be 'gmt', 'blog', or 'server'.
598
- * @return string The date of the oldest modified post.
599
- */
600
- if( !function_exists('get_lastmodified') ) {
601
- function get_lastmodified( $timezone = 'server', $post_type = 'any', $m = '' ) {
602
-
603
- return apply_filters( 'get_lastmodified', _get_post_time( $timezone, 'modified', $post_type, 'last', $m ), $timezone );
604
-
605
- }
606
- }
11
 
12
  // Polylang and WPML compat
13
  if ( function_exists('pll_the_languages') && function_exists('pll_home_url') ) {
14
+ $languages = pll_languages_list();
15
  if ( is_array($languages) ) {
16
  foreach ( $languages as $language ) {
17
+ $url = pll_home_url( $language );
18
  $data[$url] = array(
19
  'priority' => '1.0',
20
+ 'lastmod' => get_date_from_gmt( get_lastpostdate('GMT'), DATE_W3C )
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' => get_date_from_gmt( get_lastpostdate('GMT'), DATE_W3C )
31
  // TODO make lastmod date language specific
32
  );
33
  }
36
  $data = array(
37
  trailingslashit( home_url() ) => array(
38
  'priority' => '1.0',
39
+ 'lastmod' => get_date_from_gmt( get_lastpostdate('GMT'), DATE_W3C )
40
  )
41
  );
42
  }
43
 
44
+ return apply_filters( 'xmlsf_root_data', $data );
45
+
46
+ }
47
+
48
+ /**
49
+ * Author data
50
+ *
51
+ * @return array
52
+ */
53
+ function xmlsf_get_author_data() {
54
+
55
+ $author_settings = get_option( 'xmlsf_author_settings' );
56
+
57
+ $args = (array) apply_filters(
58
+ 'xmlsf_get_author_args',
59
+ array(
60
+ 'orderby' => 'post_count',
61
+ 'order' => 'DESC',
62
+ 'number' => ! empty( $author_settings['term_limit'] ) && is_numeric( $author_settings['term_limit'] ) ? $author_settings['term_limit'] : '1000',
63
+ 'fields' => array( 'ID' ), // must be an array
64
+ 'has_published_posts' => true, // means all post types
65
+ 'who' => 'authors'
66
+ )
67
+ );
68
+ // make sure 'fields' is an array and includes 'ID'
69
+ $args['fields'] = array_merge( (array) $args['fields'], array( 'ID' ) );
70
+
71
+ $users = get_users( $args );
72
+
73
+ $priority = ! empty( $author_settings['priority'] ) ? $author_settings['priority'] : '';
74
+
75
+ $post_type = ( empty( $args['has_published_posts'] ) || true === $args['has_published_posts'] ) ? 'any' : $args['has_published_posts'];
76
+
77
+ $data = array();
78
+ foreach ( $users as $user ) {
79
+ $url = get_author_posts_url( $user->ID );
80
+
81
+ // allow filtering of users
82
+ if ( apply_filters( 'xmlsf_skip_user', false, $user ) ) continue;
83
+
84
+ // last publication date
85
+ $posts = get_posts(
86
+ array(
87
+ 'author' => $user->ID,
88
+ 'post_type' => $post_type,
89
+ 'post_status' => 'publish',
90
+ 'posts_per_page' => 1,
91
+ 'order' => 'DESC',
92
+ 'orderby ' => 'post_date',
93
+ 'update_post_meta_cache' => false,
94
+ 'update_post_term_cache' => false,
95
+ 'update_cache' => false,
96
+ 'lang' => '', // TODO make multilanguage compatible
97
+ )
98
+ );
99
+
100
+ $lastmod = '';
101
+ if ( $posts ) {
102
+ $lastmod = get_the_date( DATE_W3C, $posts[0] );
103
+ }
104
+
105
+ $data[$url] = array( 'priority' => $priority, 'lastmod' => $lastmod );
106
+ }
107
+
108
+ return apply_filters( 'xmlsf_author_data', $data );
109
 
110
  }
111
 
129
 
130
  }
131
 
132
+ /**
133
+ * Do authors
134
+ *
135
+ * @return bool
136
+ */
137
+ function xmlsf_do_authors() {
138
+
139
+ $settings = get_option( 'xmlsf_author_settings', xmlsf()->defaults('author_settings') );
140
+
141
+ return is_array( $settings ) && ! empty( $settings['active'] );
142
+ }
143
+
144
  /**
145
  * Get front pages
146
  * @return array
230
  // if blog or home page then simply look for last post date
231
  if ( $post->post_type == 'page' && ( in_array( $post->ID, xmlsf_get_blogpages() ) || in_array( $post->ID, xmlsf_get_frontpages() ) ) ) {
232
 
233
+ $lastmod = get_lastpostdate( 'GMT' );
234
 
235
  } else {
236
 
237
+ $lastmod = $post->post_modified_gmt;
238
 
239
  // make sure lastmod is not older than publication date (happens on scheduled posts)
240
+ if ( isset( $post->post_date_gmt ) && strtotime( $post->post_date_gmt ) > strtotime( $lastmod ) ) {
241
+ $lastmod = $post->post_date_gmt;
242
  };
243
 
244
  // maybe update lastmod to latest comment
246
 
247
  if ( !empty($options[$post->post_type]['update_lastmod_on_comments']) ) {
248
  // assuming post meta data has been primed here
249
+ $lastcomment = get_post_meta( $post->ID, '_xmlsf_comment_date_gmt', true ); // only get one
250
 
251
  if ( ! empty( $lastcomment ) && strtotime( $lastcomment ) > strtotime( $lastmod ) )
252
  $lastmod = $lastcomment;
254
 
255
  }
256
 
257
+ return ! empty( $lastmod ) ? get_date_from_gmt( $lastmod, DATE_W3C ) : false;
258
 
259
  }
260
 
308
 
309
  }
310
 
311
+ return ! empty( $lastmod ) ? mysql2date( DATE_W3C, $lastmod, false ) : false;
312
 
313
  }
314
 
325
 
326
  $lastmodified = array();
327
  foreach ( (array)$obj->object_type as $object_type ) {
328
+ $lastmodified[] = get_lastpostdate( 'GMT', $object_type );
329
  // get last post date here, not modified date because we're only
330
  // concerned about new entries on the (first) taxonomy page
331
  }
334
  $lastmodified = array_filter( $lastmodified );
335
  $lastmod = end( $lastmodified );
336
 
337
+ return get_date_from_gmt( $lastmod, DATE_W3C );
338
 
339
  }
340
 
362
 
363
  } elseif ( !empty($options[$post->post_type]['dynamic_priority']) ) {
364
 
365
+ $post_modified = mysql2date('U',$post->post_modified);
366
 
367
  // reduce by age
368
  // NOTE : home/blog page gets same treatment as sticky post, i.e. no reduction by age
380
  $priority = apply_filters( 'xmlsf_post_priority', $priority, $post->ID );
381
 
382
  // a final check for limits and round it
383
+ return xmlsf_sanitize_priority( $priority );
384
 
385
  }
386
 
413
  $priority = apply_filters( 'xmlsf_term_priority', $priority, $term->slug );
414
 
415
  // a final check for limits and round it
416
+ return xmlsf_sanitize_priority( $priority );
417
 
418
  }
419
 
433
  return (array) apply_filters( 'xmlsf_post_images_'.$which, $images );
434
  }
435
 
 
 
 
 
 
 
 
 
 
436
  /**
437
  * Terms arguments filter
438
  * Does not check if we are really in a sitemap feed.
443
  */
444
  function xmlsf_set_terms_args( $args ) {
445
  // https://developer.wordpress.org/reference/classes/wp_term_query/__construct/
446
+
447
  $options = get_option('xmlsf_taxonomy_settings');
448
  $args['number'] = isset($options['term_limit']) ? intval($options['term_limit']) : 5000;
449
  if ( $args['number'] < 1 || $args['number'] > 50000 ) $args['number'] = 50000;
450
+
451
  $args['order'] = 'DESC';
452
  $args['orderby'] = 'count';
453
  $args['pad_counts'] = true;
459
  }
460
 
461
  /**
462
+ * Filter request for sitemaps
463
  *
464
+ * @param array $request
465
+ * @param array $feed
466
  *
467
+ * @return array $request filtered
468
  */
469
+ function xmlsf_sitemap_filter_request( $request ) {
470
 
471
+ /** FILTER HOOK FOR PLUGIN COMPATIBILITIES */
472
+ $request = apply_filters( 'xmlsf_request', $request );
473
+ /**
474
+ * Developers: add your actions that should run when a sitemap request is with:
475
+ *
476
+ * add_filter( 'xmlsf_request', 'your_filter_function' );
477
+ *
478
+ * Filters hooked here already:
479
+ * xmlsf_polylang_request - Polylang compatibility
480
+ * xmlsf_wpml_request - WPML compatibility
481
+ * xmlsf_bbpress_request - bbPress compatibility
482
+ */
483
 
484
+ $feed = explode( '-' , $request['feed'], 3 );
485
 
486
+ switch( isset( $feed[1] ) ? $feed[1] : '' ) {
487
 
488
  case 'posttype':
489
 
496
 
497
  // prepare priority calculation
498
  if ( ! empty($options[$feed[2]]['dynamic_priority']) ) {
499
+
500
+ // last of this post type modified date in Unix seconds
501
+ xmlsf()->lastmodified = get_date_from_gmt( get_lastpostmodified( 'GMT', $feed[2] ), 'U' );
502
+
503
  // calculate time span, uses get_firstpostdate() function defined in xml-sitemap/inc/functions.php !
504
+ xmlsf()->timespan = xmlsf()->lastmodified - get_date_from_gmt( get_firstpostdate( 'GMT', $feed[2]), 'U' );
505
+
506
  // total post type comment count
507
+ xmlsf()->comment_count = wp_count_comments()->approved;
508
+
509
+ // TODO count comments per post type https://wordpress.stackexchange.com/questions/134338/count-all-comments-of-a-custom-post-type
510
+ // TODO cache this more persistently than wp_cache_set does in https://developer.wordpress.org/reference/functions/wp_count_comments/
511
  };
512
 
513
+ // setup filters
514
+ add_filter( 'post_limits', function() { return 'LIMIT 0, 50000'; } );
515
 
516
+ // modify request
517
  $request['post_type'] = $feed[2];
518
  $request['orderby'] = 'modified';
519
  $request['order'] = 'DESC';
520
+
521
+ // prevent term cache update query unless needed for permalinks
522
+ if ( strpos( get_option( 'permalink_structure' ), '%category%' ) === false )
523
+ $request['update_post_term_cache'] = false;
524
+
525
+ // make sure to update meta cache for:
526
+ // 1. excluded posts
527
+ // 2. image data (if activated)
528
+ // 3. lasmod on comments (if activated)
529
+ $request['update_post_meta_cache'] = true;
530
 
531
  break;
532
 
537
  // try to raise memory limit, context added for filters
538
  wp_raise_memory_limit( 'sitemap-taxonomy-'.$feed[2] );
539
 
540
+ // pass on taxonomy name via request
541
+ $request['taxonomy'] = $feed[2];
 
 
 
 
 
 
542
 
543
+ // set terms args
544
  add_filter( 'get_terms_args', 'xmlsf_set_terms_args' );
545
 
546
+ // disable default feed query
547
+ add_filter( 'posts_request', '__return_false' );
548
 
549
  break;
550
 
551
  default:
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
552
 
553
+ add_filter( 'posts_request', '__return_false' );
 
 
 
 
 
 
 
554
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
555
  }
556
 
557
+ return $request;
558
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
models/functions.shared.php CHANGED
@@ -3,71 +3,85 @@
3
  /**
4
  * Filter request
5
  *
6
- * @param $request
7
  *
8
- * @return mixed
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;
25
 
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
40
- $request['lang'] = '';
41
- // WPML compat
42
- global $wpml_query_filter;
43
- if ( is_object($wpml_query_filter) ) {
44
- remove_filter( 'posts_join', array( $wpml_query_filter, 'posts_join_filter' ) );
45
- remove_filter( 'posts_where', array( $wpml_query_filter, 'posts_where_filter' ) );
46
- add_action( 'the_post', 'xmlsf_wpml_language_switcher' );
47
- }
48
- // bbPress
49
- remove_filter( 'bbp_request', 'bbp_request_feed_trap' );
50
 
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
 
68
- endif;
 
69
 
70
- xmlsf()->request_filtered = true;
 
 
 
 
 
 
71
 
72
  return $request;
73
  }
@@ -88,16 +102,18 @@ function xmlsf_untrailingslash( $request ) {
88
  * Ping
89
  *
90
  * @since 5.1
 
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 ) {
98
  $url = 'https://www.google.com/ping';
99
  } elseif ( 'bing' == $se ) {
100
- $url = 'https://www.bing.com/ping';
101
  } else {
102
  return '';
103
  }
@@ -145,7 +161,8 @@ function xmlsf_nginx_helper_purge_urls( $urls = array(), $redis = false ) {
145
 
146
  if ( !empty( $sitemaps['sitemap'] ) ) {
147
  $urls[] = '/sitemap.xml';
148
- $urls[] = '/sitemap-home.xml';
 
149
  $urls[] = '/sitemap-custom.xml';
150
 
151
  // add public post types sitemaps
@@ -153,7 +170,7 @@ function xmlsf_nginx_helper_purge_urls( $urls = array(), $redis = false ) {
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
  }
@@ -163,7 +180,7 @@ function xmlsf_nginx_helper_purge_urls( $urls = array(), $redis = false ) {
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
  }
3
  /**
4
  * Filter request
5
  *
6
+ * @param array $request
7
  *
8
+ * @return array $request filtered
9
  */
10
  function xmlsf_filter_request( $request ) {
11
 
12
+ global $xmlsf;
13
+ $xmlsf->request_filtered = true;
14
 
15
+ // short-circuit if request is not a feed or it does not start with 'sitemap'
16
+ if ( empty( $request['feed'] ) || strpos( $request['feed'], 'sitemap' ) !== 0 ) {
17
+ return $request;
18
+ }
19
 
20
+ /** IT'S A SITEMAP */
 
21
 
22
+ // set the sitemap conditional flag
23
+ xmlsf()->is_sitemap = true;
24
 
25
+ // save a few db queries
26
+ add_filter( 'split_the_query', '__return_false' );
27
 
28
+ // include shared public functions
29
+ require_once XMLSF_DIR . '/models/functions.public-shared.php';
30
 
31
+ /** COMPRESSION */
 
 
 
32
 
33
+ // check for gz request
34
+ if ( substr($request['feed'], -3) == '.gz' ) {
35
+ // pop that .gz
36
+ $request['feed'] = substr($request['feed'], 0, -3);
37
+ // verify/apply compression settings
38
+ xmlsf_output_compression();
39
+ }
40
 
41
+ /** PREPARE TO LOAD TEMPLATE */
 
 
 
 
 
 
 
 
 
 
 
42
 
43
+ add_action (
44
+ 'do_feed_' . $request['feed'],
45
+ 'xmlsf_load_template',
46
+ 10,
47
+ 2
48
+ );
49
 
50
+ /** MODIFY REQUEST PARAMETERS */
 
 
51
 
52
+ $request['post_status'] = 'publish';
53
+ $request['no_found_rows'] = true; // found rows calc is slow and only needed for pagination
54
+
55
+ // SPECIFIC REQUEST FILTERING AND PREPEARTIONS
56
+ if ( strpos( $request['feed'], 'news' ) === 8 ) {
57
+ // set the news sitemap conditional flag
58
+ xmlsf()->is_news = true;
59
+ // include public news functions
60
+ require_once XMLSF_DIR . '/models/functions.public-sitemap-news.php';
61
+ // filter news request
62
+ $request = xmlsf_sitemap_news_filter_request( $request );
63
+ } else {
64
+ // include public sitemap functions
65
+ require_once XMLSF_DIR . '/models/functions.public-sitemap.php';
66
+ // filter sitemap request
67
+ $request = xmlsf_sitemap_filter_request( $request );
68
+ }
69
+
70
+ /** GENERAL MISC. PREPARATIONS */
71
+
72
+ // prevent public errors breaking xml
73
+ @ini_set( 'display_errors', 0 );
74
 
75
+ // make sure we have the proper locale setting for calculations
76
+ setlocale( LC_NUMERIC, 'C' );
77
 
78
+ // REPSONSE HEADERS filtering
79
+ add_filter( 'wp_headers', 'xmlsf_headers' );
80
+
81
+ // Remove filters to prevent stuff like cdn urls for xml stylesheet and images
82
+ remove_all_filters( 'plugins_url' );
83
+ remove_all_filters( 'wp_get_attachment_url' );
84
+ remove_all_filters( 'image_downsize' );
85
 
86
  return $request;
87
  }
102
  * Ping
103
  *
104
  * @since 5.1
105
+ *
106
  * @param $se google|bing
107
  * @param $sitemap sitemap
108
  * @param $interval seconds
109
+ *
110
  * @return string ping response|999 (skipped)
111
  */
112
  function xmlsf_ping( $se, $sitemap, $interval ) {
113
  if ( 'google' == $se ) {
114
  $url = 'https://www.google.com/ping';
115
  } elseif ( 'bing' == $se ) {
116
+ $url = 'https://www.bing.com/webmaster/ping.aspx';
117
  } else {
118
  return '';
119
  }
161
 
162
  if ( !empty( $sitemaps['sitemap'] ) ) {
163
  $urls[] = '/sitemap.xml';
164
+ $urls[] = '/sitemap-root.xml';
165
+ $urls[] = '/sitemap-author.xml';
166
  $urls[] = '/sitemap-custom.xml';
167
 
168
  // add public post types sitemaps
170
  if ( is_array($post_types) ) {
171
  foreach ( $post_types as $post_type => $settings ) {
172
  $archive = !empty($settings['archive']) ? $settings['archive'] : '';
173
+ foreach ( xmlsf_get_index_archive_data( $post_type, $archive ) as $url ) {
174
  $urls[] = parse_url( $url, PHP_URL_PATH);
175
  }
176
  }
180
  $taxonomies = get_option('xmlsf_taxonomies');
181
  if ( is_array($taxonomies) ) {
182
  foreach ( $taxonomies as $taxonomy ) {
183
+ $urls[] = parse_url( xmlsf_get_index_url( 'taxonomy', array( 'type' => $taxonomy ) ), PHP_URL_PATH );
184
  }
185
  }
186
  }
models/functions.sitemap-news.php CHANGED
@@ -10,8 +10,7 @@
10
  function xmlsf_news_filter_post_types( $post_types ) {
11
  $post_types = (array) $post_types;
12
 
13
- unset( $post_types['attachment'] );
14
- unset( $post_types['reply'] );
15
 
16
  return array_filter( $post_types );
17
  }
10
  function xmlsf_news_filter_post_types( $post_types ) {
11
  $post_types = (array) $post_types;
12
 
13
+ unset( $post_types['attachment'], $post_types['reply'] );
 
14
 
15
  return array_filter( $post_types );
16
  }
models/functions.sitemap.php CHANGED
@@ -8,32 +8,45 @@
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 );
@@ -41,43 +54,56 @@ function xmlsf_get_index_url( $sitemap = 'home', $type = false, $param = false )
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), LPAD(MONTH(post_date),2,'0') ORDER BY `year` DESC, `month` 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 `year` 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;
@@ -89,8 +115,7 @@ function xmlsf_get_archives( $post_type = 'post', $type = '' ) {
89
  /**
90
  * Get archives from wp_cache
91
  *
92
- * @param string $post_type
93
- * @param string $type
94
  *
95
  * @return array
96
  */
@@ -122,10 +147,15 @@ function xmlsf_cache_get_archives( $query ) {
122
  * @return array
123
  */
124
  function xmlsf_get_taxonomies() {
 
125
  $taxonomy_settings = get_option('xmlsf_taxonomy_settings');
 
126
  $tax_array = array();
 
127
  if ( !empty( $taxonomy_settings['active'] ) ) {
 
128
  $taxonomies = get_option('xmlsf_taxonomies');
 
129
  if ( is_array($taxonomies) ) {
130
  foreach ( $taxonomies as $taxonomy ) {
131
  $count = wp_count_terms( $taxonomy, array('hide_empty'=>true) );
@@ -137,8 +167,11 @@ function xmlsf_get_taxonomies() {
137
  if ( 0 < wp_count_terms( $name, array('hide_empty'=>true) ) )
138
  $tax_array[] = $name;
139
  }
 
140
  }
 
141
  return $tax_array;
 
142
  }
143
 
144
  /**
@@ -159,8 +192,10 @@ function xmlsf_public_taxonomies() {
159
 
160
  // check each tax public flag and term count and append name to array
161
  foreach ( get_object_taxonomies( $post_type, 'objects' ) as $taxonomy ) {
 
162
  if ( !empty( $taxonomy->public ) && !in_array( $taxonomy->name, xmlsf()->disabled_taxonomies() ) )
163
  $tax_array[$taxonomy->name] = $taxonomy->label;
 
164
  }
165
 
166
  }
@@ -180,7 +215,7 @@ function xmlsf_public_taxonomies() {
180
  * @param float $max
181
  * @return float
182
  */
183
- function xmlsf_sanitize_priority( $priority, $min = 0, $max = 1 ) {
184
 
185
  $priority = (float) $priority;
186
  $min = (float) $min;
@@ -256,27 +291,163 @@ function xmlsf_images_data( $post, $which ) {
256
  return $images_data;
257
  }
258
 
 
 
 
 
259
  /**
260
- * Get instantiated sitemap controller class
 
261
  *
262
- * @since 5.2
263
- * @global XMLSF_Sitemap $xmlsf_sitemap
264
- * @return XMLSF_Sitemap object
 
 
 
 
 
265
  */
266
- function xmlsf_sitemap( $sitemap = null ) {
267
- global $xmlsf_sitemap;
268
-
269
- if ( ! isset( $xmlsf_sitemap ) ) {
270
- if ( ! class_exists( 'XMLSF_Sitemap' ) )
271
- require XMLSF_DIR . '/controllers/class.xmlsf-sitemap.php';
272
-
273
- if ( empty($sitemap) ) {
274
- $sitemaps = get_option( 'xmlsf_sitemaps' );
275
- $sitemap = $sitemaps['sitemap'];
276
- }
277
-
278
- $xmlsf_sitemap = new XMLSF_Sitemap( $sitemap );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
279
  }
280
-
281
- return $xmlsf_sitemap;
282
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8
  * @return array
9
  */
10
  function xmlsf_filter_post_types( $post_types ) {
11
+ $post_types = (array) $post_types;
12
+
13
  // Always exclude attachment and reply post types (bbpress)
14
  unset( $post_types['attachment'], $post_types['reply'] );
15
 
16
+ return array_filter( $post_types );
17
  }
18
 
19
  /**
20
  * Get index url
21
  *
22
  * @param string $sitemap
23
+ * @param array $args arguments:
24
+ * $type - post_type or taxonomy, default false
25
+ * $m - YYYY, YYYYMM, YYYYMMDD
26
+ * $w - week of the year ($m must be YYYY format)
27
+ * $gz - bool for GZ extension (triggers compression verification)
28
  *
29
  * @return string
30
  */
31
+ function xmlsf_get_index_url( $sitemap = 'root', $args = array() ) {
32
+
33
+ // get our arguments
34
+ $args = apply_filters( 'xmlsf_index_url_args', wp_parse_args( $args, array( 'type' => false, 'm' => false, 'w' => false, 'gz' => false) ) );
35
+ extract( $args );
36
 
37
  if ( xmlsf()->plain_permalinks() ) {
38
  $name = '?feed=sitemap-'.$sitemap;
39
+ $name .= $gz ? '.gz' : '';
40
  $name .= $type ? '-'.$type : '';
41
+ $name .= $m ? '&m='.$m : '';
42
+ $name .= $w ? '&w='.$w : '';
43
  } else {
44
  $name = 'sitemap-'.$sitemap;
45
  $name .= $type ? '-'.$type : '';
46
+ $name .= $m ? '.'.$m : '';
47
+ $name .= $w ? '.'.$w : '';
48
  $name .= '.xml';
49
+ $name .= $gz ? '.gz' : '';
50
  }
51
 
52
  return esc_url( trailingslashit( home_url() ) . $name );
54
  }
55
 
56
  /**
57
+ * Get post archives data
58
  *
59
  * @param string $post_type
60
+ * @param string $archive_type
61
  *
62
  * @return array
63
  */
64
+ function xmlsf_get_index_archive_data( $post_type = 'post', $archive_type = '' ) {
65
 
66
  global $wpdb;
 
67
 
68
+ if ( 'weekly' == $archive_type ) :
69
+
70
+ $week = _wp_mysql_week( '`post_date`' );
71
+ $query = "SELECT DISTINCT LPAD($week,2,'0') AS `week`, 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`), LPAD($week,2,'0') ORDER BY `year` DESC, `week` DESC";
72
+ $arcresults = xmlsf_cache_get_archives( $query );
73
+
74
+ foreach ( (array) $arcresults as $arcresult ) {
75
+ $url = xmlsf_get_index_url( 'posttype', array( 'type' => $post_type, 'm' => $arcresult->year, 'w' => $arcresult->week ) );
76
+ $return[$url] = get_date_from_gmt( get_lastmodified( 'GMT', $post_type, $arcresult->year, $arcresult->week ), DATE_W3C );
77
+ };
78
+
79
+ elseif ( 'monthly' == $archive_type ) :
80
 
81
+ $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`), LPAD(MONTH(`post_date`),2,'0') ORDER BY `year` DESC, `month` DESC";
82
  $arcresults = xmlsf_cache_get_archives( $query );
83
 
84
  foreach ( (array) $arcresults as $arcresult ) {
85
+ $url = xmlsf_get_index_url( 'posttype', array( 'type' => $post_type, 'm' => $arcresult->year . $arcresult->month ) );
86
+ $return[$url] = get_date_from_gmt( get_lastmodified( 'GMT', $post_type, $arcresult->year . $arcresult->month ), DATE_W3C );
87
  };
88
 
89
+ elseif ( 'yearly' == $archive_type ) :
90
 
91
+ $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 `year` DESC";
92
  $arcresults = xmlsf_cache_get_archives( $query );
93
 
94
  foreach ( (array) $arcresults as $arcresult ) {
95
+ $url = xmlsf_get_index_url( 'posttype', array( 'type' => $post_type, 'm' => $arcresult->year ) );
96
+ $return[$url] = get_date_from_gmt( get_lastmodified( 'GMT', $post_type, $arcresult->year ), DATE_W3C );
97
  };
98
 
99
  else :
100
 
101
+ $query = "SELECT COUNT(ID) AS `posts` FROM {$wpdb->posts} WHERE `post_type` = '{$post_type}' AND `post_status` = 'publish' ORDER BY `post_date` DESC";
102
  $arcresults = xmlsf_cache_get_archives( $query );
103
 
104
  if ( is_object($arcresults[0]) && $arcresults[0]->posts > 0 ) {
105
+ $url = xmlsf_get_index_url( 'posttype', array( 'type' => $post_type ) );
106
+ $return[$url] = get_date_from_gmt( get_lastmodified( 'GMT', $post_type ), DATE_W3C );
107
  };
108
 
109
  endif;
115
  /**
116
  * Get archives from wp_cache
117
  *
118
+ * @param string $query
 
119
  *
120
  * @return array
121
  */
147
  * @return array
148
  */
149
  function xmlsf_get_taxonomies() {
150
+
151
  $taxonomy_settings = get_option('xmlsf_taxonomy_settings');
152
+
153
  $tax_array = array();
154
+
155
  if ( !empty( $taxonomy_settings['active'] ) ) {
156
+
157
  $taxonomies = get_option('xmlsf_taxonomies');
158
+
159
  if ( is_array($taxonomies) ) {
160
  foreach ( $taxonomies as $taxonomy ) {
161
  $count = wp_count_terms( $taxonomy, array('hide_empty'=>true) );
167
  if ( 0 < wp_count_terms( $name, array('hide_empty'=>true) ) )
168
  $tax_array[] = $name;
169
  }
170
+
171
  }
172
+
173
  return $tax_array;
174
+
175
  }
176
 
177
  /**
192
 
193
  // check each tax public flag and term count and append name to array
194
  foreach ( get_object_taxonomies( $post_type, 'objects' ) as $taxonomy ) {
195
+
196
  if ( !empty( $taxonomy->public ) && !in_array( $taxonomy->name, xmlsf()->disabled_taxonomies() ) )
197
  $tax_array[$taxonomy->name] = $taxonomy->label;
198
+
199
  }
200
 
201
  }
215
  * @param float $max
216
  * @return float
217
  */
218
+ function xmlsf_sanitize_priority( $priority, $min = .1, $max = 1 ) {
219
 
220
  $priority = (float) $priority;
221
  $min = (float) $min;
291
  return $images_data;
292
  }
293
 
294
+ /* -------------------------------------
295
+ * MISSING WORDPRESS FUNCTIONS
296
+ * ------------------------------------- */
297
+
298
  /**
299
+ * Retrieve first or last post type date data based on timezone.
300
+ * Variation of function _get_last_post_time
301
  *
302
+ * @param string $timezone The location to get the time. Can be 'gmt', 'blog', or 'server'.
303
+ * @param string $field Field to check. Can be 'date' or 'modified'.
304
+ * @param string $post_type Post type to check. Defaults to 'any'.
305
+ * @param string $which Which to check. Can be 'first' or 'last'. Defaults to 'last'.
306
+ * @param string $m year, month or day period. Can be empty or integer.
307
+ * @param string $w week. Can be empty or integer.
308
+ *
309
+ * @return string The date.
310
  */
311
+ if ( ! function_exists( '_get_post_time' ) ) {
312
+ function _get_post_time( $timezone, $field, $post_type = 'any', $which = 'last', $m = '', $w = '' ) {
313
+
314
+ global $wpdb;
315
+
316
+ if ( !in_array( $field, array( 'date', 'modified' ) ) ) {
317
+ return false;
318
+ }
319
+
320
+ $timezone = strtolower( $timezone );
321
+
322
+ $m = preg_replace('|[^0-9]|', '', $m);
323
+
324
+ if ( ! empty( $w ) ) {
325
+ // when a week number is set make sure 'm' is year only
326
+ $m = substr( $m, 0, 4 );
327
+ // and append 'w' to the cache key
328
+ $key = "{$which}post{$field}{$m}.{$w}:$timezone";
329
+ } else {
330
+ $key = "{$which}post{$field}{$m}.{$w}:$timezone";
331
+ }
332
+
333
+ if ( 'any' !== $post_type ) {
334
+ $key .= ':' . sanitize_key( $post_type );
335
+ }
336
+
337
+ $date = wp_cache_get( $key, 'timeinfo' );
338
+ if ( false !== $date ) {
339
+ return $date;
340
+ }
341
+
342
+ if ( $post_type === 'any' ) {
343
+ $post_types = get_post_types( array( 'public' => true ) );
344
+ array_walk( $post_types, array( &$wpdb, 'escape_by_ref' ) );
345
+ $post_types = "'" . implode( "', '", $post_types ) . "'";
346
+ } elseif ( is_array($post_type) ) {
347
+ $types = get_post_types( array( 'public' => true ) );
348
+ foreach ( $post_type as $type )
349
+ if ( !in_array( $type, $types ) )
350
+ return false;
351
+ array_walk( $post_type, array( &$wpdb, 'escape_by_ref' ) );
352
+ $post_types = "'" . implode( "', '", $post_type ) . "'";
353
+ } else {
354
+ if ( !in_array( $post_type, get_post_types( array( 'public' => true ) ) ) )
355
+ return false;
356
+ $post_types = "'" . addslashes($post_type) . "'";
357
+ }
358
+
359
+ $where = "post_status='publish' AND post_type IN ({$post_types}) AND post_date_gmt";
360
+
361
+ // If a period is specified in the querystring, add that to the query
362
+ if ( !empty($m) ) {
363
+ $where .= " AND YEAR(post_date)=" . substr($m, 0, 4);
364
+ if ( strlen($m) > 5 ) {
365
+ $where .= " AND MONTH(post_date)=" . substr($m, 4, 2);
366
+ if ( strlen($m) > 7 ) {
367
+ $where .= " AND DAY(post_date)=" . substr($m, 6, 2);
368
+ }
369
+ }
370
+ }
371
+ if ( !empty($w) ) {
372
+ $week = _wp_mysql_week( 'post_date' );
373
+ $where .= " AND $week=$w";
374
+ }
375
+
376
+ $order = ( $which == 'last' ) ? 'DESC' : 'ASC';
377
+
378
+ /* CODE SUGGESTION BY Frédéric Demarle
379
+ * to make this language aware:
380
+ "SELECT post_{$field}_gmt FROM $wpdb->posts" . PLL()->model->post->join_clause()
381
+ ."WHERE post_status = 'publish' AND post_type IN ({$post_types})" . PLL()->model->post->where_clause( $lang )
382
+ . ORDER BY post_{$field}_gmt DESC LIMIT 1
383
+ */
384
+ switch ( $timezone ) {
385
+ case 'gmt':
386
+ $date = $wpdb->get_var("SELECT post_{$field}_gmt FROM $wpdb->posts WHERE $where ORDER BY post_{$field}_gmt $order LIMIT 1");
387
+ break;
388
+
389
+ case 'blog':
390
+ $date = $wpdb->get_var("SELECT post_{$field} FROM $wpdb->posts WHERE $where ORDER BY post_{$field}_gmt $order LIMIT 1");
391
+ break;
392
+
393
+ case 'server':
394
+ $add_seconds_server = date('Z');
395
+ $date = $wpdb->get_var("SELECT DATE_ADD(post_{$field}_gmt, INTERVAL '$add_seconds_server' SECOND) FROM $wpdb->posts WHERE $where ORDER BY post_{$field}_gmt $order LIMIT 1");
396
+ break;
397
+ }
398
+
399
+ if ( $date ) {
400
+ wp_cache_set( $key, $date, 'timeinfo' );
401
+
402
+ return $date;
403
+ }
404
+
405
+ return false;
406
+
407
+ }
408
+ }
409
+
410
+ /**
411
+ * Retrieve the date that the first post/page was published.
412
+ * Variation of function get_lastpostdate, uses _get_post_time
413
+ *
414
+ * The server timezone is the default and is the difference between GMT and
415
+ * server time. The 'blog' value is the date when the last post was posted. The
416
+ * 'gmt' is when the last post was posted in GMT formatted date.
417
+ *
418
+ * @uses apply_filters() Calls 'get_firstpostdate' filter
419
+ * @param string $timezone The location to get the time. Can be 'gmt', 'blog', or 'server'.
420
+ * @param string $post_type Post type to check.
421
+ * @return string The date of the last post.
422
+ */
423
+ if ( ! function_exists( 'get_firstpostdate' ) ) {
424
+ function get_firstpostdate( $timezone = 'server', $post_type = 'any' ) {
425
+
426
+ return apply_filters( 'get_firstpostdate', _get_post_time( $timezone, 'date', $post_type, 'first' ), $timezone );
427
+
428
  }
 
 
429
  }
430
+
431
+ /**
432
+ * Retrieve last post/page modified date depending on timezone.
433
+ * Variation of function get_lastpostmodified, uses _get_post_time
434
+ *
435
+ * The server timezone is the default and is the difference between GMT and
436
+ * server time. The 'blog' value is the date when the last post was posted. The
437
+ * 'gmt' is when the last post was posted in GMT formatted date.
438
+ *
439
+ * @uses apply_filters() Calls 'get_lastmodified' filter
440
+ * @param string $timezone The location to get the time. Can be 'gmt', 'blog', or 'server'.
441
+ * @param string $post_type The post type to get the last modified date for.
442
+ * @param string $m The period to check in. Defaults to any, can be YYYY, YYYYMM or YYYYMMDD
443
+ * @param string $w The week to check in. Defaults to any, can be one or two digit week number. Must be used with $m in YYYY format.
444
+ *
445
+ * @return string The date of the oldest modified post.
446
+ */
447
+ if ( ! function_exists( 'get_lastmodified' ) ) {
448
+ function get_lastmodified( $timezone = 'server', $post_type = 'any', $m = '', $w = '' ) {
449
+
450
+ return apply_filters( 'get_lastmodified', _get_post_time( $timezone, 'modified', $post_type, 'last', $m, $w ), $timezone );
451
+
452
+ }
453
+ }
readme.txt CHANGED
@@ -4,8 +4,8 @@ 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.4
8
- Stable tag: 5.2.7
9
 
10
  XML and Google News Sitemaps to feed the hungry spiders. Multisite, WP Super Cache, Polylang and WPML compatible.
11
 
@@ -23,7 +23,7 @@ An XML Sitemap Index becomes instantly available on **yourblog.url/sitemap.xml**
23
 
24
  Please read the FAQ's for info on how to get your articles listed on Google News.
25
 
26
- **Compatible with caching plugins** like WP Super Cache, W3 Total Cache and Quick Cache that cache feeds, allowing a faster serving to the impatient (when hungry) spider.
27
 
28
  **NOTES:**
29
 
@@ -40,7 +40,7 @@ Please read the FAQ's for info on how to get your articles listed on Google News
40
 
41
  **XML Sitemap**
42
 
43
- * Sitemap Index includes posts, pages and authors by default.
44
  * Optionally include sitemaps for custom post types, categories and tags.
45
  * Sitemap with custom URLs optional.
46
  * Custom/static sitemaps can be added to the index.
@@ -76,7 +76,7 @@ This plugin does not collect any user or visitor data nor set browser cookies. U
76
 
77
  **Data that is published**
78
 
79
- An XML Sitemap index, referencing other sitemaps containing your web site's public post URLs of selected post types that are already public, along with their last modification date and associated image URLs, and any selected public archive URLs.
80
 
81
  A Google News Sitemap containing your web site's public and recent (last 48 hours) URLs of selected news post type, along with their publication time stamp and associated image URL.
82
  An author sitemap can be included, which will contain links to author archive pages. These urls contain author/user slugs, and the author archives can contain author bio information. If you wish to keep this out of public domain, then deactivate the author sitemap and use an SEO plugin to add noindex headers.
@@ -296,30 +296,41 @@ Yes. In fact, it has been designed for it. Tested on WPMU 2.9.2 and WPMS 3+ both
296
 
297
  == Upgrade Notice ==
298
 
299
- = 5.3 =
300
-
301
 
 
302
 
303
  == Changelog ==
304
 
 
 
 
 
 
 
 
 
 
305
  = 5.3 =
306
- TODO verify date archive redirect Yoast Pro?
307
- TODO custom post type root pages
308
- TODO prime meta caches button
309
- TODO Google News Feed tab
310
  * NEW: Author sitemap
311
  * NEW: allow custom theme templates and stylesheets
312
  * NEW: request filters `xmlsf_request` and `xmlsf_news_request`
313
  * NEW: news template filters `xmlsf_news_publication_name` and `xmlsf_news_title`
314
  * NEW: sitemap template action hook `xmlsf_url`
315
  * NEW: sitemap template action hooks `xmlsf_news_url` and `xmlsf_news_tags_inner`
 
 
 
316
  * Moved news template action hook `xmlsf_news_tags_after` to after closing </news:news> tag
317
  * Less DB queries, smaller memory footprint
318
  * Better debug info with SAVEQUERIES
 
 
319
  * FIX: invalid form control not focusable when meta box is hidden
320
  * FIX: force Status 200 response
321
  * FIX: priority calculation last modified for post type
322
  * FIX: news sitemap redirection with Polylang
 
323
 
324
  = 5.2.7 =
325
  * NEW: Ad Inserter compatibility check
@@ -397,7 +408,7 @@ TODO Google News Feed tab
397
  * FIX Custom post types with a hyphen not showing
398
  * FIX Admin static files message fatal error, thanks @kitchin
399
  * FIX Improper if statement in upgrade routine, thanks @kitchin
400
- * FIX PHP 5.4 compatibility issues
401
 
402
  = 5.0 =
403
  * Complete code restructure and cleanup: MVC and JIT inclusion
@@ -447,7 +458,7 @@ TODO Google News Feed tab
447
 
448
  = 4.8.3 =
449
  * fix get_lastpostdate array/string
450
- * restore pre PHP 5.4 compatibility (popular request)
451
 
452
  = 4.8 =
453
  * NEW: Conditional functions is_sitemap() and is_news()
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.9
8
+ Stable tag: 5.3.2
9
 
10
  XML and Google News Sitemaps to feed the hungry spiders. Multisite, WP Super Cache, Polylang and WPML compatible.
11
 
23
 
24
  Please read the FAQ's for info on how to get your articles listed on Google News.
25
 
26
+ **Compatible with caching solutions** like CloudFlare, WP Super Cache, W3 Total Cache and Quick Cache that cache feeds, allowing a faster serving to the impatient (when hungry) spider.
27
 
28
  **NOTES:**
29
 
40
 
41
  **XML Sitemap**
42
 
43
+ * Sitemap Index includes **posts**, **pages** and **authors** by default.
44
  * Optionally include sitemaps for custom post types, categories and tags.
45
  * Sitemap with custom URLs optional.
46
  * Custom/static sitemaps can be added to the index.
76
 
77
  **Data that is published**
78
 
79
+ An XML Sitemap index, referencing other sitemaps containing your web site's public post URLs of selected post types that are already public, along with their last modification date and associated image URLs, and any selected public archive URLs.
80
 
81
  A Google News Sitemap containing your web site's public and recent (last 48 hours) URLs of selected news post type, along with their publication time stamp and associated image URL.
82
  An author sitemap can be included, which will contain links to author archive pages. These urls contain author/user slugs, and the author archives can contain author bio information. If you wish to keep this out of public domain, then deactivate the author sitemap and use an SEO plugin to add noindex headers.
296
 
297
  == Upgrade Notice ==
298
 
299
+ = 5.3.2 =
 
300
 
301
+ Fix Bing ping 410 error response and help links.
302
 
303
  == Changelog ==
304
 
305
+ = 5.3.2 =
306
+ * FIX: Bing ping 410 error response
307
+ * FIX: Outdated help & forum links
308
+
309
+ = 5.3.1 =
310
+ * FIX: Restore wp-sitemap.xml rewrite rules after deactivation
311
+ * FIX: Call to undefined function xmlsf_get_archives()
312
+ * Use nocache_headers()
313
+
314
  = 5.3 =
 
 
 
 
315
  * NEW: Author sitemap
316
  * NEW: allow custom theme templates and stylesheets
317
  * NEW: request filters `xmlsf_request` and `xmlsf_news_request`
318
  * NEW: news template filters `xmlsf_news_publication_name` and `xmlsf_news_title`
319
  * NEW: sitemap template action hook `xmlsf_url`
320
  * NEW: sitemap template action hooks `xmlsf_news_url` and `xmlsf_news_tags_inner`
321
+ * NEW: `xmlsf_index_url_args` filter
322
+ * NEW: All in One SEO Pack incompatibility message and instructions
323
+ * NEW: The SEO Framework incompatibility message and instructions
324
  * Moved news template action hook `xmlsf_news_tags_after` to after closing </news:news> tag
325
  * Less DB queries, smaller memory footprint
326
  * Better debug info with SAVEQUERIES
327
+ * Disable WP core sitemaps and redirect index
328
+ * FIX: conflicting static file deletion
329
  * FIX: invalid form control not focusable when meta box is hidden
330
  * FIX: force Status 200 response
331
  * FIX: priority calculation last modified for post type
332
  * FIX: news sitemap redirection with Polylang
333
+ * FIX: Cache-Control header no-cache
334
 
335
  = 5.2.7 =
336
  * NEW: Ad Inserter compatibility check
408
  * FIX Custom post types with a hyphen not showing
409
  * FIX Admin static files message fatal error, thanks @kitchin
410
  * FIX Improper if statement in upgrade routine, thanks @kitchin
411
+ * FIX PHP 5.4 compatibility issues
412
 
413
  = 5.0 =
414
  * Complete code restructure and cleanup: MVC and JIT inclusion
458
 
459
  = 4.8.3 =
460
  * fix get_lastpostdate array/string
461
+ * restore pre PHP 5.4 compatibility (popular request)
462
 
463
  = 4.8 =
464
  * NEW: Conditional functions is_sitemap() and is_news()
uninstall.php CHANGED
@@ -1,4 +1,5 @@
1
  <?php
 
2
  /**
3
  * XMLSF_MULTISITE_UNINSTALL
4
  *
@@ -12,8 +13,7 @@
12
  */
13
 
14
  // exit if uninstall not called from WordPress
15
- if ( !defined('WP_UNINSTALL_PLUGIN') )
16
- exit();
17
 
18
  /*
19
  * XML Sitemap Feed uninstallation
@@ -32,19 +32,19 @@ class XMLSitemapFeed_Uninstall {
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
  }
44
  restore_current_blog();
45
- }
46
- else
47
  $this->uninstall();
 
48
  }
49
 
50
  /*
@@ -54,21 +54,22 @@ class XMLSitemapFeed_Uninstall {
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');
@@ -76,23 +77,23 @@ class XMLSitemapFeed_Uninstall {
76
  delete_option('xmlsf_post_types');
77
  delete_option('xmlsf_taxonomies');
78
  delete_option('xmlsf_taxonomy_settings');
 
79
  delete_option('xmlsf_ping');
80
  delete_option('xmlsf_robots');
81
  delete_option('xmlsf_urls');
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
93
  if ( defined('WP_DEBUG') && WP_DEBUG ) {
94
  if ($blog_id)
95
- error_log('XML Sitemap Feeds settings cleared from site '.$blog_id.' on uninstall.');
96
  else
97
  error_log('XML Sitemap Feeds settings cleared on uninstall.');
98
  }
1
  <?php
2
+
3
  /**
4
  * XMLSF_MULTISITE_UNINSTALL
5
  *
13
  */
14
 
15
  // exit if uninstall not called from WordPress
16
+ defined('WP_UNINSTALL_PLUGIN') || exit();
 
17
 
18
  /*
19
  * XML Sitemap Feed uninstallation
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 before 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
  }
44
  restore_current_blog();
45
+ } else {
 
46
  $this->uninstall();
47
+ }
48
  }
49
 
50
  /*
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_gmt' ) );
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
+ delete_transient( 'xmlsf_prefetch_post_meta_failed' );
73
 
74
  // remove plugin settings
75
  delete_option('xmlsf_version');
77
  delete_option('xmlsf_post_types');
78
  delete_option('xmlsf_taxonomies');
79
  delete_option('xmlsf_taxonomy_settings');
80
+ delete_option('xmlsf_author_settings');
81
  delete_option('xmlsf_ping');
82
  delete_option('xmlsf_robots');
83
  delete_option('xmlsf_urls');
84
  delete_option('xmlsf_custom_sitemaps');
85
  delete_option('xmlsf_domains');
86
  delete_option('xmlsf_news_tags');
87
+ delete_option('xmlsf_images_meta_primed');
88
+ delete_option('xmlsf_comments_meta_primed');
89
 
90
+ // flush rules
 
91
  flush_rewrite_rules();
92
 
93
  // Kilroy was here
94
  if ( defined('WP_DEBUG') && WP_DEBUG ) {
95
  if ($blog_id)
96
+ error_log( $blog_id );
97
  else
98
  error_log('XML Sitemap Feeds settings cleared on uninstall.');
99
  }
upgrade.php CHANGED
@@ -31,13 +31,13 @@ class XMLSitemapFeed_Upgrade {
31
  *
32
  * @since 5.1
33
  */
34
- function install()
35
  {
36
  $defaults = xmlsf()->defaults();
37
 
38
  foreach ( $defaults as $option => $default ) {
39
  delete_option( 'xmlsf_'.$option );
40
- if ( in_array( $option, array('ping','robots') ) )
41
  add_option( 'xmlsf_'.$option, $default, null, false );
42
  else
43
  add_option( 'xmlsf_'.$option, $default );
@@ -54,7 +54,7 @@ class XMLSitemapFeed_Upgrade {
54
  *
55
  * @since 5.1
56
  */
57
- function upgrade( $db_version )
58
  {
59
  global $wpdb;
60
 
@@ -152,20 +152,6 @@ class XMLSitemapFeed_Upgrade {
152
  add_option( 'xmlsf_robots', $robots, null, false );
153
  }
154
 
155
- if ( version_compare( '5.0.2', $db_version, '>' ) ) {
156
- $defaults = xmlsf()->defaults();
157
-
158
- foreach ( $defaults as $option => $default ) {
159
- if ( get_option( 'xmlsf_'.$option ) ) continue;
160
- if ( in_array( $option, array('ping','robots') ) )
161
- add_option( 'xmlsf_'.$option, $default, null, false );
162
- else
163
- add_option( 'xmlsf_'.$option, $default );
164
- }
165
-
166
- delete_option( 'xmlsf_version' );
167
- }
168
-
169
  if ( version_compare( '5.1', $db_version, '>' ) ) {
170
  delete_transient('xmlsf_ping_google_sitemap_news');
171
  delete_transient('xmlsf_ping_google_sitemap');
@@ -177,9 +163,29 @@ class XMLSitemapFeed_Upgrade {
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
  }
183
  }
184
 
 
 
 
 
 
 
 
 
 
 
 
 
185
  }
31
  *
32
  * @since 5.1
33
  */
34
+ private function install()
35
  {
36
  $defaults = xmlsf()->defaults();
37
 
38
  foreach ( $defaults as $option => $default ) {
39
  delete_option( 'xmlsf_'.$option );
40
+ if ( in_array( $option, array( 'ping', 'robots' ) ) )
41
  add_option( 'xmlsf_'.$option, $default, null, false );
42
  else
43
  add_option( 'xmlsf_'.$option, $default );
54
  *
55
  * @since 5.1
56
  */
57
+ private function upgrade( $db_version )
58
  {
59
  global $wpdb;
60
 
152
  add_option( 'xmlsf_robots', $robots, null, false );
153
  }
154
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
155
  if ( version_compare( '5.1', $db_version, '>' ) ) {
156
  delete_transient('xmlsf_ping_google_sitemap_news');
157
  delete_transient('xmlsf_ping_google_sitemap');
163
  $wpdb->delete( $wpdb->prefix.'termmeta', array( 'meta_key' => 'term_modified_gmt' ) );
164
  }
165
 
166
+ if ( version_compare( '5.3', $db_version, '>' ) ) {
167
+ // clear comments meta
168
+ $wpdb->delete( $wpdb->prefix.'postmeta', array( 'meta_key' => '_xmlsf_comment_date' ) );
169
+ update_option( 'xmlsf_comments_meta_primed', array() );
170
+ }
171
+
172
+ $this->update_from_defaults();
173
+
174
  if ( defined('WP_DEBUG') && WP_DEBUG ) {
175
  error_log('XML Sitemap Feeds upgraded from '.$db_version.' to '.XMLSF_VERSION);
176
  }
177
  }
178
 
179
+ private function update_from_defaults() {
180
+
181
+ foreach ( xmlsf()->defaults() as $option => $default ) {
182
+ if ( get_option( 'xmlsf_'.$option ) ) continue;
183
+ if ( in_array( $option, array('ping','robots') ) )
184
+ add_option( 'xmlsf_'.$option, $default, null, false );
185
+ else
186
+ add_option( 'xmlsf_'.$option, $default );
187
+ }
188
+
189
+ }
190
+
191
  }
views/_generator.php CHANGED
File without changes
views/_usage.php CHANGED
@@ -1 +1,4 @@
1
- <!-- Queries executed: <?php echo $num; if ( $mem ) { ?> | Peak memory usage: <?php echo $mem; } ?> | Memory limit: <?php echo $limit; ?> -->
 
 
 
1
+ <!-- Queries executed: <?php echo $num; if ( $mem ) { ?> | Peak memory usage: <?php echo $mem ? $mem : 'Not availabe.'; } ?> | Memory limit: <?php echo $limit; ?> -->
2
+ <!-- Query errors: <?php echo !empty($errors) ? $errors : 'None encountered.'; ?> -->
3
+ <!-- Queries: <?php echo !empty($saved) ? $saved : 'Set SAVEQUERIES to show saved database queries here.'; ?> -->
4
+ <!-- Average system load during the last minute: <?php $load = function_exists('sys_getloadavg') ? sys_getloadavg() : false; echo $load ? $load[0] : 'Not available.'; ?> -->
views/admin/field-news-categories.php CHANGED
File without changes
views/admin/field-news-keywords.php CHANGED
File without changes
views/admin/field-news-labels.php CHANGED
@@ -1,6 +1,6 @@
1
  <fieldset id="xmlsf_news_labels">
2
  <legend class="screen-reader-text"><?php _e('Source labels','xml-sitemap-feed'); ?></legend>
3
  <p class="description">
4
- <?php printf(__('Source labels inside a News Sitemap are no longer supported by Google News. To manage your site\'s labels, please go to the %s.','xml-sitemap-feed'),'<a href="https://news.google.com/publisher" target="_blank">'.__('Google News Publisher Center','xml-sitemap-feed').'</a>'); ?>
5
  </p>
6
  </fieldset>
1
  <fieldset id="xmlsf_news_labels">
2
  <legend class="screen-reader-text"><?php _e('Source labels','xml-sitemap-feed'); ?></legend>
3
  <p class="description">
4
+ <?php printf(__('Source labels inside a News Sitemap are no longer supported by Google News. To manage your site\'s labels, please go to the %s.','xml-sitemap-feed'),'<a href="https://publishercenter.google.com" target="_blank">'.__('Google News Publisher Center','xml-sitemap-feed').'</a>'); ?>
5
  </p>
6
  </fieldset>
views/admin/field-news-name.php CHANGED
File without changes
views/admin/field-news-ping-log.php CHANGED
File without changes
views/admin/field-news-post-type.php CHANGED
@@ -1,5 +1,5 @@
1
  <fieldset>
2
- <legend class="screen-reader-text"><?php _e('Post type','xml-sitemap-feed'); ?></legend>
3
  <?php foreach ( $post_types as $post_type ) : $obj = get_post_type_object( $post_type ); if ( !is_object( $obj ) ) continue; ?>
4
  <label>
5
  <input type="<?php echo $type; ?>" name="xmlsf_news_tags[post_type][]" id="xmlsf_post_type_<?php echo $obj->name; ?>" value="<?php echo $obj->name; ?>"<?php checked( in_array($obj->name, $news_post_type), true ) . disabled( !in_array($obj->name, $allowed), true ); ?> />
@@ -9,7 +9,7 @@
9
  <?php endforeach; if ( $do_warning || 'radio' == $type ) : ?>
10
  <p class="description">
11
  <?php if ( $do_warning ) _e( 'Custom post types that do not use the post category taxonomy, cannot be included as long as any category is selected below.', 'xml-sitemap-feed' ); ?>
12
- <?php if ('radio' == $type) printf( /* Translators: Advanced plugin name */ __('Including multiple post types in the same News Sitemap is provided by the %s module.','xml-sitemap-feed'),'<a href="https://premium.status301.com/downloads/google-news-advanced/" target="_blank">'.__('Google News Advanced','xml-sitemap-feed').'</a>'); ?>
13
  </p>
14
  <?php endif; ?>
15
  </fieldset>
1
  <fieldset>
2
+ <legend class="screen-reader-text"><?php _e('Post type','xml-sitemap-feed'); ?></legend>
3
  <?php foreach ( $post_types as $post_type ) : $obj = get_post_type_object( $post_type ); if ( !is_object( $obj ) ) continue; ?>
4
  <label>
5
  <input type="<?php echo $type; ?>" name="xmlsf_news_tags[post_type][]" id="xmlsf_post_type_<?php echo $obj->name; ?>" value="<?php echo $obj->name; ?>"<?php checked( in_array($obj->name, $news_post_type), true ) . disabled( !in_array($obj->name, $allowed), true ); ?> />
9
  <?php endforeach; if ( $do_warning || 'radio' == $type ) : ?>
10
  <p class="description">
11
  <?php if ( $do_warning ) _e( 'Custom post types that do not use the post category taxonomy, cannot be included as long as any category is selected below.', 'xml-sitemap-feed' ); ?>
12
+ <?php if ( 'radio' == $type ) printf( /* Translators: Advanced plugin name */ __( 'Including multiple post types in the same News Sitemap is provided by the %s module.', 'xml-sitemap-feed' ), '<a href="https://premium.status301.com/downloads/google-news-advanced/" target="_blank">'.__('Google News Advanced','xml-sitemap-feed').'</a>' ); ?>
13
  </p>
14
  <?php endif; ?>
15
  </fieldset>
views/admin/field-news-stocktickers.php CHANGED
File without changes
views/admin/field-ping.php CHANGED
File without changes
views/admin/field-robots.php CHANGED
File without changes
views/admin/field-sitemap-author-settings.php ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <fieldset id="xmlsf_author_settings">
2
+ <legend class="screen-reader-text">
3
+ <?php echo translate( 'General' ); ?>
4
+ </legend>
5
+ <p>
6
+ <label>
7
+ <input type="checkbox" name="xmlsf_author_settings[active]" id="xmlsf_author_active" value="1"<?php checked( !empty( $author_settings['active'] ), true); ?> />
8
+ <?php _e( 'Include authors', 'xml-sitemap-feed' ); ?> (<?php echo count( get_users( array( 'fields' => 'ID', 'who' => 'authors', 'has_published_posts' => true, ) ) ); ?>)
9
+ </label>
10
+ </p>
11
+ <p>
12
+ <label>
13
+ <?php _e( 'Priority', 'xml-sitemap-feed' ); ?>
14
+ <input type="number" step="0.1" min="0.1" max="0.9" name="xmlsf_author_settings[priority]" id="xmlsf_author_priority" value="<?php echo ( isset($author_settings['priority']) ? $author_settings['priority'] : '' ); ?>" class="small-text" />
15
+ </label>
16
+ </p>
17
+ <p>
18
+ <label>
19
+ <?php _e( 'Maximum authors per sitemap', 'xml-sitemap-feed' ); ?>
20
+ <input type="number" step="100" min="0" max="50000" name="xmlsf_author_settings[term_limit]" id="xmlsf_author_term_limit" value="<?php echo ( isset($author_settings['term_limit']) ? $author_settings['term_limit'] : '' ); ?>" class="medium-text" />
21
+ </label>
22
+ </p>
23
+ <p class="description">
24
+ <?php echo apply_filters (
25
+ 'xmlsf_author_settings_description',
26
+ sprintf (
27
+ /* Translators: XML Sitemap Advanced */
28
+ __( 'More options available in %s.', 'xml-sitemap-feed' ),
29
+ '<a href="https://premium.status301.com/downloads/xml-sitemap-advanced/" target="_blank">'.__('XML Sitemap Advanced','xml-sitemap-feed').'</a>'
30
+ )
31
+ );
32
+ ?>
33
+ </p>
34
+ </fieldset>
views/admin/field-sitemap-custom.php CHANGED
@@ -1,7 +1,7 @@
1
  <fieldset>
2
- <legend class="screen-reader-text"><?php _e('External XML Sitemaps','xml-sitemap-feed'); ?></legend>
3
 
4
- <label for="xmlsf_custom_sitemaps"><?php _e('Additional XML Sitemaps to append to the main XML Sitemap Index:','xml-sitemap-feed'); ?></label>
5
  <br/>
6
- <textarea name="xmlsf_custom_sitemaps" id="xmlsf_custom_sitemaps" class="large-text" cols="50" rows="4"><?php echo $lines; ?></textarea>
7
  </fieldset>
1
  <fieldset>
2
+ <legend class="screen-reader-text"><?php _e('External XML Sitemaps','xml-sitemap-feed'); ?></legend>
3
 
4
+ <label for="xmlsf_custom_sitemaps"><?php _e('Additional XML Sitemaps to append to the main XML Sitemap Index:','xml-sitemap-feed'); ?></label>
5
  <br/>
6
+ <textarea name="xmlsf_custom_sitemaps" id="xmlsf_custom_sitemaps" class="large-text" cols="50" rows="4"><?php echo $lines; ?></textarea>
7
  </fieldset>
views/admin/field-sitemap-domains.php CHANGED
File without changes
views/admin/field-sitemap-name.php ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <fieldset>
2
+ <legend class="screen-reader-text"><?php _e('XML Sitemap URL','xml-sitemap-feed'); ?></legend>
3
+
4
+ <?php echo trailingslashit( get_home_url() ); ?><input type="text" name="xmlsf_sitemap_name" id="xmlsf_sitemap_name" placeholder="<?php echo $default; ?>" value="<?php echo $name; ?>" disabled>
5
+ <p class="description" id="xmlsf-sitemap-name-description">
6
+ <?php printf(
7
+ /* Translators: default sitemap.xml file name */
8
+ __('Set an alternative name for the sitemap index. Leave empty to use the default: %s','xml-sitemap-feed'), '<code>' . apply_filters( 'xmlsf_sitemap_filename', 'sitemap.xml' ) . '</code>'
9
+ ); ?><br/>
10
+ <?php printf (
11
+ /* Translators: XML Sitemap Advanced */
12
+ __( 'Available in %s.', 'xml-sitemap-feed' ),
13
+ '<a href="https://premium.status301.com/downloads/xml-sitemap-advanced/" target="_blank">'.__('XML Sitemap Advanced','xml-sitemap-feed').'</a>'
14
+ ); ?>
15
+ </p>
16
+ </fieldset>
views/admin/field-sitemap-post-type.php CHANGED
@@ -1,78 +1,81 @@
1
  <fieldset id="xmlsf_post_type_<?php echo $obj->name; ?>">
2
- <legend class="screen-reader-text">
3
  <?php echo $obj->label; ?>
4
  </legend>
5
 
6
  <p>
7
- <label>
8
- <input type="checkbox" name="xmlsf_post_types[<?php echo $obj->name; ?>][active]" id="xmlsf_post_types_<?php echo $obj->name; ?>" value="1"<?php checked( !empty($options[$obj->name]["active"]), true); ?> />
9
- <?php printf( /* translators: Post type name and post count */ __('Include %s', 'xml-sitemap-feed'), $obj->label ); ?> (<?php echo $count->publish; ?>)
10
- </label>
11
  </p>
12
 
13
- <?php
14
- if ( empty($obj->hierarchical) ) {
15
- $archive = isset($options[$obj->name]['archive']) ? $options[$obj->name]['archive'] : 'yearly';
16
- ?>
17
- <p>
18
- <label><?php _e('Split by','xml-sitemap-feed'); ?>
19
- <select name="xmlsf_post_types[<?php echo $obj->name; ?>][archive]" id="xmlsf_post_types_'<?php echo $obj->name; ?>_archive">
20
- <option value="">
21
- <?php echo translate('None'); ?>
22
- </option>
23
- <option value="yearly"<?php echo selected( $archive == 'yearly', true, false); ?>>
24
- <?php echo __('Year','xml-sitemap-feed'); ?>
25
- </option>
26
- <option value="monthly"<?php echo selected( $archive == 'monthly', true, false); ?>>
27
- <?php echo __('Month','xml-sitemap-feed'); ?>
28
- </option>
29
-
30
- </select>
31
- </label>
32
- </p>
33
- <?php
34
- }
 
 
 
35
 
36
- $priority_val = !empty($options[$obj->name]['priority']) ? $options[$obj->name]['priority'] : '0.5';
37
- $image = isset($options[$obj->name]['tags']['image']) ? $options[$obj->name]['tags']['image'] : 'attached';
38
- $context = ( $obj->name === 'page' ) ? 'page' : 'post';
39
- ?>
40
 
41
- <p>
42
- <label><?php echo __('Priority','xml-sitemap-feed'); ?>
43
- <input type="number" step="0.1" min="0.1" max="0.9" name="xmlsf_post_types[<?php echo $obj->name; ?>][priority]" id="xmlsf_post_types_<?php echo $obj->name; ?>_priority" value="<?php echo $priority_val; ?>" class="small-text" />
44
- </label>
45
- </p>
46
 
47
- <p>
48
- <label>
49
- <input type="checkbox" name="xmlsf_post_types[<?php echo $obj->name; ?>][dynamic_priority]" value="1"<?php echo checked( !empty($options[$obj->name]['dynamic_priority']), true, false); ?> />
50
- <?php echo __('Automatic Priority calculation.','xml-sitemap-feed'); ?>
51
- </label>
52
- </p>
53
 
54
- <p>
55
- <label>
56
- <input type="checkbox" name="xmlsf_post_types[<?php echo $obj->name; ?>][update_lastmod_on_comments]" value="1"<?php echo checked( !empty($options[$obj->name]["update_lastmod_on_comments"]), true, false); ?> />
57
- <?php echo __('Update the Last Changed date on each new comment.','xml-sitemap-feed'); ?>
58
- </label>
59
- </p>
60
 
61
- <p>
62
- <label>
63
- <?php echo __('Add image tags for','xml-sitemap-feed'); ?>
64
- <select name="xmlsf_post_types[<?php echo $obj->name; ?>][tags][image]">
65
- <option value="">
66
- <?php echo translate('None'); ?>
67
- </option>
68
- <option value="featured"<?php echo selected( $image == "featured", true, false); ?>>
69
- <?php echo translate_with_gettext_context('Featured Image',$context); ?>
70
- </option>
71
- <option value="attached"<?php echo selected( $image == "attached", true, false); ?>>
72
- <?php echo __('Attached images','xml-sitemap-feed'); ?>
73
- </option>
74
- </select>
75
- </label>
76
- </p>
77
 
78
  </fieldset>
1
  <fieldset id="xmlsf_post_type_<?php echo $obj->name; ?>">
2
+ <legend class="screen-reader-text">
3
  <?php echo $obj->label; ?>
4
  </legend>
5
 
6
  <p>
7
+ <label>
8
+ <input type="checkbox" name="xmlsf_post_types[<?php echo $obj->name; ?>][active]" id="xmlsf_post_types_<?php echo $obj->name; ?>" value="1"<?php checked( !empty($options[$obj->name]["active"]), true); ?> />
9
+ <?php printf( /* translators: Post type name and post count */ __( 'Include %s', 'xml-sitemap-feed' ), $obj->label ); ?> (<?php echo $count->publish; ?>)
10
+ </label>
11
  </p>
12
 
13
+ <?php
14
+ if ( empty($obj->hierarchical) ) {
15
+ $archive = isset($options[$obj->name]['archive']) ? $options[$obj->name]['archive'] : 'yearly';
16
+ ?>
17
+ <p>
18
+ <label><?php _e( 'Split by', 'xml-sitemap-feed' ); ?>
19
+ <select name="xmlsf_post_types[<?php echo $obj->name; ?>][archive]" id="xmlsf_post_types_'<?php echo $obj->name; ?>_archive">
20
+ <option value="">
21
+ <?php echo translate('None'); ?>
22
+ </option>
23
+ <option value="yearly"<?php echo selected( $archive == 'yearly', true, false ); ?>>
24
+ <?php echo __( 'Year', 'xml-sitemap-feed' ); ?>
25
+ </option>
26
+ <option value="monthly"<?php echo selected( $archive == 'monthly', true, false ); ?>>
27
+ <?php echo __( 'Month', 'xml-sitemap-feed' ); ?>
28
+ </option>
29
+ <?php do_action( 'xmlsf_posttype_archive_field_options', $obj, $archive ); ?>
30
+ </select>
31
+ </label>
32
+ <span class="description"><?php echo apply_filters(
33
+ 'xmlsf_posttype_archive_field_description',
34
+ sprintf( /* Translators: XML Sitemap Advanced */ __( 'More options available in %s.', 'xml-sitemap-feed' ), '<a href="https://premium.status301.com/downloads/xml-sitemap-advanced/" target="_blank">'.__('XML Sitemap Advanced','xml-sitemap-feed').'</a>' ) ); ?></span>
35
+ </p>
36
+ <?php
37
+ }
38
 
39
+ $priority_val = !empty($options[$obj->name]['priority']) ? $options[$obj->name]['priority'] : '0.5';
40
+ $image = isset($options[$obj->name]['tags']['image']) ? $options[$obj->name]['tags']['image'] : 'attached';
41
+ $context = ( $obj->name === 'page' ) ? 'page' : 'post';
42
+ ?>
43
 
44
+ <p>
45
+ <label><?php echo __('Priority','xml-sitemap-feed'); ?>
46
+ <input type="number" step="0.1" min="0.1" max="0.9" name="xmlsf_post_types[<?php echo $obj->name; ?>][priority]" id="xmlsf_post_types_<?php echo $obj->name; ?>_priority" value="<?php echo $priority_val; ?>" class="small-text" />
47
+ </label>
48
+ </p>
49
 
50
+ <p>
51
+ <label>
52
+ <input type="checkbox" name="xmlsf_post_types[<?php echo $obj->name; ?>][dynamic_priority]" value="1"<?php echo checked( !empty($options[$obj->name]['dynamic_priority']), true, false); ?> />
53
+ <?php echo __('Automatic Priority calculation.','xml-sitemap-feed'); ?>
54
+ </label>
55
+ </p>
56
 
57
+ <p>
58
+ <label>
59
+ <input type="checkbox" name="xmlsf_post_types[<?php echo $obj->name; ?>][update_lastmod_on_comments]" value="1"<?php echo checked( !empty($options[$obj->name]["update_lastmod_on_comments"]), true, false); ?> />
60
+ <?php echo __('Update the Last Changed date on each new comment.','xml-sitemap-feed'); ?>
61
+ </label>
62
+ </p>
63
 
64
+ <p>
65
+ <label>
66
+ <?php echo __('Add image tags for','xml-sitemap-feed'); ?>
67
+ <select name="xmlsf_post_types[<?php echo $obj->name; ?>][tags][image]">
68
+ <option value="">
69
+ <?php echo translate('None'); ?>
70
+ </option>
71
+ <option value="featured"<?php echo selected( $image == "featured", true, false); ?>>
72
+ <?php echo translate_with_gettext_context('Featured Image',$context); ?>
73
+ </option>
74
+ <option value="attached"<?php echo selected( $image == "attached", true, false); ?>>
75
+ <?php echo __('Attached images','xml-sitemap-feed'); ?>
76
+ </option>
77
+ </select>
78
+ </label>
79
+ </p>
80
 
81
  </fieldset>
views/admin/field-sitemap-taxonomies.php CHANGED
File without changes
views/admin/field-sitemap-taxonomy-settings.php CHANGED
@@ -1,4 +1,4 @@
1
- <fieldset id="xmlsf_taxonomies">
2
  <legend class="screen-reader-text">
3
  <?php echo translate( 'General' ); ?>
4
  </legend>
1
+ <fieldset id="xmlsf_taxonomy_settings">
2
  <legend class="screen-reader-text">
3
  <?php echo translate( 'General' ); ?>
4
  </legend>
views/admin/field-sitemap-urls.php CHANGED
File without changes
views/admin/field-sitemaps.php CHANGED
@@ -1,38 +1,38 @@
1
  <fieldset id="xmlsf_sitemaps">
2
- <legend class="screen-reader-text">
3
- <?php _e('Enable XML sitemaps','xml-sitemap-feed'); ?>
4
- </legend>
5
  <label>
6
- <input type="checkbox" name="xmlsf_sitemaps[sitemap]" id="xmlsf_sitemaps_index" value="sitemap.xml"<?php echo checked(isset($this->sitemaps['sitemap']), true, false); ?> />
7
- <?php _e('XML Sitemap Index','xml-sitemap-feed'); ?>
8
- </label>
9
 
10
- <?php if ( isset($this->sitemaps['sitemap']) ) {
11
- $sitemap_url = trailingslashit(get_bloginfo('url')) . ( xmlsf()->plain_permalinks() ? '?feed=sitemap' : $this->sitemaps['sitemap'] );
12
- ?>
13
- <span class="description">
14
- &nbsp;&ndash;&nbsp;
15
- <a href="<?php echo admin_url('options-general.php'); ?>?page=xmlsf" id="xmlsf_link"><?php echo translate('Settings'); ?></a> |
16
- <a href="<?php echo $sitemap_url; ?>" target="_blank"><?php echo translate('View'); ?></a>
17
- </span>
18
- <?php } ?>
19
 
20
- <br>
21
 
22
  <label>
23
- <input type="checkbox" name="xmlsf_sitemaps[sitemap-news]" id="xmlsf_sitemaps_news" value="sitemap-news.xml"<?php echo checked(isset($this->sitemaps['sitemap-news']), true, false); ?> />
24
- <?php _e('Google News Sitemap','xml-sitemap-feed'); ?>
25
- </label>
26
 
27
- <?php if (isset($this->sitemaps['sitemap-news'])) {
28
- $news_url = trailingslashit(get_bloginfo('url')) . ( xmlsf()->plain_permalinks() ? '?feed=sitemap-news' : $this->sitemaps['sitemap-news'] );
29
- ?>
30
  <span class="description">
31
- &nbsp;&ndash;&nbsp;
32
- <a href="<?php echo admin_url('options-general.php'); ?>?page=xmlsf_news" id="xmlsf_news_link"><?php echo translate('Settings'); ?></a> |
33
- <a href="<?php echo $news_url; ?>" target="_blank"><?php echo translate('View'); ?></a>
34
- </span>
35
- <?php } ?>
36
 
37
  </fieldset>
38
  <script>
1
  <fieldset id="xmlsf_sitemaps">
2
+ <legend class="screen-reader-text">
3
+ <?php _e('Enable XML sitemaps','xml-sitemap-feed'); ?>
4
+ </legend>
5
  <label>
6
+ <input type="checkbox" name="xmlsf_sitemaps[sitemap]" id="xmlsf_sitemaps_index" value="sitemap.xml"<?php echo checked(isset($this->sitemaps['sitemap']), true, false); ?> />
7
+ <?php _e('XML Sitemap Index','xml-sitemap-feed'); ?>
8
+ </label>
9
 
10
+ <?php if ( isset($this->sitemaps['sitemap']) ) {
11
+ $sitemap_url = trailingslashit(get_bloginfo('url')) . ( xmlsf()->plain_permalinks() ? '?feed=sitemap' : $this->sitemaps['sitemap'] );
12
+ ?>
13
+ <span class="description">
14
+ &nbsp;&ndash;&nbsp;
15
+ <a href="<?php echo admin_url('options-general.php'); ?>?page=xmlsf" id="xmlsf_link"><?php echo translate('Settings'); ?></a> |
16
+ <a href="<?php echo $sitemap_url; ?>" target="_blank"><?php echo translate('View'); ?></a>
17
+ </span>
18
+ <?php } ?>
19
 
20
+ <br>
21
 
22
  <label>
23
+ <input type="checkbox" name="xmlsf_sitemaps[sitemap-news]" id="xmlsf_sitemaps_news" value="sitemap-news.xml"<?php echo checked(isset($this->sitemaps['sitemap-news']), true, false); ?> />
24
+ <?php _e('Google News Sitemap','xml-sitemap-feed'); ?>
25
+ </label>
26
 
27
+ <?php if (isset($this->sitemaps['sitemap-news'])) {
28
+ $news_url = trailingslashit(get_bloginfo('url')) . ( xmlsf()->plain_permalinks() ? '?feed=sitemap-news' : $this->sitemaps['sitemap-news'] );
29
+ ?>
30
  <span class="description">
31
+ &nbsp;&ndash;&nbsp;
32
+ <a href="<?php echo admin_url('options-general.php'); ?>?page=xmlsf_news" id="xmlsf_news_link"><?php echo translate('Settings'); ?></a> |
33
+ <a href="<?php echo $news_url; ?>" target="_blank"><?php echo translate('View'); ?></a>
34
+ </span>
35
+ <?php } ?>
36
 
37
  </fieldset>
38
  <script>
views/admin/help-tab-advanced.php CHANGED
File without changes
views/admin/help-tab-allowed-domains.php CHANGED
File without changes
views/admin/help-tab-authors.php ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <p>
2
+ <strong><?php _e( 'Include authors', 'xml-sitemap-feed' ); ?></strong>
3
+ <br />
4
+ <?php _e( 'Activate this to include an author sitemap in the sitemap index. Only users of level Contributor and higher, with at least one published post, are included in the author sitemap.', 'xml-sitemap-feed' ); ?>
5
+ </p>
6
+ <p>
7
+ <strong><?php _e( 'Priority', 'xml-sitemap-feed' ); ?></strong>
8
+ <br />
9
+ <?php echo __( 'Priority can be used to signal the importance of author archives relative to other content like posts, pages or taxonomy term archives.', 'xml-sitemap-feed' ); ?>
10
+ </p>
11
+ <p>
12
+ <strong><?php _e( 'Maximum authors per sitemap', 'xml-sitemap-feed' ); ?></strong>
13
+ <br />
14
+ <?php _e( 'The absolute maximum allowed is 50.000 per sitemap. Reduce this number if you experience errors or slow sitemaps.', 'xml-sitemap-feed' ); ?>
15
+ <?php _e( 'Authors are ordered by number of posts, starting with the most published posts down to the least. Authors without any posts will not appear in the sitemap.', 'xml-sitemap-feed' ); ?>
16
+ </p>
17
+ <p>
18
+ <?php echo apply_filters (
19
+ 'xmlsf_author_settings_description',
20
+ sprintf (
21
+ /* Translators: XML Sitemap Advanced */
22
+ __( 'More options available in %s.', 'xml-sitemap-feed' ),
23
+ '<a href="https://premium.status301.com/downloads/xml-sitemap-advanced/" target="_blank">'.__('XML Sitemap Advanced','xml-sitemap-feed').'</a>'
24
+ )
25
+ );
26
+ ?>
27
+ </p>
views/admin/help-tab-news-categories.php CHANGED
File without changes
views/admin/help-tab-news-keywords.php CHANGED
File without changes
views/admin/help-tab-news-labels.php CHANGED
@@ -2,6 +2,6 @@
2
  <?php _e('Source labels provide more information about the content of your articles.','xml-sitemap-feed'); ?>
3
  </p>
4
  <p>
5
- <?php printf(__('Source labels inside a News Sitemap are no longer supported by Google News. To manage your site\'s labels, please go to the %s.','xml-sitemap-feed'),'<a href="https://news.google.com/publisher" target="_blank">'.__('Google News Publisher Center','xml-sitemap-feed').'</a>'); ?>
6
- <?php printf(__('Read more about source labels on %s','xml-sitemap-feed'),'<a href="https://support.google.com/news/publisher/answer/4582731" target="_blank">'.__('What does each source label mean?','xml-sitemap-feed').'</a>'); ?>
7
  </p>
2
  <?php _e('Source labels provide more information about the content of your articles.','xml-sitemap-feed'); ?>
3
  </p>
4
  <p>
5
+ <?php printf(__('Source labels inside a News Sitemap are no longer supported by Google News. To manage your site\'s labels, please go to the %s.','xml-sitemap-feed'),'<a href="https://publishercenter.google.com/" target="_blank">'.__('Google News Publisher Center','xml-sitemap-feed').'</a>'); ?>
6
+ <?php printf(__('Read more about source labels on %s','xml-sitemap-feed'),'<a href="https://support.google.com/news/publisher-center/answer/9606542" target="_blank">'.__('What does each source label mean?','xml-sitemap-feed').'</a>'); ?>
7
  </p>
views/admin/help-tab-news-name.php CHANGED
File without changes
views/admin/help-tab-news-sidebar.php CHANGED
@@ -1,29 +1,31 @@
1
  <p>
2
- <strong><?php echo translate('For more information:'); ?></strong>
3
  </p>
4
  <ul>
5
- <!--<li>
6
- <a href="https://support.google.com/news/publisher-center/answer/74288" target="_blank"><?php _e( /* https://support.google.com/news/publisher-center/answer/74288 */ 'Create a Google News sitemap', 'xml-sitemap-feed' ); ?></a>
7
- </li>-->
8
  <li>
9
- <a href="https://support.google.com/news/publisher/answer/40787" target="_blank"><?php _e( /* https://support.google.com/news/publisher/answer/40787 */ 'Getting into Google News', 'xml-sitemap-feed' ); ?></a>
10
  </li>
11
  <li>
12
- <a href="https://support.google.com/news/publisher-center/answer/6075793" target="_blank"><?php _e( /* https://support.google.com/news/publisher-center/answer/6075793 */ 'News sitemap errors', 'xml-sitemap-feed' ); ?></a>
13
  </li>
 
 
 
 
 
14
  <li>
15
- <a href="https://support.google.com/news/publisher-center/topic/9010385" target="_blank"><?php _e( /* https://support.google.com/news/publisher-center/topic/9010385 */ 'Troubleshoot an issue', 'xml-sitemap-feed' ); ?></a>
16
  </li>
17
  <li>
18
- <a href="https://support.google.com/news/publisher-center/answer/13369" target="_blank"><?php _e( /* https://support.google.com/news/publisher-center/answer/13369 */ 'Prevent missing or incorrect images', 'xml-sitemap-feed' ); ?></a>
19
  </li>
20
  <li>
21
- <a href="https://support.google.com/news/publisher-center/answer/70871" target="_blank"><?php _e( /* https://support.google.com/news/publisher-center/answer/70871 */ 'Incorrect article date', 'xml-sitemap-feed' ); ?></a>
22
  </li>
23
  <li>
24
- <a href="https://support.google.com/googlenews/" target="_blank"><?php _e( /* https://support.google.com/googlenews/ */ 'Google News Help Center', 'xml-sitemap-feed' ); ?></a>
25
  </li>
26
  <li>
27
- <a href="https://support.google.com/googlenews/community" target="_blank"><?php _e( /* https://support.google.com/googlenews/community */ 'Publisher Help Forum', 'xml-sitemap-feed' ); ?></a>
28
  </li>
29
  </ul>
1
  <p>
2
+ <strong><?php echo translate('General'); ?></strong>
3
  </p>
4
  <ul>
 
 
 
5
  <li>
6
+ <a href="https://support.google.com/googlenews/" target="_blank"><?php _e( /* Translators: Site title https://support.google.com/googlenews/ */ 'Google News Help Center', 'xml-sitemap-feed' ); ?></a>
7
  </li>
8
  <li>
9
+ <a href="https://support.google.com/googlenews/community" target="_blank"><?php _e( /* Translators: Forum title https://support.google.com/googlenews/community */ 'Publisher Help Forum', 'xml-sitemap-feed' ); ?></a>
10
  </li>
11
+ </ul>
12
+ <p>
13
+ <strong><?php echo translate('For more information:'); ?></strong>
14
+ </p>
15
+ <ul>
16
  <li>
17
+ <a href="https://developers.google.com/search/docs/advanced/sitemaps/news-sitemap" target="_blank"><?php _e( /* Translators: Article title https://developers.google.com/search/docs/advanced/sitemaps/news-sitemap */ 'Create a Google News sitemap', 'xml-sitemap-feed' ); ?></a>
18
  </li>
19
  <li>
20
+ <a href="https://support.google.com/news/publisher-center/answer/9607025" target="_blank"><?php _e( /* Translators: Article title https://support.google.com/news/publisher-center/answer/9607025 */ 'Appear in Google News', 'xml-sitemap-feed' ); ?></a>
21
  </li>
22
  <li>
23
+ <a href="https://developers.google.com/search/blog/2019/01/ways-to-succeed-in-google-news" target="_blank"><?php _e( /* Translators: Article title https://developers.google.com/search/blog/2019/01/ways-to-succeed-in-google-news */ 'Ways to succeed in Google News', 'xml-sitemap-feed' ); ?></a>
24
  </li>
25
  <li>
26
+ <a href="https://support.google.com/news/publisher-center/answer/9607104" target="_blank"><?php _e( /* Translators: Article title https://support.google.com/news/publisher-center/answer/9607104 */ 'Best practices for your article pages', 'xml-sitemap-feed' ); ?></a>
27
  </li>
28
  <li>
29
+ <a href="https://support.google.com/news/publisher-center/answer/9606470" target="_blank"><?php _e( /* Translators: Article title https://support.google.com/news/publisher-center/answer/9606470 */ 'News sitemap errors', 'xml-sitemap-feed' ); ?></a>
30
  </li>
31
  </ul>
views/admin/help-tab-news-stocktickers.php CHANGED
File without changes
views/admin/help-tab-news.php CHANGED
@@ -1,4 +1,20 @@
1
  <p>
2
- <?php _e('When you are done configuring and preparing your news content and you are convinced your site adheres to the <a href="https://support.google.com/news/publisher/answer/40787" target="_blank">Google News guidelines</a>, go ahead and <a href="https://partnerdash.google.com/partnerdash/d/news" target="_blank">submit your site for inclusion</a>!','xml-sitemap-feed'); ?>
3
- <?php _e('It is strongly recommended to submit your news sitemap to your Google Webmasters Tools account to monitor for warnings or errors.','xml-sitemap-feed'); ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4
  </p>
1
  <p>
2
+ <?php _e (
3
+ 'The options on this page allow you to configure an XML Sitemap dedicated to keep Google News informed of your latest posts.',
4
+ 'xml-sitemap-feed'
5
+ ); ?>
6
+ <?php _e (
7
+ 'Updates are instantly pinged to Google, who will then crawl your sitemap to find out more. The sitemap adheres to the Google News Sitemap standard and helps Google News to find your news content as quickly as possible. However, it is up to you to to produce high-quality content and comply with Google News content policies!',
8
+ 'xml-sitemap-feed'
9
+ ); ?>
10
+ </p>
11
+ <p>
12
+ <?php _e (
13
+ 'When you are done configuring and preparing your news content and you are convinced your site adheres to the <a href="https://support.google.com/news/publisher-center/answer/6204050" target="_blank">Google News guidelines</a>, go ahead and <a href="https://publishercenter.google.com/" target="_blank">submit your site for inclusion</a>!',
14
+ 'xml-sitemap-feed'
15
+ ); ?>
16
+ <?php _e (
17
+ 'It is strongly recommended to submit your news sitemap to your Google Search Console account to monitor for warnings or errors.',
18
+ 'xml-sitemap-feed'
19
+ ); ?>
20
  </p>
views/admin/help-tab-ping.php CHANGED
File without changes
views/admin/help-tab-post-types.php CHANGED
@@ -1,15 +1,38 @@
 
 
 
 
 
 
 
1
  <p>
2
  <strong><?php _e( 'Split by', 'xml-sitemap-feed' ); ?></strong>
3
  <br />
4
- <?php _e( /* "Split by" and "Month" are used in the option */ 'Choose Split by Month if you experience errors or slow sitemaps.', 'xml-sitemap-feed' ); ?>
 
 
 
5
  </p>
6
  <p>
7
  <strong><?php _e( 'Priority', 'xml-sitemap-feed' ); ?></strong>
8
  <br />
 
9
  <?php echo __( 'Priority can be overridden on individual posts.', 'xml-sitemap-feed' ); ?>
10
  </p>
11
  <p>
12
  <strong><?php _e( 'Automatic Priority calculation.', 'xml-sitemap-feed' ); ?></strong>
13
  <br />
14
  <?php echo __( 'Adjusts the Priority based on factors like age, comments, sticky post or blog page.', 'xml-sitemap-feed' ); ?>
 
 
 
 
 
 
 
 
 
 
 
 
15
  </p>
1
+ <p>
2
+ <strong><?php _e( 'Include...', 'xml-sitemap-feed' ); ?></strong>
3
+ <br />
4
+ <?php _e( 'Activate these to include a post type sitemap in the sitemap index.', 'xml-sitemap-feed' ); ?>
5
+ <?php _e( 'Make sure that post types are public by following links in the sitemap in an anonymous browser window or after logging out.', 'xml-sitemap-feed' ); ?>
6
+ <?php _e( 'Some post types or posts may be carrying noindex headers. Make sure to NOT include those post types or posts.', 'xml-sitemap-feed' ); ?>
7
+ </p>
8
  <p>
9
  <strong><?php _e( 'Split by', 'xml-sitemap-feed' ); ?></strong>
10
  <br />
11
+ <?php _e( 'Choose Split by Month if you experience errors or slow sitemaps.', 'xml-sitemap-feed' ); ?>
12
+ <?php echo apply_filters(
13
+ 'xmlsf_posttype_archive_field_description',
14
+ sprintf( /* Translators: XML Sitemap Advanced */ __( 'More options available in %s.', 'xml-sitemap-feed' ), '<a href="https://premium.status301.com/downloads/xml-sitemap-advanced/" target="_blank">'.__('XML Sitemap Advanced','xml-sitemap-feed').'</a>' ) ); ?>
15
  </p>
16
  <p>
17
  <strong><?php _e( 'Priority', 'xml-sitemap-feed' ); ?></strong>
18
  <br />
19
+ <?php echo __( 'Priority can be used to signal the relative importance of post types in general and individual posts in particular.', 'xml-sitemap-feed' ); ?>
20
  <?php echo __( 'Priority can be overridden on individual posts.', 'xml-sitemap-feed' ); ?>
21
  </p>
22
  <p>
23
  <strong><?php _e( 'Automatic Priority calculation.', 'xml-sitemap-feed' ); ?></strong>
24
  <br />
25
  <?php echo __( 'Adjusts the Priority based on factors like age, comments, sticky post or blog page.', 'xml-sitemap-feed' ); ?>
26
+ <?php echo __( 'Please note: this option can make sitemap generation slower and more resource intensive.', 'xml-sitemap-feed' ); ?>
27
+ </p>
28
+ <p>
29
+ <strong><?php _e( 'Update the Last Changed date on each new comment.', 'xml-sitemap-feed' ); ?></strong>
30
+ <br />
31
+ <?php echo __( 'The Last Changed timestamp will be updated whenever a comment is added. Useful for sites where user interaction like comments play a large role and give added content value. But otherwise this is not advised.', 'xml-sitemap-feed' ); ?>
32
+ <?php echo __( 'Please note: this option can make sitemap generation slower and more resource intensive.', 'xml-sitemap-feed' ); ?>
33
+ </p>
34
+ <p>
35
+ <strong><?php _e( 'Add image tags for', 'xml-sitemap-feed' ); ?></strong>
36
+ <br />
37
+ <?php echo __( 'Choose which images should be added to the sitemap. Note that images can be present in a post while not being attached to that post. If you have images in your Library that are not attached to any post, or not used as featured image, then those will not be present in your sitemap.', 'xml-sitemap-feed' ); ?>
38
  </p>
views/admin/help-tab-robots.php CHANGED
File without changes
views/admin/help-tab-sidebar.php CHANGED
@@ -1,14 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
1
  <p>
2
  <strong><?php echo translate('For more information:'); ?></strong>
3
  </p>
4
  <ul>
5
  <li>
6
- <a href="https://support.google.com/webmasters/answer/156184" target="_blank"><?php _e( /* https://support.google.com/webmasters/answer/156184 */ 'Learn more about sitemaps on Google Search Console Help', 'xml-sitemap-feed' ); ?></a>
7
  </li>
8
  <li>
9
- <a href="https://support.google.com/webmasters/answer/183669" target="_blank"><?php _e( /* https://support.google.com/webmasters/answer/183669 */ 'Manage sitemaps with the Sitemaps report', 'xml-sitemap-feed' ); ?></a>
10
  </li>
11
  <li>
12
- <a href="https://moz.com/blog/xml-sitemaps" target="_blank"><?php _e( /* https://moz.com/blog/xml-sitemaps */ 'XML Sitemaps: The Most Misunderstood Tool in the SEO\'s Toolbox', 'xml-sitemap-feed' ); ?></a>
13
  </li>
14
  </ul>
1
+ <p>
2
+ <strong><?php echo translate('General'); ?></strong>
3
+ </p>
4
+ <ul>
5
+ <li>
6
+ <a href="https://support.google.com/webmasters" target="_blank"><?php _e( /* Translators: Site title https://support.google.com/webmasters */ 'Search Console Help', 'xml-sitemap-feed' ); ?></a>
7
+ </li>
8
+ <li>
9
+ <a href="https://support.google.com/webmasters/community" target="_blank"><?php _e( /* Translators: Forum title https://support.google.com/webmasters/community */ 'Webmasters Help Community', 'xml-sitemap-feed' ); ?></a>
10
+ </li>
11
+ </ul>
12
  <p>
13
  <strong><?php echo translate('For more information:'); ?></strong>
14
  </p>
15
  <ul>
16
  <li>
17
+ <a href="https://developers.google.com/search/docs/advanced/sitemaps/overview" target="_blank"><?php _e( /* Translators: Page title https://developers.google.com/search/docs/advanced/sitemaps/overview */ 'Learn more about sitemaps on Google Search Console Help', 'xml-sitemap-feed' ); ?></a>
18
  </li>
19
  <li>
20
+ <a href="https://support.google.com/webmasters/answer/7451001" target="_blank"><?php _e( /* Translators: Page title https://support.google.com/webmasters/answer/7451001 */ 'Manage sitemaps with the Sitemaps report', 'xml-sitemap-feed' ); ?></a>
21
  </li>
22
  <li>
23
+ <a href="https://moz.com/blog/xml-sitemaps" target="_blank"><?php _e( /* Translators: Page title https://moz.com/blog/xml-sitemaps */ 'XML Sitemaps: The Most Misunderstood Tool in the SEO\'s Toolbox', 'xml-sitemap-feed' ); ?></a>
24
  </li>
25
  </ul>
views/admin/help-tab-sitemaps.php CHANGED
@@ -1,3 +1,11 @@
1
  <p>
2
  <?php _e( 'XML sitemaps list the web pages of your site to tell search engines about the organization of your site content. Search engine web crawlers read this file to more intelligently crawl your site.', 'xml-sitemap-feed' ); ?>
3
  </p>
 
 
 
 
 
 
 
 
1
  <p>
2
  <?php _e( 'XML sitemaps list the web pages of your site to tell search engines about the organization of your site content. Search engine web crawlers read this file to more intelligently crawl your site.', 'xml-sitemap-feed' ); ?>
3
  </p>
4
+ <p>
5
+ <?php _e( 'The options under the different tabs on this page allow you to include different content element sitemaps in the sitemap index.', 'xml-sitemap-feed' ); ?>
6
+ </p>
7
+ <p>
8
+ <!--<strong><?php echo translate('Tools'); ?></strong>
9
+ <br />-->
10
+ <?php _e( 'In the side bar you can find tools related to sitemap generation, debugging and search engines, and links for more information and help. Use the button Reset settings to revert all options to their default.', 'xml-sitemap-feed' ); ?>
11
+ </p>
views/admin/help-tab-support.php CHANGED
File without changes
views/admin/help-tab-taxonomies.php CHANGED
@@ -1,3 +1,13 @@
 
 
 
 
 
 
 
 
 
 
1
  <p>
2
  <strong><?php _e( 'Automatic Priority calculation.', 'xml-sitemap-feed' ); ?></strong>
3
  <br />
1
+ <p>
2
+ <strong><?php _e( 'Include taxonomies', 'xml-sitemap-feed' ); ?></strong>
3
+ <br />
4
+ <?php _e( 'Activate this to include a taxonomy terms sitemap in the sitemap index.', 'xml-sitemap-feed' ); ?>
5
+ </p>
6
+ <p>
7
+ <strong><?php _e( 'Priority', 'xml-sitemap-feed' ); ?></strong>
8
+ <br />
9
+ <?php echo __( 'Priority can be used to signal the importance of taxonomy term archives relative to other content like posts, pages or author archives.', 'xml-sitemap-feed' ); ?>
10
+ </p>
11
  <p>
12
  <strong><?php _e( 'Automatic Priority calculation.', 'xml-sitemap-feed' ); ?></strong>
13
  <br />
views/admin/meta-box-news.php CHANGED
File without changes
views/admin/meta-box.php CHANGED
File without changes
views/admin/notice-aioseop-sitemap.php ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <div class="notice notice-warning fade is-dismissible">
2
+ <p>
3
+ <strong><?php _e('XML Sitemap & Google News','xml-sitemap-feed'); ?></strong>
4
+ </p>
5
+ <p>
6
+ <?php printf( /* translators: Conflicting Plugn name, Plugin name */
7
+ __( 'The %1$s XML Sitemap is not compatible with %2$s.', 'xml-sitemap-feed'),
8
+ translate('All in One SEO Pack','all-in-one-seo-pack'),
9
+ __('XML Sitemap & Google News','xml-sitemap-feed')
10
+ ); ?>
11
+ <?php printf( /* translators: Sitemap page name (linked to SEOPress plugin settings), XML Sitemap Index, Reading Settings admin page (linked to Reading settings) */
12
+ __( 'Please either disable the XML Sitemap under %1$s in your SEO settings or disable the option %2$s on %3$s.', 'xml-sitemap-feed'),
13
+ '<a href="' . admin_url('admin.php') . '?page=all-in-one-seo-pack%2Fmodules%2Faioseop_feature_manager.php">' . translate('Feature Manager','all-in-one-seo-pack') . '</a>',
14
+ __('XML Sitemap Index','xml-sitemap-feed'),
15
+ '<a href="' . admin_url('options-reading.php') . '#xmlsf_sitemaps">' . translate('Reading Settings') . '</a>'
16
+ ); ?>
17
+ </p>
18
+ <form action="" method="post">
19
+ <?php wp_nonce_field( XMLSF_BASENAME.'-notice', '_xmlsf_notice_nonce' ); ?>
20
+ <p>
21
+ <input type="hidden" name="xmlsf-dismiss" value="aioseop_sitemap" />
22
+ <input type="submit" class="button button-small" name="xmlsf-dismiss-submit" value="<?php echo translate('Dismiss'); ?>" />
23
+ </p>
24
+ </form>
25
+ </div>
views/admin/notice-catchbox-feed-redirect.php CHANGED
File without changes
views/admin/notice-seoframework-sitemap.php ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <div class="notice notice-warning fade is-dismissible">
2
+ <p>
3
+ <strong><?php _e('XML Sitemap & Google News','xml-sitemap-feed'); ?></strong>
4
+ </p>
5
+ <p>
6
+ <?php printf( /* translators: Conflicting Plugn name, Plugin name */
7
+ __( 'The %1$s XML Sitemap is not compatible with %2$s.', 'xml-sitemap-feed'),
8
+ translate('The SEO Framework','autodescription'),
9
+ __('XML Sitemap & Google News','xml-sitemap-feed')
10
+ ); ?>
11
+ <?php printf( /* translators: Sitemap tab name (linked to The SEO Framework plugin settings), XML Sitemap Index, Reading Settings admin page (linked to Reading settings) */
12
+ __( 'Please either disable the XML Sitemap under %1$s in your SEO settings or disable the option %2$s on %3$s.', 'xml-sitemap-feed'),
13
+ '<a href="' . admin_url('admin.php') . '?page=theseoframework-settings#autodescription-sitemap-settings">' . translate('Sitemap Settings','autodescription') . '</a>',
14
+ __('XML Sitemap Index','xml-sitemap-feed'),
15
+ '<a href="' . admin_url('options-reading.php') . '#xmlsf_sitemaps">' . translate('Reading Settings') . '</a>'
16
+ ); ?>
17
+ </p>
18
+ <form action="" method="post">
19
+ <?php wp_nonce_field( XMLSF_BASENAME.'-notice', '_xmlsf_notice_nonce' ); ?>
20
+ <p>
21
+ <input type="hidden" name="xmlsf-dismiss" value="seoframework_sitemap" />
22
+ <input type="submit" class="button button-small" name="xmlsf-dismiss-submit" value="<?php echo translate('Dismiss'); ?>" />
23
+ </p>
24
+ </form>
25
+ </div>
views/admin/notice-seopress-date-redirect.php CHANGED
File without changes
views/admin/notice-seopress-sitemap.php CHANGED
File without changes
views/admin/notice-static-files.php CHANGED
@@ -1,17 +1,20 @@
1
  <div class="notice notice-warning fade is-dismissible">
2
  <p>
3
- <strong><?php _e('XML Sitemap & Google News','xml-sitemap-feed'); ?></strong>
4
- </p>
5
- <p>
6
- <?php printf( /* translators: %1$s number of files, %2$s is Reading Settings URL */ _n(
7
- 'The following static file has been found. Either delete it or disable the conflicting <a href="%2$s">sitemap</a>.',
8
- 'The following %1$s static files have been found. Either delete them or disable the conflicting <a href="%2$s">sitemaps</a>.',
9
- $number,'xml-sitemap-feed'), number_format_i18n($number), admin_url('options-reading.php') . '#xmlsf_sitemaps' ); ?>
10
- </p>
 
 
 
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>
1
  <div class="notice notice-warning fade is-dismissible">
2
  <p>
3
+ <strong><?php _e('XML Sitemap & Google News','xml-sitemap-feed'); ?></strong>
4
+ </p>
5
+ <p>
6
+ <?php
7
+ $number = count( self::$static_files );
8
+ printf( /* translators: %1$s number of files, %2$s is Reading Settings URL */ _n(
9
+ 'The following static file has been found. Either delete it or disable the conflicting <a href="%2$s">sitemap</a>.',
10
+ 'The following %1$s static files have been found. Either delete them or disable the conflicting <a href="%2$s">sitemaps</a>.',
11
+ $number,'xml-sitemap-feed'), number_format_i18n($number), admin_url('options-reading.php') . '#xmlsf_sitemaps'
12
+ ); ?>
13
+ </p>
14
  <form action="" method="post">
15
  <?php wp_nonce_field( XMLSF_BASENAME.'-notice', '_xmlsf_notice_nonce' ); ?>
16
  <ul>
17
+ <?php foreach ( self::$static_files as $name => $file) { ?>
18
  <li>
19
  <label><input type="checkbox" name="xmlsf-delete[]" value="<?php echo $name; ?>" /> <strong><?php echo $name; ?></strong> (<?php echo $file; ?>)</label>
20
  </li>
views/admin/notice-wpseo-date-redirect.php CHANGED
File without changes
views/admin/notice-wpseo-sitemap.php CHANGED
File without changes
views/admin/notice-xmlsf-advanced-news.php ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ <div class="notice notice-warning fade is-dismissible">
2
+ <p>
3
+ <strong><?php _e('XML Sitemap & Google News','xml-sitemap-feed'); ?></strong>
4
+ </p>
5
+ <form action="" method="post">
6
+ <?php wp_nonce_field( XMLSF_BASENAME.'-notice', '_xmlsf_notice_nonce' ); ?>
7
+ <input type="hidden" name="xmlsf-dismiss" value="xmlsf_advanced_news" />
8
+ <input type="submit" class="button button-small alignright" name="xmlsf-dismiss-submit" value="<?php echo translate('Dismiss'); ?>" />
9
+ </form>
10
+ <?php include XMLSF_DIR . '/views/admin/section-advanced-compat-message.php'; ?>
11
+ </div>
views/admin/page-sitemap-news.php CHANGED
@@ -1,5 +1,5 @@
1
  <style type="text/css">
2
- <?php include XMLSF_DIR . '/assets/styles/admin.css'; ?>
3
  </style>
4
  <div class="wrap">
5
 
@@ -33,13 +33,19 @@
33
  </div>
34
 
35
  <div class="sidebar">
 
 
 
 
 
 
36
  <h3><span class="dashicons dashicons-welcome-view-site"></span> <?php echo translate('View'); ?></h3>
37
  <p>
38
  <?php
39
  printf (
40
- /* translators: Sitemap name with URL */
41
- __( 'Open your %s', 'xml-sitemap-feed' ),
42
- '<strong><a href="'.$url.'" target="_blank">'.__('Google News Sitemap','xml-sitemap-feed') . '</a></strong><span class="dashicons dashicons-external"></span>'
43
  ); ?>
44
  </p>
45
 
1
  <style type="text/css">
2
+ <?php include XMLSF_DIR . '/assets/admin.css'; ?>
3
  </style>
4
  <div class="wrap">
5
 
33
  </div>
34
 
35
  <div class="sidebar">
36
+
37
+ <?php if ( defined( 'XMLSF_NEWS_ADV_VERSION' ) && version_compare( XMLSF_NEWS_ADV_VERSION, parent::$compat_pro_min, '<' ) ) {
38
+ $class = 'update-nag';
39
+ include XMLSF_DIR . '/views/admin/section-advanced-compat-message.php';
40
+ } ?>
41
+
42
  <h3><span class="dashicons dashicons-welcome-view-site"></span> <?php echo translate('View'); ?></h3>
43
  <p>
44
  <?php
45
  printf (
46
+ /* translators: Sitemap name with URL */
47
+ __( 'Open your %s', 'xml-sitemap-feed' ),
48
+ '<strong><a href="' . home_url( $sitemap ) . '" target="_blank">' . __('Google News Sitemap','xml-sitemap-feed') . '</a></strong><span class="dashicons dashicons-external"></span>'
49
  ); ?>
50
  </p>
51
 
views/admin/page-sitemap.php CHANGED
@@ -1,5 +1,5 @@
1
  <style type="text/css">
2
- <?php include XMLSF_DIR . '/assets/styles/admin.css'; ?>
3
  </style>
4
  <div class="wrap">
5
 
@@ -11,9 +11,11 @@
11
  </p>
12
 
13
  <nav class="nav-tab-wrapper">
14
- <a href="?page=xmlsf&tab=post_types" class="nav-tab <?php echo $active_tab == 'post_types' ? 'nav-tab-active' : ''; ?>"><?php _e('Post types','xml-sitemap-feed'); ?></a>
15
- <a href="?page=xmlsf&tab=taxonomies" class="nav-tab <?php echo $active_tab == 'taxonomies' ? 'nav-tab-active' : ''; ?>"><?php _e('Taxonomies','xml-sitemap-feed'); ?></a>
16
- <a href="?page=xmlsf&tab=advanced" class="nav-tab <?php echo $active_tab == 'advanced' ? 'nav-tab-active' : ''; ?>"><?php echo translate('Advanced'); ?></a>
 
 
17
  </nav>
18
 
19
  <div class="main">
@@ -33,9 +35,9 @@
33
  <p>
34
  <?php
35
  printf (
36
- /* translators: Sitemap name with URL */
37
- __( 'Open your %s', 'xml-sitemap-feed' ),
38
- '<strong><a href="'.$url.'" target="_blank">'.__('XML Sitemap Index','xml-sitemap-feed') . '</a></strong><span class="dashicons dashicons-external"></span>'
39
  ); ?>
40
  </p>
41
 
1
  <style type="text/css">
2
+ <?php include XMLSF_DIR . '/assets/admin.css'; ?>
3
  </style>
4
  <div class="wrap">
5
 
11
  </p>
12
 
13
  <nav class="nav-tab-wrapper">
14
+ <a class="nav-tab<?php echo $active_tab == 'post_types' ? ' nav-tab-active' : '" href="?page=xmlsf&tab=post_types'; ?>"><?php _e('Post types','xml-sitemap-feed'); ?></a>
15
+ <a class="nav-tab<?php echo $active_tab == 'taxonomies' ? ' nav-tab-active' : '" href="?page=xmlsf&tab=taxonomies'; ?>"><?php _e('Taxonomies','xml-sitemap-feed'); ?></a>
16
+ <a class="nav-tab<?php echo $active_tab == 'authors' ? ' nav-tab-active' : '" href="?page=xmlsf&tab=authors'; ?>"><?php _e('Authors','xml-sitemap-feed'); ?></a>
17
+ <a class="nav-tab<?php echo $active_tab == 'advanced' ? ' nav-tab-active' : '" href="?page=xmlsf&tab=advanced'; ?>"><?php echo translate('Advanced'); ?></a>
18
+ <?php do_action( 'xmlsf_sitemap_nav_tabs', $active_tab ); ?>
19
  </nav>
20
 
21
  <div class="main">
35
  <p>
36
  <?php
37
  printf (
38
+ /* translators: Sitemap name with URL */
39
+ __( 'Open your %s', 'xml-sitemap-feed' ),
40
+ '<strong><a href="' . home_url( $sitemap ) . '" target="_blank">' . __('XML Sitemap Index','xml-sitemap-feed') . '</a></strong><span class="dashicons dashicons-external"></span>'
41
  ); ?>
42
  </p>
43
 
views/admin/section-advanced-compat-message.php ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
1
+ <p<?php echo ! empty( $class ) ? ' class="'.$class.'' : '' ?>">
2
+ <?php _e ( 'Your current version of Google News Advanced is outdated. Some advanced options may not be functional.', 'xml-sitemap-feed' ); ?>
3
+ <?php printf (
4
+ __( 'Please <a href="%1$s" target="_blank">download and install the latest version</a>.', 'xml-sitemap-feed' ),
5
+ 'https://premium.status301.com/account/'
6
+ ); ?>
7
+ </p>
views/admin/section-advanced-intro.php CHANGED
File without changes
views/admin/sidebar-contribute.php CHANGED
File without changes
views/admin/sidebar-help.php CHANGED
@@ -1,8 +1,8 @@
1
  <h3><span class="dashicons dashicons-sos"></span> <?php echo translate('Help'); ?></h3>
2
  <p>
3
  <?php printf (
4
- /* translators: Support forum URL on WordPress.org */
5
- __( 'You can find instructions on the help tab above. If you still have questions, please go to the <a href="%s" target="_blank">Support forum</a>.', 'xml-sitemap-feed' ),
6
- 'https://wordpress.org/support/plugin/xml-sitemap-feed'
7
  ); ?>
8
  </p>
1
  <h3><span class="dashicons dashicons-sos"></span> <?php echo translate('Help'); ?></h3>
2
  <p>
3
  <?php printf (
4
+ /* translators: Support forum URL on WordPress.org */
5
+ __( 'You can find instructions on the help tab above. If you still have questions, please go to the <a href="%s" target="_blank">Support forum</a>.', 'xml-sitemap-feed' ),
6
+ 'https://wordpress.org/support/plugin/xml-sitemap-feed'
7
  ); ?>
8
  </p>
views/admin/sidebar-links.php CHANGED
@@ -1,18 +1,18 @@
1
  <h3><span class="dashicons dashicons-admin-links"></span> <?php echo translate('Links'); ?></h3>
2
  <ul>
3
  <li>
4
- <a href="https://search.google.com/search-console" target="_blank"><?php _e( /* https://search.google.com/search-console */ 'Google Search Console', 'xml-sitemap-feed' ); ?></a>
5
  </li>
6
  <li>
7
- <a href="https://www.bing.com/webmaster/home/mysites" target="_blank"><?php _e( /* https://www.bing.com/webmaster/home/mysites */ 'Bing Webmaster Tool', 'xml-sitemap-feed' ); ?></a>
8
  </li>
9
  <li>
10
- <a href="https://ziyuan.baidu.com/site/index" target="_blank"><?php _e( /* https://ziyuan.baidu.com/site/index */ 'Baidu Webmaster Tools', 'xml-sitemap-feed' ); ?></a>
11
  </li>
12
  <li>
13
- <a href="https://webmaster.yandex.com/sites/" target="_blank"><?php _e( /* https://webmaster.yandex.com/sites/ */ 'Yandex.Webmaster', 'xml-sitemap-feed' ); ?></a>
14
  </li>
15
  <li>
16
- <a href="https://www.xml-sitemaps.com/validate-xml-sitemap.html" target="_blank"><?php _e( /* https://www.xml-sitemaps.com/validate-xml-sitemap.html */ 'Validate an XML Sitemap', 'xml-sitemap-feed' ); ?></a>
17
  </li>
18
  </ul>
1
  <h3><span class="dashicons dashicons-admin-links"></span> <?php echo translate('Links'); ?></h3>
2
  <ul>
3
  <li>
4
+ <a href="https://search.google.com/search-console" target="_blank"><?php _e( /* Translators: Site title https://search.google.com/search-console */ 'Google Search Console', 'xml-sitemap-feed' ); ?></a>
5
  </li>
6
  <li>
7
+ <a href="https://www.bing.com/webmasters" target="_blank"><?php _e( /* Translators: Site title https://www.bing.com/webmasters */ 'Bing Webmaster Tools', 'xml-sitemap-feed' ); ?></a>
8
  </li>
9
  <li>
10
+ <a href="https://ziyuan.baidu.com/site/index" target="_blank"><?php _e( /* Translators: Site title https://ziyuan.baidu.com/site/index */ 'Baidu Webmaster Tools', 'xml-sitemap-feed' ); ?></a>
11
  </li>
12
  <li>
13
+ <a href="https://webmaster.yandex.com/sites/" target="_blank"><?php _e( /* Translators: Site title https://webmaster.yandex.com/sites/ */ 'Yandex.Webmaster', 'xml-sitemap-feed' ); ?></a>
14
  </li>
15
  <li>
16
+ <a href="https://www.xml-sitemaps.com/validate-xml-sitemap.html" target="_blank"><?php _e( /* Translators: Page title https://www.xml-sitemaps.com/validate-xml-sitemap.html */ 'Validate an XML Sitemap', 'xml-sitemap-feed' ); ?></a>
17
  </li>
18
  </ul>
views/admin/sidebar-news-links.php CHANGED
@@ -1,7 +1,7 @@
1
  <h3><span class="dashicons dashicons-admin-links"></span> <?php echo translate('Links'); ?></h3>
2
  <ul>
3
  <li>
4
- <a href="https://partnerdash.google.com/partnerdash/d/news#p:id=pfehome" target="_blank"><?php _e( /* https://partnerdash.google.com/partnerdash/d/news#p:id=pfehome */ 'Google News Publisher Center', 'xml-sitemap-feed' ); ?></a>
5
  </li>
6
  <li>
7
  <a href="https://search.google.com/search-console" target="_blank"><?php _e( /* */ 'Google Search Console', 'xml-sitemap-feed' ); ?></a>
1
  <h3><span class="dashicons dashicons-admin-links"></span> <?php echo translate('Links'); ?></h3>
2
  <ul>
3
  <li>
4
+ <a href="https://publishercenter.google.com/publications" target="_blank"><?php _e( /* https://publishercenter.google.com/publications */ 'Google News Publisher Center', 'xml-sitemap-feed' ); ?></a>
5
  </li>
6
  <li>
7
  <a href="https://search.google.com/search-console" target="_blank"><?php _e( /* */ 'Google Search Console', 'xml-sitemap-feed' ); ?></a>
views/feed-sitemap-author.php ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * XML Sitemap Feed Template for displaying an XML Sitemap feed.
4
+ *
5
+ * @package XML Sitemap Feed plugin for WordPress
6
+ */
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
+ '; ?>
13
+ <?php xmlsf_xml_stylesheet( 'author' ); ?>
14
+ <?php xmlsf_generator(); ?>
15
+ <urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
16
+ <?php do_action('xmlsf_urlset', 'home'); ?>
17
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
18
+ xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9
19
+ http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd">
20
+ <?php
21
+ foreach ( xmlsf_get_author_data() as $url => $data ) {
22
+ ?>
23
+ <url>
24
+ <loc><?php echo esc_url( $url ); ?></loc>
25
+ <?php if ( ! empty( $data['priority'] ) ) { ?>
26
+ <priority><?php echo $data['priority']; ?></priority>
27
+ <?php } ?>
28
+ <?php if ( ! empty( $data['lastmod'] ) ) { ?>
29
+ <lastmod><?php echo $data['lastmod']; ?></lastmod>
30
+ <?php } ?>
31
+ <?php do_action( 'xmlsf_tags_after', 'author' ); ?>
32
+ </url>
33
+ <?php
34
+ do_action( 'xmlsf_url_after', 'author' );
35
+ }
36
+ ?>
37
+ </urlset>
38
+ <?php xmlsf_usage(); ?>
views/feed-sitemap-custom.php CHANGED
@@ -9,8 +9,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="' . wp_make_link_relative( 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"
16
  <?php do_action('xmlsf_urlset', 'custom'); ?>
@@ -24,13 +24,12 @@ $urls = apply_filters( 'xmlsf_custom_urls', get_option('xmlsf_urls') );
24
  if ( is_array($urls) ) :
25
  // and loop away!
26
  foreach ( $urls as $url ) {
27
- if (empty($url[0]))
28
- continue;
29
  ?>
30
  <url>
31
  <loc><?php echo esc_url( $url[0] ); ?></loc>
32
  <priority><?php echo ( isset($url[1]) && is_numeric($url[1]) ) ? $url[1] : '0.5'; ?></priority>
33
- <?php do_action( 'xmlsf_tags_after', 'custom' ); ?>
34
  </url>
35
  <?php
36
  do_action( 'xmlsf_url_after', 'custom' );
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
  '; ?>
13
+ <?php xmlsf_xml_stylesheet( 'custom' ); ?>
14
  <?php xmlsf_generator(); ?>
15
  <urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
16
  <?php do_action('xmlsf_urlset', 'custom'); ?>
24
  if ( is_array($urls) ) :
25
  // and loop away!
26
  foreach ( $urls as $url ) {
27
+ if (empty($url[0])) continue;
 
28
  ?>
29
  <url>
30
  <loc><?php echo esc_url( $url[0] ); ?></loc>
31
  <priority><?php echo ( isset($url[1]) && is_numeric($url[1]) ) ? $url[1] : '0.5'; ?></priority>
32
+ <?php do_action( 'xmlsf_tags_after', 'custom' ); ?>
33
  </url>
34
  <?php
35
  do_action( 'xmlsf_url_after', 'custom' );
views/feed-sitemap-home.php CHANGED
File without changes
views/feed-sitemap-news.php CHANGED
@@ -11,59 +11,61 @@ $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="' . wp_make_link_relative( 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
  <?php do_action('xmlsf_urlset', 'news'); ?>
19
  xmlns:news="http://www.google.com/schemas/sitemap-news/0.9">
20
  <?php
21
-
22
- // set empty news sitemap flag
23
- $have_posts = false;
24
-
25
  // loop away!
26
  if ( have_posts() ) :
27
- while ( have_posts() ) :
28
- the_post();
 
 
 
29
 
30
  // check if we are not dealing with an external URL :: Thanks to Francois Deschenes :)
31
  // or if post meta says "exclude me please"
32
  if ( apply_filters(
33
- 'xmlsf_news_excluded',
34
- get_post_meta( $post->ID, '_xmlsf_news_exclude', true ),
35
- $post->ID
36
- ) || !xmlsf_is_allowed_domain( get_permalink() ) )
37
- continue;
 
 
38
 
39
- $have_posts = true;
40
- ?>
41
  <url>
42
  <loc><?php echo esc_url( get_permalink() ); ?></loc>
43
  <news:news>
44
  <news:publication>
45
  <news:name><?php
46
  if( !empty($options['name']) )
47
- echo apply_filters( 'the_title_xmlsitemap', $options['name'] );
48
  elseif(defined('XMLSF_GOOGLE_NEWS_NAME'))
49
- echo apply_filters( 'the_title_xmlsitemap', XMLSF_GOOGLE_NEWS_NAME );
50
  else
51
- echo apply_filters( 'the_title_xmlsitemap', get_bloginfo('name') ); ?></news:name>
52
- <news:language><?php echo xmlsf_get_language( $post->ID ); ?></news:language>
53
  </news:publication>
54
- <news:publication_date><?php echo mysql2date( DATE_W3C, $post->post_date ); ?></news:publication_date>
55
- <news:title><?php echo apply_filters( 'the_title_xmlsitemap', get_the_title() ); ?></news:title>
56
  <news:keywords><?php echo implode( ', ', apply_filters( 'xmlsf_news_keywords', array() ) ); ?></news:keywords>
57
  <news:stock_tickers><?php echo implode( ', ', apply_filters( 'xmlsf_news_stock_tickers', array() ) ); ?></news:stock_tickers>
58
- <?php do_action( 'xmlsf_news_tags_after' ); ?>
59
  </news:news>
 
60
  </url>
61
- <?php
62
- do_action( 'xmlsf_news_url_after' );
63
- endwhile;
64
  endif;
65
 
66
- if ( !$have_posts ) :
67
  // No posts done? Then do at least the homepage to prevent error message in GWT.
68
  ?>
69
  <url>
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
  '; ?>
15
+ <?php xmlsf_xml_stylesheet( 'news' ); ?>
16
  <?php xmlsf_generator(); ?>
17
  <urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
18
  <?php do_action('xmlsf_urlset', 'news'); ?>
19
  xmlns:news="http://www.google.com/schemas/sitemap-news/0.9">
20
  <?php
21
+ global $wp_query, $post;
 
 
 
22
  // loop away!
23
  if ( have_posts() ) :
24
+ $wp_query->in_the_loop = true;
25
+ while ( have_posts() ) :
26
+ //the_post(); // disabled to avoid expensive but useless setup_postdata(), just do:
27
+ // TODO : maybe make our own setup_postdata version?
28
+ $post = $wp_query->next_post();
29
 
30
  // check if we are not dealing with an external URL :: Thanks to Francois Deschenes :)
31
  // or if post meta says "exclude me please"
32
  if ( apply_filters(
33
+ 'xmlsf_news_excluded',
34
+ get_post_meta( $post->ID, '_xmlsf_news_exclude', true ),
35
+ $post->ID
36
+ ) || !xmlsf_is_allowed_domain( get_permalink() )
37
+ ) continue;
38
+
39
+ $did_posts = true;
40
 
41
+ do_action( 'xmlsf_news_url' ); ?>
 
42
  <url>
43
  <loc><?php echo esc_url( get_permalink() ); ?></loc>
44
  <news:news>
45
  <news:publication>
46
  <news:name><?php
47
  if( !empty($options['name']) )
48
+ echo apply_filters( 'xmlsf_news_publication_name', $options['name'] );
49
  elseif(defined('XMLSF_GOOGLE_NEWS_NAME'))
50
+ echo apply_filters( 'xmlsf_news_publication_name', XMLSF_GOOGLE_NEWS_NAME );
51
  else
52
+ echo apply_filters( 'xmlsf_news_publication_name', get_bloginfo('name') ); ?></news:name>
53
+ <news:language><?php echo apply_filters( 'xmlsf_news_language', xmlsf()->blog_language(), $post->ID, $post->post_type ); ?></news:language>
54
  </news:publication>
55
+ <news:publication_date><?php echo get_date_from_gmt( $post->post_date_gmt, DATE_W3C ); ?></news:publication_date>
56
+ <news:title><?php echo apply_filters( 'xmlsf_news_title', get_the_title() ); ?></news:title>
57
  <news:keywords><?php echo implode( ', ', apply_filters( 'xmlsf_news_keywords', array() ) ); ?></news:keywords>
58
  <news:stock_tickers><?php echo implode( ', ', apply_filters( 'xmlsf_news_stock_tickers', array() ) ); ?></news:stock_tickers>
59
+ <?php do_action( 'xmlsf_news_tags_inner' ); ?>
60
  </news:news>
61
+ <?php do_action( 'xmlsf_news_tags_after' ); ?>
62
  </url>
63
+ <?php do_action( 'xmlsf_news_url_after' );
64
+ endwhile;
65
+ $wp_query->in_the_loop = false;
66
  endif;
67
 
68
+ if ( empty( $did_posts ) ) :
69
  // No posts done? Then do at least the homepage to prevent error message in GWT.
70
  ?>
71
  <url>
views/feed-sitemap-post_type.php CHANGED
File without changes
views/feed-sitemap-posttype.php ADDED
@@ -0,0 +1,95 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * XML Sitemap Feed Template for displaying an XML Sitemap feed.
4
+ *
5
+ * @package XML Sitemap Feed plugin for WordPress
6
+ */
7
+
8
+ if ( ! defined( 'WPINC' ) ) die;
9
+
10
+ extract ( xmlsf_do_tags( get_query_var('post_type') ) );
11
+
12
+ global $xmlsf_sitemap;
13
+ $xmlsf_sitemap->prefetch_posts_meta();
14
+
15
+ if ( !empty($image) ) {
16
+ $image_xmlns = ' xmlns:image="http://www.google.com/schemas/sitemap-image/1.1"'.PHP_EOL;
17
+ $image_schema = '
18
+ http://www.google.com/schemas/sitemap-image/1.1
19
+ http://www.google.com/schemas/sitemap-image/1.1/sitemap-image.xsd';
20
+ } else {
21
+ $image_xmlns = '';
22
+ $image_schema = '';
23
+ }
24
+
25
+ // do xml tag via echo or SVN parser is going to freak out
26
+ echo '<?xml version="1.0" encoding="' . get_bloginfo('charset') . '"?>
27
+ '; ?>
28
+ <?php xmlsf_xml_stylesheet( 'posttype' ); ?>
29
+ <?php xmlsf_generator(); ?>
30
+ <urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
31
+ <?php do_action('xmlsf_urlset', 'post_type'); ?>
32
+ <?php echo $image_xmlns; ?>
33
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
34
+ xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9
35
+ http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd<?php echo $image_schema; ?>">
36
+ <?php
37
+ global $wp_query, $post;
38
+ // loop away!
39
+ if ( have_posts() ) :
40
+ while ( have_posts() ) :
41
+ // don't do the_post() here to avoid expensive setup_postdata(), just do:
42
+ $wp_query->in_the_loop = true;
43
+ $post = $wp_query->next_post();
44
+
45
+ // check if page is in the exclusion list (like front page or post meta)
46
+ // or if we are dealing with an external URL :: Thanks to Francois Deschenes :)
47
+ if ( $post->ID == get_option('page_on_front')
48
+ || apply_filters( 'xmlsf_excluded', get_post_meta( $post->ID, '_xmlsf_exclude', true ), $post->ID )
49
+ || !xmlsf_is_allowed_domain( get_permalink() )
50
+ ) continue;
51
+
52
+ $did_posts = true;
53
+
54
+ do_action( 'xmlsf_url', 'post_type' );
55
+ ?>
56
+ <url>
57
+ <loc><?php echo esc_url( get_permalink() ); ?></loc>
58
+ <priority><?php echo xmlsf_get_post_priority(); ?></priority>
59
+ <?php if ( $lastmod = xmlsf_get_post_modified() ) { ?>
60
+ <lastmod><?php echo $lastmod; ?></lastmod>
61
+ <?php } ?>
62
+ <?php
63
+ if ( !empty($image) ) :
64
+ foreach ( get_post_meta( $post->ID, '_xmlsf_image_'.$image ) as $img_data ) {
65
+
66
+ if ( empty($img_data['loc']) )
67
+ continue; ?>
68
+ <image:image>
69
+ <image:loc><?php echo utf8_uri_encode( $img_data['loc'] ); ?></image:loc>
70
+ <?php if ( !empty($img_data['title']) ) { ?>
71
+ <image:title><![CDATA[<?php echo str_replace(']]>', ']]&gt;', $img_data['title']); ?>]]></image:title>
72
+ <?php }; if ( !empty($img_data['caption']) ) { ?>
73
+ <image:caption><![CDATA[<?php echo str_replace(']]>', ']]&gt;', $img_data['caption']); ?>]]></image:caption>
74
+ <?php }
75
+ do_action( 'xmlsf_image_tags_inner', 'post_type' ); ?>
76
+ </image:image>
77
+ <?php }
78
+ endif;
79
+ do_action( 'xmlsf_tags_after', 'post_type' ); ?>
80
+ </url>
81
+ <?php do_action( 'xmlsf_url_after', 'post_type' );
82
+ endwhile;
83
+ endif;
84
+
85
+ if ( empty( $did_posts ) ) :
86
+ // No posts done? Then do at least the homepage to prevent error message in GWT.
87
+ ?>
88
+ <url>
89
+ <loc><?php echo esc_url( home_url() ); ?></loc>
90
+ <priority>1.0</priority>
91
+ </url>
92
+ <?php
93
+ endif;
94
+ ?></urlset>
95
+ <?php xmlsf_usage(); ?>
views/feed-sitemap-root.php ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * XML Sitemap Feed Template for displaying an XML Sitemap feed.
4
+ *
5
+ * @package XML Sitemap Feed plugin for WordPress
6
+ */
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
+ '; ?>
13
+ <?php xmlsf_xml_stylesheet( 'root' ); ?>
14
+ <?php xmlsf_generator(); ?>
15
+ <urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
16
+ <?php do_action('xmlsf_urlset', 'home'); ?>
17
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
18
+ xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9
19
+ http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd">
20
+ <?php
21
+ foreach ( xmlsf_get_root_data() as $url => $data ) {
22
+ ?>
23
+ <url>
24
+ <loc><?php echo esc_url( $url ); ?></loc>
25
+ <priority><?php echo $data['priority']; ?></priority>
26
+ <lastmod><?php echo $data['lastmod']; ?></lastmod>
27
+ <?php do_action( 'xmlsf_tags_after', 'home' ); ?>
28
+ </url>
29
+ <?php
30
+ do_action( 'xmlsf_url_after', 'home' );
31
+ }
32
+ ?>
33
+ </urlset>
34
+ <?php xmlsf_usage(); ?>
views/feed-sitemap-taxonomy.php CHANGED
@@ -7,18 +7,18 @@
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="' . wp_make_link_relative( 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"
16
- <?php do_action('xmlsf_urlset', 'taxonomy'); ?>
17
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
18
  xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9
19
  http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd">
20
  <?php
21
- $terms = get_terms( get_query_var('taxonomy') );
22
 
23
  if ( is_array($terms) ) :
24
  foreach ( $terms as $term ) :
7
 
8
  if ( ! defined( 'WPINC' ) ) die;
9
 
10
+ // do xml prolog via echo or plugin repository SVN parser is going to freak out
11
  echo '<?xml version="1.0" encoding="' . get_bloginfo('charset') . '"?>
 
12
  '; ?>
13
+ <?php xmlsf_xml_stylesheet( 'taxonomy' ); ?>
14
  <?php xmlsf_generator(); ?>
15
  <urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
16
+ <?php do_action( 'xmlsf_urlset', 'taxonomy' ); ?>
17
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
18
  xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9
19
  http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd">
20
  <?php
21
+ $terms = get_terms( array('taxonomy'=>get_query_var('taxonomy')) );
22
 
23
  if ( is_array($terms) ) :
24
  foreach ( $terms as $term ) :
views/feed-sitemap.php CHANGED
@@ -8,43 +8,43 @@
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="' . wp_make_link_relative( 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"
16
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
17
  xsi:schemaLocation="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( DATE_W3C, 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 ) )
29
  continue;
30
 
31
- $archive = isset($settings['archive']) ? $settings['archive'] : '';
32
 
33
- foreach ( xmlsf_get_archives($post_type,$archive) as $m => $url ) {
34
  ?>
35
  <sitemap>
36
  <loc><?php echo $url; ?></loc>
37
- <lastmod><?php echo mysql2date( DATE_W3C, get_lastmodified( 'blog', $post_type, $m ) ); ?></lastmod>
38
  </sitemap>
39
  <?php
40
  }
41
  }
42
  endif;
43
 
44
- // add rules for public taxonomies
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 } ?>
@@ -52,23 +52,32 @@ foreach ( xmlsf_get_taxonomies() as $taxonomy ) : ?>
52
  <?php
53
  endforeach;
54
 
 
 
 
 
 
 
 
 
 
55
  // custom URLs sitemap
56
- if ( apply_filters( 'xmlsf_custom_urls', get_option('xmlsf_urls') ) ) :
57
  ?>
58
  <sitemap>
59
- <loc><?php echo xmlsf_get_index_url('custom'); ?></loc>
60
  </sitemap>
61
  <?php
62
  endif;
63
 
64
  // custom sitemaps
65
- $custom_sitemaps = apply_filters( 'xmlsf_custom_sitemaps', get_option('xmlsf_custom_sitemaps', array()) );
66
- if ( is_array($custom_sitemaps) ) :
67
  foreach ( $custom_sitemaps as $url ) {
68
- if (empty($url)) continue;
69
  ?>
70
  <sitemap>
71
- <loc><?php echo esc_url($url); ?></loc>
72
  </sitemap>
73
  <?php
74
  }
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
+ <?php xmlsf_xml_stylesheet(); ?>
 
13
  <?php xmlsf_generator(); ?>
14
  <sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
15
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
16
  xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9
17
  http://www.sitemaps.org/schemas/sitemap/0.9/siteindex.xsd">
18
  <sitemap>
19
+ <loc><?php echo xmlsf_get_index_url(); ?></loc>
20
+ <lastmod><?php echo get_date_from_gmt( get_lastpostdate( 'GMT' ), DATE_W3C ); ?></lastmod>
21
  </sitemap>
22
  <?php
23
+
24
+ // public post types
25
+ $post_types = (array) apply_filters( 'xmlsf_post_types', get_option( 'xmlsf_post_types', array() ) );
26
+ if ( ! empty( $post_types ) ) :
27
  foreach ( $post_types as $post_type => $settings ) {
28
+ if ( empty( $settings['active'] ) || ! post_type_exists( $post_type ) )
29
  continue;
30
 
31
+ $archive = isset( $settings['archive'] ) ? $settings['archive'] : '';
32
 
33
+ foreach ( xmlsf_get_index_archive_data( $post_type, $archive ) as $url => $lastmod ) {
34
  ?>
35
  <sitemap>
36
  <loc><?php echo $url; ?></loc>
37
+ <lastmod><?php echo $lastmod; ?></lastmod>
38
  </sitemap>
39
  <?php
40
  }
41
  }
42
  endif;
43
 
44
+ // public taxonomies
45
  foreach ( xmlsf_get_taxonomies() as $taxonomy ) : ?>
46
  <sitemap>
47
+ <loc><?php echo xmlsf_get_index_url( 'taxonomy', array( 'type' => $taxonomy ) ); ?></loc>
48
  <?php if ( $lastmod = xmlsf_get_taxonomy_modified( $taxonomy ) ) { ?>
49
  <lastmod><?php echo $lastmod; ?></lastmod>
50
  <?php } ?>
52
  <?php
53
  endforeach;
54
 
55
+ // authors
56
+ if ( xmlsf_do_authors() ) : ?>
57
+ <sitemap>
58
+ <loc><?php echo xmlsf_get_index_url( 'author' ); ?></loc>
59
+ <lastmod><?php echo get_date_from_gmt( get_lastpostdate( 'GMT' ), DATE_W3C ); ?></lastmod>
60
+ </sitemap>
61
+ <?php
62
+ endif;
63
+
64
  // custom URLs sitemap
65
+ if ( apply_filters( 'xmlsf_custom_urls', get_option( 'xmlsf_urls' ) ) ) :
66
  ?>
67
  <sitemap>
68
+ <loc><?php echo xmlsf_get_index_url( 'custom' ); ?></loc>
69
  </sitemap>
70
  <?php
71
  endif;
72
 
73
  // custom sitemaps
74
+ $custom_sitemaps = apply_filters( 'xmlsf_custom_sitemaps', get_option( 'xmlsf_custom_sitemaps', array() ) );
75
+ if ( is_array( $custom_sitemaps ) ) :
76
  foreach ( $custom_sitemaps as $url ) {
77
+ if ( empty( $url ) ) continue;
78
  ?>
79
  <sitemap>
80
+ <loc><?php echo esc_url( $url ); ?></loc>
81
  </sitemap>
82
  <?php
83
  }
xml-sitemap.php CHANGED
@@ -1,80 +1,98 @@
1
  <?php
2
  /*
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
7
  Text Domain: xml-sitemap-feed
8
  Requires at least: 4.6
9
- Requires PHP: 5.4
10
  Author: RavanH
11
- Author URI: http://status301.net/
12
  */
13
 
14
- define( 'XMLSF_VERSION', '5.2.7' );
 
 
 
 
15
 
16
- /* Copyright 2019 RavanH
17
- http://status301.net/
18
- mailto: ravanhagen@gmail.com
19
 
20
- This program is free software; you can redistribute it and/or modify
21
- it under the terms of the GNU General Public License version 3 as
22
- published by the Free Software Foundation.
23
-
24
- This program is distributed in the hope that it will be useful,
25
- but WITHOUT ANY WARRANTY; without even the implied warranty of
26
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
27
- GNU General Public License for more details.
28
- */
29
 
30
- /* --------------------
 
31
  * AVAILABLE HOOKS
32
  * --------------------
33
  *
34
  * FILTERS
35
- * xmlsf_defaults -> Filters the default array values for different option groups.
36
- * xmlsf_allowed_domain -> Filters the response when checking the url against allowed domains.
37
- * Passes variable $url; must return true or false.
38
- * xmlsf_excluded -> Filters the response when checking the post for exclusion flags in
39
- * XML Sitemap context. Passes variable $post_id; must return true or false.
40
- * xmlsf_news_excluded -> Filters the response when checking the post for exclusion flags in
41
- * Google News sitemap context. Passes variable $post_id; must return true or false.
42
- * xmlsf_news_keywords -> Filters the news keywords array
43
- * xmlsf_news_stock_tickers -> Filters the news stock tickers array
44
- * xmlsf_disabled_taxonomies -> Filters the taxonomies that should be unavailable for sitemaps
45
- * Passes an array of taxonomies to exclude; must return an array.
46
- * the_title_xmlsitemap -> Filters the Google News publication name and title, plus
47
- * the Image title and caption tags.
48
- * xmlsf_custom_urls -> Filters the custom urls array
49
- * xmlsf_custom_sitemaps -> Filters the custom sitemaps array
50
- * xmlsf_post_language -> Filters the post language tag used in the news sitemap.
51
- * Passes variable $post_id; must return a 2 or 3 letter
52
- * language ISO 639 code with the exception of zh-cn and zh-tw.
53
- * xmlsf_post_types -> Filters the post types array for the XML sitemaps index.
54
- * xmlsf_post_priority -> Filters a post priority value. Passes variables $priority and $post->ID.
55
- * Must return a float value between 0.1 and 1.0
56
- * xmlsf_term_priority -> Filters a taxonomy term priority value. Passes variables $priority and $term->slug.
57
- * Must return a float value between 0.1 and 1.0
58
- * xmlsf_news_post_types -> Filters the post types array for the Google News sitemap settings page.
 
 
 
 
 
 
 
 
59
  *
60
  * ACTIONS
 
61
  * xmlsf_ping -> Fires when a search engine has been pinged. Carries four arguments:
62
- * search engine (google|bing), sitemap name, full ping url, ping repsonse code.
63
- * xmlsf_urlset -> Fired inside each sitemap urlset tag. Can be used to
64
  * echo additional XML namespaces. Passes parameter home|post_type|taxonomy|custom
65
- * to allow identification of the current sitemap.
 
 
 
 
 
66
  * xmlsf_tags_after -> Fired inside the XML Sitemap loop at the end of the tags, just before each
67
  * closing </url> is generated. Can be used to echo custom tags or trigger another
68
  * action in the background. Passes parameter home|post_type|taxonomy|custom
69
- * to allow identification of the current sitemap.
70
  * xmlsf_url_after -> Fired inside the XML Sitemap loop after each url node. Can be used to append
71
  * alternative url or trigger another action in the background. Passes parameter
72
- * home|post_type|taxonomy|custom to allow identification of the current sitemap.
73
  * xmlsf_news_urlset -> Fired inside the Google News Sitemap urlset tag. Can be used to
74
  * echo additional XML namespaces.
75
- * xmlsf_news_tags_after -> Fired inside the Google News Sitemap loop at the end of the news
76
  * tags, just before each closing </news:news> is generated. Can be used to
77
- * echo custom tags or trigger another action in the background.
 
 
 
78
  * xmlsf_news_url_after -> Fired inside the Google News Sitemap loop after each news url node.
79
  * Can be used to append alternative url or trigger another action in the background.
80
  * xmlsf_news_settings_before -> Fired before the Google News Sitemap settings form
@@ -96,20 +114,253 @@ define( 'XMLSF_DIR', dirname(__FILE__) );
96
 
97
  define( 'XMLSF_BASENAME', plugin_basename(__FILE__) );
98
 
99
- require XMLSF_DIR . '/models/functions.php';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
100
 
101
- require XMLSF_DIR . '/controllers/functions.php';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
102
 
103
- if ( is_admin() ) {
104
- require XMLSF_DIR . '/controllers/class.xmlsf-admin.php';
105
  }
106
 
107
- // main plugin init
108
- add_action( 'init', 'xmlsf_init' );
 
 
 
 
 
 
 
 
109
 
110
- // add rewrite rules
111
- add_filter( 'rewrite_rules_array', 'xmlsf_rewrite_rules', 99, 1 );
 
 
 
 
 
 
 
112
 
113
- register_activation_hook( __FILE__, 'xmlsf_activate' );
 
 
 
 
 
 
 
114
 
115
- register_deactivation_hook( __FILE__, 'xmlsf_deactivate' );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  <?php
2
  /*
3
  Plugin Name: XML Sitemap & Google News
4
+ Plugin URI: https://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.3.2
7
  Text Domain: xml-sitemap-feed
8
  Requires at least: 4.6
9
+ Requires PHP: 5.6
10
  Author: RavanH
11
+ Author URI: https://status301.net/
12
  */
13
 
14
+ define( 'XMLSF_VERSION', '5.3.2' );
15
+ /**
16
+ * Copyright 2021 RavanH
17
+ * https://status301.net/
18
+ * mailto: ravanhagen@gmail.com
19
 
20
+ * This program is free software; you can redistribute it and/or modify
21
+ * it under the terms of the GNU General Public License version 3 as
22
+ * published by the Free Software Foundation.
23
 
24
+ * This program is distributed in the hope that it will be useful,
25
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
26
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
27
+ * GNU General Public License for more details.
28
+ */
 
 
 
 
29
 
30
+ /**
31
+ * --------------------
32
  * AVAILABLE HOOKS
33
  * --------------------
34
  *
35
  * FILTERS
36
+ *
37
+ * xmlsf_defaults -> Filters the default array values for different option groups.
38
+ * xmlsf_request -> Filters request when an xml sitemap request is found,
39
+ * can be used for plugin compatibility.
40
+ * xmlsf_news_request -> Filters request when a news sitemap request is found
41
+ * can be used for plugin compatibility.
42
+ * xmlsf_allowed_domain -> Filters the response when checking the url against allowed domains.
43
+ * Passes variable $url; must return true or false.
44
+ * xmlsf_index_url_args -> Filters the index url arguments array
45
+ * xmlsf_excluded -> Filters the response when checking the post for exclusion flags in
46
+ * XML Sitemap context. Passes the post exclusion flag and $post_id; must return true or false.
47
+ * xmlsf_news_excluded -> Filters the response when checking the post for exclusion flags in
48
+ * Google News sitemap context. Passes variable $post_id; must exclusion flag, return true or false.
49
+ * xmlsf_news_keywords -> Filters the news keywords array
50
+ * xmlsf_news_stock_tickers -> Filters the news stock tickers array
51
+ * xmlsf_disabled_taxonomies -> Filters the taxonomies that should be unavailable for sitemaps
52
+ * Passes an array of taxonomies to exclude; must return an array.
53
+ * the_title_xmlsitemap -> Filters the Image title and caption tags.
54
+ * xmlsf_news_publication_name-> Filters the Google News publication name.
55
+ * xmlsf_news_title -> Filters the Google News post title.
56
+ * xmlsf_root_data -> Filters the root data urls (with priority and lastmod) array
57
+ * xmlsf_custom_urls -> Filters the custom urls array
58
+ * xmlsf_custom_sitemaps -> Filters the custom sitemaps array
59
+ * xmlsf_post_language -> Filters the post language tag used in the news sitemap.
60
+ * Passes variable $post_id; must return a 2 or 3 letter
61
+ * language ISO 639 code with the exception of zh-cn and zh-tw.
62
+ * xmlsf_post_types -> Filters the post types array for the XML sitemaps index.
63
+ * xmlsf_post_priority -> Filters a post priority value. Passes variables $priority and $post->ID.
64
+ * Must return a float value between 0.1 and 1.0
65
+ * xmlsf_term_priority -> Filters a taxonomy term priority value. Passes variables $priority and $term->slug.
66
+ * Must return a float value between 0.1 and 1.0
67
+ * xmlsf_news_post_types -> Filters the post types array for the Google News sitemap settings page.
68
  *
69
  * ACTIONS
70
+ *
71
  * xmlsf_ping -> Fires when a search engine has been pinged. Carries four arguments:
72
+ * search engine (google|bing), sitemap name, full ping url, ping repsonse code.
73
+ * xmlsf_urlset -> Fired inside each sitemap's urlset tag. Can be used to
74
  * echo additional XML namespaces. Passes parameter home|post_type|taxonomy|custom
75
+ * to allow identification of the current sitemap.
76
+ * xmlsf_url -> Fired inside the XML Sitemap loop at the start of each sitemap url tag. Can be used to
77
+ * echo additional XML namespaces. Passes parameter home|post_type|taxonomy|custom
78
+ * to allow identification of the current sitemap.
79
+ * xmlsf_image_tags_inner -> Fired inside the XML Sitemap loop just before each closing </image:image> is generated. Can be used to
80
+ * echo custom <image:image> tags or trigger another action in the background.
81
  * xmlsf_tags_after -> Fired inside the XML Sitemap loop at the end of the tags, just before each
82
  * closing </url> is generated. Can be used to echo custom tags or trigger another
83
  * action in the background. Passes parameter home|post_type|taxonomy|custom
84
+ * to allow identification of the current sitemap.
85
  * xmlsf_url_after -> Fired inside the XML Sitemap loop after each url node. Can be used to append
86
  * alternative url or trigger another action in the background. Passes parameter
87
+ * home|post_type|taxonomy|custom to allow identification of the current sitemap.
88
  * xmlsf_news_urlset -> Fired inside the Google News Sitemap urlset tag. Can be used to
89
  * echo additional XML namespaces.
90
+ * xmlsf_news_tags_inner -> Fired inside the Google News Sitemap loop at the end of the news
91
  * tags, just before each closing </news:news> is generated. Can be used to
92
+ * echo custom news:news tags or trigger another action in the background.
93
+ * xmlsf_news_tags_after -> Fired inside the Google News Sitemap loop at the end of the news
94
+ * tags, just before each closing </url> is generated. Can be used to
95
+ * echo custom news tags or trigger another action in the background.
96
  * xmlsf_news_url_after -> Fired inside the Google News Sitemap loop after each news url node.
97
  * Can be used to append alternative url or trigger another action in the background.
98
  * xmlsf_news_settings_before -> Fired before the Google News Sitemap settings form
114
 
115
  define( 'XMLSF_BASENAME', plugin_basename(__FILE__) );
116
 
117
+ // main plugin init
118
+ add_action( 'init', 'xmlsf_init', 9 );
119
+
120
+ register_activation_hook( __FILE__, 'xmlsf_activate' );
121
+
122
+ register_deactivation_hook( __FILE__, 'xmlsf_deactivate' );
123
+
124
+ /***********************
125
+ * CONTROLLERS
126
+ ***********************/
127
+
128
+ /**
129
+ * Plugin initialization
130
+ *
131
+ * @since 1.0
132
+ * @return void
133
+ */
134
+ function xmlsf_init() {
135
+
136
+ // add robots.txt filter
137
+ add_filter( 'robots_txt', 'xmlsf_robots_txt', 9 );
138
+
139
+ // Upgrade/install, maybe...
140
+ $db_version = get_option( 'xmlsf_version', 0 );
141
+ if ( ! version_compare( XMLSF_VERSION, $db_version, '=' ) ) {
142
+ require_once XMLSF_DIR . '/upgrade.php';
143
+ new XMLSitemapFeed_Upgrade( $db_version );
144
+ }
145
+
146
+ if ( is_admin() ) {
147
+ require XMLSF_DIR . '/controllers/class.xmlsf-admin.php';
148
+ new XMLSF_Admin();
149
+ }
150
 
151
+ $sitemaps = get_option( 'xmlsf_sitemaps' );
152
+
153
+ // return if nothing enabled
154
+ if ( empty( $sitemaps ) ) return;
155
+
156
+ // main model functions
157
+ require XMLSF_DIR . '/models/functions.shared.php';
158
+
159
+ // force remove url trailing slash
160
+ add_filter( 'user_trailingslashit', 'xmlsf_untrailingslash' );
161
+
162
+ // MAIN REQUEST filter
163
+ add_filter( 'request', 'xmlsf_filter_request', 0 );
164
+
165
+ // NGINX HELPER PURGE URLS
166
+ add_filter( 'rt_nginx_helper_purge_urls', 'xmlsf_nginx_helper_purge_urls', 10, 2 );
167
+
168
+ // main controller functions
169
+ require XMLSF_DIR . '/controllers/functions.shared.php';
170
+
171
+ add_action( 'xmlsf_ping', 'xmlsf_debug_ping', 9, 4 );
172
+
173
+ // include and instantiate main class
174
+ xmlsf();
175
+
176
+ if ( ! empty( $sitemaps['sitemap'] ) ) {
177
+ //add_rewrite_rule('sitemap(?:_index)?(\-[a-z0-9\-_]+)?(\.\d{4,6})?(\.\d{1,2})?\.xml(\.gz)?$', 'index.php?feed=sitemap$matches[1]$matches[4]&m=$matches[2]&w=$matches[3]', 'top');
178
+
179
+ require XMLSF_DIR . '/models/functions.sitemap.php';
180
+ add_filter( 'xmlsf_post_types', 'xmlsf_filter_post_types' );
181
+
182
+ // sitemap title element filters
183
+ add_filter( 'the_title_xmlsitemap', 'strip_tags' );
184
+ add_filter( 'the_title_xmlsitemap', 'ent2ncr', 8 );
185
+ add_filter( 'the_title_xmlsitemap', 'esc_html' );
186
+
187
+ global $xmlsf_sitemap;
188
+ require XMLSF_DIR . '/controllers/class.xmlsf-sitemap.php';
189
+ $xmlsf_sitemap = new XMLSF_Sitemap( $sitemaps['sitemap'] );
190
+
191
+ // replace core sitemap
192
+ remove_action( 'init', 'wp_sitemaps_get_server' );
193
+ }
194
+
195
+ if ( ! empty( $sitemaps['sitemap-news'] ) ) {
196
+ //add_rewrite_rule('sitemap-news\.xml(\.gz)?$', 'index.php?feed=sitemap-news$matches[1]', 'top');
197
+
198
+ require XMLSF_DIR . '/models/functions.sitemap-news.php';
199
+ add_filter( 'xmlsf_news_post_types', 'xmlsf_news_filter_post_types' );
200
+
201
+ // common sitemap element filters
202
+ add_filter( 'xmlsf_news_publication_name', 'strip_tags' );
203
+ add_filter( 'xmlsf_news_publication_name', 'ent2ncr', 8 );
204
+ add_filter( 'xmlsf_news_publication_name', 'esc_html' );
205
+ add_filter( 'xmlsf_news_title', 'strip_tags' );
206
+ add_filter( 'xmlsf_news_title', 'ent2ncr', 8 );
207
+ add_filter( 'xmlsf_news_title', 'esc_html' );
208
+
209
+ require XMLSF_DIR . '/controllers/class.xmlsf-sitemap-news.php';
210
+ new XMLSF_Sitemap_News( $sitemaps['sitemap-news'] );
211
+ }
212
 
 
 
213
  }
214
 
215
+ /**
216
+ * Plugin activation
217
+ *
218
+ * @since 5.0
219
+ * @return void
220
+ */
221
+ function xmlsf_activate() {
222
+ set_transient( 'xmlsf_flush_rewrite_rules', '' );
223
+ set_transient( 'xmlsf_check_static_files', '' );
224
+ }
225
 
226
+ /**
227
+ * Plugin de-activation
228
+ *
229
+ * @since 5.0
230
+ * @return void
231
+ */
232
+ function xmlsf_deactivate() {
233
+ delete_transient( 'xmlsf_flush_rewrite_rules' );
234
+ delete_transient( 'xmlsf_check_static_files' );
235
 
236
+ // remove metadata
237
+ global $wpdb;
238
+ // posts meta
239
+ $wpdb->delete( $wpdb->prefix.'postmeta', array( 'meta_key' => '_xmlsf_image_attached' ) );
240
+ $wpdb->delete( $wpdb->prefix.'postmeta', array( 'meta_key' => '_xmlsf_image_featured' ) );
241
+ $wpdb->delete( $wpdb->prefix.'postmeta', array( 'meta_key' => '_xmlsf_comment_date_gmt' ) );
242
+ // terms meta
243
+ $wpdb->delete( $wpdb->prefix.'termmeta', array( 'meta_key' => 'term_modified' ) );
244
 
245
+ // remove rules so they can be REGENERATED on the next page load (without this plugin active)
246
+ delete_option( 'rewrite_rules' );
247
+
248
+ }
249
+
250
+ /*****************
251
+ * MODELS
252
+ *****************/
253
+
254
+ /**
255
+ * Get instantiated sitemap class
256
+ *
257
+ * @since 5.0
258
+ *
259
+ * @global XMLSitemapFeed $xmlsf
260
+ * @return XMLSitemapFeed object
261
+ */
262
+ function xmlsf() {
263
+ global $xmlsf;
264
+
265
+ if ( ! isset( $xmlsf ) ) {
266
+ if ( ! class_exists( 'XMLSitemapFeed' ) )
267
+ require XMLSF_DIR . '/models/class-xmlsitemapfeed.php';
268
+
269
+ $xmlsf = new XMLSitemapFeed();
270
+ }
271
+
272
+ return $xmlsf;
273
+ }
274
+
275
+ /**
276
+ * Filter robots.txt rules
277
+ *
278
+ * @param $output
279
+ * @return string
280
+ */
281
+ function xmlsf_robots_txt( $output ) {
282
+ $url = trailingslashit( get_bloginfo('url') );
283
+
284
+ $sitemaps = get_option( 'xmlsf_sitemaps' );
285
+
286
+ // PRE
287
+ $pre = '# XML Sitemap & Google News version ' . XMLSF_VERSION . ' - https://status301.net/wordpress-plugins/xml-sitemap-feed/' . PHP_EOL;
288
+ if ( '1' != get_option('blog_public') )
289
+ $pre .= '# XML Sitemaps are disabled because of this site\'s privacy settings.' . PHP_EOL;
290
+ elseif( !is_array($sitemaps) || empty( $sitemaps ) )
291
+ $pre .= '# No XML Sitemaps are enabled on this site.' . PHP_EOL;
292
+ else
293
+ foreach ( $sitemaps as $pretty )
294
+ $pre .= 'Sitemap: ' . $url . $pretty . PHP_EOL;
295
+ $pre .= PHP_EOL;
296
+
297
+ // DEFAULT
298
+ if ( substr($output, -1) !== PHP_EOL ) $output .= PHP_EOL;
299
+
300
+ // POST
301
+ $post = get_option('xmlsf_robots');
302
+ if ( $post !== '' ) $post .= PHP_EOL;
303
+
304
+ return $pre . $output . $post;
305
+ }
306
+
307
+ /* --------------------------------
308
+ * CONDITIONAL FUNCTIONS
309
+ * -------------------------------- */
310
+
311
+ /**
312
+ * Is the query for a sitemap?
313
+ *
314
+ * @since 4.8
315
+ * @return bool
316
+ */
317
+ function is_sitemap() {
318
+ global $xmlsf;
319
+ if ( ! is_object( $xmlsf ) || $xmlsf->request_filtered === false ) {
320
+ _doing_it_wrong( __FUNCTION__, __( 'Conditional sitemap tags do not work before the sitemap request filter is run. Before then, they always return false.', 'xml-sitemap-feed' ), '4.8' );
321
+ return false;
322
+ }
323
+ return $xmlsf->is_sitemap;
324
+ }
325
+
326
+ /**
327
+ * Is the query for a news sitemap?
328
+ *
329
+ * @since 4.8
330
+ * @return bool
331
+ */
332
+ function is_news() {
333
+ global $xmlsf;
334
+ if ( ! is_object( $xmlsf ) || $xmlsf->request_filtered === false ) {
335
+ _doing_it_wrong( __FUNCTION__, __( 'Conditional sitemap tags do not work before the sitemap request filter is run. Before then, they always return false.', 'xml-sitemap-feed' ), '4.8' );
336
+ return false;
337
+ }
338
+ return $xmlsf->is_news;
339
+ }
340
+
341
+ // TODO start with namespacing and autoload
342
+ // http://justintadlock.com/archives/2018/12/14/php-namespaces-for-wordpress-developers
343
+ /*
344
+ spl_autoload_register( function( $class ) {
345
+
346
+ $namespace = 'Justin\\';
347
+ $path = 'src';
348
+
349
+ // Bail if the class is not in our namespace.
350
+ if ( 0 !== strpos( $class, $namespace ) ) {
351
+ return;
352
+ }
353
+
354
+ // Remove the namespace.
355
+ $class = str_replace( $namespace, '', $class );
356
+
357
+ // Build the filename.
358
+ $file = realpath( __DIR__ . "/{$path}" );
359
+ $file = $file . DIRECTORY_SEPARATOR . str_replace( '\\', DIRECTORY_SEPARATOR, $class ) . '.php';
360
+
361
+ // If the file exists for the class name, load it.
362
+ if ( file_exists( $file ) ) {
363
+ include( $file );
364
+ }
365
+ } );
366
+ */