Version Description
New FactCheck genre. Remove changefreq tag. Fix permalink issue with Woocommerce account page endpoints.
=
Download this release
Release Info
Developer | RavanH |
Plugin | XML Sitemap & Google News feeds |
Version | 4.9 |
Comparing to | |
See all releases |
Code changes from version 4.8.3 to 4.9
- .gitignore +0 -18
- LICENSE +0 -339
- README.md +0 -3
- includes/class-xmlsitemapfeed-admin.php +133 -94
- includes/class-xmlsitemapfeed.php +373 -354
- includes/feed-sitemap-custom.php +1 -1
- includes/feed-sitemap-home.php +1 -10
- includes/feed-sitemap-news.php +1 -1
- includes/feed-sitemap-post_type.php +1 -2
- includes/feed-sitemap-taxonomy.php +1 -2
- includes/feed-sitemap.php +1 -1
- includes/functions.php +4 -4
- includes/xsl/sitemap-index.xsl +3 -3
- includes/xsl/sitemap.xsl +3 -5
- readme.txt +2 -4
- uninstall.php +11 -12
- xml-sitemap.php +9 -13
.gitignore
DELETED
@@ -1,18 +0,0 @@
|
|
1 |
-
*.log
|
2 |
-
.htaccess
|
3 |
-
sitemap.xml
|
4 |
-
sitemap.xml.gz
|
5 |
-
wp-config.php
|
6 |
-
wp-content/advanced-cache.php
|
7 |
-
wp-content/backup-db/
|
8 |
-
wp-content/backups/
|
9 |
-
wp-content/blogs.dir/
|
10 |
-
wp-content/cache/
|
11 |
-
wp-content/upgrade/
|
12 |
-
wp-content/uploads/
|
13 |
-
wp-content/wp-cache-config.php
|
14 |
-
wp-content/plugins/hello.php
|
15 |
-
|
16 |
-
/readme.html
|
17 |
-
/license.txt
|
18 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
LICENSE
DELETED
@@ -1,339 +0,0 @@
|
|
1 |
-
GNU GENERAL PUBLIC LICENSE
|
2 |
-
Version 2, June 1991
|
3 |
-
|
4 |
-
Copyright (C) 1989, 1991 Free Software Foundation, Inc., <http://fsf.org/>
|
5 |
-
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
6 |
-
Everyone is permitted to copy and distribute verbatim copies
|
7 |
-
of this license document, but changing it is not allowed.
|
8 |
-
|
9 |
-
Preamble
|
10 |
-
|
11 |
-
The licenses for most software are designed to take away your
|
12 |
-
freedom to share and change it. By contrast, the GNU General Public
|
13 |
-
License is intended to guarantee your freedom to share and change free
|
14 |
-
software--to make sure the software is free for all its users. This
|
15 |
-
General Public License applies to most of the Free Software
|
16 |
-
Foundation's software and to any other program whose authors commit to
|
17 |
-
using it. (Some other Free Software Foundation software is covered by
|
18 |
-
the GNU Lesser General Public License instead.) You can apply it to
|
19 |
-
your programs, too.
|
20 |
-
|
21 |
-
When we speak of free software, we are referring to freedom, not
|
22 |
-
price. Our General Public Licenses are designed to make sure that you
|
23 |
-
have the freedom to distribute copies of free software (and charge for
|
24 |
-
this service if you wish), that you receive source code or can get it
|
25 |
-
if you want it, that you can change the software or use pieces of it
|
26 |
-
in new free programs; and that you know you can do these things.
|
27 |
-
|
28 |
-
To protect your rights, we need to make restrictions that forbid
|
29 |
-
anyone to deny you these rights or to ask you to surrender the rights.
|
30 |
-
These restrictions translate to certain responsibilities for you if you
|
31 |
-
distribute copies of the software, or if you modify it.
|
32 |
-
|
33 |
-
For example, if you distribute copies of such a program, whether
|
34 |
-
gratis or for a fee, you must give the recipients all the rights that
|
35 |
-
you have. You must make sure that they, too, receive or can get the
|
36 |
-
source code. And you must show them these terms so they know their
|
37 |
-
rights.
|
38 |
-
|
39 |
-
We protect your rights with two steps: (1) copyright the software, and
|
40 |
-
(2) offer you this license which gives you legal permission to copy,
|
41 |
-
distribute and/or modify the software.
|
42 |
-
|
43 |
-
Also, for each author's protection and ours, we want to make certain
|
44 |
-
that everyone understands that there is no warranty for this free
|
45 |
-
software. If the software is modified by someone else and passed on, we
|
46 |
-
want its recipients to know that what they have is not the original, so
|
47 |
-
that any problems introduced by others will not reflect on the original
|
48 |
-
authors' reputations.
|
49 |
-
|
50 |
-
Finally, any free program is threatened constantly by software
|
51 |
-
patents. We wish to avoid the danger that redistributors of a free
|
52 |
-
program will individually obtain patent licenses, in effect making the
|
53 |
-
program proprietary. To prevent this, we have made it clear that any
|
54 |
-
patent must be licensed for everyone's free use or not licensed at all.
|
55 |
-
|
56 |
-
The precise terms and conditions for copying, distribution and
|
57 |
-
modification follow.
|
58 |
-
|
59 |
-
GNU GENERAL PUBLIC LICENSE
|
60 |
-
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
61 |
-
|
62 |
-
0. This License applies to any program or other work which contains
|
63 |
-
a notice placed by the copyright holder saying it may be distributed
|
64 |
-
under the terms of this General Public License. The "Program", below,
|
65 |
-
refers to any such program or work, and a "work based on the Program"
|
66 |
-
means either the Program or any derivative work under copyright law:
|
67 |
-
that is to say, a work containing the Program or a portion of it,
|
68 |
-
either verbatim or with modifications and/or translated into another
|
69 |
-
language. (Hereinafter, translation is included without limitation in
|
70 |
-
the term "modification".) Each licensee is addressed as "you".
|
71 |
-
|
72 |
-
Activities other than copying, distribution and modification are not
|
73 |
-
covered by this License; they are outside its scope. The act of
|
74 |
-
running the Program is not restricted, and the output from the Program
|
75 |
-
is covered only if its contents constitute a work based on the
|
76 |
-
Program (independent of having been made by running the Program).
|
77 |
-
Whether that is true depends on what the Program does.
|
78 |
-
|
79 |
-
1. You may copy and distribute verbatim copies of the Program's
|
80 |
-
source code as you receive it, in any medium, provided that you
|
81 |
-
conspicuously and appropriately publish on each copy an appropriate
|
82 |
-
copyright notice and disclaimer of warranty; keep intact all the
|
83 |
-
notices that refer to this License and to the absence of any warranty;
|
84 |
-
and give any other recipients of the Program a copy of this License
|
85 |
-
along with the Program.
|
86 |
-
|
87 |
-
You may charge a fee for the physical act of transferring a copy, and
|
88 |
-
you may at your option offer warranty protection in exchange for a fee.
|
89 |
-
|
90 |
-
2. You may modify your copy or copies of the Program or any portion
|
91 |
-
of it, thus forming a work based on the Program, and copy and
|
92 |
-
distribute such modifications or work under the terms of Section 1
|
93 |
-
above, provided that you also meet all of these conditions:
|
94 |
-
|
95 |
-
a) You must cause the modified files to carry prominent notices
|
96 |
-
stating that you changed the files and the date of any change.
|
97 |
-
|
98 |
-
b) You must cause any work that you distribute or publish, that in
|
99 |
-
whole or in part contains or is derived from the Program or any
|
100 |
-
part thereof, to be licensed as a whole at no charge to all third
|
101 |
-
parties under the terms of this License.
|
102 |
-
|
103 |
-
c) If the modified program normally reads commands interactively
|
104 |
-
when run, you must cause it, when started running for such
|
105 |
-
interactive use in the most ordinary way, to print or display an
|
106 |
-
announcement including an appropriate copyright notice and a
|
107 |
-
notice that there is no warranty (or else, saying that you provide
|
108 |
-
a warranty) and that users may redistribute the program under
|
109 |
-
these conditions, and telling the user how to view a copy of this
|
110 |
-
License. (Exception: if the Program itself is interactive but
|
111 |
-
does not normally print such an announcement, your work based on
|
112 |
-
the Program is not required to print an announcement.)
|
113 |
-
|
114 |
-
These requirements apply to the modified work as a whole. If
|
115 |
-
identifiable sections of that work are not derived from the Program,
|
116 |
-
and can be reasonably considered independent and separate works in
|
117 |
-
themselves, then this License, and its terms, do not apply to those
|
118 |
-
sections when you distribute them as separate works. But when you
|
119 |
-
distribute the same sections as part of a whole which is a work based
|
120 |
-
on the Program, the distribution of the whole must be on the terms of
|
121 |
-
this License, whose permissions for other licensees extend to the
|
122 |
-
entire whole, and thus to each and every part regardless of who wrote it.
|
123 |
-
|
124 |
-
Thus, it is not the intent of this section to claim rights or contest
|
125 |
-
your rights to work written entirely by you; rather, the intent is to
|
126 |
-
exercise the right to control the distribution of derivative or
|
127 |
-
collective works based on the Program.
|
128 |
-
|
129 |
-
In addition, mere aggregation of another work not based on the Program
|
130 |
-
with the Program (or with a work based on the Program) on a volume of
|
131 |
-
a storage or distribution medium does not bring the other work under
|
132 |
-
the scope of this License.
|
133 |
-
|
134 |
-
3. You may copy and distribute the Program (or a work based on it,
|
135 |
-
under Section 2) in object code or executable form under the terms of
|
136 |
-
Sections 1 and 2 above provided that you also do one of the following:
|
137 |
-
|
138 |
-
a) Accompany it with the complete corresponding machine-readable
|
139 |
-
source code, which must be distributed under the terms of Sections
|
140 |
-
1 and 2 above on a medium customarily used for software interchange; or,
|
141 |
-
|
142 |
-
b) Accompany it with a written offer, valid for at least three
|
143 |
-
years, to give any third party, for a charge no more than your
|
144 |
-
cost of physically performing source distribution, a complete
|
145 |
-
machine-readable copy of the corresponding source code, to be
|
146 |
-
distributed under the terms of Sections 1 and 2 above on a medium
|
147 |
-
customarily used for software interchange; or,
|
148 |
-
|
149 |
-
c) Accompany it with the information you received as to the offer
|
150 |
-
to distribute corresponding source code. (This alternative is
|
151 |
-
allowed only for noncommercial distribution and only if you
|
152 |
-
received the program in object code or executable form with such
|
153 |
-
an offer, in accord with Subsection b above.)
|
154 |
-
|
155 |
-
The source code for a work means the preferred form of the work for
|
156 |
-
making modifications to it. For an executable work, complete source
|
157 |
-
code means all the source code for all modules it contains, plus any
|
158 |
-
associated interface definition files, plus the scripts used to
|
159 |
-
control compilation and installation of the executable. However, as a
|
160 |
-
special exception, the source code distributed need not include
|
161 |
-
anything that is normally distributed (in either source or binary
|
162 |
-
form) with the major components (compiler, kernel, and so on) of the
|
163 |
-
operating system on which the executable runs, unless that component
|
164 |
-
itself accompanies the executable.
|
165 |
-
|
166 |
-
If distribution of executable or object code is made by offering
|
167 |
-
access to copy from a designated place, then offering equivalent
|
168 |
-
access to copy the source code from the same place counts as
|
169 |
-
distribution of the source code, even though third parties are not
|
170 |
-
compelled to copy the source along with the object code.
|
171 |
-
|
172 |
-
4. You may not copy, modify, sublicense, or distribute the Program
|
173 |
-
except as expressly provided under this License. Any attempt
|
174 |
-
otherwise to copy, modify, sublicense or distribute the Program is
|
175 |
-
void, and will automatically terminate your rights under this License.
|
176 |
-
However, parties who have received copies, or rights, from you under
|
177 |
-
this License will not have their licenses terminated so long as such
|
178 |
-
parties remain in full compliance.
|
179 |
-
|
180 |
-
5. You are not required to accept this License, since you have not
|
181 |
-
signed it. However, nothing else grants you permission to modify or
|
182 |
-
distribute the Program or its derivative works. These actions are
|
183 |
-
prohibited by law if you do not accept this License. Therefore, by
|
184 |
-
modifying or distributing the Program (or any work based on the
|
185 |
-
Program), you indicate your acceptance of this License to do so, and
|
186 |
-
all its terms and conditions for copying, distributing or modifying
|
187 |
-
the Program or works based on it.
|
188 |
-
|
189 |
-
6. Each time you redistribute the Program (or any work based on the
|
190 |
-
Program), the recipient automatically receives a license from the
|
191 |
-
original licensor to copy, distribute or modify the Program subject to
|
192 |
-
these terms and conditions. You may not impose any further
|
193 |
-
restrictions on the recipients' exercise of the rights granted herein.
|
194 |
-
You are not responsible for enforcing compliance by third parties to
|
195 |
-
this License.
|
196 |
-
|
197 |
-
7. If, as a consequence of a court judgment or allegation of patent
|
198 |
-
infringement or for any other reason (not limited to patent issues),
|
199 |
-
conditions are imposed on you (whether by court order, agreement or
|
200 |
-
otherwise) that contradict the conditions of this License, they do not
|
201 |
-
excuse you from the conditions of this License. If you cannot
|
202 |
-
distribute so as to satisfy simultaneously your obligations under this
|
203 |
-
License and any other pertinent obligations, then as a consequence you
|
204 |
-
may not distribute the Program at all. For example, if a patent
|
205 |
-
license would not permit royalty-free redistribution of the Program by
|
206 |
-
all those who receive copies directly or indirectly through you, then
|
207 |
-
the only way you could satisfy both it and this License would be to
|
208 |
-
refrain entirely from distribution of the Program.
|
209 |
-
|
210 |
-
If any portion of this section is held invalid or unenforceable under
|
211 |
-
any particular circumstance, the balance of the section is intended to
|
212 |
-
apply and the section as a whole is intended to apply in other
|
213 |
-
circumstances.
|
214 |
-
|
215 |
-
It is not the purpose of this section to induce you to infringe any
|
216 |
-
patents or other property right claims or to contest validity of any
|
217 |
-
such claims; this section has the sole purpose of protecting the
|
218 |
-
integrity of the free software distribution system, which is
|
219 |
-
implemented by public license practices. Many people have made
|
220 |
-
generous contributions to the wide range of software distributed
|
221 |
-
through that system in reliance on consistent application of that
|
222 |
-
system; it is up to the author/donor to decide if he or she is willing
|
223 |
-
to distribute software through any other system and a licensee cannot
|
224 |
-
impose that choice.
|
225 |
-
|
226 |
-
This section is intended to make thoroughly clear what is believed to
|
227 |
-
be a consequence of the rest of this License.
|
228 |
-
|
229 |
-
8. If the distribution and/or use of the Program is restricted in
|
230 |
-
certain countries either by patents or by copyrighted interfaces, the
|
231 |
-
original copyright holder who places the Program under this License
|
232 |
-
may add an explicit geographical distribution limitation excluding
|
233 |
-
those countries, so that distribution is permitted only in or among
|
234 |
-
countries not thus excluded. In such case, this License incorporates
|
235 |
-
the limitation as if written in the body of this License.
|
236 |
-
|
237 |
-
9. The Free Software Foundation may publish revised and/or new versions
|
238 |
-
of the General Public License from time to time. Such new versions will
|
239 |
-
be similar in spirit to the present version, but may differ in detail to
|
240 |
-
address new problems or concerns.
|
241 |
-
|
242 |
-
Each version is given a distinguishing version number. If the Program
|
243 |
-
specifies a version number of this License which applies to it and "any
|
244 |
-
later version", you have the option of following the terms and conditions
|
245 |
-
either of that version or of any later version published by the Free
|
246 |
-
Software Foundation. If the Program does not specify a version number of
|
247 |
-
this License, you may choose any version ever published by the Free Software
|
248 |
-
Foundation.
|
249 |
-
|
250 |
-
10. If you wish to incorporate parts of the Program into other free
|
251 |
-
programs whose distribution conditions are different, write to the author
|
252 |
-
to ask for permission. For software which is copyrighted by the Free
|
253 |
-
Software Foundation, write to the Free Software Foundation; we sometimes
|
254 |
-
make exceptions for this. Our decision will be guided by the two goals
|
255 |
-
of preserving the free status of all derivatives of our free software and
|
256 |
-
of promoting the sharing and reuse of software generally.
|
257 |
-
|
258 |
-
NO WARRANTY
|
259 |
-
|
260 |
-
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
|
261 |
-
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
|
262 |
-
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
|
263 |
-
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
|
264 |
-
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
265 |
-
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
|
266 |
-
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
|
267 |
-
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
|
268 |
-
REPAIR OR CORRECTION.
|
269 |
-
|
270 |
-
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
271 |
-
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
|
272 |
-
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
|
273 |
-
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
|
274 |
-
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
|
275 |
-
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
|
276 |
-
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
|
277 |
-
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
|
278 |
-
POSSIBILITY OF SUCH DAMAGES.
|
279 |
-
|
280 |
-
END OF TERMS AND CONDITIONS
|
281 |
-
|
282 |
-
How to Apply These Terms to Your New Programs
|
283 |
-
|
284 |
-
If you develop a new program, and you want it to be of the greatest
|
285 |
-
possible use to the public, the best way to achieve this is to make it
|
286 |
-
free software which everyone can redistribute and change under these terms.
|
287 |
-
|
288 |
-
To do so, attach the following notices to the program. It is safest
|
289 |
-
to attach them to the start of each source file to most effectively
|
290 |
-
convey the exclusion of warranty; and each file should have at least
|
291 |
-
the "copyright" line and a pointer to where the full notice is found.
|
292 |
-
|
293 |
-
{description}
|
294 |
-
Copyright (C) {year} {fullname}
|
295 |
-
|
296 |
-
This program is free software; you can redistribute it and/or modify
|
297 |
-
it under the terms of the GNU General Public License as published by
|
298 |
-
the Free Software Foundation; either version 2 of the License, or
|
299 |
-
(at your option) any later version.
|
300 |
-
|
301 |
-
This program is distributed in the hope that it will be useful,
|
302 |
-
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
303 |
-
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
304 |
-
GNU General Public License for more details.
|
305 |
-
|
306 |
-
You should have received a copy of the GNU General Public License along
|
307 |
-
with this program; if not, write to the Free Software Foundation, Inc.,
|
308 |
-
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
309 |
-
|
310 |
-
Also add information on how to contact you by electronic and paper mail.
|
311 |
-
|
312 |
-
If the program is interactive, make it output a short notice like this
|
313 |
-
when it starts in an interactive mode:
|
314 |
-
|
315 |
-
Gnomovision version 69, Copyright (C) year name of author
|
316 |
-
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
317 |
-
This is free software, and you are welcome to redistribute it
|
318 |
-
under certain conditions; type `show c' for details.
|
319 |
-
|
320 |
-
The hypothetical commands `show w' and `show c' should show the appropriate
|
321 |
-
parts of the General Public License. Of course, the commands you use may
|
322 |
-
be called something other than `show w' and `show c'; they could even be
|
323 |
-
mouse-clicks or menu items--whatever suits your program.
|
324 |
-
|
325 |
-
You should also get your employer (if you work as a programmer) or your
|
326 |
-
school, if any, to sign a "copyright disclaimer" for the program, if
|
327 |
-
necessary. Here is a sample; alter the names:
|
328 |
-
|
329 |
-
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
|
330 |
-
`Gnomovision' (which makes passes at compilers) written by James Hacker.
|
331 |
-
|
332 |
-
{signature of Ty Coon}, 1 April 1989
|
333 |
-
Ty Coon, President of Vice
|
334 |
-
|
335 |
-
This General Public License does not permit incorporating your program into
|
336 |
-
proprietary programs. If your program is a subroutine library, you may
|
337 |
-
consider it more useful to permit linking proprietary applications with the
|
338 |
-
library. If this is what you want to do, use the GNU Lesser General
|
339 |
-
Public License instead of this License.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
README.md
DELETED
@@ -1,3 +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.
|
|
|
|
|
|
includes/class-xmlsitemapfeed-admin.php
CHANGED
@@ -18,15 +18,14 @@ class XMLSitemapFeed_Admin extends XMLSitemapFeed {
|
|
18 |
public function sitemaps_settings_field() {
|
19 |
$options = parent::get_sitemaps();
|
20 |
$disabled = ('1' == get_option('blog_public')) ? false : true;
|
21 |
-
$prefix = parent::prefix();
|
22 |
|
23 |
echo '<fieldset id="xmlsf_sitemaps"><legend class="screen-reader-text">'.__('XML Sitemaps','xml-sitemap-feed').'</legend>
|
24 |
-
<label><input type="checkbox" name="'.$prefix.'sitemaps[sitemap]" id="xmlsf_sitemaps_index" value="'.htmlspecialchars(XMLSF_NAME).'" '.checked(isset($options['sitemap']), true, false).' '.disabled($disabled, true, false).' /> '.__('XML Sitemap Index','xml-sitemap-feed').'</label>';//xmlsf
|
25 |
if (isset($options['sitemap']))
|
26 |
echo '<span class="description"> – <a href="#xmlsf" id="xmlsf_link">'.translate('Settings').'</a> – <a href="'.trailingslashit(get_bloginfo('url')). ( ('' == get_option('permalink_structure')) ? '?feed=sitemap' : $options['sitemap'] ) .'" target="_blank">'.translate('View').'</a></span>';
|
27 |
|
28 |
echo '<br>
|
29 |
-
<label><input type="checkbox" name="'.$prefix.'sitemaps[sitemap-news]" id="xmlsf_sitemaps_news" value="'.htmlspecialchars(XMLSF_NEWS_NAME).'" '.checked(isset($options['sitemap-news']), true, false).' '.disabled($disabled, true, false).' /> '.__('Google News Sitemap','xml-sitemap-feed').'</label>';
|
30 |
if (isset($options['sitemap-news']))
|
31 |
echo '<span class="description"> – <a href="#xmlnf" id="xmlnf_link">'.translate('Settings').'</a> – <a href="'.trailingslashit(get_bloginfo('url')). ( ('' == get_option('permalink_structure')) ? '?feed=sitemap-news' : $options['sitemap-news'] ) .'" target="_blank">'.translate('View').'</a></span>';
|
32 |
|
@@ -67,40 +66,41 @@ class XMLSitemapFeed_Admin extends XMLSitemapFeed {
|
|
67 |
$options = parent::get_ping();
|
68 |
$defaults = parent::defaults('ping');
|
69 |
$update_services = get_option('ping_sites');
|
70 |
-
|
71 |
$names = array(
|
72 |
'google' => array (
|
73 |
'name' => __('Google','xml-sitemap-feed'),
|
74 |
-
|
75 |
'bing' => array (
|
76 |
'name' => __('Bing & Yahoo','xml-sitemap-feed'),
|
77 |
-
|
78 |
'yandex' => array (
|
79 |
'name' => __('Yandex','xml-sitemap-feed'),
|
80 |
-
|
81 |
'baidu' => array (
|
82 |
'name' => __('Baidu','xml-sitemap-feed'),
|
83 |
-
|
84 |
'others' => array (
|
85 |
'name' => __('Ping-O-Matic','xml-sitemap-feed'),
|
86 |
-
|
87 |
-
|
88 |
foreach ( $names as $key => $values ) {
|
89 |
if (array_key_exists($key,$defaults) && is_array($values))
|
90 |
$defaults[$key] += $values;
|
91 |
}
|
|
|
92 |
echo '
|
93 |
<fieldset id="xmlsf_ping"><legend class="screen-reader-text">'.translate('Update Services').'</legend>
|
94 |
';
|
95 |
-
foreach ( $defaults as $key => $values ) {
|
96 |
|
|
|
97 |
if ( isset($values['type']) && $values['type'] == 'RPC' ) {
|
98 |
$active = ( strpos($update_services,untrailingslashit($values['uri'])) === false ) ? false : true;
|
99 |
} else {
|
100 |
$active = !empty($options[$key]['active']) ? true : false;
|
101 |
}
|
102 |
echo '
|
103 |
-
<label><input type="checkbox" name="'.$prefix.'ping['.
|
104 |
$key.'][active]" id="xmlsf_ping_'.
|
105 |
$key.'" value="1"'.
|
106 |
checked( $active, true, false).' /> ';
|
@@ -108,16 +108,16 @@ class XMLSitemapFeed_Admin extends XMLSitemapFeed {
|
|
108 |
echo '</label>';
|
109 |
|
110 |
echo '
|
111 |
-
<input type="hidden" name="'.$prefix.'ping['.
|
112 |
$key.'][uri]" value="'.
|
113 |
$values['uri'].'" />';
|
114 |
echo '
|
115 |
-
<input type="hidden" name="'.$prefix.'ping['.
|
116 |
$key.'][type]" value="'.
|
117 |
$values['type'].'" />';
|
118 |
if (isset($values['news']))
|
119 |
echo '
|
120 |
-
<input type="hidden" name="'.$prefix.'ping['.
|
121 |
$key.'][news]" value="'.
|
122 |
$values['news'].'" />';
|
123 |
|
@@ -133,7 +133,7 @@ class XMLSitemapFeed_Admin extends XMLSitemapFeed {
|
|
133 |
|
134 |
foreach ((array)$options[$key]['pong'] as $pretty => $time) {
|
135 |
echo '
|
136 |
-
<input type="hidden" name="'.$prefix.'ping['.
|
137 |
$key.'][pong]['.$pretty.']" value="'.
|
138 |
$time.'" />';
|
139 |
if ( !empty($time) )
|
@@ -199,7 +199,7 @@ class XMLSitemapFeed_Admin extends XMLSitemapFeed {
|
|
199 |
public function robots_settings_field() {
|
200 |
echo '
|
201 |
<fieldset><legend class="screen-reader-text">'.__('Additional robots.txt rules','xml-sitemap-feed').'</legend>
|
202 |
-
<label>'.sprintf(__('Rules that will be appended to the %s generated by WordPress:','xml-sitemap-feed'),'<a href="'.trailingslashit(get_bloginfo('url')).'robots.txt" target="_blank">robots.txt</a>').'<br><textarea name="'
|
203 |
<p class="description">'.__('These rules will not have effect when you are using a static robots.txt file.','xml-sitemap-feed').'<br><span style="color: red" class="warning">'.__('Only add rules here when you know what you are doing, otherwise you might break search engine access to your site.','xml-sitemap-feed').'</span></p>
|
204 |
</fieldset>';
|
205 |
}
|
@@ -207,7 +207,7 @@ class XMLSitemapFeed_Admin extends XMLSitemapFeed {
|
|
207 |
public function reset_settings_field() {
|
208 |
echo '
|
209 |
<fieldset><legend class="screen-reader-text">'.__('Reset XML sitemaps','xml-sitemap-feed').'</legend>
|
210 |
-
<label><input type="checkbox" name="'
|
211 |
__('Selecting this will clear all XML Sitemap & Google News Sitemap settings after Save Changes. Are you sure?','xml-sitemap-feed').'\')){this.checked=false}}" /> '.
|
212 |
__('Clear all XML Sitemap & Google News Sitemap settings.','xml-sitemap-feed').'</label>
|
213 |
</fieldset>';
|
@@ -230,7 +230,6 @@ class XMLSitemapFeed_Admin extends XMLSitemapFeed {
|
|
230 |
public function post_types_settings_field() {
|
231 |
$options = parent::get_post_types();
|
232 |
$defaults = parent::defaults('post_types');
|
233 |
-
$prefix = parent::prefix();
|
234 |
$do_note = false;
|
235 |
|
236 |
$post_types = get_post_types(array('public'=>true),'objects');
|
@@ -247,12 +246,12 @@ class XMLSitemapFeed_Admin extends XMLSitemapFeed {
|
|
247 |
$count = wp_count_posts( $post_type->name );
|
248 |
|
249 |
echo '
|
250 |
-
<input type="hidden" name="'.$prefix.'post_types['.
|
251 |
$post_type->name.'][name]" value="'.
|
252 |
$post_type->name.'" />';
|
253 |
|
254 |
echo '
|
255 |
-
<label><input type="checkbox" name="'.$prefix.'post_types['.
|
256 |
$post_type->name.'][active]" id="xmlsf_post_types_'.
|
257 |
$post_type->name.'" value="1" '.
|
258 |
checked( !empty($options[$post_type->name]["active"]), true, false).' /> '.
|
@@ -281,7 +280,7 @@ class XMLSitemapFeed_Admin extends XMLSitemapFeed {
|
|
281 |
);
|
282 |
$archive = !empty($options[$post_type->name]['archive']) ? $options[$post_type->name]['archive'] : $defaults[$post_type->name]['archive'];
|
283 |
echo '
|
284 |
-
<li><label>'.__('Split by','xml-sitemap-feed').' <select name="'.$prefix.'post_types['.
|
285 |
$post_type->name.'][archive]" id="xmlsf_post_types_'.
|
286 |
$post_type->name.'_archive">
|
287 |
<option value="">'.translate('None').'</option>';
|
@@ -296,28 +295,29 @@ class XMLSitemapFeed_Admin extends XMLSitemapFeed {
|
|
296 |
|
297 |
$priority_val = !empty($options[$post_type->name]['priority']) ? $options[$post_type->name]['priority'] : $defaults[$post_type->name]['priority'];
|
298 |
echo '
|
299 |
-
<li><label>'.__('Priority','xml-sitemap-feed').' <input type="number" step="0.1" min="0.1" max="0.9" name="'.$prefix.'post_types['.
|
300 |
$post_type->name.'][priority]" id="xmlsf_post_types_'.
|
301 |
$post_type->name.'_priority" value="'.$priority_val.'" class="small-text"></label> <span class="description">'.__('Priority can be overridden on individual posts.','xml-sitemap-feed').' *</span></li>';
|
302 |
|
303 |
echo '
|
304 |
-
<li><label><input type="checkbox" name="'.$prefix.'post_types['.
|
305 |
$post_type->name.'][dynamic_priority]" value="1" '.
|
306 |
checked( !empty($options[$post_type->name]['dynamic_priority']), true, false).' /> '.__('Automatic Priority calculation.','xml-sitemap-feed').'</label> <span class="description">'.__('Adjusts the Priority based on factors like age, comments, sticky post or blog page. Individual posts with fixed Priority will always keep that value.','xml-sitemap-feed').'</span></li>';
|
307 |
|
308 |
echo '
|
309 |
-
<li><label><input type="checkbox" name="'.$prefix.'post_types['.
|
310 |
$post_type->name.'][update_lastmod_on_comments]" value="1" '.
|
311 |
-
checked( !empty($options[$post_type->name]["update_lastmod_on_comments"]), true, false).' /> '.__('Update Lastmod
|
312 |
|
313 |
$image = isset($options[$post_type->name]['tags']['image']) ? $options[$post_type->name]['tags']['image'] : $defaults[$post_type->name]['tags']['image'];
|
|
|
314 |
echo '
|
315 |
-
<li><label>'.__('Add image tags for','xml-sitemap-feed').' <select name="'.$prefix.'post_types['.
|
316 |
$post_type->name.'][tags][image]">
|
317 |
<option value="">'.translate('None').'</option>
|
318 |
<option value="featured" '.
|
319 |
selected( $image == "featured", true, false).
|
320 |
-
'>'.
|
321 |
<option value="attached" '.
|
322 |
selected( $image == "attached", true, false).
|
323 |
'>'.__('Attached images','xml-sitemap-feed').'</option>
|
@@ -330,7 +330,7 @@ class XMLSitemapFeed_Admin extends XMLSitemapFeed {
|
|
330 |
}
|
331 |
|
332 |
echo '
|
333 |
-
<p class="description">* '.__('Priority settings do not affect ranking in search results in any way. They are only meant to suggest search engines which URLs to index first. Once a URL has been indexed, its Priority becomes meaningless until its Lastmod is updated.','xml-sitemap-feed').' <a href="#xmlsf_post_types_note_1_more" id="xmlsf_post_types_note_1_link">'.translate('
|
334 |
<span id="xmlsf_post_types_note_1_more">'.__('Maximum Priority (1.0) is reserved for the front page, individual posts and, when allowed, posts with high comment count.','xml-sitemap-feed').' '.__('Priority values are taken as relative values. Setting all to the same (high) value is pointless.','xml-sitemap-feed').'</span></p>
|
335 |
<script type="text/javascript">
|
336 |
jQuery( document ).ready( function() {
|
@@ -364,7 +364,7 @@ jQuery( document ).ready( function() {
|
|
364 |
|
365 |
$count = wp_count_terms( $taxonomy->name );
|
366 |
$output .= '
|
367 |
-
<label><input type="checkbox" name="'
|
368 |
$taxonomy->name.']" id="xmlsf_taxonomies_'.
|
369 |
$taxonomy->name.'" value="'.
|
370 |
$taxonomy->name.'"'.
|
@@ -387,7 +387,7 @@ jQuery( document ).ready( function() {
|
|
387 |
echo $output;
|
388 |
|
389 |
echo '
|
390 |
-
<p class="description">'.__('It is generally not recommended to include taxonomy pages, unless their content brings added value.','xml-sitemap-feed').' <a href="#xmlsf_taxonomies_note_1_more" id="xmlsf_taxonomies_note_1_link">'.translate('
|
391 |
<span id="xmlsf_taxonomies_note_1_more">'.__('For example, when you use category descriptions with information that is not present elsewhere on your site or if taxonomy pages list posts with an excerpt that is different from, but complementary to the post content. In these cases you might consider including certain taxonomies. Otherwise, if you fear <a href="http://moz.com/learn/seo/duplicate-content">negative affects of duplicate content</a> or PageRank spread, you might even consider disallowing indexation of taxonomies.','xml-sitemap-feed').' '.
|
392 |
sprintf(__('You can do this by adding specific robots.txt rules in the %s field above.','xml-sitemap-feed'),'<strong>'.__('Additional robots.txt rules','xml-sitemap-feed').'</strong>');
|
393 |
echo '</span></p>
|
@@ -414,7 +414,7 @@ jQuery( document ).ready( function() {
|
|
414 |
echo '
|
415 |
<fieldset><legend class="screen-reader-text">'.__('Include custom XML Sitemaps','xml-sitemap-feed').'</legend>
|
416 |
<label>'.__('Additional XML Sitemaps to append to the main XML Sitemap Index:','xml-sitemap-feed').'<br>
|
417 |
-
<textarea name="'
|
418 |
<p class="description">'.__('Add the full URL, including protocol (http/https) and domain, of any XML Sitemap that you want to append to the Sitemap Index. Start each URL on a new line.','xml-sitemap-feed').'<br><span style="color: red" class="warning">'.__('Only valid sitemaps are allowed in the Sitemap Index. Use your Google/Bing Webmaster Tools to verify!','xml-sitemap-feed').'</span></p>
|
419 |
</fieldset>';
|
420 |
|
@@ -434,7 +434,7 @@ jQuery( document ).ready( function() {
|
|
434 |
echo '
|
435 |
<fieldset><legend class="screen-reader-text">'.__('Include custom URLs','xml-sitemap-feed').'</legend>
|
436 |
<label>'.__('Additional URLs to append in an extra XML Sitemap:','xml-sitemap-feed').'<br>
|
437 |
-
<textarea name="'
|
438 |
<p class="description">'.__('Add the full URL, including protocol (http/https) and domain, of any (static) page that you want to append to the ones already included by WordPress. Optionally add a priority value between 0 and 1, separated with a space after the URL. Start each URL on a new line.','xml-sitemap-feed').'</p>
|
439 |
</fieldset>';
|
440 |
|
@@ -446,7 +446,7 @@ jQuery( document ).ready( function() {
|
|
446 |
|
447 |
echo '
|
448 |
<fieldset><legend class="screen-reader-text">'.__('Allowed domains','xml-sitemap-feed').'</legend>
|
449 |
-
<label>'.__('Additional domains to allow in the XML Sitemaps:','xml-sitemap-feed').'<br><textarea name="'
|
450 |
<p class="description">'.sprintf(__('By default, only the domain %s as used in your WordPress site address is allowed. This means that all URLs that use another domain (custom URLs or using a plugin like Page Links To) are filtered from the XML Sitemap. However, if you are the verified owner of other domains in your Google/Bing Webmaster Tools account, you can include these in the same sitemap. Add these domains, without protocol (http/https) each on a new line. Note that if you enter a domain with www, all URLs without it or with other subdomains will be filtered.','xml-sitemap-feed'),'<strong>'.$default.'</strong>').'</p>
|
451 |
</fieldset>';
|
452 |
|
@@ -475,7 +475,7 @@ jQuery( document ).ready( function() {
|
|
475 |
$name = !empty($options['name']) ? $options['name'] : '';
|
476 |
echo '
|
477 |
<fieldset><legend class="screen-reader-text">'.__('Publication name','xml-sitemap-feed').'</legend>
|
478 |
-
<input type="text" name="'
|
479 |
__('The publication name should match the name submitted on the Google News Publisher Center. If you wish to change it, please read <a href="https://support.google.com/news/publisher/answer/40402" target="_blank">Updated publication name</a>.','xml-sitemap-feed') . '</p>
|
480 |
</fieldset>';
|
481 |
}
|
@@ -483,9 +483,8 @@ jQuery( document ).ready( function() {
|
|
483 |
public function news_post_type_field() {
|
484 |
$defaults = parent::defaults('news_tags');
|
485 |
$options = parent::get_option('news_tags');
|
486 |
-
$prefix = parent::prefix();
|
487 |
|
488 |
-
$news_post_type = !empty($options['post_type']) ? $options['post_type'] : $defaults['post_type'];
|
489 |
|
490 |
$post_types = get_post_types(array('publicly_queryable' =>true),'objects');
|
491 |
|
@@ -515,7 +514,7 @@ jQuery( document ).ready( function() {
|
|
515 |
}
|
516 |
|
517 |
echo '
|
518 |
-
<label><input type="checkbox" name="'.$prefix.'news_tags[post_type][]" id="xmlsf_post_type_'.
|
519 |
$post_type->name.'" value="'.$post_type->name.'" '.
|
520 |
checked( $checked, true, false).' '.
|
521 |
disabled( $disabled, true, false).' /> '.
|
@@ -552,7 +551,7 @@ jQuery( document ).ready( function() {
|
|
552 |
$size = $count < 15 ? $count : 15;
|
553 |
echo '
|
554 |
<label>'.__('Limit to posts in these post categories:','xml-sitemap-feed').'<br>
|
555 |
-
<select multiple name="'
|
556 |
|
557 |
foreach($all_categories as $category) {
|
558 |
$depth = count( explode( '%#%', get_category_parents($category, false, '%#%') ) ) - 2;
|
@@ -579,28 +578,26 @@ jQuery( document ).ready( function() {
|
|
579 |
$image = !empty($options['image']) ? $options['image'] : '';
|
580 |
echo '
|
581 |
<fieldset><legend class="screen-reader-text">'.translate('Images').'</legend>
|
582 |
-
<label>'.__('Add image tags for','xml-sitemap-feed').' <select name="'
|
583 |
<option value="">'.translate('None').'</option>
|
584 |
<option value="featured" '.
|
585 |
selected( $image == "featured", true, false).
|
586 |
-
'>'.
|
587 |
<option value="attached" '.
|
588 |
selected( $image == "attached", true, false).
|
589 |
'>'.__('Attached images','xml-sitemap-feed').'</option>
|
590 |
';
|
591 |
echo '</select></label>
|
592 |
-
<p class="description">'.__('Note: Google News prefers at most one image per article in the News Sitemap. If multiple valid images are specified, the crawler will have to pick one arbitrarily. Images in News Sitemaps should be in jpeg or png format.','xml-sitemap-feed').' <a href="https://support.google.com/news/publisher/answer/13369" target="_blank">'.
|
593 |
</fieldset>';
|
594 |
}
|
595 |
|
596 |
public function news_labels_field() {
|
597 |
echo '
|
598 |
-
<fieldset id="xmlsf_news_labels"><legend class="screen-reader-text">'.__('Source labels','xml-sitemap-feed').'</legend>
|
599 |
-
|
600 |
-
<br><br>';
|
601 |
|
602 |
$options = parent::get_option('news_tags');
|
603 |
-
$prefix = parent::prefix();
|
604 |
|
605 |
// access tag
|
606 |
$access = !empty($options['access']) ? $options['access'] : '';
|
@@ -608,18 +605,18 @@ jQuery( document ).ready( function() {
|
|
608 |
$access_password = !empty($access['password']) ? $access['password'] : '';
|
609 |
echo '
|
610 |
<fieldset id="xmlsf_news_labels_access"><legend class="screen-reader-text"><access></legend>
|
611 |
-
'.sprintf(__('The %4$s tag specifies whether an article is available to all readers (%1$s), or only to those with a free (%2$s) or paid membership (%3$s) to your site.','xml-sitemap-feed'),translate('Public'),__('Registration','xml-sitemap-feed'),__('Subscription','xml-sitemap-feed'),'<strong><access></strong>').'
|
612 |
-
'.__('You can assign a different access level when writing a post.','xml-sitemap-feed') . '
|
613 |
<ul>';
|
614 |
|
615 |
echo '
|
616 |
-
<li><label>'.__('Tag normal posts as','xml-sitemap-feed').' <select name="'.$prefix.'news_tags[access][default]" id="xmlsf_news_tags_access_default">
|
617 |
<option value="">'.translate('Public').'</option>
|
618 |
<option value="Registration" '.selected( "Registration" == $access_default, true, false).'>'.__('Free registration','xml-sitemap-feed').'</option>
|
619 |
<option value="Subscription" '.selected( "Subscription" == $access_default, true, false).'>'.__('Paid subscription','xml-sitemap-feed').'</option>
|
620 |
</select></label></li>';
|
621 |
echo '
|
622 |
-
<li><label>'.__('Tag Password Protected posts as','xml-sitemap-feed').' <select name="'.$prefix.'news_tags[access][password]" id="xmlsf_news_tags_access_password">
|
623 |
<option value="Registration" '.selected( "Registration" == $access_password, true, false).'>'.__('Free registration','xml-sitemap-feed').'</option>
|
624 |
<option value="Subscription" '.selected( "Subscription" == $access_password, true, false).'>'.__('Paid subscription','xml-sitemap-feed').'</option>
|
625 |
</select></label></li>';
|
@@ -629,43 +626,49 @@ jQuery( document ).ready( function() {
|
|
629 |
|
630 |
// genres tag
|
631 |
$gn_genres = parent::gn_genres();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
632 |
$genres = !empty($options['genres']) ? $options['genres'] : array();
|
633 |
$genres_default = !empty($genres['default']) ? (array)$genres['default'] : array();
|
634 |
|
635 |
echo '
|
636 |
<fieldset id="xmlsf_news_labels_genres"><legend class="screen-reader-text"><genres></legend>
|
637 |
-
'.sprintf(__('The %s tag specifies one or more properties for an article, namely, whether it is a press release, a blog post, an opinion, an op-ed piece, user-generated content, or satire.','xml-sitemap-feed'),'<strong><genres></strong>').' '.__('You can assign different genres when writing a post.','xml-sitemap-feed');
|
638 |
|
639 |
-
echo '
|
|
|
640 |
<ul>
|
641 |
-
<li><label>'.__('Default genre:','xml-sitemap-feed').'<br><select multiple name="'.$prefix.'news_tags[genres][default][]" id="xmlsf_news_tags_genres_default" size="'.count($gn_genres).'">';
|
642 |
-
foreach ( $gn_genres as $name) {
|
643 |
-
echo '
|
644 |
-
<option value="'.$name.'" '.selected( in_array($name,$genres_default), true, false ).'>'.$name.'</option>';
|
645 |
}
|
646 |
echo '
|
647 |
</select></label></li>
|
648 |
</ul>
|
649 |
-
</fieldset>
|
650 |
-
<p class="description">'.__('Use the Ctrl/Cmd key plus click to select more than one or to deselect.','xml-sitemap-feed').' '.sprintf(__('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>').'</p>
|
651 |
</fieldset>';
|
652 |
|
653 |
-
|
654 |
// keywords
|
655 |
$keywords = !empty($options['keywords']) ? $options['keywords'] : array();
|
656 |
$keywords_from = !empty($keywords['from']) ? $keywords['from'] : '';
|
657 |
echo '
|
658 |
<fieldset id="xmlsf_news_keywords"><legend class="screen-reader-text"><keywords></legend>
|
659 |
-
'.sprintf(__('The %s tag is used to help classify the articles you submit to Google News by <strong>topic</strong>.','xml-sitemap-feed'),'<strong><keywords></strong>').'
|
660 |
<ul>
|
661 |
-
<li><label>'.sprintf(__('Use %s for topics.','xml-sitemap-feed'),' <select name="'.$prefix.'news_tags[keywords][from]" id="xmlsf_news_tags_keywords_from">
|
662 |
<option value="">'.translate('None').'</option>
|
663 |
<option value="category" '.selected( "category" == $keywords_from, true, false).'>'.translate('Categories').'</option>
|
664 |
<option value="post_tag" '.selected( "post_tag" == $keywords_from, true, false).'>'.translate('Tags').'</option>
|
665 |
</select>').'</label></li>';
|
666 |
-
if ("category"
|
667 |
echo '
|
668 |
-
<li><label>'.__('Default topic(s):','xml-sitemap-feed').' <input type="text" name="'.$prefix.'news_tags[keywords][default]" id="xmlsf_news_tags_keywords_default" value="';
|
669 |
echo !empty($keywords['default']) ? $keywords['default'] : '';
|
670 |
echo '" class="regular-text"></label> <span class="description">'.__('Separate with a comma.','xml-sitemap-feed').'</span></li>';
|
671 |
}
|
@@ -841,6 +844,7 @@ jQuery( document ).ready( function() {
|
|
841 |
}
|
842 |
|
843 |
public function sanitize_news_tags_settings($new) {
|
|
|
844 |
return $new;
|
845 |
}
|
846 |
|
@@ -909,7 +913,10 @@ jQuery( document ).ready( function() {
|
|
909 |
/* Adds a News Sitemap box to the side column */
|
910 |
public function add_meta_box_news () {
|
911 |
$news_tags = parent::get_option('news_tags');
|
912 |
-
|
|
|
|
|
|
|
913 |
// Only include metabox on post types that are included
|
914 |
add_meta_box(
|
915 |
'xmlsf_news_section',
|
@@ -988,45 +995,64 @@ jQuery( document ).ready( function() {
|
|
988 |
}
|
989 |
|
990 |
/**
|
991 |
-
|
992 |
-
|
993 |
|
994 |
-
function
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
995 |
$sitemaps = parent::get_sitemaps();
|
996 |
-
$prefix = parent::prefix();
|
997 |
|
998 |
// sitemaps
|
999 |
-
register_setting('reading', $prefix.'sitemaps', array($this,'sanitize_sitemaps_settings') );
|
1000 |
-
add_settings_field($prefix.'sitemaps', __('Enable XML sitemaps','xml-sitemap-feed'), array($this,'sitemaps_settings_field'), 'reading');
|
1001 |
|
1002 |
|
1003 |
// robots rules only when permalinks are set
|
1004 |
$rules = get_option( 'rewrite_rules' );
|
1005 |
if( get_option('permalink_structure') && isset( $rules['robots\.txt$'] ) ) {
|
1006 |
-
register_setting('reading', $prefix.'robots', array($this,'sanitize_robots_settings') );
|
1007 |
-
add_settings_field($prefix.'robots', __('Additional robots.txt rules','xml-sitemap-feed'), array($this,'robots_settings_field'), 'reading');
|
1008 |
}
|
1009 |
|
1010 |
-
// ACTION LINK
|
1011 |
-
add_filter('plugin_action_links_' . XMLSF_PLUGIN_BASENAME, array($this, 'add_action_link') );
|
1012 |
-
|
1013 |
// stop here if blog is not public
|
1014 |
if ( !get_option('blog_public') ) { return; }
|
1015 |
|
1016 |
if ( is_multisite() ) {
|
1017 |
-
add_settings_field($prefix.'reset', __('Reset XML sitemaps','xml-sitemap-feed'), array($this,'reset_settings_field'), 'reading');
|
1018 |
}
|
1019 |
|
1020 |
if ( isset($sitemaps['sitemap-news']) ) {
|
1021 |
// XML SITEMAP SETTINGS
|
1022 |
add_settings_section('news_sitemap_section', '<a name="xmlnf"></a>'.__('Google News Sitemap','xml-sitemap-feed'), array($this,'news_sitemap_settings'), 'reading');
|
1023 |
// tags
|
1024 |
-
register_setting('reading', $prefix.'news_tags', array($this,'sanitize_news_tags_settings') );
|
1025 |
-
add_settings_field($prefix.'news_name', '<label for="xmlsf_news_name">'.__('Publication name','xml-sitemap-feed').'</label>', array($this,'news_name_field'), 'reading', 'news_sitemap_section');
|
1026 |
-
add_settings_field($prefix.'news_post_type', __('Include post types','xml-sitemap-feed'), array($this,'news_post_type_field'), 'reading', 'news_sitemap_section');
|
1027 |
-
add_settings_field($prefix.'news_categories', translate('Categories'), array($this,'news_categories_field'), 'reading', 'news_sitemap_section');
|
1028 |
-
add_settings_field($prefix.'news_image', translate('Images'), array($this,'news_image_field'), 'reading', 'news_sitemap_section');
|
1029 |
-
add_settings_field($prefix.'news_labels', __('Source labels','xml-sitemap-feed'), array($this,'news_labels_field'), 'reading', 'news_sitemap_section');
|
1030 |
// post meta box
|
1031 |
add_action( 'add_meta_boxes', array($this,'add_meta_box_news') );
|
1032 |
}
|
@@ -1035,32 +1061,45 @@ jQuery( document ).ready( function() {
|
|
1035 |
// XML SITEMAP SETTINGS
|
1036 |
add_settings_section('xml_sitemap_section', '<a name="xmlsf"></a>'.__('XML Sitemap','xml-sitemap-feed'), array($this,'xml_sitemap_settings'), 'reading');
|
1037 |
// post_types
|
1038 |
-
register_setting('reading', $prefix.'post_types', array($this,'sanitize_post_types_settings') );
|
1039 |
-
add_settings_field($prefix.'post_types', __('Include post types','xml-sitemap-feed'), array($this,'post_types_settings_field'), 'reading', 'xml_sitemap_section');
|
1040 |
// taxonomies
|
1041 |
-
register_setting('reading', $prefix.'taxonomies', array($this,'sanitize_taxonomies_settings') );
|
1042 |
-
add_settings_field($prefix.'taxonomies', __('Include taxonomies','xml-sitemap-feed'), array($this,'taxonomies_settings_field'), 'reading', 'xml_sitemap_section');
|
1043 |
// custom domains
|
1044 |
-
register_setting('reading', $prefix.'domains', array($this,'sanitize_domains_settings') );
|
1045 |
-
add_settings_field($prefix.'domains', __('Allowed domains','xml-sitemap-feed'), array($this,'domains_settings_field'), 'reading', 'xml_sitemap_section');
|
1046 |
// custom urls
|
1047 |
-
register_setting('reading', $prefix.'urls', array($this,'sanitize_urls_settings') );
|
1048 |
-
add_settings_field($prefix.'urls', __('Include custom URLs','xml-sitemap-feed'), array($this,'urls_settings_field'), 'reading', 'xml_sitemap_section');
|
1049 |
// custom sitemaps
|
1050 |
-
register_setting('reading', $prefix.'custom_sitemaps', array($this,'sanitize_custom_sitemaps_settings') );
|
1051 |
-
add_settings_field($prefix.'custom_sitemaps', __('Include custom XML Sitemaps','xml-sitemap-feed'), array($this,'custom_sitemaps_settings_field'), 'reading', 'xml_sitemap_section');
|
1052 |
// post meta box
|
1053 |
add_action( 'add_meta_boxes', array($this,'add_meta_box') );
|
1054 |
}
|
1055 |
|
1056 |
if ( isset($sitemaps['sitemap']) || isset($sitemaps['sitemap-news']) ) {
|
1057 |
-
register_setting('writing', $prefix.'ping', array($this,'sanitize_ping_settings') );
|
1058 |
-
add_settings_field($prefix.'ping', translate('Update Services'), array($this,'ping_settings_field'), 'writing');
|
1059 |
// save post meta box settings
|
1060 |
add_action( 'save_post', array($this,'save_metadata') );
|
1061 |
}
|
1062 |
}
|
1063 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1064 |
}
|
1065 |
|
1066 |
/* ----------------------
|
18 |
public function sitemaps_settings_field() {
|
19 |
$options = parent::get_sitemaps();
|
20 |
$disabled = ('1' == get_option('blog_public')) ? false : true;
|
|
|
21 |
|
22 |
echo '<fieldset id="xmlsf_sitemaps"><legend class="screen-reader-text">'.__('XML Sitemaps','xml-sitemap-feed').'</legend>
|
23 |
+
<label><input type="checkbox" name="'.$this->prefix.'sitemaps[sitemap]" id="xmlsf_sitemaps_index" value="'.htmlspecialchars(XMLSF_NAME).'" '.checked(isset($options['sitemap']), true, false).' '.disabled($disabled, true, false).' /> '.__('XML Sitemap Index','xml-sitemap-feed').'</label>';//xmlsf
|
24 |
if (isset($options['sitemap']))
|
25 |
echo '<span class="description"> – <a href="#xmlsf" id="xmlsf_link">'.translate('Settings').'</a> – <a href="'.trailingslashit(get_bloginfo('url')). ( ('' == get_option('permalink_structure')) ? '?feed=sitemap' : $options['sitemap'] ) .'" target="_blank">'.translate('View').'</a></span>';
|
26 |
|
27 |
echo '<br>
|
28 |
+
<label><input type="checkbox" name="'.$this->prefix.'sitemaps[sitemap-news]" id="xmlsf_sitemaps_news" value="'.htmlspecialchars(XMLSF_NEWS_NAME).'" '.checked(isset($options['sitemap-news']), true, false).' '.disabled($disabled, true, false).' /> '.__('Google News Sitemap','xml-sitemap-feed').'</label>';
|
29 |
if (isset($options['sitemap-news']))
|
30 |
echo '<span class="description"> – <a href="#xmlnf" id="xmlnf_link">'.translate('Settings').'</a> – <a href="'.trailingslashit(get_bloginfo('url')). ( ('' == get_option('permalink_structure')) ? '?feed=sitemap-news' : $options['sitemap-news'] ) .'" target="_blank">'.translate('View').'</a></span>';
|
31 |
|
66 |
$options = parent::get_ping();
|
67 |
$defaults = parent::defaults('ping');
|
68 |
$update_services = get_option('ping_sites');
|
69 |
+
|
70 |
$names = array(
|
71 |
'google' => array (
|
72 |
'name' => __('Google','xml-sitemap-feed'),
|
73 |
+
),
|
74 |
'bing' => array (
|
75 |
'name' => __('Bing & Yahoo','xml-sitemap-feed'),
|
76 |
+
),
|
77 |
'yandex' => array (
|
78 |
'name' => __('Yandex','xml-sitemap-feed'),
|
79 |
+
),
|
80 |
'baidu' => array (
|
81 |
'name' => __('Baidu','xml-sitemap-feed'),
|
82 |
+
),
|
83 |
'others' => array (
|
84 |
'name' => __('Ping-O-Matic','xml-sitemap-feed'),
|
85 |
+
)
|
86 |
+
);
|
87 |
foreach ( $names as $key => $values ) {
|
88 |
if (array_key_exists($key,$defaults) && is_array($values))
|
89 |
$defaults[$key] += $values;
|
90 |
}
|
91 |
+
|
92 |
echo '
|
93 |
<fieldset id="xmlsf_ping"><legend class="screen-reader-text">'.translate('Update Services').'</legend>
|
94 |
';
|
|
|
95 |
|
96 |
+
foreach ( $defaults as $key => $values ) {
|
97 |
if ( isset($values['type']) && $values['type'] == 'RPC' ) {
|
98 |
$active = ( strpos($update_services,untrailingslashit($values['uri'])) === false ) ? false : true;
|
99 |
} else {
|
100 |
$active = !empty($options[$key]['active']) ? true : false;
|
101 |
}
|
102 |
echo '
|
103 |
+
<label><input type="checkbox" name="'.$this->prefix.'ping['.
|
104 |
$key.'][active]" id="xmlsf_ping_'.
|
105 |
$key.'" value="1"'.
|
106 |
checked( $active, true, false).' /> ';
|
108 |
echo '</label>';
|
109 |
|
110 |
echo '
|
111 |
+
<input type="hidden" name="'.$this->prefix.'ping['.
|
112 |
$key.'][uri]" value="'.
|
113 |
$values['uri'].'" />';
|
114 |
echo '
|
115 |
+
<input type="hidden" name="'.$this->prefix.'ping['.
|
116 |
$key.'][type]" value="'.
|
117 |
$values['type'].'" />';
|
118 |
if (isset($values['news']))
|
119 |
echo '
|
120 |
+
<input type="hidden" name="'.$this->prefix.'ping['.
|
121 |
$key.'][news]" value="'.
|
122 |
$values['news'].'" />';
|
123 |
|
133 |
|
134 |
foreach ((array)$options[$key]['pong'] as $pretty => $time) {
|
135 |
echo '
|
136 |
+
<input type="hidden" name="'.$this->prefix.'ping['.
|
137 |
$key.'][pong]['.$pretty.']" value="'.
|
138 |
$time.'" />';
|
139 |
if ( !empty($time) )
|
199 |
public function robots_settings_field() {
|
200 |
echo '
|
201 |
<fieldset><legend class="screen-reader-text">'.__('Additional robots.txt rules','xml-sitemap-feed').'</legend>
|
202 |
+
<label>'.sprintf(__('Rules that will be appended to the %s generated by WordPress:','xml-sitemap-feed'),'<a href="'.trailingslashit(get_bloginfo('url')).'robots.txt" target="_blank">robots.txt</a>').'<br><textarea name="'.$this->prefix.'robots" id="xmlsf_robots" class="large-text" cols="50" rows="6" />'.esc_attr( parent::get_robots() ).'</textarea></label>
|
203 |
<p class="description">'.__('These rules will not have effect when you are using a static robots.txt file.','xml-sitemap-feed').'<br><span style="color: red" class="warning">'.__('Only add rules here when you know what you are doing, otherwise you might break search engine access to your site.','xml-sitemap-feed').'</span></p>
|
204 |
</fieldset>';
|
205 |
}
|
207 |
public function reset_settings_field() {
|
208 |
echo '
|
209 |
<fieldset><legend class="screen-reader-text">'.__('Reset XML sitemaps','xml-sitemap-feed').'</legend>
|
210 |
+
<label><input type="checkbox" name="'.$this->prefix.'sitemaps[reset]" value="1" onchange="if(this.checked){if(!confirm(\''.
|
211 |
__('Selecting this will clear all XML Sitemap & Google News Sitemap settings after Save Changes. Are you sure?','xml-sitemap-feed').'\')){this.checked=false}}" /> '.
|
212 |
__('Clear all XML Sitemap & Google News Sitemap settings.','xml-sitemap-feed').'</label>
|
213 |
</fieldset>';
|
230 |
public function post_types_settings_field() {
|
231 |
$options = parent::get_post_types();
|
232 |
$defaults = parent::defaults('post_types');
|
|
|
233 |
$do_note = false;
|
234 |
|
235 |
$post_types = get_post_types(array('public'=>true),'objects');
|
246 |
$count = wp_count_posts( $post_type->name );
|
247 |
|
248 |
echo '
|
249 |
+
<input type="hidden" name="'.$this->prefix.'post_types['.
|
250 |
$post_type->name.'][name]" value="'.
|
251 |
$post_type->name.'" />';
|
252 |
|
253 |
echo '
|
254 |
+
<label><input type="checkbox" name="'.$this->prefix.'post_types['.
|
255 |
$post_type->name.'][active]" id="xmlsf_post_types_'.
|
256 |
$post_type->name.'" value="1" '.
|
257 |
checked( !empty($options[$post_type->name]["active"]), true, false).' /> '.
|
280 |
);
|
281 |
$archive = !empty($options[$post_type->name]['archive']) ? $options[$post_type->name]['archive'] : $defaults[$post_type->name]['archive'];
|
282 |
echo '
|
283 |
+
<li><label>'.__('Split by','xml-sitemap-feed').' <select name="'.$this->prefix.'post_types['.
|
284 |
$post_type->name.'][archive]" id="xmlsf_post_types_'.
|
285 |
$post_type->name.'_archive">
|
286 |
<option value="">'.translate('None').'</option>';
|
295 |
|
296 |
$priority_val = !empty($options[$post_type->name]['priority']) ? $options[$post_type->name]['priority'] : $defaults[$post_type->name]['priority'];
|
297 |
echo '
|
298 |
+
<li><label>'.__('Priority','xml-sitemap-feed').' <input type="number" step="0.1" min="0.1" max="0.9" name="'.$this->prefix.'post_types['.
|
299 |
$post_type->name.'][priority]" id="xmlsf_post_types_'.
|
300 |
$post_type->name.'_priority" value="'.$priority_val.'" class="small-text"></label> <span class="description">'.__('Priority can be overridden on individual posts.','xml-sitemap-feed').' *</span></li>';
|
301 |
|
302 |
echo '
|
303 |
+
<li><label><input type="checkbox" name="'.$this->prefix.'post_types['.
|
304 |
$post_type->name.'][dynamic_priority]" value="1" '.
|
305 |
checked( !empty($options[$post_type->name]['dynamic_priority']), true, false).' /> '.__('Automatic Priority calculation.','xml-sitemap-feed').'</label> <span class="description">'.__('Adjusts the Priority based on factors like age, comments, sticky post or blog page. Individual posts with fixed Priority will always keep that value.','xml-sitemap-feed').'</span></li>';
|
306 |
|
307 |
echo '
|
308 |
+
<li><label><input type="checkbox" name="'.$this->prefix.'post_types['.
|
309 |
$post_type->name.'][update_lastmod_on_comments]" value="1" '.
|
310 |
+
checked( !empty($options[$post_type->name]["update_lastmod_on_comments"]), true, false).' /> '.__('Update Lastmod on comments.','xml-sitemap-feed').'</label> <span class="description">'.__('Set this if discussion on your site warrants reindexation upon each new comment.','xml-sitemap-feed').'</li>';
|
311 |
|
312 |
$image = isset($options[$post_type->name]['tags']['image']) ? $options[$post_type->name]['tags']['image'] : $defaults[$post_type->name]['tags']['image'];
|
313 |
+
$context = ( $post_type->name === 'page' ) ? 'page' : 'post';
|
314 |
echo '
|
315 |
+
<li><label>'.__('Add image tags for','xml-sitemap-feed').' <select name="'.$this->prefix.'post_types['.
|
316 |
$post_type->name.'][tags][image]">
|
317 |
<option value="">'.translate('None').'</option>
|
318 |
<option value="featured" '.
|
319 |
selected( $image == "featured", true, false).
|
320 |
+
'>'.translate_with_gettext_context('Featured Image',$context).'</option>
|
321 |
<option value="attached" '.
|
322 |
selected( $image == "attached", true, false).
|
323 |
'>'.__('Attached images','xml-sitemap-feed').'</option>
|
330 |
}
|
331 |
|
332 |
echo '
|
333 |
+
<p class="description">* '.__('Priority settings do not affect ranking in search results in any way. They are only meant to suggest search engines which URLs to index first. Once a URL has been indexed, its Priority becomes meaningless until its Lastmod is updated.','xml-sitemap-feed').' <a href="#xmlsf_post_types_note_1_more" id="xmlsf_post_types_note_1_link">'.translate('Read more...').'</a>
|
334 |
<span id="xmlsf_post_types_note_1_more">'.__('Maximum Priority (1.0) is reserved for the front page, individual posts and, when allowed, posts with high comment count.','xml-sitemap-feed').' '.__('Priority values are taken as relative values. Setting all to the same (high) value is pointless.','xml-sitemap-feed').'</span></p>
|
335 |
<script type="text/javascript">
|
336 |
jQuery( document ).ready( function() {
|
364 |
|
365 |
$count = wp_count_terms( $taxonomy->name );
|
366 |
$output .= '
|
367 |
+
<label><input type="checkbox" name="'.$this->prefix.'taxonomies['.
|
368 |
$taxonomy->name.']" id="xmlsf_taxonomies_'.
|
369 |
$taxonomy->name.'" value="'.
|
370 |
$taxonomy->name.'"'.
|
387 |
echo $output;
|
388 |
|
389 |
echo '
|
390 |
+
<p class="description">'.__('It is generally not recommended to include taxonomy pages, unless their content brings added value.','xml-sitemap-feed').' <a href="#xmlsf_taxonomies_note_1_more" id="xmlsf_taxonomies_note_1_link">'.translate('Read more...').'</a>
|
391 |
<span id="xmlsf_taxonomies_note_1_more">'.__('For example, when you use category descriptions with information that is not present elsewhere on your site or if taxonomy pages list posts with an excerpt that is different from, but complementary to the post content. In these cases you might consider including certain taxonomies. Otherwise, if you fear <a href="http://moz.com/learn/seo/duplicate-content">negative affects of duplicate content</a> or PageRank spread, you might even consider disallowing indexation of taxonomies.','xml-sitemap-feed').' '.
|
392 |
sprintf(__('You can do this by adding specific robots.txt rules in the %s field above.','xml-sitemap-feed'),'<strong>'.__('Additional robots.txt rules','xml-sitemap-feed').'</strong>');
|
393 |
echo '</span></p>
|
414 |
echo '
|
415 |
<fieldset><legend class="screen-reader-text">'.__('Include custom XML Sitemaps','xml-sitemap-feed').'</legend>
|
416 |
<label>'.__('Additional XML Sitemaps to append to the main XML Sitemap Index:','xml-sitemap-feed').'<br>
|
417 |
+
<textarea name="'.$this->prefix.'custom_sitemaps" id="xmlsf_custom_sitemaps" class="large-text" cols="50" rows="4" />'. implode("\n",$lines) .'</textarea></label>
|
418 |
<p class="description">'.__('Add the full URL, including protocol (http/https) and domain, of any XML Sitemap that you want to append to the Sitemap Index. Start each URL on a new line.','xml-sitemap-feed').'<br><span style="color: red" class="warning">'.__('Only valid sitemaps are allowed in the Sitemap Index. Use your Google/Bing Webmaster Tools to verify!','xml-sitemap-feed').'</span></p>
|
419 |
</fieldset>';
|
420 |
|
434 |
echo '
|
435 |
<fieldset><legend class="screen-reader-text">'.__('Include custom URLs','xml-sitemap-feed').'</legend>
|
436 |
<label>'.__('Additional URLs to append in an extra XML Sitemap:','xml-sitemap-feed').'<br>
|
437 |
+
<textarea name="'.$this->prefix.'urls" id="xmlsf_urls" class="large-text" cols="50" rows="4" />'. implode("\n",$lines) .'</textarea></label>
|
438 |
<p class="description">'.__('Add the full URL, including protocol (http/https) and domain, of any (static) page that you want to append to the ones already included by WordPress. Optionally add a priority value between 0 and 1, separated with a space after the URL. Start each URL on a new line.','xml-sitemap-feed').'</p>
|
439 |
</fieldset>';
|
440 |
|
446 |
|
447 |
echo '
|
448 |
<fieldset><legend class="screen-reader-text">'.__('Allowed domains','xml-sitemap-feed').'</legend>
|
449 |
+
<label>'.__('Additional domains to allow in the XML Sitemaps:','xml-sitemap-feed').'<br><textarea name="'.$this->prefix.'domains" id="xmlsf_domains" class="large-text" cols="50" rows="4" />'. implode("\n",$domains) .'</textarea></label>
|
450 |
<p class="description">'.sprintf(__('By default, only the domain %s as used in your WordPress site address is allowed. This means that all URLs that use another domain (custom URLs or using a plugin like Page Links To) are filtered from the XML Sitemap. However, if you are the verified owner of other domains in your Google/Bing Webmaster Tools account, you can include these in the same sitemap. Add these domains, without protocol (http/https) each on a new line. Note that if you enter a domain with www, all URLs without it or with other subdomains will be filtered.','xml-sitemap-feed'),'<strong>'.$default.'</strong>').'</p>
|
451 |
</fieldset>';
|
452 |
|
475 |
$name = !empty($options['name']) ? $options['name'] : '';
|
476 |
echo '
|
477 |
<fieldset><legend class="screen-reader-text">'.__('Publication name','xml-sitemap-feed').'</legend>
|
478 |
+
<input type="text" name="'.$this->prefix.'news_tags[name]" id="xmlsf_news_name" value="'.$name.'" class="regular-text"> <span class="description">'.sprintf(__('By default, the general %s setting will be used.','xml-sitemap-feed'),'<a href="options-general.php">'.translate('Site Title').'</a>').'</span><p class="description">' .
|
479 |
__('The publication name should match the name submitted on the Google News Publisher Center. If you wish to change it, please read <a href="https://support.google.com/news/publisher/answer/40402" target="_blank">Updated publication name</a>.','xml-sitemap-feed') . '</p>
|
480 |
</fieldset>';
|
481 |
}
|
483 |
public function news_post_type_field() {
|
484 |
$defaults = parent::defaults('news_tags');
|
485 |
$options = parent::get_option('news_tags');
|
|
|
486 |
|
487 |
+
$news_post_type = isset($options['post_type']) && !empty($options['post_type']) ? $options['post_type'] : $defaults['post_type'];
|
488 |
|
489 |
$post_types = get_post_types(array('publicly_queryable' =>true),'objects');
|
490 |
|
514 |
}
|
515 |
|
516 |
echo '
|
517 |
+
<label><input type="checkbox" name="'.$this->prefix.'news_tags[post_type][]" id="xmlsf_post_type_'.
|
518 |
$post_type->name.'" value="'.$post_type->name.'" '.
|
519 |
checked( $checked, true, false).' '.
|
520 |
disabled( $disabled, true, false).' /> '.
|
551 |
$size = $count < 15 ? $count : 15;
|
552 |
echo '
|
553 |
<label>'.__('Limit to posts in these post categories:','xml-sitemap-feed').'<br>
|
554 |
+
<select multiple name="'.$this->prefix.'news_tags[categories][]" size="'.$size.'">';
|
555 |
|
556 |
foreach($all_categories as $category) {
|
557 |
$depth = count( explode( '%#%', get_category_parents($category, false, '%#%') ) ) - 2;
|
578 |
$image = !empty($options['image']) ? $options['image'] : '';
|
579 |
echo '
|
580 |
<fieldset><legend class="screen-reader-text">'.translate('Images').'</legend>
|
581 |
+
<label>'.__('Add image tags for','xml-sitemap-feed').' <select name="'.$this->prefix.'news_tags[image]">
|
582 |
<option value="">'.translate('None').'</option>
|
583 |
<option value="featured" '.
|
584 |
selected( $image == "featured", true, false).
|
585 |
+
'>'.translate_with_gettext_context('Featured Image','post').'</option>
|
586 |
<option value="attached" '.
|
587 |
selected( $image == "attached", true, false).
|
588 |
'>'.__('Attached images','xml-sitemap-feed').'</option>
|
589 |
';
|
590 |
echo '</select></label>
|
591 |
+
<p class="description">'.__('Note: Google News prefers at most one image per article in the News Sitemap. If multiple valid images are specified, the crawler will have to pick one arbitrarily. Images in News Sitemaps should be in jpeg or png format.','xml-sitemap-feed').' <a href="https://support.google.com/news/publisher/answer/13369" target="_blank">'.translate('Read more...').'</a></p>
|
592 |
</fieldset>';
|
593 |
}
|
594 |
|
595 |
public function news_labels_field() {
|
596 |
echo '
|
597 |
+
<fieldset id="xmlsf_news_labels"><legend class="screen-reader-text">' . __('Source labels','xml-sitemap-feed') . '</legend>
|
598 |
+
<p>' . __('Source labels provide more information about the content of your articles.','xml-sitemap-feed') . '</p>';
|
|
|
599 |
|
600 |
$options = parent::get_option('news_tags');
|
|
|
601 |
|
602 |
// access tag
|
603 |
$access = !empty($options['access']) ? $options['access'] : '';
|
605 |
$access_password = !empty($access['password']) ? $access['password'] : '';
|
606 |
echo '
|
607 |
<fieldset id="xmlsf_news_labels_access"><legend class="screen-reader-text"><access></legend>
|
608 |
+
<p>'.sprintf(__('The %4$s tag specifies whether an article is available to all readers (%1$s), or only to those with a free (%2$s) or paid membership (%3$s) to your site.','xml-sitemap-feed'),translate('Public'),__('Registration','xml-sitemap-feed'),__('Subscription','xml-sitemap-feed'),'<strong><access></strong>').'
|
609 |
+
'.__('You can assign a different access level when writing a post.','xml-sitemap-feed') . '</p>
|
610 |
<ul>';
|
611 |
|
612 |
echo '
|
613 |
+
<li><label>'.__('Tag normal posts as','xml-sitemap-feed').' <select name="'.$this->prefix.'news_tags[access][default]" id="xmlsf_news_tags_access_default">
|
614 |
<option value="">'.translate('Public').'</option>
|
615 |
<option value="Registration" '.selected( "Registration" == $access_default, true, false).'>'.__('Free registration','xml-sitemap-feed').'</option>
|
616 |
<option value="Subscription" '.selected( "Subscription" == $access_default, true, false).'>'.__('Paid subscription','xml-sitemap-feed').'</option>
|
617 |
</select></label></li>';
|
618 |
echo '
|
619 |
+
<li><label>'.__('Tag Password Protected posts as','xml-sitemap-feed').' <select name="'.$this->prefix.'news_tags[access][password]" id="xmlsf_news_tags_access_password">
|
620 |
<option value="Registration" '.selected( "Registration" == $access_password, true, false).'>'.__('Free registration','xml-sitemap-feed').'</option>
|
621 |
<option value="Subscription" '.selected( "Subscription" == $access_password, true, false).'>'.__('Paid subscription','xml-sitemap-feed').'</option>
|
622 |
</select></label></li>';
|
626 |
|
627 |
// genres tag
|
628 |
$gn_genres = parent::gn_genres();
|
629 |
+
$gn_translations = $gn_genres = array(
|
630 |
+
'PressRelease' => __('PressRelease','xml-sitemap-feed'),
|
631 |
+
'Satire' => __('Satire','xml-sitemap-feed'),
|
632 |
+
'Blog' => __('Blog','xml-sitemap-feed'),
|
633 |
+
'OpEd' => __('OpEd','xml-sitemap-feed'),
|
634 |
+
'Opinion' => __('Opinion','xml-sitemap-feed'),
|
635 |
+
'UserGenerated' => __('UserGenerated','xml-sitemap-feed'),
|
636 |
+
'FactCheck' => __('FactCheck','xml-sitemap-feed')
|
637 |
+
);
|
638 |
$genres = !empty($options['genres']) ? $options['genres'] : array();
|
639 |
$genres_default = !empty($genres['default']) ? (array)$genres['default'] : array();
|
640 |
|
641 |
echo '
|
642 |
<fieldset id="xmlsf_news_labels_genres"><legend class="screen-reader-text"><genres></legend>
|
643 |
+
<p>'.sprintf(__('The %s tag specifies one or more properties for an article, namely, whether it is a press release, a blog post, an opinion, an op-ed piece, user-generated content, or satire.','xml-sitemap-feed'),'<strong><genres></strong>').' '.__('You can assign different genres when writing a post.','xml-sitemap-feed');
|
644 |
|
645 |
+
echo '</p>
|
646 |
+
<p class="description">'.__('Use Ctrl plus click to select more than one or to deselect.','xml-sitemap-feed').' '.__('The FactCheck label may be applied if you publish stories with fact-checking content that\'s indicated by schema.org ClaimReview markup.','xml-sitemap-feed').' '.sprintf(__('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>').'</p>
|
647 |
<ul>
|
648 |
+
<li><label>'.__('Default genre:','xml-sitemap-feed').'<br><select multiple name="'.$this->prefix.'news_tags[genres][default][]" id="xmlsf_news_tags_genres_default" size="'.count($gn_genres).'">';
|
649 |
+
foreach ( $gn_genres as $name ) {
|
650 |
+
echo '<option value="'.$name.'" '.selected( in_array($name,$genres_default), true, false ).'>' . ( isset($gn_translations[$name]) && !empty($gn_translations[$name]) ? $gn_translations[$name] : $name ) . ' </option>';
|
|
|
651 |
}
|
652 |
echo '
|
653 |
</select></label></li>
|
654 |
</ul>
|
|
|
|
|
655 |
</fieldset>';
|
656 |
|
|
|
657 |
// keywords
|
658 |
$keywords = !empty($options['keywords']) ? $options['keywords'] : array();
|
659 |
$keywords_from = !empty($keywords['from']) ? $keywords['from'] : '';
|
660 |
echo '
|
661 |
<fieldset id="xmlsf_news_keywords"><legend class="screen-reader-text"><keywords></legend>
|
662 |
+
<p>'.sprintf(__('The %s tag is used to help classify the articles you submit to Google News by <strong>topic</strong>.','xml-sitemap-feed'),'<strong><keywords></strong>').'</p>
|
663 |
<ul>
|
664 |
+
<li><label>'.sprintf(__('Use %s for topics.','xml-sitemap-feed'),' <select name="'.$this->prefix.'news_tags[keywords][from]" id="xmlsf_news_tags_keywords_from">
|
665 |
<option value="">'.translate('None').'</option>
|
666 |
<option value="category" '.selected( "category" == $keywords_from, true, false).'>'.translate('Categories').'</option>
|
667 |
<option value="post_tag" '.selected( "post_tag" == $keywords_from, true, false).'>'.translate('Tags').'</option>
|
668 |
</select>').'</label></li>';
|
669 |
+
if ("category" !== $keywords_from) {
|
670 |
echo '
|
671 |
+
<li><label>'.__('Default topic(s):','xml-sitemap-feed').' <input type="text" name="'.$this->prefix.'news_tags[keywords][default]" id="xmlsf_news_tags_keywords_default" value="';
|
672 |
echo !empty($keywords['default']) ? $keywords['default'] : '';
|
673 |
echo '" class="regular-text"></label> <span class="description">'.__('Separate with a comma.','xml-sitemap-feed').'</span></li>';
|
674 |
}
|
844 |
}
|
845 |
|
846 |
public function sanitize_news_tags_settings($new) {
|
847 |
+
// TODO default post type : to 'post' when none are selected
|
848 |
return $new;
|
849 |
}
|
850 |
|
913 |
/* Adds a News Sitemap box to the side column */
|
914 |
public function add_meta_box_news () {
|
915 |
$news_tags = parent::get_option('news_tags');
|
916 |
+
$defaults = parent::defaults('news_tags');
|
917 |
+
$news_post_type = isset($news_tags['post_type']) && !empty($news_tags['post_type']) ? $news_tags['post_type'] : $defaults['post_type'];
|
918 |
+
|
919 |
+
foreach ( (array)$news_post_type as $post_type ) {
|
920 |
// Only include metabox on post types that are included
|
921 |
add_meta_box(
|
922 |
'xmlsf_news_section',
|
995 |
}
|
996 |
|
997 |
/**
|
998 |
+
* Catch transient flags
|
999 |
+
*/
|
1000 |
|
1001 |
+
function handle_flags() {
|
1002 |
+
// CATCH TRANSIENT for reset
|
1003 |
+
if ( delete_transient('xmlsf_clear_settings') ) {
|
1004 |
+
$this->clear_settings();
|
1005 |
+
}
|
1006 |
+
|
1007 |
+
// CATCH TRANSIENT for flushing rewrite rules after the sitemaps setting has changed
|
1008 |
+
if ( delete_transient('xmlsf_flush_rewrite_rules') ) {
|
1009 |
+
$this->flush_rules();
|
1010 |
+
}
|
1011 |
+
|
1012 |
+
// CATCH TRANSIENT for recreating terms
|
1013 |
+
if ( delete_transient('xmlsf_create_genres') ) {
|
1014 |
+
foreach ($this->gn_genres as $name) {
|
1015 |
+
wp_insert_term( $name, 'gn-genre' );
|
1016 |
+
}
|
1017 |
+
}
|
1018 |
+
}
|
1019 |
+
|
1020 |
+
/**
|
1021 |
+
* Register settings and add settings fields
|
1022 |
+
*/
|
1023 |
+
|
1024 |
+
function register_settings() {
|
1025 |
$sitemaps = parent::get_sitemaps();
|
|
|
1026 |
|
1027 |
// sitemaps
|
1028 |
+
register_setting('reading', $this->prefix.'sitemaps', array($this,'sanitize_sitemaps_settings') );
|
1029 |
+
add_settings_field($this->prefix.'sitemaps', __('Enable XML sitemaps','xml-sitemap-feed'), array($this,'sitemaps_settings_field'), 'reading');
|
1030 |
|
1031 |
|
1032 |
// robots rules only when permalinks are set
|
1033 |
$rules = get_option( 'rewrite_rules' );
|
1034 |
if( get_option('permalink_structure') && isset( $rules['robots\.txt$'] ) ) {
|
1035 |
+
register_setting('reading', $this->prefix.'robots', array($this,'sanitize_robots_settings') );
|
1036 |
+
add_settings_field($this->prefix.'robots', __('Additional robots.txt rules','xml-sitemap-feed'), array($this,'robots_settings_field'), 'reading');
|
1037 |
}
|
1038 |
|
|
|
|
|
|
|
1039 |
// stop here if blog is not public
|
1040 |
if ( !get_option('blog_public') ) { return; }
|
1041 |
|
1042 |
if ( is_multisite() ) {
|
1043 |
+
add_settings_field($this->prefix.'reset', __('Reset XML sitemaps','xml-sitemap-feed'), array($this,'reset_settings_field'), 'reading');
|
1044 |
}
|
1045 |
|
1046 |
if ( isset($sitemaps['sitemap-news']) ) {
|
1047 |
// XML SITEMAP SETTINGS
|
1048 |
add_settings_section('news_sitemap_section', '<a name="xmlnf"></a>'.__('Google News Sitemap','xml-sitemap-feed'), array($this,'news_sitemap_settings'), 'reading');
|
1049 |
// tags
|
1050 |
+
register_setting('reading', $this->prefix.'news_tags', array($this,'sanitize_news_tags_settings') );
|
1051 |
+
add_settings_field($this->prefix.'news_name', '<label for="xmlsf_news_name">'.__('Publication name','xml-sitemap-feed').'</label>', array($this,'news_name_field'), 'reading', 'news_sitemap_section');
|
1052 |
+
add_settings_field($this->prefix.'news_post_type', __('Include post types','xml-sitemap-feed'), array($this,'news_post_type_field'), 'reading', 'news_sitemap_section');
|
1053 |
+
add_settings_field($this->prefix.'news_categories', translate('Categories'), array($this,'news_categories_field'), 'reading', 'news_sitemap_section');
|
1054 |
+
add_settings_field($this->prefix.'news_image', translate('Images'), array($this,'news_image_field'), 'reading', 'news_sitemap_section');
|
1055 |
+
add_settings_field($this->prefix.'news_labels', __('Source labels','xml-sitemap-feed'), array($this,'news_labels_field'), 'reading', 'news_sitemap_section');
|
1056 |
// post meta box
|
1057 |
add_action( 'add_meta_boxes', array($this,'add_meta_box_news') );
|
1058 |
}
|
1061 |
// XML SITEMAP SETTINGS
|
1062 |
add_settings_section('xml_sitemap_section', '<a name="xmlsf"></a>'.__('XML Sitemap','xml-sitemap-feed'), array($this,'xml_sitemap_settings'), 'reading');
|
1063 |
// post_types
|
1064 |
+
register_setting('reading', $this->prefix.'post_types', array($this,'sanitize_post_types_settings') );
|
1065 |
+
add_settings_field($this->prefix.'post_types', __('Include post types','xml-sitemap-feed'), array($this,'post_types_settings_field'), 'reading', 'xml_sitemap_section');
|
1066 |
// taxonomies
|
1067 |
+
register_setting('reading', $this->prefix.'taxonomies', array($this,'sanitize_taxonomies_settings') );
|
1068 |
+
add_settings_field($this->prefix.'taxonomies', __('Include taxonomies','xml-sitemap-feed'), array($this,'taxonomies_settings_field'), 'reading', 'xml_sitemap_section');
|
1069 |
// custom domains
|
1070 |
+
register_setting('reading', $this->prefix.'domains', array($this,'sanitize_domains_settings') );
|
1071 |
+
add_settings_field($this->prefix.'domains', __('Allowed domains','xml-sitemap-feed'), array($this,'domains_settings_field'), 'reading', 'xml_sitemap_section');
|
1072 |
// custom urls
|
1073 |
+
register_setting('reading', $this->prefix.'urls', array($this,'sanitize_urls_settings') );
|
1074 |
+
add_settings_field($this->prefix.'urls', __('Include custom URLs','xml-sitemap-feed'), array($this,'urls_settings_field'), 'reading', 'xml_sitemap_section');
|
1075 |
// custom sitemaps
|
1076 |
+
register_setting('reading', $this->prefix.'custom_sitemaps', array($this,'sanitize_custom_sitemaps_settings') );
|
1077 |
+
add_settings_field($this->prefix.'custom_sitemaps', __('Include custom XML Sitemaps','xml-sitemap-feed'), array($this,'custom_sitemaps_settings_field'), 'reading', 'xml_sitemap_section');
|
1078 |
// post meta box
|
1079 |
add_action( 'add_meta_boxes', array($this,'add_meta_box') );
|
1080 |
}
|
1081 |
|
1082 |
if ( isset($sitemaps['sitemap']) || isset($sitemaps['sitemap-news']) ) {
|
1083 |
+
register_setting('writing', $this->prefix.'ping', array($this,'sanitize_ping_settings') );
|
1084 |
+
add_settings_field($this->prefix.'ping', translate('Update Services'), array($this,'ping_settings_field'), 'writing');
|
1085 |
// save post meta box settings
|
1086 |
add_action( 'save_post', array($this,'save_metadata') );
|
1087 |
}
|
1088 |
}
|
1089 |
|
1090 |
+
/**
|
1091 |
+
* CONSTRUCTOR
|
1092 |
+
*/
|
1093 |
+
|
1094 |
+
function __construct() {
|
1095 |
+
|
1096 |
+
// ACTION LINK
|
1097 |
+
add_filter('plugin_action_links_' . $this->plugin_basename, array($this, 'add_action_link') );
|
1098 |
+
|
1099 |
+
$this->handle_flags();
|
1100 |
+
|
1101 |
+
$this->register_settings();
|
1102 |
+
}
|
1103 |
}
|
1104 |
|
1105 |
/* ----------------------
|
includes/class-xmlsitemapfeed.php
CHANGED
@@ -5,6 +5,12 @@
|
|
5 |
|
6 |
class XMLSitemapFeed {
|
7 |
|
|
|
|
|
|
|
|
|
|
|
|
|
8 |
/**
|
9 |
* Pretty permalinks base name
|
10 |
* @var string
|
@@ -17,6 +23,12 @@ class XMLSitemapFeed {
|
|
17 |
*/
|
18 |
public $extension = 'xml';
|
19 |
|
|
|
|
|
|
|
|
|
|
|
|
|
20 |
/**
|
21 |
* Signifies whether the current query is for a sitemap feed.
|
22 |
* @var bool
|
@@ -33,7 +45,7 @@ class XMLSitemapFeed {
|
|
33 |
* Database options prefix
|
34 |
* @var string
|
35 |
*/
|
36 |
-
|
37 |
|
38 |
/**
|
39 |
* Default language
|
@@ -74,13 +86,14 @@ class XMLSitemapFeed {
|
|
74 |
* Google News genres
|
75 |
* @var array
|
76 |
*/
|
77 |
-
|
78 |
'PressRelease',
|
79 |
'Satire',
|
80 |
'Blog',
|
81 |
'OpEd',
|
82 |
'Opinion',
|
83 |
-
'UserGenerated'
|
|
|
84 |
);
|
85 |
|
86 |
/**
|
@@ -113,14 +126,6 @@ class XMLSitemapFeed {
|
|
113 |
return (bool) $this->is_news;
|
114 |
}
|
115 |
|
116 |
-
/**
|
117 |
-
* Get prefix
|
118 |
-
* @return string
|
119 |
-
*/
|
120 |
-
public function prefix() {
|
121 |
-
return $this->prefix;
|
122 |
-
}
|
123 |
-
|
124 |
/**
|
125 |
* Get gn_genres
|
126 |
* @return array
|
@@ -162,12 +167,7 @@ class XMLSitemapFeed {
|
|
162 |
* @return string
|
163 |
*/
|
164 |
public function home_url() {
|
165 |
-
|
166 |
-
if ( empty($this->home_url) ) {
|
167 |
-
$this->home_url = home_url();
|
168 |
-
}
|
169 |
-
|
170 |
-
return $this->home_url;
|
171 |
}
|
172 |
|
173 |
/**
|
@@ -177,39 +177,45 @@ class XMLSitemapFeed {
|
|
177 |
*/
|
178 |
private function set_defaults() {
|
179 |
// sitemaps
|
180 |
-
if ( '1' == get_option('blog_public') )
|
181 |
$this->defaults['sitemaps'] = array(
|
182 |
-
|
183 |
-
|
184 |
-
else
|
185 |
$this->defaults['sitemaps'] = array();
|
|
|
186 |
|
187 |
// post_types
|
188 |
$this->defaults['post_types'] = array();
|
|
|
189 |
foreach ( get_post_types(array('public'=>true),'names') as $name ) { // want 'publicly_queryable' but that excludes pages for some weird reason
|
190 |
// skip unallowed post types
|
191 |
-
if (in_array($name,$this->disabled_post_types))
|
192 |
continue;
|
|
|
193 |
|
194 |
$this->defaults['post_types'][$name] = array(
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
}
|
203 |
|
204 |
$active_arr = array('post','page');
|
205 |
|
206 |
-
foreach ( $active_arr as $name )
|
207 |
-
if ( isset($this->defaults['post_types'][$name]) )
|
208 |
$this->defaults['post_types'][$name]['active'] = '1';
|
|
|
|
|
209 |
|
210 |
if ( isset($this->defaults['post_types']['post']) ) {
|
211 |
-
if (wp_count_posts('post')->publish > 500)
|
212 |
$this->defaults['post_types']['post']['archive'] = 'yearly';
|
|
|
213 |
$this->defaults['post_types']['post']['priority'] = '0.7';
|
214 |
$this->defaults['post_types']['post']['dynamic_priority'] = '1';
|
215 |
}
|
@@ -228,34 +234,36 @@ class XMLSitemapFeed {
|
|
228 |
|
229 |
// search engines to ping
|
230 |
$this->defaults['ping'] = array(
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
|
|
|
|
259 |
|
260 |
// robots
|
261 |
$this->defaults['robots'] = '';
|
@@ -271,23 +279,23 @@ class XMLSitemapFeed {
|
|
271 |
|
272 |
// news sitemap tags settings
|
273 |
$this->defaults['news_tags'] = array(
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
|
282 |
-
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
}
|
292 |
|
293 |
/**
|
@@ -298,10 +306,11 @@ class XMLSitemapFeed {
|
|
298 |
* @return array
|
299 |
*/
|
300 |
protected function defaults($key = false) {
|
301 |
-
if (empty($this->defaults))
|
302 |
$this->set_defaults();
|
|
|
303 |
|
304 |
-
if ($key) {
|
305 |
$return = ( isset($this->defaults[$key]) ) ? $this->defaults[$key] : '';
|
306 |
} else {
|
307 |
$return = $this->defaults;
|
@@ -318,7 +327,7 @@ class XMLSitemapFeed {
|
|
318 |
* @return array
|
319 |
*/
|
320 |
public function get_option($option) {
|
321 |
-
return get_option($this->prefix.$option, $this->defaults($option));
|
322 |
}
|
323 |
|
324 |
/**
|
@@ -328,8 +337,8 @@ class XMLSitemapFeed {
|
|
328 |
public function get_sitemaps() {
|
329 |
$return = $this->get_option('sitemaps');
|
330 |
|
331 |
-
// make sure it's an array we are returning
|
332 |
-
return
|
333 |
}
|
334 |
|
335 |
/**
|
@@ -339,8 +348,8 @@ class XMLSitemapFeed {
|
|
339 |
public function get_ping() {
|
340 |
$return = $this->get_option('ping');
|
341 |
|
342 |
-
// make sure it's an array we are returning
|
343 |
-
return
|
344 |
}
|
345 |
|
346 |
/**
|
@@ -371,7 +380,7 @@ class XMLSitemapFeed {
|
|
371 |
$return = $this->get_option('post_types');
|
372 |
|
373 |
// make sure it's an array we are returning
|
374 |
-
return
|
375 |
}
|
376 |
|
377 |
/**
|
@@ -382,17 +391,16 @@ class XMLSitemapFeed {
|
|
382 |
$return = array();
|
383 |
|
384 |
foreach ( $this->get_post_types() as $type => $values ) {
|
385 |
-
if(!empty($values['active'])) {
|
386 |
$count = wp_count_posts( $values['name'] );
|
387 |
-
if ($count->publish > 0) {
|
388 |
$values['count'] = $count->publish;
|
389 |
$return[$type] = $values;
|
390 |
}
|
391 |
}
|
392 |
}
|
393 |
|
394 |
-
|
395 |
-
return (!empty($return)) ? (array)$return : array();
|
396 |
}
|
397 |
|
398 |
/**
|
@@ -403,7 +411,7 @@ class XMLSitemapFeed {
|
|
403 |
$return = $this->get_option('taxonomies');
|
404 |
|
405 |
// make sure it's an array we are returning
|
406 |
-
return
|
407 |
}
|
408 |
|
409 |
/**
|
@@ -413,7 +421,7 @@ class XMLSitemapFeed {
|
|
413 |
public function get_custom_sitemaps() {
|
414 |
$urls = $this->get_option('custom_sitemaps');
|
415 |
// make sure it's an array we are returning
|
416 |
-
if(!empty($urls)) {
|
417 |
$return = ( !is_array($urls) ) ? explode( PHP_EOL, $urls ) : $urls;
|
418 |
} else {
|
419 |
$return = array();
|
@@ -428,7 +436,7 @@ class XMLSitemapFeed {
|
|
428 |
public function get_urls() {
|
429 |
$urls = $this->get_option('urls');
|
430 |
// make sure it's an array we are returning
|
431 |
-
if( !empty($urls) ) {
|
432 |
$return = ( !is_array($urls) ) ? explode( PHP_EOL, $urls ) : $urls;
|
433 |
} else {
|
434 |
$return = array();
|
@@ -442,10 +450,11 @@ class XMLSitemapFeed {
|
|
442 |
*/
|
443 |
public function get_domains() {
|
444 |
$domains = $this->get_option('domains');
|
445 |
-
if (!empty($domains) && is_array($domains))
|
446 |
return array_merge( array( $this->domain() ), $domains );
|
447 |
-
else
|
448 |
return array( $this->domain() );
|
|
|
449 |
}
|
450 |
|
451 |
/**
|
@@ -456,13 +465,16 @@ class XMLSitemapFeed {
|
|
456 |
*
|
457 |
* @return array
|
458 |
*/
|
459 |
-
public function get_archives($post_type = 'post', $type = '') {
|
460 |
global $wpdb;
|
461 |
$return = array();
|
462 |
-
|
463 |
-
|
|
|
|
|
464 |
$key = md5($query);
|
465 |
$cache = wp_cache_get( 'xmlsf_get_archives' , 'general');
|
|
|
466 |
if ( !isset( $cache[ $key ] ) ) {
|
467 |
$arcresults = $wpdb->get_results($query);
|
468 |
$cache[ $key ] = $arcresults;
|
@@ -470,15 +482,19 @@ class XMLSitemapFeed {
|
|
470 |
} else {
|
471 |
$arcresults = $cache[ $key ];
|
472 |
}
|
|
|
473 |
if ( $arcresults ) {
|
474 |
foreach ( (array) $arcresults as $arcresult ) {
|
475 |
$return[$arcresult->year.$arcresult->month] = $this->get_index_url( 'posttype', $post_type, $arcresult->year . $arcresult->month );
|
476 |
}
|
477 |
-
}
|
478 |
-
|
479 |
-
|
|
|
|
|
480 |
$key = md5($query);
|
481 |
$cache = wp_cache_get( 'xmlsf_get_archives' , 'general');
|
|
|
482 |
if ( !isset( $cache[ $key ] ) ) {
|
483 |
$arcresults = $wpdb->get_results($query);
|
484 |
$cache[ $key ] = $arcresults;
|
@@ -486,14 +502,19 @@ class XMLSitemapFeed {
|
|
486 |
} else {
|
487 |
$arcresults = $cache[ $key ];
|
488 |
}
|
|
|
489 |
if ($arcresults) {
|
490 |
foreach ( (array) $arcresults as $arcresult) {
|
491 |
$return[$arcresult->year] = $this->get_index_url( 'posttype', $post_type, $arcresult->year );
|
492 |
}
|
493 |
-
}
|
494 |
-
|
|
|
|
|
495 |
$return[0] = $this->get_index_url('posttype', $post_type); // $sitemap = 'home', $type = false, $param = false
|
496 |
-
|
|
|
|
|
497 |
return $return;
|
498 |
}
|
499 |
|
@@ -517,10 +538,10 @@ class XMLSitemapFeed {
|
|
517 |
|
518 |
// make sure it's an array we are returning
|
519 |
return (
|
520 |
-
|
521 |
-
|
522 |
-
|
523 |
-
|
524 |
}
|
525 |
|
526 |
/**
|
@@ -535,8 +556,9 @@ class XMLSitemapFeed {
|
|
535 |
// Polylang compat
|
536 |
if ( function_exists('pll_get_post_translations') ) {
|
537 |
$translations = pll_get_post_translations($post_id);
|
538 |
-
foreach ( $translations as $slug => $id )
|
539 |
if ( $post_id != $id ) $translation_ids[] = $id;
|
|
|
540 |
}
|
541 |
// WPML compat
|
542 |
global $sitepress;
|
@@ -594,7 +616,7 @@ class XMLSitemapFeed {
|
|
594 |
* @return bool
|
595 |
*/
|
596 |
private function is_home( $id ) {
|
597 |
-
|
598 |
}
|
599 |
|
600 |
/**
|
@@ -606,32 +628,25 @@ class XMLSitemapFeed {
|
|
606 |
*
|
607 |
* @return string
|
608 |
*/
|
609 |
-
public function
|
610 |
-
|
611 |
-
if ( ob_get_level() ) ob_clean();
|
612 |
|
613 |
// check if headers are already sent (bad) and set up a warning in admin (how?)
|
614 |
-
if (
|
615 |
-
status_header('200'); // force header('HTTP/1.1 200 OK') for sites without posts
|
616 |
-
header('Content-Type: text/xml; charset=' . get_bloginfo('charset'), true);
|
617 |
-
header('X-Robots-Tag: noindex, follow', true);
|
618 |
-
$output = '';
|
619 |
-
} else {
|
620 |
-
// output warning in sitemap for now, TODO admin message
|
621 |
$output = "<!-- WARNING: Headers already sent by $filename on line $linenum. Please fix! -->\n";
|
622 |
-
}
|
623 |
|
624 |
// which style sheet
|
625 |
switch ($style) {
|
626 |
case 'index':
|
627 |
-
|
628 |
-
|
|
|
629 |
case 'news':
|
630 |
-
|
631 |
-
|
|
|
632 |
default:
|
633 |
-
|
634 |
-
break;
|
635 |
}
|
636 |
|
637 |
$output .= '<?xml version="1.0" encoding="' . get_bloginfo('charset') . '"?>' . PHP_EOL;
|
@@ -654,9 +669,9 @@ class XMLSitemapFeed {
|
|
654 |
* @return string
|
655 |
*/
|
656 |
public function modified( $sitemap = 'post_type', $term = '' ) {
|
657 |
-
|
658 |
|
659 |
-
|
660 |
|
661 |
// if blog page then look for last post date
|
662 |
if ( $post->post_type == 'page' && $this->is_home($post->ID) )
|
@@ -691,22 +706,23 @@ class XMLSitemapFeed {
|
|
691 |
if ( is_object($term) ) {
|
692 |
if ( !isset($this->termmodified[$term->term_id]) ) {
|
693 |
// get the latest post in this taxonomy item, to use its post_date as lastmod
|
694 |
-
$posts = get_posts (
|
695 |
-
|
696 |
-
|
697 |
-
|
698 |
-
|
699 |
-
|
700 |
-
|
701 |
-
|
702 |
-
|
703 |
-
|
704 |
-
|
705 |
-
|
706 |
-
|
707 |
)
|
708 |
)
|
709 |
-
)
|
|
|
710 |
$this->termmodified[$term->term_id] = isset($posts[0]->post_date_gmt) ? $posts[0]->post_date_gmt : '';
|
711 |
}
|
712 |
return $this->termmodified[$term->term_id];
|
@@ -725,11 +741,9 @@ class XMLSitemapFeed {
|
|
725 |
return end($lastmodified);
|
726 |
}
|
727 |
|
728 |
-
else :
|
729 |
-
|
730 |
-
return '';
|
731 |
-
|
732 |
endif;
|
|
|
|
|
733 |
}
|
734 |
|
735 |
/**
|
@@ -767,7 +781,9 @@ class XMLSitemapFeed {
|
|
767 |
*/
|
768 |
public function get_images( $sitemap = '' ) {
|
769 |
global $post;
|
770 |
-
|
|
|
|
|
771 |
if ( 'news' == $sitemap ) {
|
772 |
$options = $this->get_option('news_tags');
|
773 |
$which = isset($options['image']) ? $options['image'] : '';
|
@@ -775,6 +791,7 @@ class XMLSitemapFeed {
|
|
775 |
$options = $this->get_post_types();
|
776 |
$which = isset($options[$post->post_type]['tags']['image']) ? $options[$post->post_type]['tags']['image'] : '';
|
777 |
}
|
|
|
778 |
if ( 'attached' == $which ) {
|
779 |
$args = array( 'post_type' => 'attachment', 'post_mime_type' => 'image', 'numberposts' => -1, 'post_status' =>'inherit', 'post_parent' => $post->ID );
|
780 |
$attachments = get_posts($args);
|
@@ -782,13 +799,14 @@ class XMLSitemapFeed {
|
|
782 |
foreach ( $attachments as $attachment ) {
|
783 |
$url = wp_get_attachment_image_url( $attachment->ID, 'full' );
|
784 |
$url = $this->get_absolute_url( $url );
|
785 |
-
if ( !empty($url) )
|
786 |
$this->images[$post->ID][] = array(
|
787 |
-
|
788 |
-
|
789 |
-
|
790 |
-
|
791 |
-
|
|
|
792 |
}
|
793 |
}
|
794 |
} elseif ( 'featured' == $which ) {
|
@@ -796,16 +814,19 @@ class XMLSitemapFeed {
|
|
796 |
//$attachment = get_post( get_post_thumbnail_id( $post->ID ) );
|
797 |
$url = wp_get_attachment_image_url( get_post_thumbnail_id( $post->ID ), 'full' );
|
798 |
$url = $this->get_absolute_url( $url );
|
799 |
-
if ( !empty($url) )
|
800 |
$this->images[$post->ID][] = array(
|
801 |
-
|
802 |
-
|
803 |
-
|
804 |
-
|
805 |
-
|
|
|
806 |
}
|
807 |
}
|
808 |
-
|
|
|
|
|
809 |
return ( isset($this->images[$post->ID]) ) ? $this->images[$post->ID] : false;
|
810 |
}
|
811 |
|
@@ -823,37 +844,6 @@ class XMLSitemapFeed {
|
|
823 |
' : '';
|
824 |
}
|
825 |
|
826 |
-
/**
|
827 |
-
* Get change frequency
|
828 |
-
*
|
829 |
-
* @param string $sitemap
|
830 |
-
* @param string $term
|
831 |
-
*
|
832 |
-
* @return string
|
833 |
-
*/
|
834 |
-
public function get_changefreq( $sitemap = 'post_type', $term = '' ) {
|
835 |
-
$modified = trim($this->modified($sitemap,$term));
|
836 |
-
|
837 |
-
if (empty($modified))
|
838 |
-
return 'weekly';
|
839 |
-
|
840 |
-
$lastactivityage = ( gmdate('U') - mysql2date( 'U', $modified, false ) ); // post age
|
841 |
-
|
842 |
-
if ( ($lastactivityage/86400) < 1 ) { // last activity less than 1 day old
|
843 |
-
$changefreq = 'hourly';
|
844 |
-
} elseif ( ($lastactivityage/86400) < 7 ) { // last activity less than 1 week old
|
845 |
-
$changefreq = 'daily';
|
846 |
-
} elseif ( ($lastactivityage/86400) < 30 ) { // last activity less than one month old
|
847 |
-
$changefreq = 'weekly';
|
848 |
-
} elseif ( ($lastactivityage/86400) < 365 ) { // last activity less than 1 year old
|
849 |
-
$changefreq = 'monthly';
|
850 |
-
} else {
|
851 |
-
$changefreq = 'yearly'; // over a year old...
|
852 |
-
}
|
853 |
-
|
854 |
-
return $changefreq;
|
855 |
-
}
|
856 |
-
|
857 |
/**
|
858 |
* Get priority
|
859 |
*
|
@@ -863,54 +853,55 @@ class XMLSitemapFeed {
|
|
863 |
* @return string
|
864 |
*/
|
865 |
public function get_priority( $sitemap = 'post_type', $term = '' ) {
|
|
|
866 |
if ( 'post_type' == $sitemap ) :
|
|
|
867 |
global $post;
|
868 |
$options = $this->get_post_types();
|
869 |
$defaults = $this->defaults('post_types');
|
870 |
$priority_meta = get_metadata('post', $post->ID, '_xmlsf_priority' , true);
|
871 |
|
872 |
if ( !empty($priority_meta) || $priority_meta == '0' ) {
|
873 |
-
|
874 |
$priority = floatval(str_replace(',','.',$priority_meta));
|
875 |
-
|
876 |
} elseif ( !empty($options[$post->post_type]['dynamic_priority']) ) {
|
877 |
-
|
878 |
$post_modified = mysql2date('U',$post->post_modified_gmt, false);
|
879 |
|
880 |
-
if ( empty($this->lastmodified) )
|
881 |
$this->lastmodified = mysql2date('U',get_lastpostmodified('gmt',$post->post_type),false);
|
882 |
// last posts or page modified date in Unix seconds
|
|
|
883 |
|
884 |
-
if ( empty($this->firstdate) )
|
885 |
$this->firstdate = mysql2date('U',get_firstpostdate('gmt',$post->post_type),false);
|
886 |
// uses get_firstpostdate() function defined in xml-sitemap/hacks.php !
|
|
|
887 |
|
888 |
-
if ( isset($options[$post->post_type]['priority']) )
|
889 |
$priority_value = floatval(str_replace(',','.',$options[$post->post_type]['priority']));
|
890 |
-
else
|
891 |
$priority_value = floatval($defaults[$post->post_type]['priority']);
|
|
|
892 |
|
893 |
// reduce by age
|
894 |
// NOTE : home/blog page gets same treatment as sticky post, i.e. no reduction by age
|
895 |
-
if ( is_sticky($post->ID) || $this->is_home($post->ID) )
|
896 |
$priority = $priority_value;
|
897 |
-
else
|
898 |
$priority = ( $this->lastmodified > $this->firstdate ) ? $priority_value - $priority_value * ( $this->lastmodified - $post_modified ) / ( $this->lastmodified - $this->firstdate ) : $priority_value;
|
|
|
899 |
|
900 |
-
if ( $post->comment_count > 0 )
|
901 |
$priority = $priority + 0.1 + ( 0.9 - $priority ) * $post->comment_count / wp_count_comments($post->post_type)->approved;
|
902 |
-
|
903 |
} else {
|
904 |
-
|
905 |
$priority = ( isset($options[$post->post_type]['priority']) && is_numeric($options[$post->post_type]['priority']) ) ? $options[$post->post_type]['priority'] : $defaults[$post->post_type]['priority'];
|
906 |
-
|
907 |
}
|
908 |
|
909 |
elseif ( ! empty($term) ) :
|
910 |
|
911 |
$max_priority = 0.4;
|
912 |
$min_priority = 0.0;
|
913 |
-
// TODO make these values optional
|
914 |
|
915 |
$tax_obj = get_taxonomy($term->taxonomy);
|
916 |
$postcount = 0;
|
@@ -927,15 +918,17 @@ class XMLSitemapFeed {
|
|
927 |
|
928 |
endif;
|
929 |
|
930 |
-
// make sure we're not below zero
|
931 |
-
|
932 |
-
|
933 |
-
|
934 |
-
|
935 |
-
|
936 |
-
|
|
|
|
|
937 |
|
938 |
-
return number_format($priority,1);
|
939 |
}
|
940 |
|
941 |
/**
|
@@ -948,14 +941,17 @@ class XMLSitemapFeed {
|
|
948 |
global $sitepress; // Polylang and WPML compat
|
949 |
if ( function_exists('pll_the_languages') ) {
|
950 |
$languages = pll_the_languages( array( 'raw' => 1 ) );
|
951 |
-
if ( is_array($languages) )
|
952 |
-
foreach ( $languages as $language )
|
953 |
$urls[] = pll_home_url( $language['slug'] );
|
954 |
-
|
|
|
955 |
$urls[] = $this->home_url();
|
|
|
956 |
} elseif ( isset($sitepress) && is_object($sitepress) && method_exists($sitepress, 'get_languages') && method_exists($sitepress, 'language_url') ) {
|
957 |
-
foreach ( array_keys ( $sitepress->get_languages(false,true) ) as $term )
|
958 |
$urls[] = $sitepress->language_url($term);
|
|
|
959 |
} else {
|
960 |
$urls[] = $this->home_url();
|
961 |
}
|
@@ -974,10 +970,11 @@ class XMLSitemapFeed {
|
|
974 |
// no ID, try and get it from global post object
|
975 |
if ( null == $post_id ) {
|
976 |
global $post;
|
977 |
-
if ( is_object($post) && isset($post->ID))
|
978 |
$post_id = $post->ID;
|
979 |
-
else
|
980 |
return false;
|
|
|
981 |
}
|
982 |
|
983 |
$excluded = get_post_meta($post_id,'_xmlsf_exclude',true) || in_array($post_id,$this->get_frontpages()) ? true : false;
|
@@ -1021,16 +1018,13 @@ class XMLSitemapFeed {
|
|
1021 |
public function get_index_url( $sitemap = 'home', $type = false, $param = false ) {
|
1022 |
$split_url = explode('?', $this->home_url());
|
1023 |
|
1024 |
-
$name = $this->base_name.'-'.$sitemap;
|
1025 |
-
|
1026 |
-
if ( $type )
|
1027 |
-
$name .= '-'.$type;
|
1028 |
-
|
1029 |
if ( '' == get_option('permalink_structure') || '1' != get_option('blog_public')) {
|
1030 |
$name = '?feed='.$name;
|
1031 |
$name .= $param ? '&m='.$param : '';
|
1032 |
$name .= isset($split_url[1]) && !empty($split_url[1]) ? '&' . $split_url[1] : '';
|
1033 |
} else {
|
|
|
|
|
1034 |
$name .= $param ? '.'.$param : '';
|
1035 |
$name .= '.'.$this->extension;
|
1036 |
$name .= isset($split_url[1]) && !empty($split_url[1]) ? '?' . $split_url[1] : '';
|
@@ -1086,8 +1080,7 @@ class XMLSitemapFeed {
|
|
1086 |
*/
|
1087 |
|
1088 |
// add sitemap location in robots.txt generated by WP
|
1089 |
-
public function robots($output)
|
1090 |
-
{
|
1091 |
echo '# XML Sitemap & Google News Feeds version ' . XMLSF_VERSION . ' - http://status301.net/wordpress-plugins/xml-sitemap-feed/' . PHP_EOL;
|
1092 |
|
1093 |
if ( '1' != get_option('blog_public') ) {
|
@@ -1099,6 +1092,7 @@ class XMLSitemapFeed {
|
|
1099 |
if ( empty($pretty) )
|
1100 |
echo '# No XML Sitemaps are enabled. Please see XML Sitemaps on Settings > Reading.' . PHP_EOL;
|
1101 |
}
|
|
|
1102 |
echo PHP_EOL;
|
1103 |
}
|
1104 |
|
@@ -1126,10 +1120,7 @@ class XMLSitemapFeed {
|
|
1126 |
* @return mixed
|
1127 |
*/
|
1128 |
public function trailingslash($request) {
|
1129 |
-
|
1130 |
-
return untrailingslashit($request);
|
1131 |
-
}
|
1132 |
-
return $request;
|
1133 |
}
|
1134 |
|
1135 |
/**
|
@@ -1143,8 +1134,9 @@ class XMLSitemapFeed {
|
|
1143 |
$xmlsf_rules = array();
|
1144 |
$sitemaps = $this->get_sitemaps();
|
1145 |
|
1146 |
-
foreach ( $sitemaps as $name => $pretty )
|
1147 |
$xmlsf_rules[ preg_quote($pretty) . '$' ] = $wp_rewrite->index . '?feed=' . $name;
|
|
|
1148 |
|
1149 |
if (!empty($sitemaps['sitemap'])) {
|
1150 |
// home urls
|
@@ -1152,8 +1144,9 @@ class XMLSitemapFeed {
|
|
1152 |
|
1153 |
// add rules for post types (can be split by month or year)
|
1154 |
foreach ( $this->get_post_types() as $post_type ) {
|
1155 |
-
if ( isset($post_type['active']) && '1' == $post_type['active'] )
|
1156 |
$xmlsf_rules[ $this->base_name . '-posttype-' . $post_type['name'] . '\.([0-9]+)?\.?' . $this->extension . '$' ] = $wp_rewrite->index . '?feed=sitemap-posttype-' . $post_type['name'] . '&m=$matches[1]';
|
|
|
1157 |
}
|
1158 |
|
1159 |
// add rules for taxonomies
|
@@ -1162,8 +1155,9 @@ class XMLSitemapFeed {
|
|
1162 |
}
|
1163 |
|
1164 |
$urls = $this->get_urls();
|
1165 |
-
if(!empty($urls))
|
1166 |
$xmlsf_rules[ $this->base_name . '-custom\.' . $this->extension . '$' ] = $wp_rewrite->index . '?feed=sitemap-custom';
|
|
|
1167 |
|
1168 |
}
|
1169 |
|
@@ -1176,10 +1170,10 @@ class XMLSitemapFeed {
|
|
1176 |
*/
|
1177 |
public function wpml_language_switcher() {
|
1178 |
global $sitepress,$post;
|
1179 |
-
|
1180 |
-
|
1181 |
-
|
1182 |
-
|
1183 |
}
|
1184 |
|
1185 |
/**
|
@@ -1190,7 +1184,14 @@ class XMLSitemapFeed {
|
|
1190 |
* @return mixed
|
1191 |
*/
|
1192 |
public function filter_request( $request ) {
|
|
|
|
|
1193 |
if ( isset($request['feed']) && strpos($request['feed'],'sitemap') === 0 ) :
|
|
|
|
|
|
|
|
|
|
|
1194 |
// modify request parameters
|
1195 |
$request['post_status'] = 'publish';
|
1196 |
$request['no_found_rows'] = true;
|
@@ -1213,7 +1214,9 @@ class XMLSitemapFeed {
|
|
1213 |
$defaults = $this->defaults('news_tags');
|
1214 |
$options = $this->get_option('news_tags');
|
1215 |
$news_post_type = isset($options['post_type']) && !empty($options['post_type']) ? $options['post_type'] : $defaults['post_type'];
|
1216 |
-
if (empty($news_post_type))
|
|
|
|
|
1217 |
|
1218 |
// disable caching
|
1219 |
define('DONOTCACHEPAGE', true);
|
@@ -1227,8 +1230,9 @@ class XMLSitemapFeed {
|
|
1227 |
$request['post_type'] = $news_post_type;
|
1228 |
|
1229 |
// categories
|
1230 |
-
if ( isset($options['categories']) && is_array($options['categories']) )
|
1231 |
$request['cat'] = implode(',',$options['categories']);
|
|
|
1232 |
|
1233 |
// set the news sitemap conditional tag
|
1234 |
$this->is_news = true;
|
@@ -1275,11 +1279,41 @@ class XMLSitemapFeed {
|
|
1275 |
}
|
1276 |
}
|
1277 |
}
|
|
|
1278 |
endif;
|
1279 |
|
1280 |
return $request;
|
1281 |
}
|
1282 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1283 |
/**
|
1284 |
* FEED TEMPLATES
|
1285 |
*/
|
@@ -1365,8 +1399,7 @@ class XMLSitemapFeed {
|
|
1365 |
* in case there is no news, just take the latest post
|
1366 |
* @return string
|
1367 |
*/
|
1368 |
-
public function filter_no_news_limits( $limits )
|
1369 |
-
{
|
1370 |
return 'LIMIT 0, 1';
|
1371 |
}
|
1372 |
|
@@ -1383,17 +1416,9 @@ class XMLSitemapFeed {
|
|
1383 |
* @return bool
|
1384 |
*/
|
1385 |
public function ping($uri, $timeout = 3) {
|
1386 |
-
$
|
1387 |
-
$options['timeout'] = $timeout;
|
1388 |
|
1389 |
-
$response
|
1390 |
-
|
1391 |
-
if ( '200' == wp_remote_retrieve_response_code($response) )
|
1392 |
-
$succes = true;
|
1393 |
-
else
|
1394 |
-
$succes = false;
|
1395 |
-
|
1396 |
-
return $succes;
|
1397 |
}
|
1398 |
|
1399 |
/**
|
@@ -1421,17 +1446,18 @@ class XMLSitemapFeed {
|
|
1421 |
// loop through ping targets
|
1422 |
foreach ($to_ping as $se => $data) {
|
1423 |
// check active switch
|
1424 |
-
if( empty($data['active']) || empty($data['news']) )
|
1425 |
continue;
|
|
|
1426 |
// and if we did not ping already within the last 5 minutes
|
1427 |
-
if( !empty($data['pong']) && is_array($data['pong']) && !empty($data['pong'][$sitemaps['sitemap-news']]) && (int)$data['pong'][$sitemaps['sitemap-news']] + 300 > time() )
|
1428 |
-
|
|
|
1429 |
// ping !
|
1430 |
-
if ( $this->ping( $data['
|
1431 |
$to_ping[$se]['pong'][$sitemaps['sitemap-news']] = time();
|
1432 |
$update = true;
|
1433 |
}
|
1434 |
-
|
1435 |
}
|
1436 |
}
|
1437 |
}
|
@@ -1446,13 +1472,15 @@ class XMLSitemapFeed {
|
|
1446 |
if ( $old_status != 'publish' && $new_status == 'publish' ) {
|
1447 |
foreach ($to_ping as $se => $data) {
|
1448 |
// check active switch
|
1449 |
-
if( empty($data['active']) || empty($data['type']) || $data['type']!='GET' )
|
1450 |
continue;
|
|
|
1451 |
// and if we did not ping already within the last hour
|
1452 |
-
if( !empty($data['pong']) && is_array($data['pong']) && !empty($data['pong'][$sitemaps['sitemap']]) && (int)$data['pong'][$sitemaps['sitemap']] + 3600 > time() )
|
1453 |
-
|
|
|
1454 |
// ping !
|
1455 |
-
if ( $this->ping( $data['
|
1456 |
$to_ping[$se]['pong'][$sitemaps['sitemap']] = time();
|
1457 |
$update = true;
|
1458 |
}
|
@@ -1473,13 +1501,13 @@ class XMLSitemapFeed {
|
|
1473 |
* Clear settings
|
1474 |
*/
|
1475 |
public function clear_settings() {
|
1476 |
-
delete_option('xmlsf_version');
|
1477 |
foreach ( $this->defaults() as $option => $settings ) {
|
1478 |
-
delete_option('xmlsf_'
|
1479 |
}
|
1480 |
|
1481 |
if ( defined('WP_DEBUG') && WP_DEBUG ) {
|
1482 |
-
error_log('XML Sitemap Feeds settings cleared');
|
1483 |
}
|
1484 |
}
|
1485 |
|
@@ -1495,7 +1523,7 @@ class XMLSitemapFeed {
|
|
1495 |
|
1496 |
// TODO get year / month here to delete specific keys too !!!!
|
1497 |
$m = mysql2date('Ym',$post->post_date_gmt, false);
|
1498 |
-
$y = substr($m, 0, 4);
|
1499 |
|
1500 |
// clear possible last post modified cache keys
|
1501 |
wp_cache_delete( 'lastpostmodified:gmt', 'timeinfo' ); // should be handled by WP core?
|
@@ -1510,8 +1538,8 @@ class XMLSitemapFeed {
|
|
1510 |
|
1511 |
// clear possible fist post date cache keys
|
1512 |
wp_cache_delete( 'firstpostdate:gmt', 'timeinfo' );
|
1513 |
-
wp_cache_delete( 'firstpostdate:gmt:'.$post->post_type, 'timeinfo' );
|
1514 |
-
}
|
1515 |
|
1516 |
/**
|
1517 |
* Nginx helper purge urls
|
@@ -1524,16 +1552,14 @@ class XMLSitemapFeed {
|
|
1524 |
*/
|
1525 |
public function nginx_helper_purge_urls( $urls = array(), $redis = false ) {
|
1526 |
// are permalinks set, blog public and $urls an array?
|
1527 |
-
if ( '' == get_option('permalink_structure') || '1' != get_option('blog_public') || ! is_array( $urls ) )
|
1528 |
return $urls;
|
|
|
1529 |
|
1530 |
if ( $redis ) {
|
1531 |
-
|
1532 |
// wildcard allowed, this makes everything simple
|
1533 |
$urls[] = '/sitemap*.xml';
|
1534 |
-
|
1535 |
} else {
|
1536 |
-
|
1537 |
// no wildcard, go through the motions
|
1538 |
foreach ( $this->get_sitemaps() as $pretty ) {
|
1539 |
|
@@ -1545,8 +1571,9 @@ class XMLSitemapFeed {
|
|
1545 |
// add public post types sitemaps
|
1546 |
foreach ( $this->have_post_types() as $post_type ) {
|
1547 |
$archive = !empty($post_type['archive']) ? $post_type['archive'] : '';
|
1548 |
-
foreach ( $this->get_archives($post_type['name'],$archive) as $url )
|
1549 |
$urls[] = parse_url( $url, PHP_URL_PATH);
|
|
|
1550 |
}
|
1551 |
|
1552 |
// add public post taxonomies sitemaps
|
@@ -1562,14 +1589,14 @@ class XMLSitemapFeed {
|
|
1562 |
|
1563 |
// custom sitemaps
|
1564 |
foreach ($this->get_custom_sitemaps() as $url) {
|
1565 |
-
if ( !empty($url) && $this->is_allowed_domain($url) )
|
1566 |
$urls[] = parse_url( esc_url($url), PHP_URL_PATH);
|
|
|
1567 |
}
|
1568 |
}
|
1569 |
}
|
1570 |
|
1571 |
$urls[] = '/' . $pretty;
|
1572 |
-
|
1573 |
}
|
1574 |
|
1575 |
return $urls;
|
@@ -1586,42 +1613,48 @@ class XMLSitemapFeed {
|
|
1586 |
// rewrite rules not available on plugins_loaded
|
1587 |
// and don't flush rules from init as Polylang chokes on that
|
1588 |
// just remove the db option and let WP regenerate them when ready...
|
1589 |
-
delete_option('rewrite_rules');
|
1590 |
// ... but make sure rules are regenerated when admin is visited.
|
1591 |
-
set_transient('xmlsf_flush_rewrite_rules','');
|
1592 |
|
1593 |
-
// remove robots.txt
|
1594 |
-
if ( version_compare('4.4', $old_version, '>') && $robot_rules = get_option($this->prefix.'robots')) {
|
1595 |
$robot_rules = str_replace(array('Disallow: */wp-content/','Allow: */wp-content/uploads/'),'',$robot_rules);
|
1596 |
-
delete_option($this->prefix.'robots');
|
1597 |
-
add_option($this->prefix.'robots', $robot_rules, '', 'no');
|
1598 |
}
|
1599 |
|
1600 |
if ( version_compare('4.4.1', $old_version, '>') ) {
|
1601 |
// register location taxonomies then delete all terms
|
1602 |
register_taxonomy( 'gn-location-3', null );
|
1603 |
-
$terms = get_terms('gn-location-3',array('hide_empty' => false));
|
1604 |
-
foreach ( $terms as $term )
|
1605 |
wp_delete_term( $term->term_id, 'gn-location-3' );
|
|
|
1606 |
|
1607 |
register_taxonomy( 'gn-location-2', null );
|
1608 |
-
$terms = get_terms('gn-location-2',array('hide_empty' => false));
|
1609 |
-
foreach ( $terms as $term )
|
1610 |
wp_delete_term( $term->term_id, 'gn-location-2' );
|
|
|
1611 |
|
1612 |
register_taxonomy( 'gn-location-1', null );
|
1613 |
-
$terms = get_terms('gn-location-1',array('hide_empty' => false));
|
1614 |
-
foreach ( $terms as $term )
|
1615 |
wp_delete_term( $term->term_id, 'gn-location-1' );
|
|
|
1616 |
}
|
1617 |
|
1618 |
-
if ( version_compare('4.
|
1619 |
// purge genres taxonomy terms
|
1620 |
$this->register_gn_taxonomies();
|
1621 |
-
$terms = get_terms('gn-genre',array('hide_empty' => false));
|
1622 |
-
foreach ( $terms as $term )
|
1623 |
wp_delete_term( $term->term_id, 'gn-genre' );
|
1624 |
-
|
|
|
|
|
|
|
1625 |
}
|
1626 |
|
1627 |
// upgrade pings
|
@@ -1643,8 +1676,7 @@ class XMLSitemapFeed {
|
|
1643 |
add_option( $this->prefix.'ping', array_merge( $this->defaults('ping'), $ping ), '', 'no' );
|
1644 |
}
|
1645 |
|
1646 |
-
|
1647 |
-
add_option($this->prefix.'version', XMLSF_VERSION, '', 'no');
|
1648 |
|
1649 |
if ( defined('WP_DEBUG') && WP_DEBUG ) {
|
1650 |
error_log('XML Sitemap Feeds upgraded from '.$old_version.' to '.XMLSF_VERSION);
|
@@ -1657,7 +1689,7 @@ class XMLSitemapFeed {
|
|
1657 |
public function plugins_loaded() {
|
1658 |
// TEXT DOMAIN
|
1659 |
if ( is_admin() ) { // text domain needed on admin only
|
1660 |
-
load_plugin_textdomain('xml-sitemap-feed', false, dirname(
|
1661 |
}
|
1662 |
}
|
1663 |
|
@@ -1675,8 +1707,9 @@ class XMLSitemapFeed {
|
|
1675 |
$home_path = trailingslashit( get_home_path() );
|
1676 |
$sitemaps = $this->get_sitemaps();
|
1677 |
foreach ( $sitemaps as $name => $pretty ) {
|
1678 |
-
if ( file_exists( $home_path . $pretty ) )
|
1679 |
unlink( $home_path . $pretty );
|
|
|
1680 |
}
|
1681 |
}
|
1682 |
}
|
@@ -1686,7 +1719,7 @@ class XMLSitemapFeed {
|
|
1686 |
*/
|
1687 |
public function init() {
|
1688 |
// UPGRADE
|
1689 |
-
$version = get_option('xmlsf_version', 0);
|
1690 |
|
1691 |
if ( version_compare(XMLSF_VERSION, $version, '>') ) {
|
1692 |
$this->upgrade($version);
|
@@ -1695,31 +1728,24 @@ class XMLSitemapFeed {
|
|
1695 |
$sitemaps = $this->get_sitemaps();
|
1696 |
|
1697 |
if (isset($sitemaps['sitemap'])) {
|
1698 |
-
//
|
1699 |
-
add_action('do_feed_sitemap', array($this, 'load_template_index'), 10, 1);
|
1700 |
-
add_action('do_feed_sitemap-home', array($this, 'load_template_base'), 10, 1);
|
1701 |
-
add_action('do_feed_sitemap-custom', array($this, 'load_template_custom'), 10, 1);
|
1702 |
foreach ( $this->get_post_types() as $post_type ) {
|
1703 |
-
add_action('do_feed_sitemap-posttype-'.$post_type['name'], array($this, 'load_template'), 10, 1);
|
1704 |
}
|
1705 |
foreach ( $this->get_taxonomies() as $taxonomy ) {
|
1706 |
-
add_action('do_feed_sitemap-taxonomy-'.$taxonomy, array($this, 'load_template_taxonomy'), 10, 1);
|
1707 |
}
|
1708 |
}
|
1709 |
|
1710 |
if (isset($sitemaps['sitemap-news'])) {
|
1711 |
-
//
|
1712 |
add_action('do_feed_sitemap-news', array($this, 'load_template_news'), 10, 1);
|
1713 |
|
1714 |
// register the taxonomies
|
1715 |
$this->register_gn_taxonomies();
|
1716 |
-
|
1717 |
-
// create terms
|
1718 |
-
if ( delete_transient('xmlsf_create_genres') ) {
|
1719 |
-
foreach ($this->gn_genres as $name) {
|
1720 |
-
wp_insert_term( $name, 'gn-genre' );
|
1721 |
-
}
|
1722 |
-
}
|
1723 |
}
|
1724 |
}
|
1725 |
|
@@ -1727,14 +1753,6 @@ class XMLSitemapFeed {
|
|
1727 |
* Admin init
|
1728 |
*/
|
1729 |
public function admin_init() {
|
1730 |
-
// CATCH TRANSIENT for reset
|
1731 |
-
if (delete_transient('xmlsf_clear_settings'))
|
1732 |
-
$this->clear_settings();
|
1733 |
-
|
1734 |
-
// CATCH TRANSIENT for flushing rewrite rules after the sitemaps setting has changed
|
1735 |
-
if (delete_transient('xmlsf_flush_rewrite_rules'))
|
1736 |
-
$this->flush_rules();
|
1737 |
-
|
1738 |
// Include the admin class file
|
1739 |
include_once( dirname( __FILE__ ) . '/class-xmlsitemapfeed-admin.php' );
|
1740 |
}
|
@@ -1746,15 +1764,15 @@ class XMLSitemapFeed {
|
|
1746 |
*/
|
1747 |
public function flush_rules( $hard = false ) {
|
1748 |
// did you flush already?
|
1749 |
-
if ($this->yes_mother)
|
1750 |
return; // yes, mother!
|
|
|
1751 |
|
1752 |
-
|
1753 |
-
$wp_rewrite->init();
|
1754 |
-
$wp_rewrite->flush_rules($hard);
|
1755 |
|
1756 |
-
if ( defined('WP_DEBUG') && WP_DEBUG )
|
1757 |
error_log('XML Sitemap Feeds rewrite rules flushed');
|
|
|
1758 |
|
1759 |
$this->yes_mother = true;
|
1760 |
}
|
@@ -1771,21 +1789,21 @@ class XMLSitemapFeed {
|
|
1771 |
register_taxonomy( 'gn-genre', $post_types, array(
|
1772 |
'hierarchical' => true,
|
1773 |
'labels' => array(
|
1774 |
-
|
1775 |
-
|
1776 |
-
|
1777 |
-
|
1778 |
-
|
1779 |
'public' => false,
|
1780 |
'show_ui' => true,
|
1781 |
'show_tagcloud' => false,
|
1782 |
'query_var' => false,
|
1783 |
'capabilities' => array( // prevent creation / deletion
|
1784 |
-
|
1785 |
-
|
1786 |
-
|
1787 |
-
|
1788 |
-
|
1789 |
));
|
1790 |
}
|
1791 |
|
@@ -1793,12 +1811,12 @@ class XMLSitemapFeed {
|
|
1793 |
* Echo usage info
|
1794 |
* for debugging
|
1795 |
*/
|
1796 |
-
public function _e_usage()
|
1797 |
-
|
1798 |
-
if (defined('WP_DEBUG') && WP_DEBUG == true) {
|
1799 |
echo '<!-- Queries executed '.get_num_queries();
|
1800 |
-
if(function_exists('memory_get_peak_usage'))
|
1801 |
echo ' | Peak memory usage '.round(memory_get_peak_usage()/1024/1024,2).'M';
|
|
|
1802 |
echo ' -->';
|
1803 |
}
|
1804 |
}
|
@@ -1807,44 +1825,45 @@ class XMLSitemapFeed {
|
|
1807 |
* CONSTRUCTOR
|
1808 |
*/
|
1809 |
|
1810 |
-
function __construct()
|
1811 |
-
|
|
|
1812 |
// sitemap element filters
|
1813 |
-
add_filter('the_title_xmlsitemap', 'strip_tags');
|
1814 |
-
add_filter('the_title_xmlsitemap', 'ent2ncr', 8);
|
1815 |
-
add_filter('the_title_xmlsitemap', 'esc_html');
|
1816 |
-
add_filter('bloginfo_xmlsitemap', 'ent2ncr', 8);
|
1817 |
|
1818 |
-
// REQUEST
|
1819 |
-
add_filter('request', array($this, 'filter_request'), 1 );
|
1820 |
|
1821 |
// TEXT DOMAIN...
|
1822 |
-
add_action('plugins_loaded', array($this,'plugins_loaded'), 11 );
|
1823 |
|
1824 |
// REWRITES
|
1825 |
-
add_action('generate_rewrite_rules', array($this, 'rewrite_rules') );
|
1826 |
-
add_filter('user_trailingslashit', array($this, 'trailingslash') );
|
1827 |
|
1828 |
// TAXONOMIES, ACTIONS, UPGRADE...
|
1829 |
-
add_action('init', array($this,'init'), 0 );
|
1830 |
|
1831 |
// REGISTER SETTINGS, SETTINGS FIELDS...
|
1832 |
-
add_action('admin_init', array($this,'admin_init'), 0);
|
1833 |
|
1834 |
// ROBOTSTXT
|
1835 |
-
add_action('do_robotstxt', array($this, 'robots'), 0 );
|
1836 |
-
add_filter('robots_txt', array($this, 'robots_txt'), 9 );
|
1837 |
|
1838 |
// PINGING
|
1839 |
-
add_action('transition_post_status', array($this, 'do_pings'), 10, 3);
|
1840 |
|
1841 |
// CLEAR OBJECT CACHE KEYS
|
1842 |
-
add_action('clean_post_cache', array($this, 'clean_post_cache'), 99, 2);
|
1843 |
|
1844 |
// NGINX HELPER PURGE URLS
|
1845 |
-
add_filter('rt_nginx_helper_purge_urls', array($this, 'nginx_helper_purge_urls'), 10, 2);
|
1846 |
|
1847 |
// ACTIVATION
|
1848 |
-
register_activation_hook(
|
1849 |
}
|
1850 |
}
|
5 |
|
6 |
class XMLSitemapFeed {
|
7 |
|
8 |
+
/**
|
9 |
+
* Plugin base name
|
10 |
+
* @var string
|
11 |
+
*/
|
12 |
+
public $plugin_basename;
|
13 |
+
|
14 |
/**
|
15 |
* Pretty permalinks base name
|
16 |
* @var string
|
23 |
*/
|
24 |
public $extension = 'xml';
|
25 |
|
26 |
+
/**
|
27 |
+
* Signifies whether the request has been filtered.
|
28 |
+
* @var bool
|
29 |
+
*/
|
30 |
+
public $request_filtered = false;
|
31 |
+
|
32 |
/**
|
33 |
* Signifies whether the current query is for a sitemap feed.
|
34 |
* @var bool
|
45 |
* Database options prefix
|
46 |
* @var string
|
47 |
*/
|
48 |
+
protected $prefix = 'xmlsf_';
|
49 |
|
50 |
/**
|
51 |
* Default language
|
86 |
* Google News genres
|
87 |
* @var array
|
88 |
*/
|
89 |
+
protected $gn_genres = array(
|
90 |
'PressRelease',
|
91 |
'Satire',
|
92 |
'Blog',
|
93 |
'OpEd',
|
94 |
'Opinion',
|
95 |
+
'UserGenerated',
|
96 |
+
'FactCheck'
|
97 |
);
|
98 |
|
99 |
/**
|
126 |
return (bool) $this->is_news;
|
127 |
}
|
128 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
129 |
/**
|
130 |
* Get gn_genres
|
131 |
* @return array
|
167 |
* @return string
|
168 |
*/
|
169 |
public function home_url() {
|
170 |
+
return empty($this->home_url) ? home_url() : $this->home_url;
|
|
|
|
|
|
|
|
|
|
|
171 |
}
|
172 |
|
173 |
/**
|
177 |
*/
|
178 |
private function set_defaults() {
|
179 |
// sitemaps
|
180 |
+
if ( '1' == get_option('blog_public') ) {
|
181 |
$this->defaults['sitemaps'] = array(
|
182 |
+
'sitemap' => XMLSF_NAME
|
183 |
+
);
|
184 |
+
} else {
|
185 |
$this->defaults['sitemaps'] = array();
|
186 |
+
}
|
187 |
|
188 |
// post_types
|
189 |
$this->defaults['post_types'] = array();
|
190 |
+
|
191 |
foreach ( get_post_types(array('public'=>true),'names') as $name ) { // want 'publicly_queryable' but that excludes pages for some weird reason
|
192 |
// skip unallowed post types
|
193 |
+
if (in_array($name,$this->disabled_post_types)) {
|
194 |
continue;
|
195 |
+
}
|
196 |
|
197 |
$this->defaults['post_types'][$name] = array(
|
198 |
+
'name' => $name,
|
199 |
+
'active' => '',
|
200 |
+
'archive' => '',
|
201 |
+
'priority' => '0.5',
|
202 |
+
'dynamic_priority' => '',
|
203 |
+
'tags' => array('image' => 'attached'/*,'video' => ''*/)
|
204 |
+
);
|
205 |
}
|
206 |
|
207 |
$active_arr = array('post','page');
|
208 |
|
209 |
+
foreach ( $active_arr as $name ) {
|
210 |
+
if ( isset($this->defaults['post_types'][$name]) ) {
|
211 |
$this->defaults['post_types'][$name]['active'] = '1';
|
212 |
+
}
|
213 |
+
}
|
214 |
|
215 |
if ( isset($this->defaults['post_types']['post']) ) {
|
216 |
+
if (wp_count_posts('post')->publish > 500) {
|
217 |
$this->defaults['post_types']['post']['archive'] = 'yearly';
|
218 |
+
}
|
219 |
$this->defaults['post_types']['post']['priority'] = '0.7';
|
220 |
$this->defaults['post_types']['post']['dynamic_priority'] = '1';
|
221 |
}
|
234 |
|
235 |
// search engines to ping
|
236 |
$this->defaults['ping'] = array(
|
237 |
+
'google' => array (
|
238 |
+
'active' => '1',
|
239 |
+
'uri' => 'http://www.google.com/ping',
|
240 |
+
'type' => 'GET',
|
241 |
+
'req' => 'sitemap',
|
242 |
+
'news' => '1'
|
243 |
+
),
|
244 |
+
'bing' => array (
|
245 |
+
'active' => '1',
|
246 |
+
'uri' => 'http://www.bing.com/ping',
|
247 |
+
'type' => 'GET',
|
248 |
+
'req' => 'sitemap',
|
249 |
+
'news' => '1'
|
250 |
+
),
|
251 |
+
'yandex' => array (
|
252 |
+
'active' => '',
|
253 |
+
'uri' => 'http://ping.blogs.yandex.ru/RPC2',
|
254 |
+
'type' => 'RPC',
|
255 |
+
),
|
256 |
+
'baidu' => array (
|
257 |
+
'active' => '',
|
258 |
+
'uri' => 'http://ping.baidu.com/ping/RPC2',
|
259 |
+
'type' => 'RPC',
|
260 |
+
),
|
261 |
+
'others' => array (
|
262 |
+
'active' => '1',
|
263 |
+
'uri' => 'http://rpc.pingomatic.com/',
|
264 |
+
'type' => 'RPC',
|
265 |
+
),
|
266 |
+
);
|
267 |
|
268 |
// robots
|
269 |
$this->defaults['robots'] = '';
|
279 |
|
280 |
// news sitemap tags settings
|
281 |
$this->defaults['news_tags'] = array(
|
282 |
+
'name' => '',
|
283 |
+
'post_type' => array('post'),
|
284 |
+
'categories' => '',
|
285 |
+
'image' => 'featured',
|
286 |
+
'access' => array(
|
287 |
+
'default' => '',
|
288 |
+
//'private' => 'Registration', // private posts do not show up in feeds when not logged in. no point in setting access level then...
|
289 |
+
'password' => 'Subscription'
|
290 |
+
),
|
291 |
+
'genres' => array(
|
292 |
+
'default' => ''
|
293 |
+
),
|
294 |
+
'keywords' => array(
|
295 |
+
'from' => 'category',
|
296 |
+
'default' => ''
|
297 |
+
)
|
298 |
+
);
|
299 |
}
|
300 |
|
301 |
/**
|
306 |
* @return array
|
307 |
*/
|
308 |
protected function defaults($key = false) {
|
309 |
+
if ( empty($this->defaults) ) {
|
310 |
$this->set_defaults();
|
311 |
+
}
|
312 |
|
313 |
+
if ( $key ) {
|
314 |
$return = ( isset($this->defaults[$key]) ) ? $this->defaults[$key] : '';
|
315 |
} else {
|
316 |
$return = $this->defaults;
|
327 |
* @return array
|
328 |
*/
|
329 |
public function get_option($option) {
|
330 |
+
return get_option( $this->prefix.$option, $this->defaults($option) );
|
331 |
}
|
332 |
|
333 |
/**
|
337 |
public function get_sitemaps() {
|
338 |
$return = $this->get_option('sitemaps');
|
339 |
|
340 |
+
// make very sure it's an array we are returning
|
341 |
+
return !empty($return) ? (array)$return : array();
|
342 |
}
|
343 |
|
344 |
/**
|
348 |
public function get_ping() {
|
349 |
$return = $this->get_option('ping');
|
350 |
|
351 |
+
// make very sure it's an array we are returning
|
352 |
+
return !empty($return) ? (array)$return : array();
|
353 |
}
|
354 |
|
355 |
/**
|
380 |
$return = $this->get_option('post_types');
|
381 |
|
382 |
// make sure it's an array we are returning
|
383 |
+
return !empty($return) ? (array)$return : array();
|
384 |
}
|
385 |
|
386 |
/**
|
391 |
$return = array();
|
392 |
|
393 |
foreach ( $this->get_post_types() as $type => $values ) {
|
394 |
+
if ( !empty($values['active']) ) {
|
395 |
$count = wp_count_posts( $values['name'] );
|
396 |
+
if ( $count->publish > 0 ) {
|
397 |
$values['count'] = $count->publish;
|
398 |
$return[$type] = $values;
|
399 |
}
|
400 |
}
|
401 |
}
|
402 |
|
403 |
+
return $return;
|
|
|
404 |
}
|
405 |
|
406 |
/**
|
411 |
$return = $this->get_option('taxonomies');
|
412 |
|
413 |
// make sure it's an array we are returning
|
414 |
+
return !empty($return) ? (array)$return : array();
|
415 |
}
|
416 |
|
417 |
/**
|
421 |
public function get_custom_sitemaps() {
|
422 |
$urls = $this->get_option('custom_sitemaps');
|
423 |
// make sure it's an array we are returning
|
424 |
+
if (!empty($urls)) {
|
425 |
$return = ( !is_array($urls) ) ? explode( PHP_EOL, $urls ) : $urls;
|
426 |
} else {
|
427 |
$return = array();
|
436 |
public function get_urls() {
|
437 |
$urls = $this->get_option('urls');
|
438 |
// make sure it's an array we are returning
|
439 |
+
if ( !empty($urls) ) {
|
440 |
$return = ( !is_array($urls) ) ? explode( PHP_EOL, $urls ) : $urls;
|
441 |
} else {
|
442 |
$return = array();
|
450 |
*/
|
451 |
public function get_domains() {
|
452 |
$domains = $this->get_option('domains');
|
453 |
+
if ( !empty($domains) && is_array($domains) ) {
|
454 |
return array_merge( array( $this->domain() ), $domains );
|
455 |
+
} else {
|
456 |
return array( $this->domain() );
|
457 |
+
}
|
458 |
}
|
459 |
|
460 |
/**
|
465 |
*
|
466 |
* @return array
|
467 |
*/
|
468 |
+
public function get_archives( $post_type = 'post', $type = '' ) {
|
469 |
global $wpdb;
|
470 |
$return = array();
|
471 |
+
|
472 |
+
if ( 'monthly' == $type ) :
|
473 |
+
|
474 |
+
$query = "SELECT YEAR(post_date) AS `year`, LPAD(MONTH(post_date),2,'0') AS `month`, count(ID) as posts FROM {$wpdb->posts} WHERE post_type = '{$post_type}' AND post_status = 'publish' GROUP BY YEAR(post_date), MONTH(post_date) ORDER BY post_date DESC";
|
475 |
$key = md5($query);
|
476 |
$cache = wp_cache_get( 'xmlsf_get_archives' , 'general');
|
477 |
+
|
478 |
if ( !isset( $cache[ $key ] ) ) {
|
479 |
$arcresults = $wpdb->get_results($query);
|
480 |
$cache[ $key ] = $arcresults;
|
482 |
} else {
|
483 |
$arcresults = $cache[ $key ];
|
484 |
}
|
485 |
+
|
486 |
if ( $arcresults ) {
|
487 |
foreach ( (array) $arcresults as $arcresult ) {
|
488 |
$return[$arcresult->year.$arcresult->month] = $this->get_index_url( 'posttype', $post_type, $arcresult->year . $arcresult->month );
|
489 |
}
|
490 |
+
};
|
491 |
+
|
492 |
+
elseif ( 'yearly' == $type ) :
|
493 |
+
|
494 |
+
$query = "SELECT YEAR(post_date) AS `year`, count(ID) as posts FROM {$wpdb->posts} WHERE post_type = '{$post_type}' AND post_status = 'publish' GROUP BY YEAR(post_date) ORDER BY post_date DESC";
|
495 |
$key = md5($query);
|
496 |
$cache = wp_cache_get( 'xmlsf_get_archives' , 'general');
|
497 |
+
|
498 |
if ( !isset( $cache[ $key ] ) ) {
|
499 |
$arcresults = $wpdb->get_results($query);
|
500 |
$cache[ $key ] = $arcresults;
|
502 |
} else {
|
503 |
$arcresults = $cache[ $key ];
|
504 |
}
|
505 |
+
|
506 |
if ($arcresults) {
|
507 |
foreach ( (array) $arcresults as $arcresult) {
|
508 |
$return[$arcresult->year] = $this->get_index_url( 'posttype', $post_type, $arcresult->year );
|
509 |
}
|
510 |
+
};
|
511 |
+
|
512 |
+
else :
|
513 |
+
|
514 |
$return[0] = $this->get_index_url('posttype', $post_type); // $sitemap = 'home', $type = false, $param = false
|
515 |
+
|
516 |
+
endif;
|
517 |
+
|
518 |
return $return;
|
519 |
}
|
520 |
|
538 |
|
539 |
// make sure it's an array we are returning
|
540 |
return (
|
541 |
+
is_string($type) &&
|
542 |
+
isset($return[$type]) &&
|
543 |
+
!empty($return[$type]['tags'])
|
544 |
+
) ? (array)$return[$type]['tags'] : array();
|
545 |
}
|
546 |
|
547 |
/**
|
556 |
// Polylang compat
|
557 |
if ( function_exists('pll_get_post_translations') ) {
|
558 |
$translations = pll_get_post_translations($post_id);
|
559 |
+
foreach ( $translations as $slug => $id ) {
|
560 |
if ( $post_id != $id ) $translation_ids[] = $id;
|
561 |
+
}
|
562 |
}
|
563 |
// WPML compat
|
564 |
global $sitepress;
|
616 |
* @return bool
|
617 |
*/
|
618 |
private function is_home( $id ) {
|
619 |
+
return in_array( $id, $this->get_blogpages() );
|
620 |
}
|
621 |
|
622 |
/**
|
628 |
*
|
629 |
* @return string
|
630 |
*/
|
631 |
+
public function head( $style = '' ) {
|
632 |
+
$output = '';
|
|
|
633 |
|
634 |
// check if headers are already sent (bad) and set up a warning in admin (how?)
|
635 |
+
if ( headers_sent($filename, $linenum) )
|
|
|
|
|
|
|
|
|
|
|
|
|
636 |
$output = "<!-- WARNING: Headers already sent by $filename on line $linenum. Please fix! -->\n";
|
|
|
637 |
|
638 |
// which style sheet
|
639 |
switch ($style) {
|
640 |
case 'index':
|
641 |
+
$style_sheet = plugins_url('xsl/sitemap-index.xsl',__FILE__);
|
642 |
+
break;
|
643 |
+
|
644 |
case 'news':
|
645 |
+
$style_sheet = plugins_url('xsl/sitemap-news.xsl',__FILE__);
|
646 |
+
break;
|
647 |
+
|
648 |
default:
|
649 |
+
$style_sheet = plugins_url('xsl/sitemap.xsl',__FILE__);
|
|
|
650 |
}
|
651 |
|
652 |
$output .= '<?xml version="1.0" encoding="' . get_bloginfo('charset') . '"?>' . PHP_EOL;
|
669 |
* @return string
|
670 |
*/
|
671 |
public function modified( $sitemap = 'post_type', $term = '' ) {
|
672 |
+
global $post;
|
673 |
|
674 |
+
if ( 'post_type' == $sitemap ) :
|
675 |
|
676 |
// if blog page then look for last post date
|
677 |
if ( $post->post_type == 'page' && $this->is_home($post->ID) )
|
706 |
if ( is_object($term) ) {
|
707 |
if ( !isset($this->termmodified[$term->term_id]) ) {
|
708 |
// get the latest post in this taxonomy item, to use its post_date as lastmod
|
709 |
+
$posts = get_posts (
|
710 |
+
array(
|
711 |
+
'post_type' => 'any',
|
712 |
+
'numberposts' => 1,
|
713 |
+
'no_found_rows' => true,
|
714 |
+
'update_post_meta_cache' => false,
|
715 |
+
'update_post_term_cache' => false,
|
716 |
+
'update_cache' => false,
|
717 |
+
'tax_query' => array(
|
718 |
+
array(
|
719 |
+
'taxonomy' => $term->taxonomy,
|
720 |
+
'field' => 'slug',
|
721 |
+
'terms' => $term->slug
|
722 |
)
|
723 |
)
|
724 |
+
)
|
725 |
+
);
|
726 |
$this->termmodified[$term->term_id] = isset($posts[0]->post_date_gmt) ? $posts[0]->post_date_gmt : '';
|
727 |
}
|
728 |
return $this->termmodified[$term->term_id];
|
741 |
return end($lastmodified);
|
742 |
}
|
743 |
|
|
|
|
|
|
|
|
|
744 |
endif;
|
745 |
+
|
746 |
+
return '';
|
747 |
}
|
748 |
|
749 |
/**
|
781 |
*/
|
782 |
public function get_images( $sitemap = '' ) {
|
783 |
global $post;
|
784 |
+
|
785 |
+
if ( empty($this->images[$post->ID]) ) :
|
786 |
+
|
787 |
if ( 'news' == $sitemap ) {
|
788 |
$options = $this->get_option('news_tags');
|
789 |
$which = isset($options['image']) ? $options['image'] : '';
|
791 |
$options = $this->get_post_types();
|
792 |
$which = isset($options[$post->post_type]['tags']['image']) ? $options[$post->post_type]['tags']['image'] : '';
|
793 |
}
|
794 |
+
|
795 |
if ( 'attached' == $which ) {
|
796 |
$args = array( 'post_type' => 'attachment', 'post_mime_type' => 'image', 'numberposts' => -1, 'post_status' =>'inherit', 'post_parent' => $post->ID );
|
797 |
$attachments = get_posts($args);
|
799 |
foreach ( $attachments as $attachment ) {
|
800 |
$url = wp_get_attachment_image_url( $attachment->ID, 'full' );
|
801 |
$url = $this->get_absolute_url( $url );
|
802 |
+
if ( !empty($url) ) {
|
803 |
$this->images[$post->ID][] = array(
|
804 |
+
'loc' => esc_attr( esc_url_raw( $url ) ),
|
805 |
+
'title' => apply_filters( 'the_title_xmlsitemap', $attachment->post_title ),
|
806 |
+
'caption' => apply_filters( 'the_title_xmlsitemap', $attachment->post_excerpt )
|
807 |
+
// 'caption' => apply_filters( 'the_title_xmlsitemap', get_post_meta( $attachment->ID, '_wp_attachment_image_alt', true ) )
|
808 |
+
);
|
809 |
+
}
|
810 |
}
|
811 |
}
|
812 |
} elseif ( 'featured' == $which ) {
|
814 |
//$attachment = get_post( get_post_thumbnail_id( $post->ID ) );
|
815 |
$url = wp_get_attachment_image_url( get_post_thumbnail_id( $post->ID ), 'full' );
|
816 |
$url = $this->get_absolute_url( $url );
|
817 |
+
if ( !empty($url) ) {
|
818 |
$this->images[$post->ID][] = array(
|
819 |
+
'loc' => esc_attr( esc_url_raw( $url ) ),
|
820 |
+
'title' => apply_filters( 'the_title_xmlsitemap', $attachment->post_title ),
|
821 |
+
'caption' => apply_filters( 'the_title_xmlsitemap', $attachment->post_excerpt )
|
822 |
+
// 'caption' => apply_filters( 'the_title_xmlsitemap', get_post_meta( $attachment->ID, '_wp_attachment_image_alt', true ) )
|
823 |
+
);
|
824 |
+
}
|
825 |
}
|
826 |
}
|
827 |
+
|
828 |
+
endif;
|
829 |
+
|
830 |
return ( isset($this->images[$post->ID]) ) ? $this->images[$post->ID] : false;
|
831 |
}
|
832 |
|
844 |
' : '';
|
845 |
}
|
846 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
847 |
/**
|
848 |
* Get priority
|
849 |
*
|
853 |
* @return string
|
854 |
*/
|
855 |
public function get_priority( $sitemap = 'post_type', $term = '' ) {
|
856 |
+
|
857 |
if ( 'post_type' == $sitemap ) :
|
858 |
+
|
859 |
global $post;
|
860 |
$options = $this->get_post_types();
|
861 |
$defaults = $this->defaults('post_types');
|
862 |
$priority_meta = get_metadata('post', $post->ID, '_xmlsf_priority' , true);
|
863 |
|
864 |
if ( !empty($priority_meta) || $priority_meta == '0' ) {
|
|
|
865 |
$priority = floatval(str_replace(',','.',$priority_meta));
|
|
|
866 |
} elseif ( !empty($options[$post->post_type]['dynamic_priority']) ) {
|
|
|
867 |
$post_modified = mysql2date('U',$post->post_modified_gmt, false);
|
868 |
|
869 |
+
if ( empty($this->lastmodified) ) {
|
870 |
$this->lastmodified = mysql2date('U',get_lastpostmodified('gmt',$post->post_type),false);
|
871 |
// last posts or page modified date in Unix seconds
|
872 |
+
}
|
873 |
|
874 |
+
if ( empty($this->firstdate) ) {
|
875 |
$this->firstdate = mysql2date('U',get_firstpostdate('gmt',$post->post_type),false);
|
876 |
// uses get_firstpostdate() function defined in xml-sitemap/hacks.php !
|
877 |
+
}
|
878 |
|
879 |
+
if ( isset($options[$post->post_type]['priority']) ) {
|
880 |
$priority_value = floatval(str_replace(',','.',$options[$post->post_type]['priority']));
|
881 |
+
} else {
|
882 |
$priority_value = floatval($defaults[$post->post_type]['priority']);
|
883 |
+
}
|
884 |
|
885 |
// reduce by age
|
886 |
// NOTE : home/blog page gets same treatment as sticky post, i.e. no reduction by age
|
887 |
+
if ( is_sticky($post->ID) || $this->is_home($post->ID) ) {
|
888 |
$priority = $priority_value;
|
889 |
+
} else {
|
890 |
$priority = ( $this->lastmodified > $this->firstdate ) ? $priority_value - $priority_value * ( $this->lastmodified - $post_modified ) / ( $this->lastmodified - $this->firstdate ) : $priority_value;
|
891 |
+
}
|
892 |
|
893 |
+
if ( $post->comment_count > 0 ) {
|
894 |
$priority = $priority + 0.1 + ( 0.9 - $priority ) * $post->comment_count / wp_count_comments($post->post_type)->approved;
|
895 |
+
}
|
896 |
} else {
|
|
|
897 |
$priority = ( isset($options[$post->post_type]['priority']) && is_numeric($options[$post->post_type]['priority']) ) ? $options[$post->post_type]['priority'] : $defaults[$post->post_type]['priority'];
|
|
|
898 |
}
|
899 |
|
900 |
elseif ( ! empty($term) ) :
|
901 |
|
902 |
$max_priority = 0.4;
|
903 |
$min_priority = 0.0;
|
904 |
+
// TODO make these values optional?
|
905 |
|
906 |
$tax_obj = get_taxonomy($term->taxonomy);
|
907 |
$postcount = 0;
|
918 |
|
919 |
endif;
|
920 |
|
921 |
+
// make sure we're not below zero or cases where we ended up above 1 (sticky posts with many comments)
|
922 |
+
$priority = filter_var( $priority, FILTER_VALIDATE_INT, array(
|
923 |
+
'options' => array(
|
924 |
+
'default' => .5,
|
925 |
+
'min_range' => 0,
|
926 |
+
'max_range' => 1
|
927 |
+
)
|
928 |
+
)
|
929 |
+
);
|
930 |
|
931 |
+
return number_format( $priority, 1 );
|
932 |
}
|
933 |
|
934 |
/**
|
941 |
global $sitepress; // Polylang and WPML compat
|
942 |
if ( function_exists('pll_the_languages') ) {
|
943 |
$languages = pll_the_languages( array( 'raw' => 1 ) );
|
944 |
+
if ( is_array($languages) ) {
|
945 |
+
foreach ( $languages as $language ) {
|
946 |
$urls[] = pll_home_url( $language['slug'] );
|
947 |
+
}
|
948 |
+
} else {
|
949 |
$urls[] = $this->home_url();
|
950 |
+
}
|
951 |
} elseif ( isset($sitepress) && is_object($sitepress) && method_exists($sitepress, 'get_languages') && method_exists($sitepress, 'language_url') ) {
|
952 |
+
foreach ( array_keys ( $sitepress->get_languages(false,true) ) as $term ) {
|
953 |
$urls[] = $sitepress->language_url($term);
|
954 |
+
}
|
955 |
} else {
|
956 |
$urls[] = $this->home_url();
|
957 |
}
|
970 |
// no ID, try and get it from global post object
|
971 |
if ( null == $post_id ) {
|
972 |
global $post;
|
973 |
+
if ( is_object($post) && isset($post->ID)) {
|
974 |
$post_id = $post->ID;
|
975 |
+
} else {
|
976 |
return false;
|
977 |
+
}
|
978 |
}
|
979 |
|
980 |
$excluded = get_post_meta($post_id,'_xmlsf_exclude',true) || in_array($post_id,$this->get_frontpages()) ? true : false;
|
1018 |
public function get_index_url( $sitemap = 'home', $type = false, $param = false ) {
|
1019 |
$split_url = explode('?', $this->home_url());
|
1020 |
|
|
|
|
|
|
|
|
|
|
|
1021 |
if ( '' == get_option('permalink_structure') || '1' != get_option('blog_public')) {
|
1022 |
$name = '?feed='.$name;
|
1023 |
$name .= $param ? '&m='.$param : '';
|
1024 |
$name .= isset($split_url[1]) && !empty($split_url[1]) ? '&' . $split_url[1] : '';
|
1025 |
} else {
|
1026 |
+
$name = $this->base_name.'-'.$sitemap;
|
1027 |
+
$name .= $type ? '-'.$type : '';
|
1028 |
$name .= $param ? '.'.$param : '';
|
1029 |
$name .= '.'.$this->extension;
|
1030 |
$name .= isset($split_url[1]) && !empty($split_url[1]) ? '?' . $split_url[1] : '';
|
1080 |
*/
|
1081 |
|
1082 |
// add sitemap location in robots.txt generated by WP
|
1083 |
+
public function robots($output) {
|
|
|
1084 |
echo '# XML Sitemap & Google News Feeds version ' . XMLSF_VERSION . ' - http://status301.net/wordpress-plugins/xml-sitemap-feed/' . PHP_EOL;
|
1085 |
|
1086 |
if ( '1' != get_option('blog_public') ) {
|
1092 |
if ( empty($pretty) )
|
1093 |
echo '# No XML Sitemaps are enabled. Please see XML Sitemaps on Settings > Reading.' . PHP_EOL;
|
1094 |
}
|
1095 |
+
|
1096 |
echo PHP_EOL;
|
1097 |
}
|
1098 |
|
1120 |
* @return mixed
|
1121 |
*/
|
1122 |
public function trailingslash($request) {
|
1123 |
+
return pathinfo($request, PATHINFO_EXTENSION) ? untrailingslashit($request) : $request;
|
|
|
|
|
|
|
1124 |
}
|
1125 |
|
1126 |
/**
|
1134 |
$xmlsf_rules = array();
|
1135 |
$sitemaps = $this->get_sitemaps();
|
1136 |
|
1137 |
+
foreach ( $sitemaps as $name => $pretty ) {
|
1138 |
$xmlsf_rules[ preg_quote($pretty) . '$' ] = $wp_rewrite->index . '?feed=' . $name;
|
1139 |
+
}
|
1140 |
|
1141 |
if (!empty($sitemaps['sitemap'])) {
|
1142 |
// home urls
|
1144 |
|
1145 |
// add rules for post types (can be split by month or year)
|
1146 |
foreach ( $this->get_post_types() as $post_type ) {
|
1147 |
+
if ( isset($post_type['active']) && '1' == $post_type['active'] ) {
|
1148 |
$xmlsf_rules[ $this->base_name . '-posttype-' . $post_type['name'] . '\.([0-9]+)?\.?' . $this->extension . '$' ] = $wp_rewrite->index . '?feed=sitemap-posttype-' . $post_type['name'] . '&m=$matches[1]';
|
1149 |
+
}
|
1150 |
}
|
1151 |
|
1152 |
// add rules for taxonomies
|
1155 |
}
|
1156 |
|
1157 |
$urls = $this->get_urls();
|
1158 |
+
if(!empty($urls)) {
|
1159 |
$xmlsf_rules[ $this->base_name . '-custom\.' . $this->extension . '$' ] = $wp_rewrite->index . '?feed=sitemap-custom';
|
1160 |
+
}
|
1161 |
|
1162 |
}
|
1163 |
|
1170 |
*/
|
1171 |
public function wpml_language_switcher() {
|
1172 |
global $sitepress,$post;
|
1173 |
+
if( isset( $sitepress ) ) {
|
1174 |
+
$post_language = apply_filters( 'wpml_post_language_details', NULL, $post->ID );
|
1175 |
+
$sitepress->switch_lang($post_language['language_code']);
|
1176 |
+
}
|
1177 |
}
|
1178 |
|
1179 |
/**
|
1184 |
* @return mixed
|
1185 |
*/
|
1186 |
public function filter_request( $request ) {
|
1187 |
+
$this->request_filtered = true;
|
1188 |
+
|
1189 |
if ( isset($request['feed']) && strpos($request['feed'],'sitemap') === 0 ) :
|
1190 |
+
|
1191 |
+
// CONTENT_TYPE and REPSONSE HEADERS filtering function
|
1192 |
+
add_filter( 'feed_content_type', array($this, 'content_type') );
|
1193 |
+
add_filter( 'wp_headers', array($this, 'headers') );
|
1194 |
+
|
1195 |
// modify request parameters
|
1196 |
$request['post_status'] = 'publish';
|
1197 |
$request['no_found_rows'] = true;
|
1214 |
$defaults = $this->defaults('news_tags');
|
1215 |
$options = $this->get_option('news_tags');
|
1216 |
$news_post_type = isset($options['post_type']) && !empty($options['post_type']) ? $options['post_type'] : $defaults['post_type'];
|
1217 |
+
if (empty($news_post_type)) {
|
1218 |
+
$news_post_type = 'post';
|
1219 |
+
}
|
1220 |
|
1221 |
// disable caching
|
1222 |
define('DONOTCACHEPAGE', true);
|
1230 |
$request['post_type'] = $news_post_type;
|
1231 |
|
1232 |
// categories
|
1233 |
+
if ( isset($options['categories']) && is_array($options['categories']) ) {
|
1234 |
$request['cat'] = implode(',',$options['categories']);
|
1235 |
+
}
|
1236 |
|
1237 |
// set the news sitemap conditional tag
|
1238 |
$this->is_news = true;
|
1279 |
}
|
1280 |
}
|
1281 |
}
|
1282 |
+
|
1283 |
endif;
|
1284 |
|
1285 |
return $request;
|
1286 |
}
|
1287 |
|
1288 |
+
/**
|
1289 |
+
* XML Sitemap content type filter
|
1290 |
+
*
|
1291 |
+
* @param $content_type
|
1292 |
+
* @param $type
|
1293 |
+
*
|
1294 |
+
* @return string
|
1295 |
+
*/
|
1296 |
+
function content_type( $content_type, $type = 'sitemap' ) {
|
1297 |
+
if ( strpos($type,'sitemap') === 0 )
|
1298 |
+
$content_type = 'text/xml';
|
1299 |
+
|
1300 |
+
return $content_type;
|
1301 |
+
}
|
1302 |
+
|
1303 |
+
/**
|
1304 |
+
* Response headers filter
|
1305 |
+
* Does not check if we are really in a sitemap feed.
|
1306 |
+
*
|
1307 |
+
* @param $headers
|
1308 |
+
*
|
1309 |
+
* @return array
|
1310 |
+
*/
|
1311 |
+
function headers( $headers ) {
|
1312 |
+
// set noindex
|
1313 |
+
$headers['X-Robots-Tag'] = 'noindex, follow';
|
1314 |
+
return $headers;
|
1315 |
+
}
|
1316 |
+
|
1317 |
/**
|
1318 |
* FEED TEMPLATES
|
1319 |
*/
|
1399 |
* in case there is no news, just take the latest post
|
1400 |
* @return string
|
1401 |
*/
|
1402 |
+
public function filter_no_news_limits( $limits ) {
|
|
|
1403 |
return 'LIMIT 0, 1';
|
1404 |
}
|
1405 |
|
1416 |
* @return bool
|
1417 |
*/
|
1418 |
public function ping($uri, $timeout = 3) {
|
1419 |
+
$response = wp_remote_request( $uri, array('timeout'=>$timeout) );
|
|
|
1420 |
|
1421 |
+
return ( '200' == wp_remote_retrieve_response_code($response) ) ? true : false;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1422 |
}
|
1423 |
|
1424 |
/**
|
1446 |
// loop through ping targets
|
1447 |
foreach ($to_ping as $se => $data) {
|
1448 |
// check active switch
|
1449 |
+
if( empty($data['active']) || empty($data['news']) ) {
|
1450 |
continue;
|
1451 |
+
}
|
1452 |
// and if we did not ping already within the last 5 minutes
|
1453 |
+
if( !empty($data['pong']) && is_array($data['pong']) && !empty($data['pong'][$sitemaps['sitemap-news']]) && (int)$data['pong'][$sitemaps['sitemap-news']] + 300 > time() ) {
|
1454 |
+
continue;
|
1455 |
+
}
|
1456 |
// ping !
|
1457 |
+
if ( $this->ping( add_query_arg( $data['req'], urlencode(trailingslashit(get_bloginfo('url')).$sitemaps['sitemap-news']), $data['uri'] ) ) ) {
|
1458 |
$to_ping[$se]['pong'][$sitemaps['sitemap-news']] = time();
|
1459 |
$update = true;
|
1460 |
}
|
|
|
1461 |
}
|
1462 |
}
|
1463 |
}
|
1472 |
if ( $old_status != 'publish' && $new_status == 'publish' ) {
|
1473 |
foreach ($to_ping as $se => $data) {
|
1474 |
// check active switch
|
1475 |
+
if ( empty($data['active']) || empty($data['type']) || $data['type']!='GET' ) {
|
1476 |
continue;
|
1477 |
+
}
|
1478 |
// and if we did not ping already within the last hour
|
1479 |
+
if ( !empty($data['pong']) && is_array($data['pong']) && !empty($data['pong'][$sitemaps['sitemap']]) && (int)$data['pong'][$sitemaps['sitemap']] + 3600 > time() ) {
|
1480 |
+
continue;
|
1481 |
+
}
|
1482 |
// ping !
|
1483 |
+
if ( $this->ping( add_query_arg( $data['req'], urlencode(trailingslashit(get_bloginfo('url')).$sitemaps['sitemap']), $data['uri'] ) ) ) {
|
1484 |
$to_ping[$se]['pong'][$sitemaps['sitemap']] = time();
|
1485 |
$update = true;
|
1486 |
}
|
1501 |
* Clear settings
|
1502 |
*/
|
1503 |
public function clear_settings() {
|
1504 |
+
delete_option( 'xmlsf_version' );
|
1505 |
foreach ( $this->defaults() as $option => $settings ) {
|
1506 |
+
delete_option( 'xmlsf_' . $option );
|
1507 |
}
|
1508 |
|
1509 |
if ( defined('WP_DEBUG') && WP_DEBUG ) {
|
1510 |
+
error_log( 'XML Sitemap Feeds settings cleared' );
|
1511 |
}
|
1512 |
}
|
1513 |
|
1523 |
|
1524 |
// TODO get year / month here to delete specific keys too !!!!
|
1525 |
$m = mysql2date('Ym',$post->post_date_gmt, false);
|
1526 |
+
$y = substr($m, 0, 4);
|
1527 |
|
1528 |
// clear possible last post modified cache keys
|
1529 |
wp_cache_delete( 'lastpostmodified:gmt', 'timeinfo' ); // should be handled by WP core?
|
1538 |
|
1539 |
// clear possible fist post date cache keys
|
1540 |
wp_cache_delete( 'firstpostdate:gmt', 'timeinfo' );
|
1541 |
+
wp_cache_delete( 'firstpostdate:gmt:'.$post->post_type, 'timeinfo' );
|
1542 |
+
}
|
1543 |
|
1544 |
/**
|
1545 |
* Nginx helper purge urls
|
1552 |
*/
|
1553 |
public function nginx_helper_purge_urls( $urls = array(), $redis = false ) {
|
1554 |
// are permalinks set, blog public and $urls an array?
|
1555 |
+
if ( '' == get_option('permalink_structure') || '1' != get_option('blog_public') || ! is_array( $urls ) ) {
|
1556 |
return $urls;
|
1557 |
+
}
|
1558 |
|
1559 |
if ( $redis ) {
|
|
|
1560 |
// wildcard allowed, this makes everything simple
|
1561 |
$urls[] = '/sitemap*.xml';
|
|
|
1562 |
} else {
|
|
|
1563 |
// no wildcard, go through the motions
|
1564 |
foreach ( $this->get_sitemaps() as $pretty ) {
|
1565 |
|
1571 |
// add public post types sitemaps
|
1572 |
foreach ( $this->have_post_types() as $post_type ) {
|
1573 |
$archive = !empty($post_type['archive']) ? $post_type['archive'] : '';
|
1574 |
+
foreach ( $this->get_archives($post_type['name'],$archive) as $url ) {
|
1575 |
$urls[] = parse_url( $url, PHP_URL_PATH);
|
1576 |
+
}
|
1577 |
}
|
1578 |
|
1579 |
// add public post taxonomies sitemaps
|
1589 |
|
1590 |
// custom sitemaps
|
1591 |
foreach ($this->get_custom_sitemaps() as $url) {
|
1592 |
+
if ( !empty($url) && $this->is_allowed_domain($url) ) {
|
1593 |
$urls[] = parse_url( esc_url($url), PHP_URL_PATH);
|
1594 |
+
}
|
1595 |
}
|
1596 |
}
|
1597 |
}
|
1598 |
|
1599 |
$urls[] = '/' . $pretty;
|
|
|
1600 |
}
|
1601 |
|
1602 |
return $urls;
|
1613 |
// rewrite rules not available on plugins_loaded
|
1614 |
// and don't flush rules from init as Polylang chokes on that
|
1615 |
// just remove the db option and let WP regenerate them when ready...
|
1616 |
+
delete_option( 'rewrite_rules' );
|
1617 |
// ... but make sure rules are regenerated when admin is visited.
|
1618 |
+
set_transient( 'xmlsf_flush_rewrite_rules', '' );
|
1619 |
|
1620 |
+
// remove robots.txt rules blocking stylesheets, but only one time!
|
1621 |
+
if ( version_compare('4.4', $old_version, '>') && $robot_rules = get_option($this->prefix.'robots') ) {
|
1622 |
$robot_rules = str_replace(array('Disallow: */wp-content/','Allow: */wp-content/uploads/'),'',$robot_rules);
|
1623 |
+
delete_option( $this->prefix.'robots' );
|
1624 |
+
add_option( $this->prefix.'robots', $robot_rules, '', 'no' );
|
1625 |
}
|
1626 |
|
1627 |
if ( version_compare('4.4.1', $old_version, '>') ) {
|
1628 |
// register location taxonomies then delete all terms
|
1629 |
register_taxonomy( 'gn-location-3', null );
|
1630 |
+
$terms = get_terms( 'gn-location-3', array('hide_empty' => false) );
|
1631 |
+
foreach ( $terms as $term ) {
|
1632 |
wp_delete_term( $term->term_id, 'gn-location-3' );
|
1633 |
+
}
|
1634 |
|
1635 |
register_taxonomy( 'gn-location-2', null );
|
1636 |
+
$terms = get_terms( 'gn-location-2',array('hide_empty' => false) );
|
1637 |
+
foreach ( $terms as $term ) {
|
1638 |
wp_delete_term( $term->term_id, 'gn-location-2' );
|
1639 |
+
}
|
1640 |
|
1641 |
register_taxonomy( 'gn-location-1', null );
|
1642 |
+
$terms = get_terms( 'gn-location-1',array('hide_empty' => false) );
|
1643 |
+
foreach ( $terms as $term ) {
|
1644 |
wp_delete_term( $term->term_id, 'gn-location-1' );
|
1645 |
+
}
|
1646 |
}
|
1647 |
|
1648 |
+
if ( version_compare('4.9', $old_version, '>') ) {
|
1649 |
// purge genres taxonomy terms
|
1650 |
$this->register_gn_taxonomies();
|
1651 |
+
$terms = get_terms( 'gn-genre',array('hide_empty' => false) );
|
1652 |
+
foreach ( $terms as $term ) {
|
1653 |
wp_delete_term( $term->term_id, 'gn-genre' );
|
1654 |
+
}
|
1655 |
+
foreach ($this->gn_genres as $name) {
|
1656 |
+
wp_insert_term( $name, 'gn-genre' );
|
1657 |
+
}
|
1658 |
}
|
1659 |
|
1660 |
// upgrade pings
|
1676 |
add_option( $this->prefix.'ping', array_merge( $this->defaults('ping'), $ping ), '', 'no' );
|
1677 |
}
|
1678 |
|
1679 |
+
update_option( $this->prefix.'version', XMLSF_VERSION );
|
|
|
1680 |
|
1681 |
if ( defined('WP_DEBUG') && WP_DEBUG ) {
|
1682 |
error_log('XML Sitemap Feeds upgraded from '.$old_version.' to '.XMLSF_VERSION);
|
1689 |
public function plugins_loaded() {
|
1690 |
// TEXT DOMAIN
|
1691 |
if ( is_admin() ) { // text domain needed on admin only
|
1692 |
+
load_plugin_textdomain('xml-sitemap-feed', false, dirname( $this->plugin_basename ) . '/languages' );
|
1693 |
}
|
1694 |
}
|
1695 |
|
1707 |
$home_path = trailingslashit( get_home_path() );
|
1708 |
$sitemaps = $this->get_sitemaps();
|
1709 |
foreach ( $sitemaps as $name => $pretty ) {
|
1710 |
+
if ( file_exists( $home_path . $pretty ) ) {
|
1711 |
unlink( $home_path . $pretty );
|
1712 |
+
}
|
1713 |
}
|
1714 |
}
|
1715 |
}
|
1719 |
*/
|
1720 |
public function init() {
|
1721 |
// UPGRADE
|
1722 |
+
$version = get_option( 'xmlsf_version', 0 );
|
1723 |
|
1724 |
if ( version_compare(XMLSF_VERSION, $version, '>') ) {
|
1725 |
$this->upgrade($version);
|
1728 |
$sitemaps = $this->get_sitemaps();
|
1729 |
|
1730 |
if (isset($sitemaps['sitemap'])) {
|
1731 |
+
// setup feed templates
|
1732 |
+
add_action( 'do_feed_sitemap', array($this, 'load_template_index'), 10, 1 );
|
1733 |
+
add_action( 'do_feed_sitemap-home', array($this, 'load_template_base'), 10, 1 );
|
1734 |
+
add_action( 'do_feed_sitemap-custom', array($this, 'load_template_custom'), 10, 1 );
|
1735 |
foreach ( $this->get_post_types() as $post_type ) {
|
1736 |
+
add_action( 'do_feed_sitemap-posttype-'.$post_type['name'], array($this, 'load_template'), 10, 1 );
|
1737 |
}
|
1738 |
foreach ( $this->get_taxonomies() as $taxonomy ) {
|
1739 |
+
add_action( 'do_feed_sitemap-taxonomy-'.$taxonomy, array($this, 'load_template_taxonomy'), 10, 1 );
|
1740 |
}
|
1741 |
}
|
1742 |
|
1743 |
if (isset($sitemaps['sitemap-news'])) {
|
1744 |
+
// setup feed template
|
1745 |
add_action('do_feed_sitemap-news', array($this, 'load_template_news'), 10, 1);
|
1746 |
|
1747 |
// register the taxonomies
|
1748 |
$this->register_gn_taxonomies();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1749 |
}
|
1750 |
}
|
1751 |
|
1753 |
* Admin init
|
1754 |
*/
|
1755 |
public function admin_init() {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1756 |
// Include the admin class file
|
1757 |
include_once( dirname( __FILE__ ) . '/class-xmlsitemapfeed-admin.php' );
|
1758 |
}
|
1764 |
*/
|
1765 |
public function flush_rules( $hard = false ) {
|
1766 |
// did you flush already?
|
1767 |
+
if ( $this->yes_mother ) {
|
1768 |
return; // yes, mother!
|
1769 |
+
}
|
1770 |
|
1771 |
+
flush_rewrite_rules($hard);
|
|
|
|
|
1772 |
|
1773 |
+
if ( defined('WP_DEBUG') && WP_DEBUG ) {
|
1774 |
error_log('XML Sitemap Feeds rewrite rules flushed');
|
1775 |
+
}
|
1776 |
|
1777 |
$this->yes_mother = true;
|
1778 |
}
|
1789 |
register_taxonomy( 'gn-genre', $post_types, array(
|
1790 |
'hierarchical' => true,
|
1791 |
'labels' => array(
|
1792 |
+
'name' => __('Google News Genres','xml-sitemap-feed'),
|
1793 |
+
'singular_name' => __('Google News Genre','xml-sitemap-feed'),
|
1794 |
+
'all_items' => translate('All') // __('All Genres','xml-sitemap-feed')
|
1795 |
+
//'menu_name' => __('GN Genres','xml-sitemap-feed'),
|
1796 |
+
),
|
1797 |
'public' => false,
|
1798 |
'show_ui' => true,
|
1799 |
'show_tagcloud' => false,
|
1800 |
'query_var' => false,
|
1801 |
'capabilities' => array( // prevent creation / deletion
|
1802 |
+
'manage_terms' => 'nobody',
|
1803 |
+
'edit_terms' => 'nobody',
|
1804 |
+
'delete_terms' => 'nobody',
|
1805 |
+
'assign_terms' => 'edit_posts'
|
1806 |
+
)
|
1807 |
));
|
1808 |
}
|
1809 |
|
1811 |
* Echo usage info
|
1812 |
* for debugging
|
1813 |
*/
|
1814 |
+
public function _e_usage() {
|
1815 |
+
if ( defined('WP_DEBUG') && WP_DEBUG == true ) {
|
|
|
1816 |
echo '<!-- Queries executed '.get_num_queries();
|
1817 |
+
if(function_exists('memory_get_peak_usage')) {
|
1818 |
echo ' | Peak memory usage '.round(memory_get_peak_usage()/1024/1024,2).'M';
|
1819 |
+
}
|
1820 |
echo ' -->';
|
1821 |
}
|
1822 |
}
|
1825 |
* CONSTRUCTOR
|
1826 |
*/
|
1827 |
|
1828 |
+
function __construct( $basename = 'xml-sitemap-feed/xml-sitemap.php') {
|
1829 |
+
$this->plugin_basename = $basename;
|
1830 |
+
|
1831 |
// sitemap element filters
|
1832 |
+
add_filter( 'the_title_xmlsitemap', 'strip_tags' );
|
1833 |
+
add_filter( 'the_title_xmlsitemap', 'ent2ncr', 8 );
|
1834 |
+
add_filter( 'the_title_xmlsitemap', 'esc_html' );
|
1835 |
+
add_filter( 'bloginfo_xmlsitemap', 'ent2ncr', 8 );
|
1836 |
|
1837 |
+
// main REQUEST filtering function
|
1838 |
+
add_filter( 'request', array($this, 'filter_request'), 1 );
|
1839 |
|
1840 |
// TEXT DOMAIN...
|
1841 |
+
add_action( 'plugins_loaded', array($this,'plugins_loaded'), 11 );
|
1842 |
|
1843 |
// REWRITES
|
1844 |
+
add_action( 'generate_rewrite_rules', array($this, 'rewrite_rules') );
|
1845 |
+
add_filter( 'user_trailingslashit', array($this, 'trailingslash') );
|
1846 |
|
1847 |
// TAXONOMIES, ACTIONS, UPGRADE...
|
1848 |
+
add_action( 'init', array($this,'init'), 0 );
|
1849 |
|
1850 |
// REGISTER SETTINGS, SETTINGS FIELDS...
|
1851 |
+
add_action( 'admin_init', array($this,'admin_init'), 0 );
|
1852 |
|
1853 |
// ROBOTSTXT
|
1854 |
+
add_action( 'do_robotstxt', array($this, 'robots'), 0 );
|
1855 |
+
add_filter( 'robots_txt', array($this, 'robots_txt'), 9 );
|
1856 |
|
1857 |
// PINGING
|
1858 |
+
add_action( 'transition_post_status', array($this, 'do_pings'), 10, 3 );
|
1859 |
|
1860 |
// CLEAR OBJECT CACHE KEYS
|
1861 |
+
add_action( 'clean_post_cache', array($this, 'clean_post_cache'), 99, 2 );
|
1862 |
|
1863 |
// NGINX HELPER PURGE URLS
|
1864 |
+
add_filter( 'rt_nginx_helper_purge_urls', array($this, 'nginx_helper_purge_urls'), 10, 2 );
|
1865 |
|
1866 |
// ACTIVATION
|
1867 |
+
register_activation_hook( $basename, array($this, 'activate') );
|
1868 |
}
|
1869 |
}
|
includes/feed-sitemap-custom.php
CHANGED
@@ -10,7 +10,7 @@ if ( ! defined( 'WPINC' ) ) die;
|
|
10 |
global $xmlsf;
|
11 |
|
12 |
// start output
|
13 |
-
echo $xmlsf->
|
14 |
?>
|
15 |
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
|
16 |
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
10 |
global $xmlsf;
|
11 |
|
12 |
// start output
|
13 |
+
echo $xmlsf->head();
|
14 |
?>
|
15 |
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
|
16 |
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
includes/feed-sitemap-home.php
CHANGED
@@ -10,7 +10,7 @@ if ( ! defined( 'WPINC' ) ) die;
|
|
10 |
global $xmlsf;
|
11 |
|
12 |
// start output
|
13 |
-
echo $xmlsf->
|
14 |
?>
|
15 |
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
|
16 |
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
@@ -25,15 +25,6 @@ foreach ( $xmlsf->get_home_urls() as $url ) {
|
|
25 |
<url>
|
26 |
<loc><?php echo esc_url( $url ); ?></loc>
|
27 |
<lastmod><?php echo mysql2date('Y-m-d\TH:i:s+00:00', $lastmodified, false); ?></lastmod>
|
28 |
-
<changefreq><?php
|
29 |
-
if ( ($lastactivityage/86400) < 1 ) { // last activity less than 1 day old
|
30 |
-
echo 'hourly';
|
31 |
-
} else if ( ($lastactivityage/86400) < 7 ) { // last activity less than 1 week old
|
32 |
-
echo 'daily';
|
33 |
-
} else { // over a week old
|
34 |
-
echo 'weekly';
|
35 |
-
}
|
36 |
-
?></changefreq>
|
37 |
<priority>1.0</priority>
|
38 |
</url>
|
39 |
<?php
|
10 |
global $xmlsf;
|
11 |
|
12 |
// start output
|
13 |
+
echo $xmlsf->head();
|
14 |
?>
|
15 |
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
|
16 |
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
25 |
<url>
|
26 |
<loc><?php echo esc_url( $url ); ?></loc>
|
27 |
<lastmod><?php echo mysql2date('Y-m-d\TH:i:s+00:00', $lastmodified, false); ?></lastmod>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
28 |
<priority>1.0</priority>
|
29 |
</url>
|
30 |
<?php
|
includes/feed-sitemap-news.php
CHANGED
@@ -22,7 +22,7 @@ if ( !empty($options['image']) ) {
|
|
22 |
}
|
23 |
|
24 |
// start output
|
25 |
-
echo $xmlsf->
|
26 |
?>
|
27 |
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
|
28 |
xmlns:news="http://www.google.com/schemas/sitemap-news/0.9"
|
22 |
}
|
23 |
|
24 |
// start output
|
25 |
+
echo $xmlsf->head('news');
|
26 |
?>
|
27 |
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
|
28 |
xmlns:news="http://www.google.com/schemas/sitemap-news/0.9"
|
includes/feed-sitemap-post_type.php
CHANGED
@@ -23,7 +23,7 @@ if ( !empty($image) ) {
|
|
23 |
}
|
24 |
|
25 |
// start output
|
26 |
-
echo $xmlsf->
|
27 |
?>
|
28 |
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
|
29 |
<?php echo $image_xmlns; ?>
|
@@ -52,7 +52,6 @@ if ( have_posts() ) :
|
|
52 |
<url>
|
53 |
<loc><?php echo esc_url( get_permalink() ); ?></loc>
|
54 |
<?php echo $xmlsf->get_lastmod(); ?>
|
55 |
-
<changefreq><?php echo $xmlsf->get_changefreq(); ?></changefreq>
|
56 |
<priority><?php echo $xmlsf->get_priority(); ?></priority>
|
57 |
<?php
|
58 |
if ( !empty($image) && $xmlsf->get_images() ) :
|
23 |
}
|
24 |
|
25 |
// start output
|
26 |
+
echo $xmlsf->head();
|
27 |
?>
|
28 |
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
|
29 |
<?php echo $image_xmlns; ?>
|
52 |
<url>
|
53 |
<loc><?php echo esc_url( get_permalink() ); ?></loc>
|
54 |
<?php echo $xmlsf->get_lastmod(); ?>
|
|
|
55 |
<priority><?php echo $xmlsf->get_priority(); ?></priority>
|
56 |
<?php
|
57 |
if ( !empty($image) && $xmlsf->get_images() ) :
|
includes/feed-sitemap-taxonomy.php
CHANGED
@@ -10,7 +10,7 @@ if ( ! defined( 'WPINC' ) ) die;
|
|
10 |
global $xmlsf;
|
11 |
|
12 |
// start output
|
13 |
-
echo $xmlsf->
|
14 |
?>
|
15 |
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
|
16 |
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
@@ -34,7 +34,6 @@ if ( $terms ) :
|
|
34 |
<loc><?php echo get_term_link( $term ); ?></loc>
|
35 |
<priority><?php echo $xmlsf->get_priority('taxonomy',$term); ?></priority>
|
36 |
<?php echo $xmlsf->get_lastmod('taxonomy',$term); ?>
|
37 |
-
<changefreq><?php echo $xmlsf->get_changefreq('taxonomy',$term); ?></changefreq>
|
38 |
</url>
|
39 |
<?php
|
40 |
endforeach;
|
10 |
global $xmlsf;
|
11 |
|
12 |
// start output
|
13 |
+
echo $xmlsf->head();
|
14 |
?>
|
15 |
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
|
16 |
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
34 |
<loc><?php echo get_term_link( $term ); ?></loc>
|
35 |
<priority><?php echo $xmlsf->get_priority('taxonomy',$term); ?></priority>
|
36 |
<?php echo $xmlsf->get_lastmod('taxonomy',$term); ?>
|
|
|
37 |
</url>
|
38 |
<?php
|
39 |
endforeach;
|
includes/feed-sitemap.php
CHANGED
@@ -10,7 +10,7 @@ if ( ! defined( 'WPINC' ) ) die;
|
|
10 |
global $xmlsf;
|
11 |
|
12 |
// start output
|
13 |
-
echo $xmlsf->
|
14 |
?>
|
15 |
<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
|
16 |
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
10 |
global $xmlsf;
|
11 |
|
12 |
// start output
|
13 |
+
echo $xmlsf->head('index');
|
14 |
?>
|
15 |
<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
|
16 |
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
includes/functions.php
CHANGED
@@ -14,8 +14,8 @@
|
|
14 |
function is_sitemap() {
|
15 |
global $xmlsf;
|
16 |
|
17 |
-
if ( !
|
18 |
-
_doing_it_wrong( __FUNCTION__, __( 'Conditional sitemap tags do not work before the sitemap request filter is run. Before then, they always return false.' ), '4.8' );
|
19 |
return false;
|
20 |
}
|
21 |
|
@@ -33,8 +33,8 @@
|
|
33 |
function is_news() {
|
34 |
global $xmlsf;
|
35 |
|
36 |
-
if ( !
|
37 |
-
_doing_it_wrong( __FUNCTION__, __( 'Conditional sitemap tags do not work before the sitemap request filter is run. Before then, they always return false.' ), '4.8' );
|
38 |
return false;
|
39 |
}
|
40 |
|
14 |
function is_sitemap() {
|
15 |
global $xmlsf;
|
16 |
|
17 |
+
if ( ! is_object( $xmlsf ) || $xmlsf->request_filtered === false ) {
|
18 |
+
_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' );
|
19 |
return false;
|
20 |
}
|
21 |
|
33 |
function is_news() {
|
34 |
global $xmlsf;
|
35 |
|
36 |
+
if ( ! is_object( $xmlsf ) || $xmlsf->request_filtered === false ) {
|
37 |
+
_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' );
|
38 |
return false;
|
39 |
}
|
40 |
|
includes/xsl/sitemap-index.xsl
CHANGED
@@ -1,8 +1,8 @@
|
|
1 |
<?xml version="1.0" encoding="UTF-8"?>
|
2 |
-
<xsl:stylesheet version="2.0"
|
3 |
xmlns:html="http://www.w3.org/TR/REC-html40"
|
4 |
-
xmlns:sitemap="http://www.sitemaps.org/schemas/sitemap/0.9"
|
5 |
-
sitemap:news="http://www.google.com/schemas/sitemap-news/0.9"
|
6 |
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
|
7 |
<xsl:output method="html" version="1.0" encoding="UTF-8" indent="yes"/>
|
8 |
<xsl:template match="/">
|
1 |
<?xml version="1.0" encoding="UTF-8"?>
|
2 |
+
<xsl:stylesheet version="2.0"
|
3 |
xmlns:html="http://www.w3.org/TR/REC-html40"
|
4 |
+
xmlns:sitemap="http://www.sitemaps.org/schemas/sitemap/0.9"
|
5 |
+
sitemap:news="http://www.google.com/schemas/sitemap-news/0.9"
|
6 |
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
|
7 |
<xsl:output method="html" version="1.0" encoding="UTF-8" indent="yes"/>
|
8 |
<xsl:template match="/">
|
includes/xsl/sitemap.xsl
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
<?xml version="1.0" encoding="UTF-8"?>
|
2 |
-
<xsl:stylesheet version="2.0"
|
3 |
-
xmlns:html="http://www.w3.org/TR/REC-html40"
|
4 |
-
xmlns:sitemap="http://www.sitemaps.org/schemas/sitemap/0.9"
|
5 |
xmlns:image="http://www.google.com/schemas/sitemap-image/1.1"
|
6 |
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
|
7 |
<xsl:output method="html" version="1.0" encoding="UTF-8" indent="yes"/>
|
@@ -24,7 +24,6 @@
|
|
24 |
<th>URL</th>
|
25 |
<th># Images</th>
|
26 |
<th>Priority</th>
|
27 |
-
<th>Change Frequency</th>
|
28 |
<th>Last Changed</th>
|
29 |
</tr>
|
30 |
<xsl:variable name="lower" select="'abcdefghijklmnopqrstuvwxyz'"/>
|
@@ -35,7 +34,6 @@
|
|
35 |
<td><xsl:variable name="itemURL"><xsl:value-of select="sitemap:loc"/></xsl:variable><a href="{$itemURL}"><xsl:value-of select="sitemap:loc"/></a></td>
|
36 |
<td><xsl:value-of select="count(image:image)"/></td>
|
37 |
<td><xsl:value-of select="concat(sitemap:priority*100,'%')"/></td>
|
38 |
-
<td><xsl:value-of select="concat(translate(substring(sitemap:changefreq, 1, 1),concat($lower, $upper),concat($upper, $lower)),substring(sitemap:changefreq, 2))"/></td>
|
39 |
<td><xsl:value-of select="concat(substring(sitemap:lastmod,0,11),concat(' ', substring(sitemap:lastmod,12,5)))"/></td>
|
40 |
</tr>
|
41 |
</xsl:for-each>
|
1 |
<?xml version="1.0" encoding="UTF-8"?>
|
2 |
+
<xsl:stylesheet version="2.0"
|
3 |
+
xmlns:html="http://www.w3.org/TR/REC-html40"
|
4 |
+
xmlns:sitemap="http://www.sitemaps.org/schemas/sitemap/0.9"
|
5 |
xmlns:image="http://www.google.com/schemas/sitemap-image/1.1"
|
6 |
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
|
7 |
<xsl:output method="html" version="1.0" encoding="UTF-8" indent="yes"/>
|
24 |
<th>URL</th>
|
25 |
<th># Images</th>
|
26 |
<th>Priority</th>
|
|
|
27 |
<th>Last Changed</th>
|
28 |
</tr>
|
29 |
<xsl:variable name="lower" select="'abcdefghijklmnopqrstuvwxyz'"/>
|
34 |
<td><xsl:variable name="itemURL"><xsl:value-of select="sitemap:loc"/></xsl:variable><a href="{$itemURL}"><xsl:value-of select="sitemap:loc"/></a></td>
|
35 |
<td><xsl:value-of select="count(image:image)"/></td>
|
36 |
<td><xsl:value-of select="concat(sitemap:priority*100,'%')"/></td>
|
|
|
37 |
<td><xsl:value-of select="concat(substring(sitemap:lastmod,0,11),concat(' ', substring(sitemap:lastmod,12,5)))"/></td>
|
38 |
</tr>
|
39 |
</xsl:for-each>
|
readme.txt
CHANGED
@@ -4,7 +4,7 @@ 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: 3.2
|
6 |
Tested up to: 4.9
|
7 |
-
Stable tag: 4.
|
8 |
|
9 |
XML and Google News Sitemaps to feed the hungry spiders. Multisite, WP Super Cache, Polylang and WPML compatible.
|
10 |
|
@@ -281,11 +281,9 @@ New FactCheck genre. Remove changefreq tag. Fix permalink issue with Woocommerce
|
|
281 |
* NEW: FactCheck genre
|
282 |
* Changefreq tag dropped
|
283 |
* NEW: translation strings for genres
|
284 |
-
* FIX: zlib.output_compression compatibility
|
285 |
* FIX: permalink issue with Woocommerce account page endpoints
|
286 |
* FIX: undefined index in news post types
|
287 |
-
* TODO make priority optional
|
288 |
-
* TODO dedicated keywords taxonomy
|
289 |
|
290 |
= 4.8.3 =
|
291 |
* fix get_lastpostdate array/string
|
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: 3.2
|
6 |
Tested up to: 4.9
|
7 |
+
Stable tag: 4.9
|
8 |
|
9 |
XML and Google News Sitemaps to feed the hungry spiders. Multisite, WP Super Cache, Polylang and WPML compatible.
|
10 |
|
281 |
* NEW: FactCheck genre
|
282 |
* Changefreq tag dropped
|
283 |
* NEW: translation strings for genres
|
284 |
+
* FIX: zlib.output_compression compatibility, thanks @alicewondermiscreations
|
285 |
* FIX: permalink issue with Woocommerce account page endpoints
|
286 |
* FIX: undefined index in news post types
|
|
|
|
|
287 |
|
288 |
= 4.8.3 =
|
289 |
* fix get_lastpostdate array/string
|
uninstall.php
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
<?php
|
2 |
// if uninstall not called from WordPress exit
|
3 |
-
if (!defined('WP_UNINSTALL_PLUGIN'))
|
4 |
exit();
|
5 |
|
6 |
/*
|
@@ -15,12 +15,11 @@ class XMLSitemapFeed_Uninstall {
|
|
15 |
*
|
16 |
* @since 4.4
|
17 |
*/
|
18 |
-
function __construct()
|
19 |
-
{
|
20 |
global $wpdb;
|
21 |
|
22 |
// check if it is a multisite and if XMLSF_MULTISITE_UNINSTALL constant is defined
|
23 |
-
|
24 |
if ( is_multisite() && defined('XMLSF_MULTISITE_UNINSTALL') && XMLSF_MULTISITE_UNINSTALL ) {
|
25 |
error_log('Clearing XML Sitemap Feeds settings from each site brefore uninstall:');
|
26 |
foreach ($wpdb->get_col("SELECT blog_id FROM $wpdb->blogs") as $blog_id) {
|
@@ -28,7 +27,6 @@ class XMLSitemapFeed_Uninstall {
|
|
28 |
$this->uninstall($blog_id);
|
29 |
}
|
30 |
restore_current_blog();
|
31 |
-
error_log('Done.');
|
32 |
}
|
33 |
else
|
34 |
$this->uninstall();
|
@@ -39,12 +37,11 @@ class XMLSitemapFeed_Uninstall {
|
|
39 |
*
|
40 |
* @since 4.4
|
41 |
*/
|
42 |
-
function uninstall($blog_id = false)
|
43 |
-
{
|
44 |
// delete all taxonomy terms
|
45 |
register_taxonomy( 'gn-genre', null );
|
46 |
|
47 |
-
$terms = get_terms('gn-genre',array('hide_empty' => false));
|
48 |
|
49 |
if ( is_array($terms) )
|
50 |
foreach ( $terms as $term )
|
@@ -67,10 +64,12 @@ class XMLSitemapFeed_Uninstall {
|
|
67 |
delete_option('rewrite_rules');
|
68 |
|
69 |
// Kilroy was here
|
70 |
-
if (
|
71 |
-
|
72 |
-
|
73 |
-
|
|
|
|
|
74 |
}
|
75 |
}
|
76 |
|
1 |
<?php
|
2 |
// if uninstall not called from WordPress exit
|
3 |
+
if ( !defined('WP_UNINSTALL_PLUGIN') )
|
4 |
exit();
|
5 |
|
6 |
/*
|
15 |
*
|
16 |
* @since 4.4
|
17 |
*/
|
18 |
+
function __construct() {
|
|
|
19 |
global $wpdb;
|
20 |
|
21 |
// check if it is a multisite and if XMLSF_MULTISITE_UNINSTALL constant is defined
|
22 |
+
// if so, run the uninstall function for each blog id
|
23 |
if ( is_multisite() && defined('XMLSF_MULTISITE_UNINSTALL') && XMLSF_MULTISITE_UNINSTALL ) {
|
24 |
error_log('Clearing XML Sitemap Feeds settings from each site brefore uninstall:');
|
25 |
foreach ($wpdb->get_col("SELECT blog_id FROM $wpdb->blogs") as $blog_id) {
|
27 |
$this->uninstall($blog_id);
|
28 |
}
|
29 |
restore_current_blog();
|
|
|
30 |
}
|
31 |
else
|
32 |
$this->uninstall();
|
37 |
*
|
38 |
* @since 4.4
|
39 |
*/
|
40 |
+
function uninstall($blog_id = false) {
|
|
|
41 |
// delete all taxonomy terms
|
42 |
register_taxonomy( 'gn-genre', null );
|
43 |
|
44 |
+
$terms = get_terms( 'gn-genre', array('hide_empty' => false) );
|
45 |
|
46 |
if ( is_array($terms) )
|
47 |
foreach ( $terms as $term )
|
64 |
delete_option('rewrite_rules');
|
65 |
|
66 |
// Kilroy was here
|
67 |
+
if ( defined('WP_DEBUG') && WP_DEBUG ) {
|
68 |
+
if ($blog_id)
|
69 |
+
error_log('XML Sitemap Feeds settings cleared from site '.$blog_id.' on uninstall.');
|
70 |
+
else
|
71 |
+
error_log('XML Sitemap Feeds settings cleared on uninstall.');
|
72 |
+
}
|
73 |
}
|
74 |
}
|
75 |
|
xml-sitemap.php
CHANGED
@@ -2,9 +2,9 @@
|
|
2 |
/*
|
3 |
Plugin Name: XML Sitemap & Google News feeds
|
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
|
6 |
Text Domain: xml-sitemap-feed
|
7 |
-
Version: 4.
|
8 |
Requires PHP: 5.6
|
9 |
Author: RavanH
|
10 |
Author URI: http://status301.net/
|
@@ -59,9 +59,7 @@ if ( ! defined( 'WPINC' ) ) die;
|
|
59 |
* CONSTANTS
|
60 |
* -------------------- */
|
61 |
|
62 |
-
|
63 |
-
|
64 |
-
define('XMLSF_PLUGIN_BASENAME', plugin_basename(__FILE__));
|
65 |
|
66 |
/*
|
67 |
* The following constants can be used to change plugin defaults
|
@@ -75,7 +73,6 @@ if ( ! defined( 'WPINC' ) ) die;
|
|
75 |
*/
|
76 |
|
77 |
if ( !defined('XMLSF_NAME') )
|
78 |
-
|
79 |
define('XMLSF_NAME', 'sitemap.xml');
|
80 |
|
81 |
/*
|
@@ -85,7 +82,6 @@ if ( !defined('XMLSF_NAME') )
|
|
85 |
*/
|
86 |
|
87 |
if ( !defined('XMLSF_NEWS_NAME') )
|
88 |
-
|
89 |
define('XMLSF_NEWS_NAME', 'sitemap-news.xml');
|
90 |
|
91 |
/*
|
@@ -105,16 +101,16 @@ if ( !defined('XMLSF_NEWS_NAME') )
|
|
105 |
* INCLUDE HACKS & CLASS
|
106 |
* ------------------------------------- */
|
107 |
|
108 |
-
$xmlsf_dir =
|
109 |
|
110 |
-
if ( file_exists ( $xmlsf_dir.'
|
111 |
-
$xmlsf_dir .= '
|
112 |
|
113 |
-
include_once( $xmlsf_dir.'
|
114 |
-
include_once( $xmlsf_dir.'
|
115 |
|
116 |
/* ----------------------
|
117 |
* INSTANTIATE
|
118 |
* ---------------------- */
|
119 |
|
120 |
-
$xmlsf = new XMLSitemapFeed();
|
2 |
/*
|
3 |
Plugin Name: XML Sitemap & Google News feeds
|
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 |
Text Domain: xml-sitemap-feed
|
7 |
+
Version: 4.9
|
8 |
Requires PHP: 5.6
|
9 |
Author: RavanH
|
10 |
Author URI: http://status301.net/
|
59 |
* CONSTANTS
|
60 |
* -------------------- */
|
61 |
|
62 |
+
define('XMLSF_VERSION', '4.9');
|
|
|
|
|
63 |
|
64 |
/*
|
65 |
* The following constants can be used to change plugin defaults
|
73 |
*/
|
74 |
|
75 |
if ( !defined('XMLSF_NAME') )
|
|
|
76 |
define('XMLSF_NAME', 'sitemap.xml');
|
77 |
|
78 |
/*
|
82 |
*/
|
83 |
|
84 |
if ( !defined('XMLSF_NEWS_NAME') )
|
|
|
85 |
define('XMLSF_NEWS_NAME', 'sitemap-news.xml');
|
86 |
|
87 |
/*
|
101 |
* INCLUDE HACKS & CLASS
|
102 |
* ------------------------------------- */
|
103 |
|
104 |
+
$xmlsf_dir = plugin_dir_path( __FILE__ );
|
105 |
|
106 |
+
if ( file_exists ( $xmlsf_dir . 'xml-sitemap-feed' ) )
|
107 |
+
$xmlsf_dir .= 'xml-sitemap-feed/';
|
108 |
|
109 |
+
include_once( $xmlsf_dir . 'includes/functions.php' );
|
110 |
+
include_once( $xmlsf_dir . 'includes/class-xmlsitemapfeed.php' );
|
111 |
|
112 |
/* ----------------------
|
113 |
* INSTANTIATE
|
114 |
* ---------------------- */
|
115 |
|
116 |
+
$xmlsf = new XMLSitemapFeed( plugin_basename(__FILE__) );
|