XML Sitemap & Google News feeds - Version 4.9

Version Description

New FactCheck genre. Remove changefreq tag. Fix permalink issue with Woocommerce account page endpoints.

=

Download this release

Release Info

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

Code changes from version 4.8.3 to 4.9

.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 &amp; 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"> &nbsp;&ndash;&nbsp; <a href="#xmlsf" id="xmlsf_link">'.translate('Settings').'</a> &nbsp;&ndash;&nbsp; <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"> &nbsp;&ndash;&nbsp; <a href="#xmlnf" id="xmlnf_link">'.translate('Settings').'</a> &nbsp;&ndash;&nbsp; <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
- $prefix = parent::prefix();
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="'.parent::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,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="'.parent::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,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 and Changefreq 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>';
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
- '>'.translate('Featured Image').'</option>
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('[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,7 +364,7 @@ jQuery( document ).ready( function() {
364
 
365
  $count = wp_count_terms( $taxonomy->name );
366
  $output .= '
367
- <label><input type="checkbox" name="'.parent::prefix().'taxonomies['.
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('[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,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="'.parent::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,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="'.parent::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,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="'.parent::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,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="'.parent::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,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="'.parent::prefix().'news_tags[categories][]" size="'.$size.'">';
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="'.parent::prefix().'news_tags[image]">
583
  <option value="">'.translate('None').'</option>
584
  <option value="featured" '.
585
  selected( $image == "featured", true, false).
586
- '>'.translate('Featured Image').'</option>
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">'.__('More information&hellip;','xml-sitemap-feed').'</a></p>
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
- sprintf(__('You can use the %1$s and %2$s tags to provide Google more information about the content of your articles.','xml-sitemap-feed'),'&lt;access&gt;','&lt;genres&gt;') . ' <a href="https://support.google.com/news/publisher/answer/93992" target="_blank">'.__('More information&hellip;','xml-sitemap-feed').'</a>
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">&lt;access&gt;</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>&lt;access&gt;</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">&lt;genres&gt;</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>&lt;genres&gt;</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">&lt;keywords&gt;</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>&lt;keywords&gt;</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" != $keywords_from) {
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
- foreach ( (array)$news_tags['post_type'] as $post_type ) {
 
 
 
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
- * CONSTRUCTOR
992
- */
993
 
994
- function __construct() {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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"> &nbsp;&ndash;&nbsp; <a href="#xmlsf" id="xmlsf_link">'.translate('Settings').'</a> &nbsp;&ndash;&nbsp; <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"> &nbsp;&ndash;&nbsp; <a href="#xmlnf" id="xmlnf_link">'.translate('Settings').'</a> &nbsp;&ndash;&nbsp; <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">&lt;access&gt;</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>&lt;access&gt;</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">&lt;genres&gt;</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>&lt;genres&gt;</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 ) . '&nbsp;</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">&lt;keywords&gt;</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>&lt;keywords&gt;</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
- private $prefix = 'xmlsf_';
37
 
38
  /**
39
  * Default language
@@ -74,13 +86,14 @@ class XMLSitemapFeed {
74
  * Google News genres
75
  * @var array
76
  */
77
- private $gn_genres = array(
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
- // home url
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
- 'sitemap' => XMLSF_NAME
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
- 'name' => $name,
196
- 'active' => '',
197
- 'archive' => '',
198
- 'priority' => '0.5',
199
- 'dynamic_priority' => '',
200
- 'tags' => array('image' => 'attached'/*,'video' => ''*/)
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
- 'google' => array (
232
- 'active' => '1',
233
- 'uri' => 'http://www.google.com/ping?sitemap=',
234
- 'type' => 'GET',
235
- 'news' => '1'
236
- ),
237
- 'bing' => array (
238
- 'active' => '1',
239
- 'uri' => 'http://www.bing.com/ping?sitemap=',
240
- 'type' => 'GET',
241
- 'news' => '1'
242
- ),
243
- 'yandex' => array (
244
- 'active' => '',
245
- 'uri' => 'http://ping.blogs.yandex.ru/RPC2',
246
- 'type' => 'RPC',
247
- ),
248
- 'baidu' => array (
249
- 'active' => '',
250
- 'uri' => 'http://ping.baidu.com/ping/RPC2',
251
- 'type' => 'RPC',
252
- ),
253
- 'others' => array (
254
- 'active' => '1',
255
- 'uri' => 'http://rpc.pingomatic.com/',
256
- 'type' => 'RPC',
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
- 'name' => '',
275
- 'post_type' => array('post'),
276
- 'categories' => '',
277
- 'image' => 'featured',
278
- 'access' => array(
279
- 'default' => '',
280
- //'private' => 'Registration', // private posts do not show up in feeds when not logged in. no point in setting access level then...
281
- 'password' => 'Subscription'
282
- ),
283
- 'genres' => array(
284
- 'default' => ''
285
- ),
286
- 'keywords' => array(
287
- 'from' => 'category',
288
- 'default' => ''
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 (!empty($return)) ? (array)$return : array();
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 (!empty($return)) ? (array)$return : array();
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 (!empty($return)) ? (array)$return : array();
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
- // make sure it's an array we are returning
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 (!empty($return)) ? (array)$return : array();
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
- if ( 'monthly' == $type ) {
463
- $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';
 
 
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
- } elseif ('yearly' == $type) {
479
- $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';
 
 
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
- } else {
 
 
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
- is_string($type) &&
521
- isset($return[$type]) &&
522
- !empty($return[$type]['tags'])
523
- ) ? (array)$return[$type]['tags'] : array();
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
- return in_array( $id, $this->get_blogpages() );
598
  }
599
 
600
  /**
@@ -606,32 +628,25 @@ class XMLSitemapFeed {
606
  *
607
  * @return string
608
  */
609
- public function headers( $style = '' ) {
610
- // maybe output buffering is on, then just make sure we start with a clean buffer
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 ( !headers_sent($filename, $linenum) ) {
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
- $style_sheet = plugins_url('xsl/sitemap-index.xsl',__FILE__);
628
- break;
 
629
  case 'news':
630
- $style_sheet = plugins_url('xsl/sitemap-news.xsl',__FILE__);
631
- break;
 
632
  default:
633
- $style_sheet = plugins_url('xsl/sitemap.xsl',__FILE__);
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
- if ('post_type' == $sitemap) :
658
 
659
- global $post;
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 ( array(
695
- 'post_type' => 'any',
696
- 'numberposts' => 1,
697
- 'no_found_rows' => true,
698
- 'update_post_meta_cache' => false,
699
- 'update_post_term_cache' => false,
700
- 'update_cache' => false,
701
- 'tax_query' => array(
702
- array(
703
- 'taxonomy' => $term->taxonomy,
704
- 'field' => 'slug',
705
- 'terms' => $term->slug
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
- if ( empty($this->images[$post->ID]) ) {
 
 
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
- 'loc' => esc_attr( esc_url_raw( $url ) ),
788
- 'title' => apply_filters( 'the_title_xmlsitemap', $attachment->post_title ),
789
- 'caption' => apply_filters( 'the_title_xmlsitemap', $attachment->post_excerpt )
790
- // 'caption' => apply_filters( 'the_title_xmlsitemap', get_post_meta( $attachment->ID, '_wp_attachment_image_alt', true ) )
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
- 'loc' => esc_attr( esc_url_raw( $url ) ),
802
- 'title' => apply_filters( 'the_title_xmlsitemap', $attachment->post_title ),
803
- 'caption' => apply_filters( 'the_title_xmlsitemap', $attachment->post_excerpt )
804
- // 'caption' => apply_filters( 'the_title_xmlsitemap', get_post_meta( $attachment->ID, '_wp_attachment_image_alt', true ) )
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
- if ($priority < 0)
932
- $priority = 0;
933
-
934
- // and a final trim for cases where we ended up above 1 (sticky posts with many comments)
935
- if ($priority > 1)
936
- $priority = 1;
 
 
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
- else
 
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
- if (pathinfo($request, PATHINFO_EXTENSION)) {
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
- if( isset($sitepress) ) {
1180
- $post_language = apply_filters( 'wpml_post_language_details', NULL, $post->ID );
1181
- $sitepress->switch_lang($post_language['language_code']);
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)) $news_post_type = 'post';
 
 
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
- $options = array();
1387
- $options['timeout'] = $timeout;
1388
 
1389
- $response = wp_remote_request( $uri, $options );
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
- continue;
 
1429
  // ping !
1430
- if ( $this->ping( $data['uri'].urlencode(trailingslashit(get_bloginfo('url')) . $sitemaps['sitemap-news']) ) ) {
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
- continue;
 
1454
  // ping !
1455
- if ( $this->ping( $data['uri'].urlencode(trailingslashit(get_bloginfo('url')) . $sitemaps['sitemap']) ) ) {
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_'.$option);
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 rule blocking stylesheets, but only one time!
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.5', $old_version, '>') ) {
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
- set_transient('xmlsf_create_genres','', 10); // flag recreation
 
 
 
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
- delete_option('xmlsf_version');
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( XMLSF_PLUGIN_BASENAME ) . '/languages' );
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
- // load feed templates
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
- // load feed template
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
- global $wp_rewrite;
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
- 'name' => __('Google News Genres','xml-sitemap-feed'),
1775
- 'singular_name' => __('Google News Genre','xml-sitemap-feed'),
1776
- 'all_items' => translate('All') // __('All Genres','xml-sitemap-feed')
1777
- //'menu_name' => __('GN Genres','xml-sitemap-feed'),
1778
- ),
1779
  'public' => false,
1780
  'show_ui' => true,
1781
  'show_tagcloud' => false,
1782
  'query_var' => false,
1783
  'capabilities' => array( // prevent creation / deletion
1784
- 'manage_terms' => 'nobody',
1785
- 'edit_terms' => 'nobody',
1786
- 'delete_terms' => 'nobody',
1787
- 'assign_terms' => 'edit_posts'
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 main filtering function
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