XML Sitemap & Google News feeds - Version 5.1

Version Description

New filter and action hooks. Bugfixes and admin UI improvements.

=

Download this release

Release Info

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

Code changes from version 5.0.7 to 5.1

Files changed (97) hide show
  1. .gitignore +1 -0
  2. LICENSE +0 -0
  3. README.md +6 -0
  4. controllers/admin/main.php +69 -210
  5. controllers/admin/notices.php +20 -33
  6. controllers/admin/sitemap-news.php +241 -67
  7. controllers/admin/sitemap.php +190 -2
  8. controllers/global.php +36 -181
  9. controllers/main.php +43 -132
  10. controllers/public/shared.php +0 -34
  11. controllers/public/sitemap.php +0 -106
  12. controllers/{public/sitemap-news.php → sitemap-news.php} +2 -2
  13. controllers/sitemap.php +241 -0
  14. controllers/upgrade.php +178 -0
  15. models/admin/main.php +2 -57
  16. models/admin/sitemap-news.php +0 -0
  17. models/admin/sitemap.php +0 -0
  18. models/class-xmlsitemapfeed.php +14 -34
  19. models/global.php +50 -20
  20. models/main.php +94 -28
  21. models/public/shared.php +0 -0
  22. models/public/sitemap-news.php +3 -3
  23. models/public/sitemap.php +42 -87
  24. models/sitemap-news.php +17 -0
  25. models/sitemap.php +68 -0
  26. readme.txt +32 -4
  27. uninstall.php +4 -3
  28. views/_generator.php +0 -0
  29. views/_usage.php +0 -0
  30. views/admin/field-news-categories.php +0 -0
  31. views/admin/field-news-image.php +0 -0
  32. views/admin/field-news-keywords.php +13 -0
  33. views/admin/field-news-labels.php +0 -0
  34. views/admin/field-news-name.php +0 -0
  35. views/admin/field-news-ping-log.php +20 -0
  36. views/admin/field-news-post-type.php +12 -20
  37. views/admin/field-news-stocktickers.php +15 -0
  38. views/admin/field-ping.php +8 -1
  39. views/admin/field-robots.php +0 -0
  40. views/admin/field-sitemap-custom.php +0 -0
  41. views/admin/field-sitemap-domains.php +0 -0
  42. views/admin/field-sitemap-post-type.php +0 -0
  43. views/admin/field-sitemap-taxonomies.php +0 -0
  44. views/admin/field-sitemap-taxonomy-settings.php +0 -0
  45. views/admin/field-sitemap-urls.php +0 -0
  46. views/admin/field-sitemaps.php +9 -1
  47. views/admin/help-tab-advanced.php +0 -0
  48. views/admin/help-tab-allowed-domains.php +0 -0
  49. views/admin/help-tab-news-categories.php +0 -0
  50. views/admin/help-tab-news-images.php +0 -0
  51. views/admin/help-tab-news-keywords.php +3 -0
  52. views/admin/help-tab-news-labels.php +0 -1
  53. views/admin/help-tab-news-name.php +0 -0
  54. views/admin/help-tab-news-sidebar.php +20 -9
  55. views/admin/help-tab-news-stocktickers.php +7 -0
  56. views/admin/help-tab-news.php +0 -0
  57. views/admin/help-tab-ping.php +0 -0
  58. views/admin/help-tab-post-types.php +0 -0
  59. views/admin/help-tab-robots.php +6 -0
  60. views/admin/help-tab-sidebar.php +11 -6
  61. views/admin/help-tab-sitemaps.php +0 -0
  62. views/admin/help-tab-support.php +0 -0
  63. views/admin/help-tab-taxonomies.php +0 -0
  64. views/admin/help-tab-tools.php +0 -8
  65. views/admin/meta-box-news.php +0 -0
  66. views/admin/meta-box.php +2 -2
  67. views/admin/notice-catchbox-feed-redirect.php +22 -0
  68. views/admin/notice-cleared.php +0 -5
  69. views/admin/notice-deleted.php +0 -5
  70. views/admin/notice-failed.php +0 -8
  71. views/admin/notice-nonce-error.php +0 -5
  72. views/admin/notice-none-found.php +0 -5
  73. views/admin/notice-not-allowed.php +0 -5
  74. views/admin/{notice-date-redirect.php → notice-seopress-date-redirect.php} +5 -4
  75. views/admin/notice-seopress-sitemap.php +22 -0
  76. views/admin/notice-static-files.php +3 -3
  77. views/admin/notice-wpseo-date-redirect.php +15 -15
  78. views/admin/notice-wpseo-sitemap.php +1 -1
  79. views/admin/notice.php +0 -26
  80. views/admin/page-sitemap-news.php +24 -6
  81. views/admin/page-sitemap.php +14 -3
  82. views/admin/section-advanced-intro.php +3 -0
  83. views/admin/sidebar-contribute.php +0 -0
  84. views/admin/sidebar-help.php +0 -0
  85. views/feed-sitemap-custom.php +0 -0
  86. views/feed-sitemap-home.php +0 -0
  87. views/feed-sitemap-news.php +25 -32
  88. views/feed-sitemap-post_type.php +0 -0
  89. views/feed-sitemap-taxonomy.php +0 -0
  90. views/feed-sitemap.php +1 -1
  91. views/robots.php +0 -19
  92. views/styles/admin.css +0 -0
  93. views/styles/sitemap-index.xsl +1 -1
  94. views/styles/sitemap-news.xsl +5 -1
  95. views/styles/sitemap-taxonomy.xsl +1 -1
  96. views/styles/sitemap.xsl +1 -1
  97. xml-sitemap.php +38 -28
.gitignore ADDED
@@ -0,0 +1 @@
 
1
+ .vscode
LICENSE CHANGED
File without changes
README.md ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
1
+ # XML Sitemap & Google News feeds
2
+
3
+ XML and Google News Sitemaps for WordPress to feed the hungry spiders. Multisite, WP Super Cache, Polylang and WPML compatible.
4
+
5
+ [https://wordpress.org/plugins/xml-sitemap-feed/](https://wordpress.org/plugins/xml-sitemap-feed/)
6
+
controllers/admin/main.php CHANGED
@@ -11,6 +11,12 @@ class XMLSF_Admin_Controller
11
  */
12
  public static $static_files = null;
13
 
 
 
 
 
 
 
14
  /**
15
  * CONSTRUCTOR
16
  * Runs on init
@@ -33,20 +39,18 @@ class XMLSF_Admin_Controller
33
  require XMLSF_DIR . '/controllers/admin/sitemap-news.php';
34
  }
35
 
36
- // NGINX HELPER PURGE URLS
37
- add_filter( 'rt_nginx_helper_purge_urls', 'xmlsf_nginx_helper_purge_urls', 10, 2 );
38
-
39
  // ACTION LINK
40
  add_filter( 'plugin_action_links_' . XMLSF_BASENAME, 'xmlsf_add_action_link' );
41
 
42
  add_action( 'admin_init', array( $this, 'notices_actions' ) );
43
  add_action( 'admin_init', array( $this, 'transients_actions' ) );
44
- add_action( 'admin_init', array( $this, 'tools_actions' ) );
45
  add_action( 'admin_init', array( $this, 'register_settings' ) );
46
- add_action( 'admin_init', array( $this, 'register_meta_boxes' ) );
 
 
47
  if ( ( !is_multisite() && current_user_can( 'manage_options' ) ) || is_super_admin() )
48
  add_action( 'admin_init', array( $this, 'static_files' ) );
49
- add_action( 'admin_init', array( $this, 'verify_wpseo_settings' ) );
50
  }
51
 
52
  /**
@@ -196,170 +200,24 @@ class XMLSF_Admin_Controller
196
  include XMLSF_DIR . '/views/admin/field-ping.php';
197
  }
198
 
199
- /**
200
- * META BOXES
201
- */
202
-
203
- /**
204
- * Register settings and add settings fields
205
- */
206
-
207
- public function register_meta_boxes()
208
- {
209
- $sitemaps = (array) get_option( 'xmlsf_sitemaps' );
210
-
211
- if ( isset($sitemaps['sitemap-news']) ) {
212
- // post meta box
213
- add_action( 'add_meta_boxes', array($this,'add_meta_box_news') );
214
- }
215
-
216
- if ( isset($sitemaps['sitemap']) ) {
217
- // post meta box
218
- add_action( 'add_meta_boxes', array($this,'add_meta_box') );
219
- }
220
-
221
- if ( isset($sitemaps['sitemap']) || isset($sitemaps['sitemap-news']) ) {
222
- // save post meta box settings
223
- add_action( 'save_post', array($this,'save_metadata') );
224
- }
225
- }
226
-
227
- /* Adds a XML Sitemap box to the side column */
228
- public function add_meta_box ()
229
- {
230
- $post_types = get_option( 'xmlsf_post_types' );
231
- if ( !is_array( $post_types ) ) return;
232
-
233
- foreach ( $post_types as $post_type => $settings ) {
234
- // Only include metaboxes on post types that are included
235
- if ( isset( $settings["active"] ) )
236
- add_meta_box(
237
- 'xmlsf_section',
238
- __( 'XML Sitemap', 'xml-sitemap-feed' ),
239
- array( $this, 'meta_box' ),
240
- $post_type,
241
- 'side',
242
- 'low'
243
- );
244
- }
245
- }
246
-
247
- public function meta_box( $post )
248
- {
249
- // Use nonce for verification
250
- wp_nonce_field( XMLSF_BASENAME, '_xmlsf_nonce' );
251
-
252
- // Use get_post_meta to retrieve an existing value from the database and use the value for the form
253
- $exclude = get_post_meta( $post->ID, '_xmlsf_exclude', true );
254
- $priority = get_post_meta( $post->ID, '_xmlsf_priority', true );
255
- $disabled = false;
256
-
257
- // disable options and (visibly) set excluded to true for private posts
258
- if ( 'private' == $post->post_status ) {
259
- $disabled = true;
260
- $exclude = true;
261
- }
262
-
263
- // disable options and (visibly) set priority to 1 for front page
264
- if ( $post->ID == get_option('page_on_front') ) {
265
- $disabled = true;
266
- $exclude = false;
267
- $priority = '1'; // force priority to 1 for front page
268
- }
269
-
270
- $description = sprintf(
271
- __('Leave empty for automatic Priority as configured on %1$s > %2$s.','xml-sitemap-feed'),
272
- translate('Settings'),
273
- '<a href="' . admin_url('options-general.php') . '?page=xmlsf">' . __('XML Sitemap','xml-sitemap-feed') . '</a>'
274
- );
275
-
276
- // The actual fields for data entry
277
- include XMLSF_DIR . '/views/admin/meta-box.php';
278
- }
279
-
280
- /* Adds a News Sitemap box to the side column */
281
- public function add_meta_box_news ()
282
- {
283
- $news_tags = get_option('xmlsf_news_tags');
284
- $news_post_types = !empty($news_tags['post_type']) && is_array($news_tags['post_type']) ? $news_tags['post_type'] : array('post');
285
-
286
- foreach ( $news_post_types as $post_type ) {
287
- // Only include metabox on post types that are included
288
- add_meta_box(
289
- 'xmlsf_news_section',
290
- __( 'Google News', 'xml-sitemap-feed' ),
291
- array($this,'meta_box_news'),
292
- $post_type,
293
- 'side'
294
- );
295
- }
296
- }
297
-
298
- public function meta_box_news( $post )
299
- {
300
- // Use nonce for verification
301
- wp_nonce_field( XMLSF_BASENAME, '_xmlsf_nonce' );
302
-
303
- // Use get_post_meta to retrieve an existing value from the database and use the value for the form
304
- $exclude = 'private' == $post->post_status || get_post_meta( $post->ID, '_xmlsf_news_exclude', true );
305
- $disabled = 'private' == $post->post_status;
306
-
307
- // The actual fields for data entry
308
- include XMLSF_DIR . '/views/admin/meta-box-news.php';
309
- }
310
-
311
- /* When the post is saved, save our meta data */
312
- public function save_metadata( $post_id )
313
- {
314
- if ( !isset($post_id) )
315
- $post_id = (int)$_REQUEST['post_ID'];
316
-
317
- if ( !current_user_can( 'edit_post', $post_id ) || !isset($_POST['_xmlsf_nonce']) || !wp_verify_nonce($_POST['_xmlsf_nonce'], XMLSF_BASENAME) )
318
- return;
319
-
320
- // _xmlsf_priority
321
- if ( empty($_POST['xmlsf_priority']) && '0' !== $_POST['xmlsf_priority'] ) {
322
- delete_post_meta($post_id, '_xmlsf_priority');
323
- } else {
324
- update_post_meta($post_id, '_xmlsf_priority', XMLSF_Admin_Sitemap_Sanitize::priority($_POST['xmlsf_priority']) );
325
- }
326
-
327
- // _xmlsf_exclude
328
- if ( isset($_POST['xmlsf_exclude']) && $_POST['xmlsf_exclude'] != '' ) {
329
- update_post_meta($post_id, '_xmlsf_exclude', $_POST['xmlsf_exclude']);
330
- } else {
331
- delete_post_meta($post_id, '_xmlsf_exclude');
332
- }
333
-
334
- // _xmlsf_news_exclude
335
- if ( isset($_POST['xmlsf_news_exclude']) && $_POST['xmlsf_news_exclude'] != '' ) {
336
- update_post_meta($post_id, '_xmlsf_news_exclude', $_POST['xmlsf_news_exclude']);
337
- } else {
338
- delete_post_meta($post_id, '_xmlsf_news_exclude');
339
- }
340
- }
341
-
342
  /**
343
  * Clear settings
344
  */
345
- public function clear_settings()
346
  {
347
- if ( !isset( $_POST['_xmlsf_help_nonce'] ) || !wp_verify_nonce( $_POST['_xmlsf_help_nonce'], XMLSF_BASENAME.'-help' ) ) {
348
- add_action( 'admin_notices', array('XMLSF_Admin_Notices','notice_nonce_fail') );
349
- return;
350
- }
351
 
352
- $defaults = xmlsf()->defaults();
353
- unset($defaults['sitemaps']);
354
 
355
  foreach ( $defaults as $option => $settings ) {
356
  update_option( 'xmlsf_' . $option, $settings );
357
  }
358
 
359
- delete_option( 'xmlsf_static_files' );
360
- delete_option( 'xmlsf_pong' );
361
 
362
- add_action( 'admin_notices', array('XMLSF_Admin_Notices','notice_clear_settings') );
363
  }
364
 
365
  /**
@@ -368,12 +226,8 @@ class XMLSF_Admin_Controller
368
 
369
  public function delete_static_files()
370
  {
371
- if ( !isset( $_POST['_xmlsf_notice_nonce'] ) || !wp_verify_nonce( $_POST['_xmlsf_notice_nonce'], XMLSF_BASENAME.'-notice' ) ) {
372
- add_action( 'admin_notices', array('XMLSF_Admin_Notices','notice_nonce_fail') );
373
- return;
374
- }
375
-
376
  if ( empty($_POST['xmlsf-delete']) ) {
 
377
  return;
378
  }
379
 
@@ -381,11 +235,10 @@ class XMLSF_Admin_Controller
381
 
382
  $this->static_files();
383
 
384
- $i = '1';
385
  foreach ( $_POST['xmlsf-delete'] as $name ) {
386
  if ( !in_array($name,$allowed_files) ) {
387
  unset(self::$static_files[$name]);
388
- add_action( 'admin_notices', array('XMLSF_Admin_Notices','static_files_not_allowed'), $i );
389
  continue;
390
  }
391
  if ( !isset(self::$static_files[$name]) ) {
@@ -394,53 +247,28 @@ class XMLSF_Admin_Controller
394
  }
395
  if ( unlink(self::$static_files[$name]) ) {
396
  unset(self::$static_files[$name]);
397
- add_action( 'admin_notices', array('XMLSF_Admin_Notices','static_files_deleted'), $i );
398
  } else {
399
- add_action( 'admin_notices', array('XMLSF_Admin_Notices','static_files_failed'), $i );
 
 
400
  }
401
- $i ++;
402
  }
403
 
404
  $this->check_static_files();
405
  }
406
 
407
- /**
408
- * Check for conflicting WPSEO settings
409
- */
410
- public function verify_wpseo_settings()
411
- {
412
- // WP SEO Plugin conflict notice
413
- if ( is_plugin_active('wordpress-seo/wp-seo.php') ) {
414
- // check date archive redirection
415
- $wpseo_titles = get_option( 'wpseo_titles' );
416
- if ( !empty( $wpseo_titles['disable-date'] ) ) {
417
- // check is Split by option is set anywhere
418
- foreach ( (array) get_option( 'xmlsf_post_types' ) as $type => $settings ) {
419
- if ( is_array( $settings ) && !empty( $settings['archive'] ) ) {
420
- add_action( 'admin_notices', array( 'XMLSF_Admin_Notices', 'notice_wpseo_date_redirect' ) );
421
- break;
422
- }
423
- }
424
- }
425
- // check wpseo sitemap option
426
- $wpseo = get_option( 'wpseo' );
427
- $sitemaps = get_option( 'xmlsf_sitemaps' );
428
- if ( !empty( $wpseo['enable_xml_sitemap'] ) && !empty( $sitemaps['sitemap'] ) ) {
429
- add_action( 'admin_notices', array( 'XMLSF_Admin_Notices', 'notice_wpseo_sitemap' ) );
430
- }
431
- }
432
- }
433
-
434
  /**
435
  * Check for static sitemap files
436
  */
437
  public function static_files()
438
  {
439
  if ( null === self::$static_files )
440
- self::$static_files = get_option( 'xmlsf_static_files', array() );
441
 
442
- if ( !empty(self::$static_files) )
443
- add_action( 'admin_notices', array('XMLSF_Admin_Notices','notice_static_files') );
 
444
  }
445
 
446
  /**
@@ -463,46 +291,77 @@ class XMLSF_Admin_Controller
463
  }
464
 
465
  if ( !empty( self::$static_files ) ) {
466
- update_option( 'xmlsf_static_files', self::$static_files, false );
467
  } else {
468
- delete_option( 'xmlsf_static_files' );
 
 
 
 
 
 
 
 
 
 
 
 
469
  }
470
  }
471
 
472
  public function tools_actions()
473
  {
474
- if ( isset( $_POST['xmlsf-clear-settings'] ) ) {
475
- $this->clear_settings();
 
 
 
 
476
  }
477
 
478
  if ( isset( $_POST['xmlsf-delete-submit'] ) ) {
479
- $this->delete_static_files();
 
 
 
 
480
  }
481
 
482
  if ( isset( $_POST['xmlsf-check-conflicts'] ) ) {
483
  if ( isset( $_POST['_xmlsf_help_nonce'] ) && wp_verify_nonce( $_POST['_xmlsf_help_nonce'], XMLSF_BASENAME.'-help' ) ) {
484
  // reset ignored warnings
485
  delete_user_meta( get_current_user_id(), 'xmlsf_dismissed' );
 
486
 
487
  $this->check_static_files();
488
  if ( empty( self::$static_files ) )
489
- add_action( 'admin_notices', array('XMLSF_Admin_Notices','static_files_none_found') );
490
-
491
- $this->verify_wpseo_settings();
 
 
492
 
 
 
 
 
 
493
  } else {
494
- add_action( 'admin_notices', array('XMLSF_Admin_Notices','notice_nonce_fail') );
495
  }
496
  }
497
  }
498
 
499
  public function notices_actions()
500
  {
501
- if ( isset( $_POST['xmlsf-dismiss'] ) ) {
 
 
502
  if ( isset( $_POST['_xmlsf_notice_nonce'] ) && wp_verify_nonce( $_POST['_xmlsf_notice_nonce'], XMLSF_BASENAME.'-notice' ) ) {
503
  add_user_meta( get_current_user_id(), 'xmlsf_dismissed', $_POST['xmlsf-dismiss'], false );
 
504
  } else {
505
- add_action( 'admin_notices', array('XMLSF_Admin_Notices','notice_nonce_fail') );
506
  }
507
  }
508
  }
11
  */
12
  public static $static_files = null;
13
 
14
+ /**
15
+ * Dismissed notices array
16
+ * @var array
17
+ */
18
+ public static $dismissed = array();
19
+
20
  /**
21
  * CONSTRUCTOR
22
  * Runs on init
39
  require XMLSF_DIR . '/controllers/admin/sitemap-news.php';
40
  }
41
 
 
 
 
42
  // ACTION LINK
43
  add_filter( 'plugin_action_links_' . XMLSF_BASENAME, 'xmlsf_add_action_link' );
44
 
45
  add_action( 'admin_init', array( $this, 'notices_actions' ) );
46
  add_action( 'admin_init', array( $this, 'transients_actions' ) );
 
47
  add_action( 'admin_init', array( $this, 'register_settings' ) );
48
+
49
+ // ACTIONS & CHECKS
50
+ add_action( 'admin_init', array( $this, 'tools_actions' ) );
51
  if ( ( !is_multisite() && current_user_can( 'manage_options' ) ) || is_super_admin() )
52
  add_action( 'admin_init', array( $this, 'static_files' ) );
53
+ add_action( 'admin_init', array( $this, 'check_theme_conflicts' ) );
54
  }
55
 
56
  /**
200
  include XMLSF_DIR . '/views/admin/field-ping.php';
201
  }
202
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
203
  /**
204
  * Clear settings
205
  */
206
+ public function clear_settings( $sitemap = '' )
207
  {
208
+ $defaults = 'sitemap-news' == $sitemap ? array(
209
+ 'news_tags' => xmlsf()->default_news_tags
210
+ ) : xmlsf()->defaults();
 
211
 
212
+ unset( $defaults['sitemaps'] );
 
213
 
214
  foreach ( $defaults as $option => $settings ) {
215
  update_option( 'xmlsf_' . $option, $settings );
216
  }
217
 
218
+ delete_transient( 'xmlsf_static_files' );
 
219
 
220
+ add_settings_error( 'notice_clear_settings', 'notice_clear_settings', __('Settings reset to the plugin defaults.','xml-sitemap-feed'), 'updated' );
221
  }
222
 
223
  /**
226
 
227
  public function delete_static_files()
228
  {
 
 
 
 
 
229
  if ( empty($_POST['xmlsf-delete']) ) {
230
+ add_settings_error( 'static_files', 'none_selected', __('No files selected for deletion!','xml-sitemap-feed'), 'notice-warning' );
231
  return;
232
  }
233
 
235
 
236
  $this->static_files();
237
 
 
238
  foreach ( $_POST['xmlsf-delete'] as $name ) {
239
  if ( !in_array($name,$allowed_files) ) {
240
  unset(self::$static_files[$name]);
241
+ add_settings_error( 'static_files', 'file_not_allowed', sprintf( /* Translators: static file name */ __('File %s not in the list of allowed files!','xml-sitemap-feed'), '<em>' . $name . '</em>' ) );
242
  continue;
243
  }
244
  if ( !isset(self::$static_files[$name]) ) {
247
  }
248
  if ( unlink(self::$static_files[$name]) ) {
249
  unset(self::$static_files[$name]);
250
+ add_settings_error( 'static_files', 'file_deleted_'.$name, sprintf( /* Translators: static file name */ __('Static file %s succesfully deleted.','xml-sitemap-feed'), '<em>' . $name . '</em>' ), 'updated' );
251
  } else {
252
+ add_settings_error( 'static_files', 'file_failed_'.$name,
253
+ sprintf( /* Translators: static file name */ __('Static file %s deletion failed.','xml-sitemap-feed'), '<em>' . $name . '</em>' ) . ' ' . sprintf( /* Translators: static file full path and name */ __('This is probably due to insufficient rights. Please try to remove %s manually via FTP or your hosting provider control panel.','xml-sitemap-feed'), self::$static_files[$name] )
254
+ );
255
  }
 
256
  }
257
 
258
  $this->check_static_files();
259
  }
260
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
261
  /**
262
  * Check for static sitemap files
263
  */
264
  public function static_files()
265
  {
266
  if ( null === self::$static_files )
267
+ self::$static_files = get_transient( 'xmlsf_static_files' );
268
 
269
+ if ( !empty(self::$static_files) && !in_array( 'static_files', self::$dismissed ) ) {
270
+ add_action( 'admin_notices', array( 'XMLSF_Admin_Notices', 'notice_static_files' ) );
271
+ }
272
  }
273
 
274
  /**
291
  }
292
 
293
  if ( !empty( self::$static_files ) ) {
294
+ set_transient( 'xmlsf_static_files', self::$static_files );
295
  } else {
296
+ delete_transient( 'xmlsf_static_files' );
297
+ }
298
+ }
299
+
300
+ /**
301
+ * Check for conflicting themes and their settings
302
+ */
303
+
304
+ public function check_theme_conflicts()
305
+ {
306
+ // Catch Box Pro feed redirect
307
+ if ( !in_array( 'catchbox_feed_redirect', self::$dismissed ) && function_exists( 'catchbox_is_feed_url_present' ) && catchbox_is_feed_url_present(null) ) {
308
+ add_action( 'admin_notices', array( 'XMLSF_Admin_Notices', 'notice_catchbox_feed_redirect' ) );
309
  }
310
  }
311
 
312
  public function tools_actions()
313
  {
314
+ if ( isset( $_POST['xmlsf-clear-settings-submit'] ) && isset( $_POST['xmlsf-clear-settings'] ) ) {
315
+ if ( isset( $_POST['_xmlsf_help_nonce'] ) && wp_verify_nonce( $_POST['_xmlsf_help_nonce'], XMLSF_BASENAME.'-help' ) ) {
316
+ $this->clear_settings( $_POST['xmlsf-clear-settings'] );
317
+ } else {
318
+ add_settings_error( 'clear_settings', 'clear_settings_failed', translate('Security check failed.') );
319
+ }
320
  }
321
 
322
  if ( isset( $_POST['xmlsf-delete-submit'] ) ) {
323
+ if ( isset( $_POST['_xmlsf_notice_nonce'] ) && wp_verify_nonce( $_POST['_xmlsf_notice_nonce'], XMLSF_BASENAME.'-notice' ) ) {
324
+ $this->delete_static_files();
325
+ } else {
326
+ add_settings_error( 'delete_files', 'delete_files_failed', translate('Security check failed.') );
327
+ }
328
  }
329
 
330
  if ( isset( $_POST['xmlsf-check-conflicts'] ) ) {
331
  if ( isset( $_POST['_xmlsf_help_nonce'] ) && wp_verify_nonce( $_POST['_xmlsf_help_nonce'], XMLSF_BASENAME.'-help' ) ) {
332
  // reset ignored warnings
333
  delete_user_meta( get_current_user_id(), 'xmlsf_dismissed' );
334
+ self::$dismissed = array();
335
 
336
  $this->check_static_files();
337
  if ( empty( self::$static_files ) )
338
+ add_settings_error( 'static_files_notice', 'static_files', __('No conflicting static files found.','xml-sitemap-feed'), 'notice-info');
339
+ } else {
340
+ add_settings_error( 'check_conflicts', 'check_conflicts_failed', translate('Security check failed.') );
341
+ }
342
+ }
343
 
344
+ if ( isset( $_POST['xmlsf-flush-rewrite-rules'] ) ) {
345
+ if ( isset( $_POST['_xmlsf_help_nonce'] ) && wp_verify_nonce( $_POST['_xmlsf_help_nonce'], XMLSF_BASENAME.'-help' ) ) {
346
+ // flush rewrite rules
347
+ flush_rewrite_rules();
348
+ add_settings_error( 'flush_admin_notice', 'flush_admin_notice', __('WordPress rewrite rules have been flushed.','xml-sitemap-feed'), 'updated' );
349
  } else {
350
+ add_settings_error( 'flush_rewrite_rules', 'flush_rewrite_rules_failed', translate('Security check failed.') );
351
  }
352
  }
353
  }
354
 
355
  public function notices_actions()
356
  {
357
+ self::$dismissed = (array) get_user_meta( get_current_user_id(), 'xmlsf_dismissed' );
358
+
359
+ if ( isset( $_POST['xmlsf-dismiss-submit'] ) && isset( $_POST['xmlsf-dismiss'] ) ) {
360
  if ( isset( $_POST['_xmlsf_notice_nonce'] ) && wp_verify_nonce( $_POST['_xmlsf_notice_nonce'], XMLSF_BASENAME.'-notice' ) ) {
361
  add_user_meta( get_current_user_id(), 'xmlsf_dismissed', $_POST['xmlsf-dismiss'], false );
362
+ self::$dismissed[] = $_POST['xmlsf-dismiss'];
363
  } else {
364
+ add_settings_error( 'dismiss_notice', 'dismiss_notice_failed', translate('Security check failed.') );
365
  }
366
  }
367
  }
controllers/admin/notices.php CHANGED
@@ -1,58 +1,45 @@
1
  <?php
2
 
 
 
 
 
3
  class XMLSF_Admin_Notices extends XMLSF_Admin_Controller
4
  {
5
  function __construct() {}
6
 
7
- public static function notice_clear_settings()
8
- {
9
- include XMLSF_DIR . '/views/admin/notice-cleared.php';
10
- }
11
-
12
- public static function static_files_deleted()
13
  {
14
- include XMLSF_DIR . '/views/admin/notice-deleted.php';
15
- }
 
 
16
 
17
- public static function static_files_not_allowed()
18
- {
19
- include XMLSF_DIR . '/views/admin/notice-not-allowed.php';
20
  }
21
 
22
- public static function static_files_none_found()
23
  {
24
- include XMLSF_DIR . '/views/admin/notice-none-found.php';
25
  }
26
 
27
- public static function static_files_failed()
28
- {
29
- include XMLSF_DIR . '/views/admin/notice-failed.php';
30
- }
31
-
32
- public static function notice_nonce_fail()
33
  {
34
- include XMLSF_DIR . '/views/admin/notice-nonce-error.php';
35
  }
36
 
37
- public static function notice_static_files()
38
  {
39
- if ( !in_array( 'static_files', get_user_meta( get_current_user_id(), 'xmlsf_dismissed' ) ) ) {
40
- if ( $number = count(parent::$static_files) )
41
- include XMLSF_DIR . '/views/admin/notice-static-files.php';
42
- }
43
  }
44
 
45
- public static function notice_wpseo_date_redirect()
46
  {
47
- if ( !in_array( 'date_redirect', get_user_meta( get_current_user_id(), 'xmlsf_dismissed' ) ) ) {
48
- include XMLSF_DIR . '/views/admin/notice-wpseo-date-redirect.php';
49
- }
50
  }
51
 
52
- public static function notice_wpseo_sitemap()
53
  {
54
- if ( !in_array( 'wpseo_sitemap', get_user_meta( get_current_user_id(), 'xmlsf_dismissed' ) ) ) {
55
- include XMLSF_DIR . '/views/admin/notice-wpseo-sitemap.php';
56
- }
57
  }
58
  }
1
  <?php
2
 
3
+ /***
4
+ * Dismissable or interactive admin notices
5
+ */
6
+
7
  class XMLSF_Admin_Notices extends XMLSF_Admin_Controller
8
  {
9
  function __construct() {}
10
 
11
+ public static function notice_static_files()
 
 
 
 
 
12
  {
13
+ $number = count( parent::$static_files );
14
+ if ( 0 == $number ) return;
15
+
16
+ $static_files = parent::$static_files;
17
 
18
+ include XMLSF_DIR . '/views/admin/notice-static-files.php';
 
 
19
  }
20
 
21
+ public static function notice_catchbox_feed_redirect()
22
  {
23
+ include XMLSF_DIR . '/views/admin/notice-catchbox-feed-redirect.php';
24
  }
25
 
26
+ public static function notice_wpseo_date_redirect()
 
 
 
 
 
27
  {
28
+ include XMLSF_DIR . '/views/admin/notice-wpseo-date-redirect.php';
29
  }
30
 
31
+ public static function notice_wpseo_sitemap()
32
  {
33
+ include XMLSF_DIR . '/views/admin/notice-wpseo-sitemap.php';
 
 
 
34
  }
35
 
36
+ public static function notice_seopress_date_redirect()
37
  {
38
+ include XMLSF_DIR . '/views/admin/notice-seopress-date-redirect.php';
 
 
39
  }
40
 
41
+ public static function notice_seopress_sitemap()
42
  {
43
+ include XMLSF_DIR . '/views/admin/notice-seopress-sitemap.php';
 
 
44
  }
45
  }
controllers/admin/sitemap-news.php CHANGED
@@ -1,85 +1,214 @@
1
  <?php
2
 
3
- class XMLSF_Admin_Sitemap_News
4
  {
5
  /**
6
- * Holds the values to be used in the fields callbacks
7
- */
8
- private $screen_id;
9
-
10
- /**
11
- * Holds the values to be used in the fields callbacks
12
- */
13
- private $options;
14
-
15
- /**
16
- * Start up
17
- */
18
- public function __construct()
19
- {
20
- add_action( 'admin_menu', array( $this, 'add_settings_page' ) );
21
  add_action( 'admin_init', array( $this, 'register_settings' ) );
22
- }
 
 
 
 
 
 
 
23
 
24
  /**
25
- * Add options page
26
- */
27
- public function add_settings_page()
 
28
  {
29
- // This page will be under "Settings"
30
- $this->screen_id = add_options_page(
31
- __('Google News Sitemap','xml-sitemap-feed'),
32
- __('Google News','xml-sitemap-feed'),
33
- 'manage_options',
34
- 'xmlsf-news',
35
- array( $this, 'settings_page' )
36
- );
37
- }
38
 
39
- /**
40
- * Options page callback
41
- */
42
- public function settings_page()
43
- {
44
- $this->options = get_option( 'xmlsf_news_tags', array() );
45
 
46
- // SECTION
47
- add_settings_section( 'news_sitemap_section', /* '<a name="xmlnf"></a>'.__('Google News Sitemap','xml-sitemap-feed') */ '', '', 'xmlsf-news' );
48
 
49
- // SETTINGS
50
- add_settings_field( 'xmlsf_news_name', '<label for="xmlsf_news_name">'.__('Publication name','xml-sitemap-feed').'</label>', array($this,'name_field'), 'xmlsf-news', 'news_sitemap_section' );
51
- add_settings_field( 'xmlsf_news_post_type', __('Post type','xml-sitemap-feed'), array($this,'post_type_field'), 'xmlsf-news', 'news_sitemap_section' );
 
 
52
 
53
- global $wp_taxonomies;
54
- $news_post_type = isset( $this->options['post_type'] ) && !empty( $this->options['post_type'] ) ? (array) $this->options['post_type'] : array('post');
55
- $post_types = ( isset( $wp_taxonomies['category'] ) ) ? $wp_taxonomies['category']->object_type : array();
 
56
 
57
- foreach ( $news_post_type as $post_type ) {
58
- if ( in_array( $post_type, $post_types ) ) {
59
- add_settings_field( 'xmlsf_news_categories', translate('Categories'), array($this,'categories_field'), 'xmlsf-news', 'news_sitemap_section' );
60
  break;
 
 
 
 
61
  }
 
 
 
 
 
62
  }
 
63
 
64
- add_settings_field( 'xmlsf_news_image', translate('Images'), array( $this,'image_field' ), 'xmlsf-news', 'news_sitemap_section' );
65
- add_settings_field( 'xmlsf_news_labels', __('Source labels', 'xml-sitemap-feed' ), array($this,'labels_field'), 'xmlsf-news', 'news_sitemap_section' );
 
66
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
67
  $options = (array) get_option( 'xmlsf_sitemaps' );
68
  $url = trailingslashit(get_bloginfo('url')) . ( xmlsf()->plain_permalinks() ? '?feed=sitemap-news' : $options['sitemap-news'] );
69
 
70
- include XMLSF_DIR . '/views/admin/page-sitemap-news.php';
71
- }
72
 
73
- /**
74
- * Register and add settings
75
- */
76
- public function register_settings()
77
- {
78
- // Help tab
79
- add_action( 'load-'.$this->screen_id, array($this,'help_tab') );
80
 
81
- register_setting( 'xmlsf-news', 'xmlsf_news_tags', array('XMLSF_Admin_Sitemap_News_Sanitize','news_tags_settings') );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
82
  }
 
 
 
 
 
 
 
 
 
83
 
84
  /**
85
  * GOOGLE NEWS SITEMAP SECTION
@@ -110,6 +239,17 @@ class XMLSF_Admin_Sitemap_News
110
  'content' => $content
111
  ) );
112
 
 
 
 
 
 
 
 
 
 
 
 
113
  ob_start();
114
  include XMLSF_DIR . '/views/admin/help-tab-news-images.php';
115
  include XMLSF_DIR . '/views/admin/help-tab-support.php';
@@ -122,13 +262,24 @@ class XMLSF_Admin_Sitemap_News
122
  ) );
123
 
124
  ob_start();
125
- include XMLSF_DIR . '/views/admin/help-tab-news-categories.php';
126
  include XMLSF_DIR . '/views/admin/help-tab-support.php';
127
  $content = ob_get_clean();
128
 
129
  $screen->add_help_tab( array(
130
- 'id' => 'sitemap-news-categories',
131
- 'title' => translate('Categories'),
 
 
 
 
 
 
 
 
 
 
 
132
  'content' => $content
133
  ) );
134
 
@@ -167,7 +318,7 @@ class XMLSF_Admin_Sitemap_News
167
 
168
  $news_post_type = isset($this->options['post_type']) && !empty( $this->options['post_type'] ) ? (array) $this->options['post_type'] : array('post');
169
 
170
- $type = ( 1 == count( $news_post_type ) ) ? 'radio' : 'checkbox';
171
 
172
  $allowed = ( !empty( $this->options['categories'] ) && isset( $wp_taxonomies['category'] ) ) ? $wp_taxonomies['category']->object_type : $post_types;
173
 
@@ -193,16 +344,34 @@ class XMLSF_Admin_Sitemap_News
193
  include XMLSF_DIR . '/views/admin/field-news-categories.php';
194
  }
195
 
196
- public function image_field() {
197
- $options = get_option( 'xmlsf_news_tags' );
198
-
199
- $image = !empty( $options['image'] ) ? $options['image'] : '';
200
 
201
  // The actual fields for data entry
202
  include XMLSF_DIR . '/views/admin/field-news-image.php';
203
  }
204
 
205
- public function labels_field() {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
206
  // The actual fields for data entry
207
  include XMLSF_DIR . '/views/admin/field-news-labels.php';
208
  }
@@ -210,3 +379,8 @@ class XMLSF_Admin_Sitemap_News
210
  }
211
 
212
  new XMLSF_Admin_Sitemap_News();
 
 
 
 
 
1
  <?php
2
 
3
+ class XMLSF_Admin_Sitemap_News extends XMLSF_Admin_Controller
4
  {
5
  /**
6
+ * Holds the values to be used in the fields callbacks
7
+ */
8
+ private $options;
9
+
10
+ /**
11
+ * Start up
12
+ */
13
+ public function __construct()
14
+ {
15
+ // META
16
+ add_action( 'add_meta_boxes', array( $this, 'add_meta_box' ) );
17
+ add_action( 'save_post', array( $this, 'save_metadata' ) );
18
+
19
+ // SETTINGS
 
20
  add_action( 'admin_init', array( $this, 'register_settings' ) );
21
+ add_action( 'admin_menu', array( $this, 'add_settings_page' ) );
22
+ // advanced tab options
23
+ add_action( 'xmlsf_news_settings_before', 'xmlsf_news_section_advanced_intro' );
24
+ add_action( 'xmlsf_news_add_settings', array( $this, 'add_settings' ) );
25
+
26
+ // TOOLS ACTIONS
27
+ add_action( 'admin_init', array( $this, 'tools_actions' ) );
28
+ }
29
 
30
  /**
31
+ * TOOLS ACTIONS
32
+ */
33
+
34
+ public function tools_actions()
35
  {
36
+ if ( ! isset( $_POST['xmlsf-ping-sitemap-news'] ) )
37
+ return;
 
 
 
 
 
 
 
38
 
39
+ if ( isset( $_POST['_xmlsf_help_nonce'] ) && wp_verify_nonce( $_POST['_xmlsf_help_nonce'], XMLSF_BASENAME.'-help' ) ) {
 
 
 
 
 
40
 
41
+ $sitemaps = get_option( 'xmlsf_sitemaps' );
42
+ $result = xmlsf_ping( 'google', $sitemaps['sitemap-news'], 5 * MINUTE_IN_SECONDS );
43
 
44
+ switch( $result ) {
45
+ case 200:
46
+ $msg = sprintf( /* Translators: Search engine / Service name */ __( 'Pinged %s with success.', 'xml-sitemap-feed' ), __( 'Google News', 'xml-sitemap-feed' ) );
47
+ $type = 'updated';
48
+ break;
49
 
50
+ case 999:
51
+ $msg = sprintf( /* Translators: Search engine / Service name, interval number */ __( 'Ping %s skipped: Sitemap already sent within the last %d minutes.', 'xml-sitemap-feed' ), __( 'Google News', 'xml-sitemap-feed' ), 5 );
52
+ $type = 'notice-warning';
53
+ break;
54
 
55
+ case '':
56
+ $msg = sprintf( translate('Oops: %s'), translate('Something went wrong.') );
57
+ $type = 'error';
58
  break;
59
+
60
+ default:
61
+ $msg = sprintf( /* Translators: Search engine / Service name, response code number */ __( 'Ping %s failed with response code: %d', 'xml-sitemap-feed' ), __( 'Google News', 'xml-sitemap-feed' ), $result );
62
+ $type = 'error';
63
  }
64
+
65
+ add_settings_error( 'ping_sitemap', 'ping_sitemap', $msg, $type );
66
+
67
+ } else {
68
+ add_settings_error( 'ping_sitemap', 'ping_sitemap', translate('Security check failed.') );
69
  }
70
+ }
71
 
72
+ /**
73
+ * META BOXES
74
+ */
75
 
76
+ /* Adds a News Sitemap box to the side column */
77
+ public function add_meta_box()
78
+ {
79
+ $news_tags = get_option('xmlsf_news_tags');
80
+ $news_post_types = !empty($news_tags['post_type']) && is_array($news_tags['post_type']) ? $news_tags['post_type'] : array('post');
81
+
82
+ // Only include metabox on post types that are included
83
+ foreach ( $news_post_types as $post_type ) {
84
+ add_meta_box(
85
+ 'xmlsf_news_section',
86
+ __( 'Google News', 'xml-sitemap-feed' ),
87
+ array( $this, 'meta_box' ),
88
+ $post_type,
89
+ 'side'
90
+ );
91
+ }
92
+ }
93
+
94
+ public function meta_box( $post )
95
+ {
96
+ // Use nonce for verification
97
+ wp_nonce_field( XMLSF_BASENAME, '_xmlsf_news_nonce' );
98
+
99
+ // Use get_post_meta to retrieve an existing value from the database and use the value for the form
100
+ $exclude = 'private' == $post->post_status || get_post_meta( $post->ID, '_xmlsf_news_exclude', true );
101
+ $disabled = 'private' == $post->post_status;
102
+
103
+ // The actual fields for data entry
104
+ include XMLSF_DIR . '/views/admin/meta-box-news.php';
105
+ }
106
+
107
+ /* When the post is saved, save our meta data */
108
+ public function save_metadata( $post_id )
109
+ {
110
+ if ( !isset($post_id) )
111
+ $post_id = (int)$_REQUEST['post_ID'];
112
+
113
+ if ( !current_user_can( 'edit_post', $post_id ) || !isset($_POST['_xmlsf_news_nonce']) || !wp_verify_nonce($_POST['_xmlsf_news_nonce'], XMLSF_BASENAME) )
114
+ return;
115
+
116
+ // _xmlsf_news_exclude
117
+ if ( empty($_POST['xmlsf_news_exclude']) )
118
+ delete_post_meta($post_id, '_xmlsf_news_exclude');
119
+ else
120
+ update_post_meta($post_id, '_xmlsf_news_exclude', $_POST['xmlsf_news_exclude']);
121
+ }
122
+
123
+ /**
124
+ * SETTINGS
125
+ */
126
+
127
+ /**
128
+ * Add options page
129
+ */
130
+ public function add_settings_page()
131
+ {
132
+ // This page will be under "Settings"
133
+ $screen_id = add_options_page(
134
+ __('Google News Sitemap','xml-sitemap-feed'),
135
+ __('Google News','xml-sitemap-feed'),
136
+ 'manage_options',
137
+ 'xmlsf_news',
138
+ array( $this, 'settings_page' )
139
+ );
140
+
141
+ // Help tab
142
+ add_action( 'load-'.$screen_id, array( $this, 'help_tab' ) );
143
+ }
144
+
145
+ /**
146
+ * Options page callback
147
+ */
148
+ public function settings_page()
149
+ {
150
+ $this->options = get_option( 'xmlsf_news_tags', array() );
151
  $options = (array) get_option( 'xmlsf_sitemaps' );
152
  $url = trailingslashit(get_bloginfo('url')) . ( xmlsf()->plain_permalinks() ? '?feed=sitemap-news' : $options['sitemap-news'] );
153
 
154
+ $active_tab = isset( $_GET[ 'tab' ] ) ? $_GET[ 'tab' ] : 'general';
 
155
 
156
+ do_action( 'xmlsf_news_add_settings', $active_tab );
 
 
 
 
 
 
157
 
158
+ include XMLSF_DIR . '/views/admin/page-sitemap-news.php';
159
+ }
160
+
161
+ /**
162
+ * Add advanced settings
163
+ */
164
+ public function add_settings( $active_tab = '' )
165
+ {
166
+ if ( 'advanced' == $active_tab ) {
167
+ // ADVANCED SECTION
168
+ add_settings_section( 'news_sitemap_advanced_section', /* '<a name="xmlnf"></a>'.__('Google News Sitemap','xml-sitemap-feed') */ '', '', 'xmlsf_news_advanced' );
169
+
170
+ // Keywords
171
+ add_settings_field( 'xmlsf_news_keywords', __('Keywords', 'xml-sitemap-feed' ), array( $this,'keywords_field' ), 'xmlsf_news_advanced', 'news_sitemap_advanced_section' );
172
+
173
+ // Stock tickers
174
+ add_settings_field( 'xmlsf_news_stock_tickers', __('Stock tickers', 'xml-sitemap-feed' ), array( $this,'stock_tickers_field' ), 'xmlsf_news_advanced', 'news_sitemap_advanced_section' );
175
+
176
+ // Ping log
177
+ add_settings_field( 'xmlsf_news_ping_log', __('Ping log', 'xml-sitemap-feed' ), array( $this,'ping_log_field' ), 'xmlsf_news_advanced', 'news_sitemap_advanced_section' );
178
+ } else {
179
+ // GENERAL SECTION
180
+ add_settings_section( 'news_sitemap_general_section', /* '<a name="xmlnf"></a>'.__('Google News Sitemap','xml-sitemap-feed') */ '', '', 'xmlsf_news_general' );
181
+
182
+ // SETTINGS
183
+ add_settings_field( 'xmlsf_news_name', '<label for="xmlsf_news_name">'.__('Publication name','xml-sitemap-feed').'</label>', array($this,'name_field'), 'xmlsf_news_general', 'news_sitemap_general_section' );
184
+ add_settings_field( 'xmlsf_news_post_type', __('Post type','xml-sitemap-feed'), array($this,'post_type_field'), 'xmlsf_news_general', 'news_sitemap_general_section' );
185
+
186
+ global $wp_taxonomies;
187
+ $news_post_type = isset( $this->options['post_type'] ) && !empty( $this->options['post_type'] ) ? (array) $this->options['post_type'] : array('post');
188
+ $post_types = ( isset( $wp_taxonomies['category'] ) ) ? $wp_taxonomies['category']->object_type : array();
189
+
190
+ foreach ( $news_post_type as $post_type ) {
191
+ if ( in_array( $post_type, $post_types ) ) {
192
+ add_settings_field( 'xmlsf_news_categories', translate('Categories'), array($this,'categories_field'), 'xmlsf_news_general', 'news_sitemap_general_section' );
193
+ break;
194
+ }
195
+ }
196
+
197
+ // Images
198
+ add_settings_field( 'xmlsf_news_image', translate('Images'), array( $this,'image_field' ), 'xmlsf_news_general', 'news_sitemap_general_section' );
199
+
200
+ // Source labels - deprecated
201
+ add_settings_field( 'xmlsf_news_labels', __('Source labels', 'xml-sitemap-feed' ), array($this,'labels_field'), 'xmlsf_news_general', 'news_sitemap_general_section' );
202
  }
203
+ }
204
+
205
+ /**
206
+ * Register settings
207
+ */
208
+ public function register_settings()
209
+ {
210
+ register_setting( 'xmlsf_news_general', 'xmlsf_news_tags', array('XMLSF_Admin_Sitemap_News_Sanitize','news_tags_settings') );
211
+ }
212
 
213
  /**
214
  * GOOGLE NEWS SITEMAP SECTION
239
  'content' => $content
240
  ) );
241
 
242
+ ob_start();
243
+ include XMLSF_DIR . '/views/admin/help-tab-news-categories.php';
244
+ include XMLSF_DIR . '/views/admin/help-tab-support.php';
245
+ $content = ob_get_clean();
246
+
247
+ $screen->add_help_tab( array(
248
+ 'id' => 'sitemap-news-categories',
249
+ 'title' => translate('Categories'),
250
+ 'content' => $content
251
+ ) );
252
+
253
  ob_start();
254
  include XMLSF_DIR . '/views/admin/help-tab-news-images.php';
255
  include XMLSF_DIR . '/views/admin/help-tab-support.php';
262
  ) );
263
 
264
  ob_start();
265
+ include XMLSF_DIR . '/views/admin/help-tab-news-keywords.php';
266
  include XMLSF_DIR . '/views/admin/help-tab-support.php';
267
  $content = ob_get_clean();
268
 
269
  $screen->add_help_tab( array(
270
+ 'id' => 'sitemap-news-keywords',
271
+ 'title' => __( 'Keywords', 'xml-sitemap-feed' ),
272
+ 'content' => $content
273
+ ) );
274
+
275
+ ob_start();
276
+ include XMLSF_DIR . '/views/admin/help-tab-news-stocktickers.php';
277
+ include XMLSF_DIR . '/views/admin/help-tab-support.php';
278
+ $content = ob_get_clean();
279
+
280
+ $screen->add_help_tab( array(
281
+ 'id' => 'sitemap-news-stocktickers',
282
+ 'title' => __( 'Stock tickers', 'xml-sitemap-feed' ),
283
  'content' => $content
284
  ) );
285
 
318
 
319
  $news_post_type = isset($this->options['post_type']) && !empty( $this->options['post_type'] ) ? (array) $this->options['post_type'] : array('post');
320
 
321
+ $type = apply_filters( 'xmlsf_news_post_type_field_type', 1 == count( $news_post_type ) ? 'radio' : 'checkbox' );
322
 
323
  $allowed = ( !empty( $this->options['categories'] ) && isset( $wp_taxonomies['category'] ) ) ? $wp_taxonomies['category']->object_type : $post_types;
324
 
344
  include XMLSF_DIR . '/views/admin/field-news-categories.php';
345
  }
346
 
347
+ public function image_field()
348
+ {
349
+ $image = !empty( $this->options['image'] ) ? $this->options['image'] : '';
 
350
 
351
  // The actual fields for data entry
352
  include XMLSF_DIR . '/views/admin/field-news-image.php';
353
  }
354
 
355
+ public function keywords_field()
356
+ {
357
+ // The actual fields for data entry
358
+ include XMLSF_DIR . '/views/admin/field-news-keywords.php';
359
+ }
360
+
361
+ public function stock_tickers_field()
362
+ {
363
+ // The actual fields for data entry
364
+ include XMLSF_DIR . '/views/admin/field-news-stocktickers.php';
365
+ }
366
+
367
+ public function ping_log_field()
368
+ {
369
+ // The actual fields for data entry
370
+ include XMLSF_DIR . '/views/admin/field-news-ping-log.php';
371
+ }
372
+
373
+ public function labels_field()
374
+ {
375
  // The actual fields for data entry
376
  include XMLSF_DIR . '/views/admin/field-news-labels.php';
377
  }
379
  }
380
 
381
  new XMLSF_Admin_Sitemap_News();
382
+
383
+ function xmlsf_news_section_advanced_intro( $active_tab = '' ) {
384
+ if ( 'advanced' == $active_tab )
385
+ include XMLSF_DIR . '/views/admin/section-advanced-intro.php';
386
+ }
controllers/admin/sitemap.php CHANGED
@@ -1,6 +1,6 @@
1
  <?php
2
 
3
- class XMLSF_Admin_Sitemap
4
  {
5
  /**
6
  * Holds the values to be used in the fields callbacks
@@ -18,7 +18,194 @@ class XMLSF_Admin_Sitemap
18
  public function __construct()
19
  {
20
  add_action( 'admin_menu', array( $this, 'add_settings_page' ) );
 
 
21
  add_action( 'admin_init', array( $this, 'register_settings' ) );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
22
  }
23
 
24
  /**
@@ -27,7 +214,8 @@ class XMLSF_Admin_Sitemap
27
  public function public_taxonomies()
28
  {
29
  if ( !isset( $this->public_taxonomies ) ) {
30
- include XMLSF_DIR . '/models/public/sitemap.php';
 
31
  $this->public_taxonomies = xmlsf_public_taxonomies();
32
  }
33
 
1
  <?php
2
 
3
+ class XMLSF_Admin_Sitemap extends XMLSF_Admin_Controller
4
  {
5
  /**
6
  * Holds the values to be used in the fields callbacks
18
  public function __construct()
19
  {
20
  add_action( 'admin_menu', array( $this, 'add_settings_page' ) );
21
+ add_action( 'admin_init', array( $this, 'tools_actions' ) );
22
+ add_action( 'admin_init', array( $this, 'check_plugin_conflicts' ) );
23
  add_action( 'admin_init', array( $this, 'register_settings' ) );
24
+ add_action( 'add_meta_boxes', array( $this, 'add_meta_box' ) );
25
+ add_action( 'save_post', array( $this, 'save_metadata' ) );
26
+ }
27
+
28
+ public function tools_actions()
29
+ {
30
+ if ( isset( $_POST['xmlsf-ping-sitemap'] ) ) {
31
+ if ( isset( $_POST['_xmlsf_help_nonce'] ) && wp_verify_nonce( $_POST['_xmlsf_help_nonce'], XMLSF_BASENAME.'-help' ) ) {
32
+
33
+ $sitemaps = get_option( 'xmlsf_sitemaps' );
34
+
35
+ foreach ( array('google','bing') as $se ) {
36
+ $result = xmlsf_ping( $se, $sitemaps['sitemap'], HOUR_IN_SECONDS );
37
+
38
+ $se_name = 'google' == $se ? __('Google','xml-sitemap-feed') : __('Bing & Yahoo','xml-sitemap-feed');
39
+
40
+ switch( $result ) {
41
+ case 200:
42
+ $msg = sprintf( /* Translators: Search engine / Service name */ __( 'Pinged %s with success.', 'xml-sitemap-feed' ), $se_name );
43
+ $type = 'updated';
44
+ break;
45
+
46
+ case 999:
47
+ $msg = sprintf( /* Translators: Search engine / Service name, interval number */ __( 'Ping %s skipped: Sitemap already sent within the last %d minutes.', 'xml-sitemap-feed' ), $se_name, 60 );
48
+ $type = 'notice-warning';
49
+ break;
50
+
51
+ case '':
52
+ $msg = sprintf( translate('Oops: %s'), translate('Something went wrong.') );
53
+ $type = 'error';
54
+ break;
55
+
56
+ default:
57
+ $msg = sprintf( /* Translators: Search engine / Service name, response code number */ __( 'Ping %s failed with response code: %d', 'xml-sitemap-feed' ), $se_name, $result );
58
+ $type = 'error';
59
+ }
60
+
61
+ add_settings_error( 'ping_sitemap', 'ping_sitemap', $msg, $type );
62
+ }
63
+
64
+ } else {
65
+ add_settings_error( 'ping_sitemap', 'ping_sitemap', translate('Security check failed.') );
66
+ }
67
+ }
68
+ }
69
+
70
+ /**
71
+ * Check for conflicting plugins and their settings
72
+ */
73
+ public function check_plugin_conflicts()
74
+ {
75
+ // TODO:
76
+ // W3TC static files 404 exclusion rules ? Said to be fixed in W3TC next veresion...
77
+ // Google (XML) Sitemaps Generator Plugin for WordPress and Google News sitemap incompatibility
78
+
79
+ // WP SEO conflict notices
80
+ if ( is_plugin_active('wordpress-seo/wp-seo.php') ) {
81
+ // check date archive redirection
82
+ if ( !in_array( 'wpseo_date_redirect', parent::$dismissed ) ) {
83
+ $wpseo_titles = get_option( 'wpseo_titles' );
84
+ if ( !empty( $wpseo_titles['disable-date'] ) ) {
85
+ // check if Split by option is set anywhere
86
+ foreach ( (array) get_option( 'xmlsf_post_types' ) as $type => $settings ) {
87
+ if ( is_array( $settings ) && !empty( $settings['archive'] ) ) {
88
+ add_action( 'admin_notices', array( 'XMLSF_Admin_Notices', 'notice_wpseo_date_redirect' ) );
89
+ break;
90
+ }
91
+ }
92
+ }
93
+ }
94
+
95
+ // check wpseo sitemap option
96
+ if ( !in_array( 'wpseo_sitemap', parent::$dismissed ) ) {
97
+ $wpseo = get_option( 'wpseo' );
98
+ if ( !empty( $wpseo['enable_xml_sitemap'] ) ) {
99
+ add_action( 'admin_notices', array( 'XMLSF_Admin_Notices', 'notice_wpseo_sitemap' ) );
100
+ }
101
+ }
102
+ }
103
+
104
+ // SEOPress conflict notices
105
+ if ( is_plugin_active('wp-seopress/seopress.php') ) {
106
+
107
+ // check date archive redirection
108
+ $seopress_toggle = get_option( 'seopress_toggle' );
109
+ if ( !in_array( 'seopress_date_redirect', parent::$dismissed ) ) {
110
+ $seopress_titles = get_option( 'seopress_titles_option_name' );
111
+ if ( ! empty( $seopress_toggle['toggle-titles'] ) && ! empty( $seopress_titles['seopress_titles_archives_date_disable'] ) ) {
112
+ // check if Split by option is set anywhere
113
+ foreach ( (array) get_option( 'xmlsf_post_types' ) as $type => $settings ) {
114
+ if ( is_array( $settings ) && !empty( $settings['archive'] ) ) {
115
+ add_action( 'admin_notices', array( 'XMLSF_Admin_Notices', 'notice_seopress_date_redirect' ) );
116
+ break;
117
+ }
118
+ }
119
+ }
120
+ }
121
+
122
+ // check seopress sitemap option
123
+ if ( !in_array( 'seopress_sitemap', parent::$dismissed ) ) {
124
+ $seopress_xml_sitemap = get_option( 'seopress_xml_sitemap_option_name' );
125
+ if ( ! empty( $seopress_toggle['toggle-xml-sitemap'] ) && !empty( $seopress_xml_sitemap['seopress_xml_sitemap_general_enable'] ) ) {
126
+ add_action( 'admin_notices', array( 'XMLSF_Admin_Notices', 'notice_seopress_sitemap' ) );
127
+ }
128
+ }
129
+ }
130
+ }
131
+
132
+ /**
133
+ * META BOXES
134
+ */
135
+
136
+ /* Adds a XML Sitemap box to the side column */
137
+ public function add_meta_box()
138
+ {
139
+ $post_types = get_option( 'xmlsf_post_types' );
140
+ if ( !is_array( $post_types ) ) return;
141
+
142
+ foreach ( $post_types as $post_type => $settings ) {
143
+ // Only include metaboxes on post types that are included
144
+ if ( isset( $settings["active"] ) )
145
+ add_meta_box(
146
+ 'xmlsf_section',
147
+ __( 'XML Sitemap', 'xml-sitemap-feed' ),
148
+ array( $this, 'meta_box' ),
149
+ $post_type,
150
+ 'side',
151
+ 'low'
152
+ );
153
+ }
154
+ }
155
+
156
+ public function meta_box( $post )
157
+ {
158
+ // Use nonce for verification
159
+ wp_nonce_field( XMLSF_BASENAME, '_xmlsf_nonce' );
160
+
161
+ // Use get_post_meta to retrieve an existing value from the database and use the value for the form
162
+ $exclude = get_post_meta( $post->ID, '_xmlsf_exclude', true );
163
+ $priority = get_post_meta( $post->ID, '_xmlsf_priority', true );
164
+ $disabled = false;
165
+
166
+ // disable options and (visibly) set excluded to true for private posts
167
+ if ( 'private' == $post->post_status ) {
168
+ $disabled = true;
169
+ $exclude = true;
170
+ }
171
+
172
+ // disable options and (visibly) set priority to 1 for front page
173
+ if ( $post->ID == get_option('page_on_front') ) {
174
+ $disabled = true;
175
+ $exclude = false;
176
+ $priority = '1'; // force priority to 1 for front page
177
+ }
178
+
179
+ $description = sprintf(
180
+ __('Leave empty for automatic Priority as configured on %1$s > %2$s.','xml-sitemap-feed'),
181
+ translate('Settings'),
182
+ '<a href="' . admin_url('options-general.php') . '?page=xmlsf">' . __('XML Sitemap','xml-sitemap-feed') . '</a>'
183
+ );
184
+
185
+ // The actual fields for data entry
186
+ include XMLSF_DIR . '/views/admin/meta-box.php';
187
+ }
188
+
189
+ /* When the post is saved, save our meta data */
190
+ public function save_metadata( $post_id )
191
+ {
192
+ if ( !isset($post_id) )
193
+ $post_id = (int)$_REQUEST['post_ID'];
194
+
195
+ if ( !current_user_can( 'edit_post', $post_id ) || !isset($_POST['_xmlsf_nonce']) || !wp_verify_nonce($_POST['_xmlsf_nonce'], XMLSF_BASENAME) )
196
+ return;
197
+
198
+ // _xmlsf_priority
199
+ if ( empty($_POST['xmlsf_priority']) )
200
+ delete_post_meta($post_id, '_xmlsf_priority');
201
+ else
202
+ update_post_meta($post_id, '_xmlsf_priority', XMLSF_Admin_Sitemap_Sanitize::priority($_POST['xmlsf_priority']) );
203
+
204
+ // _xmlsf_exclude
205
+ if ( empty($_POST['xmlsf_exclude']) )
206
+ delete_post_meta($post_id, '_xmlsf_exclude');
207
+ else
208
+ update_post_meta($post_id, '_xmlsf_exclude', $_POST['xmlsf_exclude']);
209
  }
210
 
211
  /**
214
  public function public_taxonomies()
215
  {
216
  if ( !isset( $this->public_taxonomies ) ) {
217
+ require_once XMLSF_DIR . '/models/public/sitemap.php';
218
+
219
  $this->public_taxonomies = xmlsf_public_taxonomies();
220
  }
221
 
controllers/global.php CHANGED
@@ -6,209 +6,63 @@
6
 
7
  function xmlsf_init() {
8
 
9
- xmlsf_maybe_upgrade();
 
 
 
 
 
10
 
11
  if ( is_admin() ) {
12
  require XMLSF_DIR . '/controllers/admin/main.php';
13
  }
14
 
 
15
  // include sitemaps if any enabled
16
- if ( get_option( 'xmlsf_sitemaps' ) ) {
17
-
18
- // include main controller functions
19
- require XMLSF_DIR . '/controllers/main.php';
20
-
21
- add_action( 'clean_post_cache', 'xmlsf_clean_post_cache', 99, 2 );
22
-
23
- // PINGING
24
- add_action( 'transition_post_status', 'xmlsf_do_pings', 10, 3 );
25
-
26
- // Update term meta lastmod date
27
- add_action( 'transition_post_status', 'update_term_modified_meta', 10, 3 );
28
-
29
- // add rewrite rules
30
- xmlsf_rewrite_rules();
31
-
32
- // include main model functions
33
  require XMLSF_DIR . '/models/main.php';
34
 
35
- // MAIN REQUEST filter
36
- add_filter( 'request', 'xmlsf_filter_request', 1 );
37
-
38
  // force remove url trailing slash
39
  add_filter( 'user_trailingslashit', 'xmlsf_untrailingslash' );
40
 
41
- // common sitemap element filters
42
- add_filter( 'the_title_xmlsitemap', 'strip_tags' );
43
- add_filter( 'the_title_xmlsitemap', 'ent2ncr', 8 );
44
- add_filter( 'the_title_xmlsitemap', 'esc_html' );
 
45
 
46
- add_filter( 'xmlsf_news_post_types', 'xmlsf_news_filter_post_types' );
47
- add_filter( 'xmlsf_post_types', 'xmlsf_filter_post_types' );
48
 
49
  // include and instantiate class
50
  xmlsf();
51
- }
52
-
53
- // add robots.txt filter
54
- add_filter( 'robots_txt', 'xmlsf_robots_txt', 9 );
55
- }
56
-
57
- /**
58
- * Upgrade/install, maybe...
59
- *
60
- * @since 5.0
61
- * @return void
62
- */
63
- function xmlsf_maybe_upgrade() {
64
- $db_version = get_option( 'xmlsf_version', 0 );
65
-
66
- if ( version_compare( XMLSF_VERSION, $db_version, '=' ) ) {
67
- return;
68
- }
69
-
70
- // don't flush rules from init as Polylang chokes on that
71
- // just remove the db option and let WP regenerate them when ready...
72
- delete_option( 'rewrite_rules' );
73
- // ... but make sure rules are regenerated when admin is visited.
74
- set_transient( 'xmlsf_flush_rewrite_rules', '' );
75
- // static files checking
76
- set_transient( 'xmlsf_check_static_files', '' );
77
-
78
- // upgrade or install
79
- if ( $db_version ) :
80
-
81
- if ( version_compare( '4.4', $db_version, '>' ) ) {
82
- // remove robots.txt rules blocking stylesheets
83
- if ( $robot_rules = get_option( 'xmlsf_robots' ) ) {
84
- $robot_rules = str_replace( array('Disallow: */wp-content/','Allow: */wp-content/uploads/'), '', $robot_rules );
85
- delete_option( 'xmlsf_robots' );
86
- add_option( 'xmlsf_robots', $robot_rules, null, false );
87
- }
88
-
89
- // make sure custom sitemaps is an array
90
- $urls = get_option('xmlsf_custom_sitemaps');
91
- if ( !is_array($urls) ) {
92
- $urls = explode( PHP_EOL, $urls );
93
- update_option('xmlsf_custom_sitemaps',$urls);
94
- }
95
-
96
- // register location taxonomies then delete all terms
97
- register_taxonomy( 'gn-location-3', null );
98
- $terms = get_terms( 'gn-location-3', array('hide_empty' => false) );
99
- foreach ( $terms as $term ) {
100
- wp_delete_term( $term->term_id, 'gn-location-3' );
101
- }
102
-
103
- register_taxonomy( 'gn-location-2', null );
104
- $terms = get_terms( 'gn-location-2',array( 'hide_empty' => false ) );
105
- foreach ( $terms as $term ) {
106
- wp_delete_term( $term->term_id, 'gn-location-2' );
107
- }
108
-
109
- register_taxonomy( 'gn-location-1', null );
110
- $terms = get_terms( 'gn-location-1',array( 'hide_empty' => false ) );
111
- foreach ( $terms as $term ) {
112
- wp_delete_term( $term->term_id, 'gn-location-1' );
113
- }
114
- }
115
 
116
- if ( version_compare( '5.0.1', $db_version, '>' ) ) {
117
- // delete all taxonomy terms
118
- register_taxonomy( 'gn-genre', null );
119
-
120
- $terms = get_terms( 'gn-genre', array( 'hide_empty' => false ) );
121
-
122
- if ( is_array( $terms ) )
123
- foreach ( $terms as $term )
124
- wp_delete_term( $term->term_id, 'gn-genre' );
125
-
126
- // new taxonomy settings
127
- $taxonomies = get_option( 'xmlsf_taxonomies' );
128
- if ( empty($taxonomies) ) {
129
- $active = '';
130
- } else {
131
- $available = 0;
132
- $checked = count($taxonomies);
133
- foreach ( (array) get_option( 'xmlsf_post_types' ) as $post_type => $settings ) {
134
- if ( empty($settings['active']) ) continue;
135
- $taxonomies = get_object_taxonomies( $post_type, 'objects' );
136
- // check each tax public flag and term count and append name to array
137
- foreach ( $taxonomies as $taxonomy ) {
138
- if ( !empty( $taxonomy->public ) && !in_array( $taxonomy->name, xmlsf()->disabled_taxonomies() ) )
139
- $available++;
140
- }
141
- }
142
- if ( $checked == $available )
143
- update_option( 'xmlsf_taxonomies', '' );
144
- $active = '1';
145
- }
146
- $taxonomy_settings = array(
147
- 'active' => $active,
148
- 'priority' => '0.3',
149
- 'dynamic_priority' => '1',
150
- 'term_limit' => '5000'
151
- );
152
- add_option( 'xmlsf_taxonomy_settings', $taxonomy_settings );
153
-
154
- // update ping option
155
- $ping = get_option( 'xmlsf_ping' );
156
- $new = array( 'google', 'bing' );
157
- if ( is_array($ping) ) {
158
- foreach ( $ping as $key => $value ) {
159
- if ( is_array($value) && empty( $value['active'] ) && isset( $new[$key] ) ) {
160
- unset( $new[$key] );
161
- }
162
- }
163
- }
164
- update_option( 'xmlsf_ping', $new, false );
165
-
166
- // make sure no pong option remains
167
- delete_option( 'xmlsf_pong');
168
-
169
- // update or create robots option
170
- $robots = get_option( 'xmlsf_robots', '' );
171
- delete_option( 'xmlsf_robots');
172
- add_option( 'xmlsf_robots', $robots, null, false );
173
- }
174
-
175
- if ( version_compare( '5.0.2', $db_version, '>' ) ) {
176
- $defaults = xmlsf()->defaults();
177
 
178
- foreach ( $defaults as $option => $default ) {
179
- if ( get_option( 'xmlsf_'.$option ) ) continue;
180
- if ( in_array( $option, array('ping','robots') ) )
181
- add_option( 'xmlsf_'.$option, $default, null, false );
182
- else
183
- add_option( 'xmlsf_'.$option, $default );
184
- }
185
-
186
- delete_option( 'xmlsf_version' );
187
  }
188
 
189
- if ( defined('WP_DEBUG') && WP_DEBUG ) {
190
- error_log('XML Sitemap Feeds upgraded from '.$db_version.' to '.XMLSF_VERSION);
191
- };
192
-
193
- else :
194
 
195
- $defaults = xmlsf()->defaults();
196
-
197
- foreach ( $defaults as $option => $default ) {
198
- delete_option( 'xmlsf_'.$option );
199
- if ( in_array( $option, array('ping','robots') ) )
200
- add_option( 'xmlsf_'.$option, $default, null, false );
201
- else
202
- add_option( 'xmlsf_'.$option, $default );
203
  }
204
 
205
- if ( defined('WP_DEBUG') && WP_DEBUG ) {
206
- error_log('XML Sitemap Feeds version '.XMLSF_VERSION.' installed.');
207
- };
208
-
209
- endif;
210
 
211
- update_option( 'xmlsf_version', XMLSF_VERSION );
 
212
  }
213
 
214
  /**
@@ -219,7 +73,6 @@ function xmlsf_maybe_upgrade() {
219
  */
220
 
221
  function xmlsf_activate() {
222
- delete_option( 'rewrite_rules' );
223
  set_transient( 'xmlsf_flush_rewrite_rules', '' );
224
  set_transient( 'xmlsf_check_static_files', '' );
225
  }
@@ -234,5 +87,7 @@ function xmlsf_activate() {
234
  function xmlsf_deactivate() {
235
  delete_transient( 'xmlsf_flush_rewrite_rules' );
236
  delete_transient( 'xmlsf_check_static_files' );
 
 
237
  flush_rewrite_rules();
238
  }
6
 
7
  function xmlsf_init() {
8
 
9
+ // Upgrade/install, maybe...
10
+ $db_version = get_option( 'xmlsf_version', 0 );
11
+ if ( ! version_compare( XMLSF_VERSION, $db_version, '=' ) ) {
12
+ require XMLSF_DIR . '/controllers/upgrade.php';
13
+ new XMLSitemapFeed_Upgrade( $db_version );
14
+ }
15
 
16
  if ( is_admin() ) {
17
  require XMLSF_DIR . '/controllers/admin/main.php';
18
  }
19
 
20
+ $sitemaps = get_option( 'xmlsf_sitemaps' );
21
  // include sitemaps if any enabled
22
+ if ( $sitemaps ) {
23
+ // main model functions
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
24
  require XMLSF_DIR . '/models/main.php';
25
 
 
 
 
26
  // force remove url trailing slash
27
  add_filter( 'user_trailingslashit', 'xmlsf_untrailingslash' );
28
 
29
+ // MAIN REQUEST filter
30
+ add_filter( 'request', 'xmlsf_filter_request', 1 );
31
+
32
+ // NGINX HELPER PURGE URLS
33
+ add_filter( 'rt_nginx_helper_purge_urls', 'xmlsf_nginx_helper_purge_urls', 10, 2 );
34
 
35
+ // main controller functions
36
+ require XMLSF_DIR . '/controllers/main.php';
37
 
38
  // include and instantiate class
39
  xmlsf();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
40
 
41
+ if ( ! empty( $sitemaps['sitemap-news'] ) ) {
42
+ require XMLSF_DIR . '/models/sitemap-news.php';
43
+ add_filter( 'xmlsf_news_post_types', 'xmlsf_news_filter_post_types' );
44
+ //add_filter( 'request', 'xmlsf_news_filter_request', 2 );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
45
 
46
+ require XMLSF_DIR . '/controllers/sitemap-news.php';
 
 
 
 
 
 
 
 
47
  }
48
 
49
+ if ( ! empty( $sitemaps['sitemap'] ) ) {
50
+ require XMLSF_DIR . '/models/sitemap.php';
51
+ add_filter( 'xmlsf_post_types', 'xmlsf_filter_post_types' );
52
+ //add_filter( 'request', 'xmlsf_sitemap_filter_request', 3 );
 
53
 
54
+ require XMLSF_DIR . '/controllers/sitemap.php';
55
+ new XMLSF_Sitemap_Controller( $sitemaps['sitemap'] );
 
 
 
 
 
 
56
  }
57
 
58
+ // common sitemap element filters
59
+ add_filter( 'the_title_xmlsitemap', 'strip_tags' );
60
+ add_filter( 'the_title_xmlsitemap', 'ent2ncr', 8 );
61
+ add_filter( 'the_title_xmlsitemap', 'esc_html' );
62
+ }
63
 
64
+ // add robots.txt filter
65
+ add_filter( 'robots_txt', 'xmlsf_robots_txt', 9 );
66
  }
67
 
68
  /**
73
  */
74
 
75
  function xmlsf_activate() {
 
76
  set_transient( 'xmlsf_flush_rewrite_rules', '' );
77
  set_transient( 'xmlsf_check_static_files', '' );
78
  }
87
  function xmlsf_deactivate() {
88
  delete_transient( 'xmlsf_flush_rewrite_rules' );
89
  delete_transient( 'xmlsf_check_static_files' );
90
+ // remove filter and flush rules
91
+ remove_filter( 'rewrite_rules_array', 'xmlsf_rewrite_rules', 1, 1 );
92
  flush_rewrite_rules();
93
  }
controllers/main.php CHANGED
@@ -1,57 +1,5 @@
1
  <?php
2
 
3
- /**
4
- * Add sitemap rewrite rules
5
- *
6
- * @uses object $wp_rewrite
7
- *
8
- * @return void
9
- */
10
- function xmlsf_rewrite_rules() {
11
- global $wp_rewrite;
12
-
13
- $sitemaps = get_option( 'xmlsf_sitemaps' );
14
-
15
- if ( isset($sitemaps['sitemap']) ) {
16
- /* One rule to ring them all */
17
- add_rewrite_rule('sitemap([a-z0-9_-]+)?\.([0-9]+)?\.?xml$', $wp_rewrite->index . '?feed=sitemap$matches[1]&m=$matches[2]', 'top');
18
- }
19
-
20
- if( isset($sitemaps['sitemap-news']) ) {
21
- add_rewrite_rule('sitemap-news\.xml$', $wp_rewrite->index . '?feed=sitemap-news', 'top');
22
- }
23
- }
24
-
25
- /**
26
- * Cache delete on clean_post_cache
27
- *
28
- * @param $post_ID
29
- * @param $post
30
- */
31
- function xmlsf_clean_post_cache( $post_ID, $post ) {
32
- // are we moving the post in or out of published status?
33
- wp_cache_delete('xmlsf_get_archives', 'general');
34
-
35
- // TODO get year / month here to delete specific keys too !!!!
36
- $m = mysql2date('Ym',$post->post_date_gmt, false);
37
- $y = substr($m, 0, 4);
38
-
39
- // clear possible last post modified cache keys
40
- wp_cache_delete( 'lastpostmodified:gmt', 'timeinfo' ); // should be handled by WP core?
41
- wp_cache_delete( 'lastpostmodified'.$y.':gmt', 'timeinfo' );
42
- wp_cache_delete( 'lastpostmodified'.$m.':gmt', 'timeinfo' );
43
- wp_cache_delete( 'lastpostmodified'.$y.':gmt:'.$post->post_type, 'timeinfo' );
44
- wp_cache_delete( 'lastpostmodified'.$m.':gmt:'.$post->post_type, 'timeinfo' );
45
-
46
- // clear possible last post date cache keys
47
- wp_cache_delete( 'lastpostdate:gmt', 'timeinfo' );
48
- wp_cache_delete( 'lastpostdate:gmt:'.$post->post_type, 'timeinfo' );
49
-
50
- // clear possible fist post date cache keys
51
- wp_cache_delete( 'firstpostdate:gmt', 'timeinfo' );
52
- wp_cache_delete( 'firstpostdate:gmt:'.$post->post_type, 'timeinfo' );
53
- }
54
-
55
  /**
56
  * Do pings, hooked to transition post status
57
  *
@@ -71,108 +19,71 @@ function xmlsf_do_pings( $new_status, $old_status, $post ) {
71
  return;
72
 
73
  if ( isset( $sitemaps['sitemap-news'] ) ) {
74
-
75
  // check if we've got a post type that is included in our news sitemap
 
76
  $news_tags = get_option('xmlsf_news_tags');
77
- if ( !empty($news_tags['post_type']) && is_array($news_tags['post_type']) && in_array($post->post_type,$news_tags['post_type']) ) {
78
-
79
- // Google ?
80
- if ( in_array( 'google', $ping ) ) {
81
- // check if we did not ping already within the last hour
82
- if ( false === get_transient('xmlsf_ping_google_sitemap_news') ) {
83
- // Ping !
84
- $uri = add_query_arg( 'sitemap', urlencode( trailingslashit( get_bloginfo( 'url' ) ) . $sitemaps['sitemap-news'] ), 'https://www.google.com/ping' );
85
- $response = wp_remote_request( $uri );
86
- $code = wp_remote_retrieve_response_code( $response );
87
- if ( 200 === $code ) {
88
- set_transient( 'xmlsf_ping_google_sitemap_news', $sitemaps['sitemap-news'], 5 * MINUTE_IN_SECONDS );
89
- } elseif ( defined('WP_DEBUG') && WP_DEBUG == true ) {
90
- error_log( 'Ping to '. $uri .' failed with response code: ' . $code );
91
- }
92
- } elseif ( defined('WP_DEBUG') && WP_DEBUG == true ) {
93
- error_log( 'Ping skipped: previous News Sitemap was sent to Google less than ' . 5 * MINUTE_IN_SECONDS . ' seconds ago.' );
94
- }
95
- }
96
-
97
- // Bing ?
98
- // nope...
99
  }
100
  }
101
 
102
  if ( isset( $sitemaps['sitemap'] ) ) {
103
-
104
  // check if we've got a post type that is included in our sitemap
105
  $post_types = get_option( 'xmlsf_post_types' );
106
  if ( is_array( $post_types ) && array_key_exists( $post->post_type, $post_types ) ) {
107
 
108
- // Google ?
109
- if ( in_array( 'google', $ping ) ) {
110
- // check if we did not ping already within the last hour
111
- if ( false === get_transient('xmlsf_ping_google_sitemap') ) {
112
- // Ping !
113
- $uri = add_query_arg( 'sitemap', urlencode( trailingslashit( get_bloginfo( 'url' ) ) . $sitemaps['sitemap'] ), 'https://www.google.com/ping' );
114
- $response = wp_remote_request( $uri );
115
- $code = wp_remote_retrieve_response_code( $response );
116
- if ( 200 === $code ) {
117
- set_transient( 'xmlsf_ping_google_sitemap', $sitemaps['sitemap'], HOUR_IN_SECONDS );
118
- } elseif ( defined('WP_DEBUG') && WP_DEBUG == true ) {
119
- error_log( 'Ping to '. $uri .' failed with response code: ' . $code );
120
- }
121
- } elseif ( defined('WP_DEBUG') && WP_DEBUG == true ) {
122
- error_log( 'Ping skipped: previous XML Sitemap was sent to Google less than ' . HOUR_IN_SECONDS . ' seconds ago.' );
123
- }
124
- }
125
-
126
- // Bing ?
127
- if ( in_array( 'bing', $ping ) ) {
128
- // check if we did not ping already within the last hour
129
- if ( false === get_transient('xmlsf_ping_bing_sitemap') ) {
130
- // Ping !
131
- $uri = add_query_arg( 'sitemap', urlencode( trailingslashit( get_bloginfo( 'url' ) ) . $sitemaps['sitemap'] ), 'https://www.bing.com/ping' );
132
- $response = wp_remote_request( $uri );
133
- $code = wp_remote_retrieve_response_code( $response );
134
- if ( 200 === $code ) {
135
- set_transient( 'xmlsf_ping_bing_sitemap', $sitemaps['sitemap'], HOUR_IN_SECONDS );
136
- } elseif ( defined('WP_DEBUG') && WP_DEBUG == true ) {
137
- error_log( 'Ping to '. $uri .' failed with response code: ' . $code );
138
- }
139
- } elseif ( defined('WP_DEBUG') && WP_DEBUG == true ) {
140
- error_log( 'Ping skipped: previous XML Sitemap was sent to Bing less than ' . HOUR_IN_SECONDS . ' seconds ago.' );
141
- }
142
  }
143
  }
144
  }
145
  }
146
 
147
  /**
148
- * Update term modified meta, hooked to transition post status
149
- *
150
- * @param $new_status
151
- * @param $old_status
152
- * @param $post
153
  */
154
- function update_term_modified_meta( $new_status, $old_status, $post ) {
 
 
 
 
 
 
155
 
156
- $taxonomies = get_option( 'xmlsf_taxonomies' );
 
 
 
 
157
 
158
- if ( empty( $taxonomies ) )
159
- return;
160
 
161
- // are we not publishing or unpublishing?
162
- if ( $old_status == $new_status || $old_status != 'publish' && $new_status != 'publish' )
163
- return;
 
 
 
 
164
 
165
- $term_ids = array();
166
- foreach ( $taxonomies as $tax_name ) {
167
- $terms = wp_get_post_terms( $post->ID, $tax_name, array( 'fields' => 'ids' ));
168
- if ( !is_wp_error($terms) ) {
169
- $term_ids = array_merge( $term_ids, $terms );
170
- }
171
  }
 
172
 
173
- $time = date('Y-m-d H:i:s');
174
-
175
- foreach( $term_ids as $id ) {
176
- update_term_meta( $id, 'term_modified_gmt', $time );
 
 
 
 
 
 
 
 
 
177
  }
178
  }
1
  <?php
2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3
  /**
4
  * Do pings, hooked to transition post status
5
  *
19
  return;
20
 
21
  if ( isset( $sitemaps['sitemap-news'] ) ) {
 
22
  // check if we've got a post type that is included in our news sitemap
23
+ // TODO also check category if needed
24
  $news_tags = get_option('xmlsf_news_tags');
25
+ if ( ! empty( $news_tags['post_type'] ) && in_array( $post->post_type, (array) $news_tags['post_type'] ) ) {
26
+ xmlsf_ping( 'google', $sitemaps['sitemap-news'], 5 * MINUTE_IN_SECONDS );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
27
  }
28
  }
29
 
30
  if ( isset( $sitemaps['sitemap'] ) ) {
 
31
  // check if we've got a post type that is included in our sitemap
32
  $post_types = get_option( 'xmlsf_post_types' );
33
  if ( is_array( $post_types ) && array_key_exists( $post->post_type, $post_types ) ) {
34
 
35
+ foreach ( $ping as $se ) {
36
+ xmlsf_ping( $se, $sitemaps['sitemap'], HOUR_IN_SECONDS );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
37
  }
38
  }
39
  }
40
  }
41
 
42
  /**
43
+ * WPML: switch language
44
+ * @see https://wpml.org/wpml-hook/wpml_post_language_details/
 
 
 
45
  */
46
+ function xmlsf_wpml_language_switcher() {
47
+ global $sitepress, $post;
48
+ if ( isset( $sitepress ) ) {
49
+ $post_language = apply_filters( 'wpml_post_language_details', NULL, $post->ID );
50
+ $sitepress->switch_lang( $post_language['language_code'] );
51
+ }
52
+ }
53
 
54
+ /**
55
+ * Generator info
56
+ */
57
+ function xmlsf_generator() {
58
+ $date = date('Y-m-d\TH:i:s+00:00');
59
 
60
+ require XMLSF_DIR . '/views/_generator.php';
61
+ }
62
 
63
+ /**
64
+ * Usage info for debugging
65
+ */
66
+ function xmlsf_usage() {
67
+ if ( defined('WP_DEBUG') && WP_DEBUG == true ) {
68
+ $num = get_num_queries();
69
+ $mem = function_exists('memory_get_peak_usage') ? round(memory_get_peak_usage()/1024/1024,2) : 0;
70
 
71
+ require XMLSF_DIR . '/views/_usage.php';
 
 
 
 
 
72
  }
73
+ }
74
 
75
+ /**
76
+ * Try to turn on ob_gzhandler output compression
77
+ */
78
+ function xmlsf_ob_gzhandler() {
79
+ in_array('ob_gzhandler', ob_list_handlers())
80
+ || ob_get_contents()
81
+ || ini_get("zlib.output_compression")
82
+ || ( isset($_SERVER['HTTP_X_VARNISH']) && is_numeric($_SERVER['HTTP_X_VARNISH']) )
83
+ || ob_start("ob_gzhandler");
84
+
85
+ if ( defined('WP_DEBUG') && WP_DEBUG == true ) {
86
+ $status = in_array('ob_gzhandler', ob_list_handlers()) ? 'ENABLED' : 'DISABLED';
87
+ error_log('GZhandler output buffer compression '.$status);
88
  }
89
  }
controllers/public/shared.php DELETED
@@ -1,34 +0,0 @@
1
- <?php
2
-
3
- /**
4
- * WPML: switch language
5
- * @see https://wpml.org/wpml-hook/wpml_post_language_details/
6
- */
7
- function xmlsf_wpml_language_switcher() {
8
- global $sitepress, $post;
9
- if ( isset( $sitepress ) ) {
10
- $post_language = apply_filters( 'wpml_post_language_details', NULL, $post->ID );
11
- $sitepress->switch_lang( $post_language['language_code'] );
12
- }
13
- }
14
-
15
- /**
16
- * Generator info
17
- */
18
- function xmlsf_generator() {
19
- $date = date('Y-m-d\TH:i:s+00:00');
20
-
21
- require XMLSF_DIR . '/views/_generator.php';
22
- }
23
-
24
- /**
25
- * Usage info for debugging
26
- */
27
- function xmlsf_usage() {
28
- if ( defined('WP_DEBUG') && WP_DEBUG == true ) {
29
- $num = get_num_queries();
30
- $mem = function_exists('memory_get_peak_usage') ? round(memory_get_peak_usage()/1024/1024,2) : 0;
31
-
32
- require XMLSF_DIR . '/views/_usage.php';
33
- }
34
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
controllers/public/sitemap.php DELETED
@@ -1,106 +0,0 @@
1
- <?php
2
- /**
3
- * FEED TEMPLATES
4
- */
5
-
6
- /**
7
- * Set up the sitemap index template
8
- */
9
- function xmlsf_load_template_index() {
10
- load_template( XMLSF_DIR . '/views/feed-sitemap.php' );
11
- }
12
-
13
- /**
14
- * set up the sitemap home page(s) template
15
- */
16
- function xmlsf_load_template_home() {
17
- load_template( XMLSF_DIR . '/views/feed-sitemap-home.php' );
18
- }
19
-
20
- /**
21
- * set up the post types sitemap template
22
- */
23
- function xmlsf_load_template() {
24
- load_template( XMLSF_DIR . '/views/feed-sitemap-post_type.php' );
25
- }
26
-
27
- /**
28
- * set up the taxonomy sitemap template
29
- */
30
- function xmlsf_load_template_taxonomy() {
31
- load_template( XMLSF_DIR . '/views/feed-sitemap-taxonomy.php' );
32
- }
33
-
34
- /**
35
- * set up the custom sitemap template
36
- */
37
- function xmlsf_load_template_custom() {
38
- load_template( XMLSF_DIR . '/views/feed-sitemap-custom.php' );
39
- }
40
-
41
- /**
42
- * Do feed templates
43
- */
44
- function xmlsf_feed_templates() {
45
- $sitemaps = get_option( 'xmlsf_sitemaps' );
46
-
47
- if ( is_array($sitemaps) && isset($sitemaps['sitemap'])) {
48
- // setup feed templates
49
- add_action( 'do_feed_sitemap', 'xmlsf_load_template_index', 10, 1 );
50
- add_action( 'do_feed_sitemap_index', 'xmlsf_load_template_index', 10, 1 );
51
- add_action( 'do_feed_sitemap-home', 'xmlsf_load_template_home', 10, 1 );
52
- add_action( 'do_feed_sitemap-custom', 'xmlsf_load_template_custom', 10, 1 );
53
-
54
- $post_types = get_option('xmlsf_post_types');
55
- if ( is_array($post_types) ) {
56
- foreach ( $post_types as $post_type => $settings ) {
57
- if ( !empty($settings['active']) )
58
- add_action( 'do_feed_sitemap-posttype-'.$post_type, 'xmlsf_load_template', 10, 1 );
59
- }
60
- }
61
- foreach ( xmlsf_get_taxonomies() as $name ) {
62
- add_action( 'do_feed_sitemap-taxonomy-'.$name, 'xmlsf_load_template_taxonomy', 10, 1 );
63
- }
64
- }
65
- }
66
-
67
- /* -------------------------------------
68
- * MISSING WORDPRESS FUNCTIONS
69
- * ------------------------------------- */
70
-
71
- /**
72
- * Retrieve the date that the first post/page was published.
73
- * Variation of function get_lastpostdate, uses _get_post_time
74
- *
75
- * The server timezone is the default and is the difference between GMT and
76
- * server time. The 'blog' value is the date when the last post was posted. The
77
- * 'gmt' is when the last post was posted in GMT formatted date.
78
- *
79
- * @uses apply_filters() Calls 'get_firstpostdate' filter
80
- * @param string $timezone The location to get the time. Can be 'gmt', 'blog', or 'server'.
81
- * @param string $post_type Post type to check.
82
- * @return string The date of the last post.
83
- */
84
- if( !function_exists('get_firstpostdate') ) {
85
- function get_firstpostdate($timezone = 'server', $post_type = 'any') {
86
- return apply_filters( 'get_firstpostdate', _get_post_time( $timezone, 'date', $post_type, 'first' ), $timezone );
87
- }
88
- }
89
-
90
- /**
91
- * Retrieve last post/page modified date depending on timezone.
92
- * Variation of function get_lastpostmodified, uses _get_post_time
93
- *
94
- * The server timezone is the default and is the difference between GMT and
95
- * server time. The 'blog' value is the date when the last post was posted. The
96
- * 'gmt' is when the last post was posted in GMT formatted date.
97
- *
98
- * @uses apply_filters() Calls 'get_lastmodified' filter
99
- * @param string $timezone The location to get the time. Can be 'gmt', 'blog', or 'server'.
100
- * @return string The date of the oldest modified post.
101
- */
102
- if( !function_exists('get_lastmodified') ) {
103
- function get_lastmodified( $timezone = 'server', $post_type = 'any', $m = '' ) {
104
- return apply_filters( 'get_lastmodified', _get_post_time( $timezone, 'modified', $post_type, 'last', $m ), $timezone );
105
- }
106
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
controllers/{public/sitemap-news.php → sitemap-news.php} RENAMED
@@ -2,8 +2,8 @@
2
  /**
3
  * set up the news sitemap template
4
  */
5
- function xmlsf_load_template_news() {
6
  load_template( XMLSF_DIR . '/views/feed-sitemap-news.php' );
7
  }
8
 
9
- add_action('do_feed_sitemap-news', 'xmlsf_load_template_news', 10, 1);
2
  /**
3
  * set up the news sitemap template
4
  */
5
+ function xmlsf_news_load_template() {
6
  load_template( XMLSF_DIR . '/views/feed-sitemap-news.php' );
7
  }
8
 
9
+ add_action('do_feed_sitemap-news', 'xmlsf_news_load_template', 10, 1);
controllers/sitemap.php ADDED
@@ -0,0 +1,241 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /* ------------------------------
4
+ * XMLSF Controller CLASS
5
+ * ------------------------------ */
6
+
7
+ class XMLSF_Sitemap_Controller
8
+ {
9
+ /**
10
+ * Sitemap index name
11
+ * @var string
12
+ */
13
+ private $sitemap = 'sitemap.xml';
14
+
15
+ /**
16
+ * Post types included in sitemap index
17
+ * @var array
18
+ */
19
+ private $post_types;
20
+
21
+ /**
22
+ * CONSTRUCTOR
23
+ * Runs on init
24
+ */
25
+
26
+ function __construct( $sitemap )
27
+ {
28
+ $this->sitemap = $sitemap;
29
+
30
+ // Cache clearance
31
+ add_action( 'clean_post_cache', array($this,'clean_post_cache'), 99, 2 );
32
+
33
+ // Update term meta lastmod date
34
+ add_action( 'transition_post_status', array($this,'update_term_modified_meta'), 10, 3 );
35
+
36
+ // PINGING
37
+ add_action( 'transition_post_status', array($this,'do_pings'), 10, 3 );
38
+
39
+ // FEED TEMPLATES
40
+ add_action( 'do_feed_sitemap', 'xmlsf_load_template_index', 10, 1 );
41
+ add_action( 'do_feed_sitemap_index', 'xmlsf_load_template_index', 10, 1 );
42
+ add_action( 'do_feed_sitemap-home', 'xmlsf_load_template_home', 10, 1 );
43
+ add_action( 'do_feed_sitemap-custom', 'xmlsf_load_template_custom', 10, 1 );
44
+
45
+ $this->post_types = get_option( 'xmlsf_post_types' );
46
+
47
+ if ( is_array($this->post_types) ) {
48
+ foreach ( $this->post_types as $post_type => $settings ) {
49
+ if ( !empty($settings['active']) )
50
+ add_action( 'do_feed_sitemap-posttype-'.$post_type, 'xmlsf_load_template', 10, 1 );
51
+ }
52
+ }
53
+
54
+ foreach ( xmlsf_get_taxonomies() as $name ) {
55
+ add_action( 'do_feed_sitemap-taxonomy-'.$name, 'xmlsf_load_template_taxonomy', 10, 1 );
56
+ }
57
+ }
58
+
59
+ /**
60
+ * Do pings, hooked to transition post status
61
+ *
62
+ * @param $new_status
63
+ * @param $old_status
64
+ * @param $post
65
+ */
66
+ public function do_pings( $new_status, $old_status, $post ) {
67
+ // are we publishing?
68
+ if ( $old_status == 'publish' || $new_status != 'publish' )
69
+ return;
70
+
71
+ $ping = get_option( 'xmlsf_ping' );
72
+
73
+ if ( empty( $ping ) )
74
+ return;
75
+
76
+ // check if we've got a post type that is included in our sitemap
77
+ $post_types = get_option( 'xmlsf_post_types' );
78
+ if ( array_key_exists( $post->post_type, (array) $this->post_types ) ) {
79
+
80
+ foreach ( $ping as $se ) {
81
+ xmlsf_ping( $se, $this->sitemap, HOUR_IN_SECONDS );
82
+ }
83
+ }
84
+ }
85
+
86
+ /**
87
+ * Cache delete on clean_post_cache
88
+ *
89
+ * @param $post_ID
90
+ * @param $post
91
+ */
92
+ public function clean_post_cache( $post_ID, $post ) {
93
+ // are we moving the post in or out of published status?
94
+ wp_cache_delete( 'xmlsf_get_archives', 'general' );
95
+
96
+ // TODO get year / month here to delete specific keys too !!!!
97
+ $m = mysql2date( 'Ym', $post->post_date_gmt, false );
98
+ $y = substr( $m, 0, 4 );
99
+
100
+ // clear possible last post modified cache keys
101
+ wp_cache_delete( 'lastpostmodified:gmt', 'timeinfo' ); // should be handled by WP core?
102
+ wp_cache_delete( 'lastpostmodified'.$y.':gmt', 'timeinfo' );
103
+ wp_cache_delete( 'lastpostmodified'.$m.':gmt', 'timeinfo' );
104
+ wp_cache_delete( 'lastpostmodified'.$y.':gmt:'.$post->post_type, 'timeinfo' );
105
+ wp_cache_delete( 'lastpostmodified'.$m.':gmt:'.$post->post_type, 'timeinfo' );
106
+
107
+ // clear possible last post date cache keys
108
+ wp_cache_delete( 'lastpostdate:gmt', 'timeinfo' );
109
+ wp_cache_delete( 'lastpostdate:gmt:'.$post->post_type, 'timeinfo' );
110
+
111
+ // clear possible fist post date cache keys
112
+ wp_cache_delete( 'firstpostdate:gmt', 'timeinfo' );
113
+ wp_cache_delete( 'firstpostdate:gmt:'.$post->post_type, 'timeinfo' );
114
+ }
115
+
116
+ /**
117
+ * Update term modified meta, hooked to transition post status
118
+ *
119
+ * @param $new_status
120
+ * @param $old_status
121
+ * @param $post
122
+ */
123
+ public function update_term_modified_meta( $new_status, $old_status, $post ) {
124
+
125
+ // bail out on inactive post types
126
+ if ( ! array_key_exists($post->post_type, $this->post_types) || empty( $this->post_types[$post->post_type]['active'] ) )
127
+ return;
128
+
129
+ // bail out when not publishing or unpublishing or editing a live post
130
+ // note: prepend " $old_status == $new_status || " to exclude live editong too
131
+ if ( $new_status != 'publish' && $old_status != 'publish' )
132
+ return;
133
+
134
+ $taxonomy_settings = get_option( 'xmlsf_taxonomy_settings' );
135
+
136
+ // bail if no taxonomies activated
137
+ if ( ! is_array($taxonomy_settings) || empty( $taxonomy_settings['active'] ) )
138
+ return;
139
+
140
+ require_once XMLSF_DIR . '/models/public/sitemap.php';
141
+
142
+ $taxonomies = get_option( 'xmlsf_taxonomies' );
143
+ if ( empty( $taxonomies ) )
144
+ $taxonomies = xmlsf_public_taxonomies();
145
+
146
+ $term_ids = array();
147
+ foreach ( (array) $taxonomies as $tax_name ) {
148
+ $terms = wp_get_post_terms( $post->ID, $tax_name, array( 'fields' => 'ids' ));
149
+ if ( !is_wp_error($terms) ) {
150
+ $term_ids = array_merge( $term_ids, $terms );
151
+ }
152
+ }
153
+
154
+ $time = date('Y-m-d H:i:s');
155
+
156
+ foreach( $term_ids as $id ) {
157
+ update_term_meta( $id, 'term_modified_gmt', $time );
158
+ }
159
+ }
160
+
161
+ }
162
+
163
+ /**
164
+ * FEED TEMPLATES
165
+ */
166
+
167
+ /**
168
+ * Set up the sitemap index template
169
+ */
170
+ function xmlsf_load_template_index() {
171
+ load_template( XMLSF_DIR . '/views/feed-sitemap.php' );
172
+ }
173
+
174
+ /**
175
+ * set up the sitemap home page(s) template
176
+ */
177
+ function xmlsf_load_template_home() {
178
+ load_template( XMLSF_DIR . '/views/feed-sitemap-home.php' );
179
+ }
180
+
181
+ /**
182
+ * set up the post types sitemap template
183
+ */
184
+ function xmlsf_load_template() {
185
+ load_template( XMLSF_DIR . '/views/feed-sitemap-post_type.php' );
186
+ }
187
+
188
+ /**
189
+ * set up the taxonomy sitemap template
190
+ */
191
+ function xmlsf_load_template_taxonomy() {
192
+ load_template( XMLSF_DIR . '/views/feed-sitemap-taxonomy.php' );
193
+ }
194
+
195
+ /**
196
+ * set up the custom sitemap template
197
+ */
198
+ function xmlsf_load_template_custom() {
199
+ load_template( XMLSF_DIR . '/views/feed-sitemap-custom.php' );
200
+ }
201
+
202
+ /* -------------------------------------
203
+ * MISSING WORDPRESS FUNCTIONS
204
+ * ------------------------------------- */
205
+
206
+ /**
207
+ * Retrieve the date that the first post/page was published.
208
+ * Variation of function get_lastpostdate, uses _get_post_time
209
+ *
210
+ * The server timezone is the default and is the difference between GMT and
211
+ * server time. The 'blog' value is the date when the last post was posted. The
212
+ * 'gmt' is when the last post was posted in GMT formatted date.
213
+ *
214
+ * @uses apply_filters() Calls 'get_firstpostdate' filter
215
+ * @param string $timezone The location to get the time. Can be 'gmt', 'blog', or 'server'.
216
+ * @param string $post_type Post type to check.
217
+ * @return string The date of the last post.
218
+ */
219
+ if( !function_exists('get_firstpostdate') ) {
220
+ function get_firstpostdate($timezone = 'server', $post_type = 'any') {
221
+ return apply_filters( 'get_firstpostdate', _get_post_time( $timezone, 'date', $post_type, 'first' ), $timezone );
222
+ }
223
+ }
224
+
225
+ /**
226
+ * Retrieve last post/page modified date depending on timezone.
227
+ * Variation of function get_lastpostmodified, uses _get_post_time
228
+ *
229
+ * The server timezone is the default and is the difference between GMT and
230
+ * server time. The 'blog' value is the date when the last post was posted. The
231
+ * 'gmt' is when the last post was posted in GMT formatted date.
232
+ *
233
+ * @uses apply_filters() Calls 'get_lastmodified' filter
234
+ * @param string $timezone The location to get the time. Can be 'gmt', 'blog', or 'server'.
235
+ * @return string The date of the oldest modified post.
236
+ */
237
+ if( !function_exists('get_lastmodified') ) {
238
+ function get_lastmodified( $timezone = 'server', $post_type = 'any', $m = '' ) {
239
+ return apply_filters( 'get_lastmodified', _get_post_time( $timezone, 'modified', $post_type, 'last', $m ), $timezone );
240
+ }
241
+ }
controllers/upgrade.php ADDED
@@ -0,0 +1,178 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * XML Sitemap Feed upgrade routines
4
+ *
5
+ * @since 5.1
6
+ */
7
+ class XMLSitemapFeed_Upgrade {
8
+
9
+ /*
10
+ * constructor: manages upgrade
11
+ *
12
+ * @since 5.1
13
+ */
14
+ function __construct( $db_version = null )
15
+ {
16
+ // make sure rules are regenerated when admin is visited.
17
+ set_transient( 'xmlsf_flush_rewrite_rules', '' );
18
+ // static files checking
19
+ set_transient( 'xmlsf_check_static_files', '' );
20
+
21
+ if ( $db_version )
22
+ $this->upgrade( $db_version );
23
+ else
24
+ $this->install();
25
+
26
+ update_option( 'xmlsf_version', XMLSF_VERSION );
27
+ }
28
+
29
+ /*
30
+ * set up default plugin data
31
+ *
32
+ * @since 5.1
33
+ */
34
+ function install()
35
+ {
36
+ $defaults = xmlsf()->defaults();
37
+
38
+ foreach ( $defaults as $option => $default ) {
39
+ delete_option( 'xmlsf_'.$option );
40
+ if ( in_array( $option, array('ping','robots') ) )
41
+ add_option( 'xmlsf_'.$option, $default, null, false );
42
+ else
43
+ add_option( 'xmlsf_'.$option, $default );
44
+ }
45
+
46
+ // Kilroy was here
47
+ if ( defined('WP_DEBUG') && WP_DEBUG ) {
48
+ error_log('XML Sitemap Feeds version '.XMLSF_VERSION.' installed.');
49
+ }
50
+ }
51
+
52
+ /*
53
+ * upgrade plugin data
54
+ *
55
+ * @since 5.1
56
+ */
57
+ function upgrade( $db_version )
58
+ {
59
+ if ( version_compare( '4.4', $db_version, '>' ) ) {
60
+ // remove robots.txt rules blocking stylesheets
61
+ if ( $robot_rules = get_option( 'xmlsf_robots' ) ) {
62
+ $robot_rules = str_replace( array('Disallow: */wp-content/','Allow: */wp-content/uploads/'), '', $robot_rules );
63
+ delete_option( 'xmlsf_robots' );
64
+ add_option( 'xmlsf_robots', $robot_rules, null, false );
65
+ }
66
+
67
+ // make sure custom sitemaps is an array
68
+ $urls = get_option('xmlsf_custom_sitemaps');
69
+ if ( !is_array($urls) ) {
70
+ $urls = explode( PHP_EOL, $urls );
71
+ update_option('xmlsf_custom_sitemaps',$urls);
72
+ }
73
+
74
+ // register location taxonomies then delete all terms
75
+ register_taxonomy( 'gn-location-3', null );
76
+ $terms = get_terms( 'gn-location-3', array('hide_empty' => false) );
77
+ foreach ( $terms as $term ) {
78
+ wp_delete_term( $term->term_id, 'gn-location-3' );
79
+ }
80
+
81
+ register_taxonomy( 'gn-location-2', null );
82
+ $terms = get_terms( 'gn-location-2',array( 'hide_empty' => false ) );
83
+ foreach ( $terms as $term ) {
84
+ wp_delete_term( $term->term_id, 'gn-location-2' );
85
+ }
86
+
87
+ register_taxonomy( 'gn-location-1', null );
88
+ $terms = get_terms( 'gn-location-1',array( 'hide_empty' => false ) );
89
+ foreach ( $terms as $term ) {
90
+ wp_delete_term( $term->term_id, 'gn-location-1' );
91
+ }
92
+ }
93
+
94
+ if ( version_compare( '5.0.1', $db_version, '>' ) ) {
95
+ // delete all taxonomy terms
96
+ register_taxonomy( 'gn-genre', null );
97
+
98
+ $terms = get_terms( 'gn-genre', array( 'hide_empty' => false ) );
99
+
100
+ if ( is_array( $terms ) )
101
+ foreach ( $terms as $term )
102
+ wp_delete_term( $term->term_id, 'gn-genre' );
103
+
104
+ // new taxonomy settings
105
+ $taxonomies = get_option( 'xmlsf_taxonomies' );
106
+ if ( empty($taxonomies) ) {
107
+ $active = '';
108
+ } else {
109
+ $available = 0;
110
+ $checked = count($taxonomies);
111
+ foreach ( (array) get_option( 'xmlsf_post_types' ) as $post_type => $settings ) {
112
+ if ( empty($settings['active']) ) continue;
113
+ $taxonomies = get_object_taxonomies( $post_type, 'objects' );
114
+ // check each tax public flag and term count and append name to array
115
+ foreach ( $taxonomies as $taxonomy ) {
116
+ if ( !empty( $taxonomy->public ) && !in_array( $taxonomy->name, xmlsf()->disabled_taxonomies() ) )
117
+ $available++;
118
+ }
119
+ }
120
+ if ( $checked == $available )
121
+ update_option( 'xmlsf_taxonomies', '' );
122
+ $active = '1';
123
+ }
124
+ $taxonomy_settings = array(
125
+ 'active' => $active,
126
+ 'priority' => '0.3',
127
+ 'dynamic_priority' => '1',
128
+ 'term_limit' => '5000'
129
+ );
130
+ add_option( 'xmlsf_taxonomy_settings', $taxonomy_settings );
131
+
132
+ // update ping option
133
+ $ping = get_option( 'xmlsf_ping' );
134
+ $new = array( 'google', 'bing' );
135
+ if ( is_array($ping) ) {
136
+ foreach ( $ping as $key => $value ) {
137
+ if ( is_array($value) && empty( $value['active'] ) && isset( $new[$key] ) ) {
138
+ unset( $new[$key] );
139
+ }
140
+ }
141
+ }
142
+ update_option( 'xmlsf_ping', $new, false );
143
+
144
+ // make sure no pong option remains
145
+ delete_option( 'xmlsf_pong');
146
+
147
+ // update or create robots option
148
+ $robots = get_option( 'xmlsf_robots', '' );
149
+ delete_option( 'xmlsf_robots');
150
+ add_option( 'xmlsf_robots', $robots, null, false );
151
+ }
152
+
153
+ if ( version_compare( '5.0.2', $db_version, '>' ) ) {
154
+ $defaults = xmlsf()->defaults();
155
+
156
+ foreach ( $defaults as $option => $default ) {
157
+ if ( get_option( 'xmlsf_'.$option ) ) continue;
158
+ if ( in_array( $option, array('ping','robots') ) )
159
+ add_option( 'xmlsf_'.$option, $default, null, false );
160
+ else
161
+ add_option( 'xmlsf_'.$option, $default );
162
+ }
163
+
164
+ delete_option( 'xmlsf_version' );
165
+ }
166
+
167
+ if ( version_compare( '5.1', $db_version, '>' ) ) {
168
+ delete_transient('xmlsf_ping_google_sitemap_news');
169
+ delete_transient('xmlsf_ping_google_sitemap');
170
+ delete_transient('xmlsf_ping_bing_sitemap');
171
+ }
172
+
173
+ if ( defined('WP_DEBUG') && WP_DEBUG ) {
174
+ error_log('XML Sitemap Feeds upgraded from '.$db_version.' to '.XMLSF_VERSION);
175
+ }
176
+ }
177
+
178
+ }
models/admin/main.php CHANGED
@@ -1,59 +1,9 @@
1
  <?php
2
 
3
- /**
4
- * Nginx helper purge urls
5
- * adds sitemap urls to the purge array.
6
- *
7
- * @param $urls array
8
- * @param $redis bool|false
9
- *
10
- * @return $urls array
11
- */
12
- function xmlsf_nginx_helper_purge_urls( $urls = array(), $redis = false ) {
13
-
14
- if ( $redis ) {
15
- // wildcard allowed, this makes everything simple
16
- $urls[] = '/sitemap*.xml';
17
- } else {
18
- // no wildcard, go through the motions
19
- $sitemaps = get_option( 'xmlsf_sitemaps' );
20
-
21
- if ( !empty( $sitemaps['sitemap-news'] ) ) {
22
- $urls[] = '/sitemap-news.xml';
23
- }
24
-
25
- if ( !empty( $sitemaps['sitemap'] ) ) {
26
- $urls[] = '/sitemap.xml';
27
- $urls[] = '/sitemap-home.xml';
28
- $urls[] = '/sitemap-custom.xml';
29
-
30
- include_once XMLSF_DIR . '/models/public/sitemap.php';
31
-
32
- // add public post types sitemaps
33
- $post_types = get_option( 'xmlsf_post_types' );
34
- if ( is_array($post_types) )
35
- foreach ( $post_types as $post_type => $settings ) {
36
- $archive = !empty($settings['archive']) ? $settings['archive'] : '';
37
- foreach ( xmlsf_get_archives($post_type,$archive) as $url )
38
- $urls[] = parse_url( $url, PHP_URL_PATH);
39
- };
40
-
41
- // add public post taxonomies sitemaps
42
- $taxonomies = get_option('xmlsf_taxonomies');
43
- if ( is_array($taxonomies) )
44
- foreach ( $taxonomies as $taxonomy ) {
45
- $urls[] = parse_url( xmlsf_get_index_url('taxonomy',$taxonomy), PHP_URL_PATH);
46
- };
47
- }
48
- }
49
-
50
- return $urls;
51
- }
52
-
53
  // plugin action links
54
 
55
  function xmlsf_add_action_link( $links ) {
56
- $settings_link = '<a href="' . admin_url('options-reading.php') . '#blog_public">' . translate('Settings') . '</a>';
57
  array_unshift( $links, $settings_link );
58
  return $links;
59
  }
@@ -79,12 +29,7 @@ class XMLSF_Admin_Sanitize
79
  if ( !empty($new['sitemap-news']) && empty($old['sitemap-news'] ) ) {
80
  // check news tag settings
81
  if ( !get_option( 'xmlsf_news_tags' ) ) {
82
- add_option( 'xmlsf_news_tags', array(
83
- 'name' => '',
84
- 'post_type' => array('post'),
85
- 'categories' => '',
86
- 'image' => 'featured'
87
- ) );
88
  }
89
  }
90
  }
1
  <?php
2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3
  // plugin action links
4
 
5
  function xmlsf_add_action_link( $links ) {
6
+ $settings_link = '<a href="' . admin_url('options-reading.php') . '#xmlsf_sitemaps">' . translate('Settings') . '</a>';
7
  array_unshift( $links, $settings_link );
8
  return $links;
9
  }
29
  if ( !empty($new['sitemap-news']) && empty($old['sitemap-news'] ) ) {
30
  // check news tag settings
31
  if ( !get_option( 'xmlsf_news_tags' ) ) {
32
+ add_option( 'xmlsf_news_tags', xmlsf()->default_news_tags );
 
 
 
 
 
33
  }
34
  }
35
  }
models/admin/sitemap-news.php CHANGED
File without changes
models/admin/sitemap.php CHANGED
File without changes
models/class-xmlsitemapfeed.php CHANGED
@@ -8,6 +8,17 @@ class XMLSitemapFeed {
8
  */
9
  private $defaults = array();
10
 
 
 
 
 
 
 
 
 
 
 
 
11
  /**
12
  * Front pages
13
  *
@@ -60,14 +71,6 @@ class XMLSitemapFeed {
60
  */
61
  private $plain_permalinks = null;
62
 
63
- /**
64
- * Excluded post types
65
- *
66
- * post format taxonomy is disabled
67
- * @var array
68
- */
69
- private $disabled_post_types = array('attachment','reply');
70
-
71
  /**
72
  * Excluded taxonomies
73
  *
@@ -154,7 +157,7 @@ class XMLSitemapFeed {
154
  ),
155
  'taxonomies' => '',
156
  'taxonomy_settings' => array(
157
- 'active' => '1',
158
  'priority' => '0.3',
159
  'dynamic_priority' => '1',
160
  'term_limit' => '5000'
@@ -169,20 +172,6 @@ class XMLSitemapFeed {
169
  'domains' => ''
170
  );
171
 
172
- $post_types = apply_filters( 'xmlsf_post_types', get_post_types(array('public'=>true,'_builtin'=>false),'names') );
173
-
174
- // append public post_types defaults
175
- if ( is_array($post_types) )
176
- foreach ( $post_types as $name )
177
- $this->defaults['post_types'][$name] = array(
178
- //'name' => $name,
179
- 'active' => '',
180
- 'archive' => '',
181
- 'priority' => '0.5',
182
- 'dynamic_priority' => '',
183
- 'tags' => array( 'image' => 'attached' )
184
- );
185
-
186
  endif;
187
 
188
  if ( $key ) {
@@ -242,8 +231,6 @@ class XMLSitemapFeed {
242
  return $this->blog_language;
243
  }
244
 
245
-
246
-
247
  /**
248
  * Get scheme
249
  * @return string
@@ -258,19 +245,12 @@ class XMLSitemapFeed {
258
  return $this->scheme;
259
  }
260
 
261
- /**
262
- * Get disabled post types
263
- * @return array
264
- */
265
- public function disabled_post_types() {
266
- return $this->disabled_post_types;
267
- }
268
-
269
  /**
270
  * Get disabled taxonomies
271
  * @return array
272
  */
273
  public function disabled_taxonomies() {
274
- return $this->disabled_taxonomies;
275
  }
 
276
  }
8
  */
9
  private $defaults = array();
10
 
11
+ /**
12
+ * Defaults
13
+ * @var array
14
+ */
15
+ public $default_news_tags = array(
16
+ 'name' => '',
17
+ 'post_type' => array('post'),
18
+ 'categories' => '',
19
+ 'image' => 'featured'
20
+ );
21
+
22
  /**
23
  * Front pages
24
  *
71
  */
72
  private $plain_permalinks = null;
73
 
 
 
 
 
 
 
 
 
74
  /**
75
  * Excluded taxonomies
76
  *
157
  ),
158
  'taxonomies' => '',
159
  'taxonomy_settings' => array(
160
+ 'active' => '',
161
  'priority' => '0.3',
162
  'dynamic_priority' => '1',
163
  'term_limit' => '5000'
172
  'domains' => ''
173
  );
174
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
175
  endif;
176
 
177
  if ( $key ) {
231
  return $this->blog_language;
232
  }
233
 
 
 
234
  /**
235
  * Get scheme
236
  * @return string
245
  return $this->scheme;
246
  }
247
 
 
 
 
 
 
 
 
 
248
  /**
249
  * Get disabled taxonomies
250
  * @return array
251
  */
252
  public function disabled_taxonomies() {
253
+ return apply_filters( 'xmlsf_disabled_taxonomies', $this->disabled_taxonomies );
254
  }
255
+
256
  }
models/global.php CHANGED
@@ -1,5 +1,49 @@
1
  <?php
2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3
  /**
4
  * Filter robots.txt rules
5
  *
@@ -11,6 +55,7 @@ function xmlsf_robots_txt( $output ) {
11
 
12
  $sitemaps = get_option( 'xmlsf_sitemaps' );
13
 
 
14
  $pre = '# XML Sitemap & Google News version ' . XMLSF_VERSION . ' - https://status301.net/wordpress-plugins/xml-sitemap-feed/' . PHP_EOL;
15
  if ( '1' != get_option('blog_public') )
16
  $pre .= '# XML Sitemaps are disabled because of this site\'s privacy settings.' . PHP_EOL;
@@ -21,31 +66,16 @@ function xmlsf_robots_txt( $output ) {
21
  $pre .= 'Sitemap: ' . $url . $pretty . PHP_EOL;
22
  $pre .= PHP_EOL;
23
 
 
 
 
 
24
  $post = get_option('xmlsf_robots');
 
25
 
26
  return $pre . $output . $post;
27
  }
28
 
29
- /**
30
- * Get instantiated sitemap class
31
- *
32
- * @since 5.0
33
- * @global XMLSitemapFeed $xmlsf
34
- * @return XMLSitemapFeed object
35
- */
36
- function xmlsf() {
37
- global $xmlsf;
38
-
39
- if ( ! isset( $xmlsf ) ) {
40
- if ( ! class_exists( 'XMLSitemapFeed' ) )
41
- require XMLSF_DIR . '/models/class-xmlsitemapfeed.php';
42
-
43
- $xmlsf = new XMLSitemapFeed();
44
- }
45
-
46
- return $xmlsf;
47
- }
48
-
49
  /* -------------------------------------
50
  * CONDITIONAL FUNCTIONS
51
  * ------------------------------------- */
1
  <?php
2
 
3
+ /**
4
+ * Get instantiated sitemap class
5
+ *
6
+ * @since 5.0
7
+ * @global XMLSitemapFeed $xmlsf
8
+ * @return XMLSitemapFeed object
9
+ */
10
+ function xmlsf() {
11
+ global $xmlsf;
12
+
13
+ if ( ! isset( $xmlsf ) ) {
14
+ if ( ! class_exists( 'XMLSitemapFeed' ) )
15
+ require XMLSF_DIR . '/models/class-xmlsitemapfeed.php';
16
+
17
+ $xmlsf = new XMLSitemapFeed();
18
+ }
19
+
20
+ return $xmlsf;
21
+ }
22
+
23
+ /**
24
+ * Add sitemap rewrite rules
25
+ *
26
+ * @global object $wp_rewrite
27
+ * @param array $rewrite_rules
28
+ * @return array $rewrite_rules
29
+ */
30
+ function xmlsf_rewrite_rules( $rewrite_rules ) {
31
+ global $wp_rewrite;
32
+
33
+ $sitemaps = get_option( 'xmlsf_sitemaps' );
34
+
35
+ if ( isset($sitemaps['sitemap']) ) {
36
+ /* One rule to ring them all */
37
+ //add_rewrite_rule('sitemap(-[a-z0-9_\-]+)?\.([0-9]+\.)?xml$', $wp_rewrite->index . '?feed=sitemap$matches[1]&m=$matches[2]', 'top');
38
+ return array_merge( array( 'sitemap(\-[a-z0-9_\-]+)?(\.[0-9]+)?\.xml(\.gz)?$' => $wp_rewrite->index . '?feed=sitemap$matches[1]$matches[3]&m=$matches[2]' ), $rewrite_rules );
39
+ } elseif ( isset($sitemaps['sitemap-news']) ) {
40
+ //add_rewrite_rule('sitemap-news\.xml$', $wp_rewrite->index . '?feed=sitemap-news', 'top');
41
+ return array_merge( array( 'sitemap-news\.xml(\.gz)?$' => $wp_rewrite->index . '?feed=sitemap-news$matches[1]' ), $rewrite_rules );
42
+ }
43
+
44
+ return $rewrite_rules;
45
+ }
46
+
47
  /**
48
  * Filter robots.txt rules
49
  *
55
 
56
  $sitemaps = get_option( 'xmlsf_sitemaps' );
57
 
58
+ // PRE
59
  $pre = '# XML Sitemap & Google News version ' . XMLSF_VERSION . ' - https://status301.net/wordpress-plugins/xml-sitemap-feed/' . PHP_EOL;
60
  if ( '1' != get_option('blog_public') )
61
  $pre .= '# XML Sitemaps are disabled because of this site\'s privacy settings.' . PHP_EOL;
66
  $pre .= 'Sitemap: ' . $url . $pretty . PHP_EOL;
67
  $pre .= PHP_EOL;
68
 
69
+ // DEFAULT
70
+ if ( substr($output, -1) !== PHP_EOL ) $output .= PHP_EOL;
71
+
72
+ // POST
73
  $post = get_option('xmlsf_robots');
74
+ if ( $post !== '' ) $post .= PHP_EOL;
75
 
76
  return $pre . $output . $post;
77
  }
78
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
79
  /* -------------------------------------
80
  * CONDITIONAL FUNCTIONS
81
  * ------------------------------------- */
models/main.php CHANGED
@@ -14,8 +14,7 @@ function xmlsf_filter_request( $request ) {
14
  // make sure we have the proper locale setting for calculations
15
  setlocale( LC_NUMERIC, 'C' );
16
 
17
- require_once XMLSF_DIR . '/controllers/public/shared.php';
18
- require_once XMLSF_DIR . '/models/public/shared.php';
19
 
20
  // set the sitemap conditional flag
21
  xmlsf()->is_sitemap = true;
@@ -30,7 +29,8 @@ function xmlsf_filter_request( $request ) {
30
  $request['update_post_term_cache'] = false;
31
  $request['update_post_meta_cache'] = false;
32
 
33
- // Polylang compat
 
34
  $request['lang'] = '';
35
  // WPML compat
36
  global $wpml_query_filter;
@@ -39,19 +39,24 @@ function xmlsf_filter_request( $request ) {
39
  remove_filter( 'posts_where', array( $wpml_query_filter, 'posts_where_filter' ) );
40
  add_action( 'the_post', 'xmlsf_wpml_language_switcher' );
41
  }
 
 
42
 
43
- if ( $request['feed'] == 'sitemap-news' ) {
 
 
 
 
 
 
44
  // set the news sitemap conditional flag
45
  xmlsf()->is_news = true;
46
 
47
- require_once XMLSF_DIR . '/controllers/public/sitemap-news.php';
48
- require_once XMLSF_DIR . '/models/public/sitemap-news.php';
49
- $request = xmlsf_sitemap_news_filter_request( $request );
50
  } else {
51
- require_once XMLSF_DIR . '/controllers/public/sitemap.php';
52
  require_once XMLSF_DIR . '/models/public/sitemap.php';
53
- xmlsf_feed_templates();
54
- $request = xmlsf_sitemap_filter_request( $request );
55
  }
56
 
57
  endif;
@@ -74,33 +79,94 @@ function xmlsf_untrailingslash( $request ) {
74
  }
75
 
76
  /**
77
- * Filter sitemap post types
78
  *
79
- * @since 5.0
80
- * @param $post_types array
81
- * @return array
 
 
82
  */
83
- function xmlsf_filter_post_types( $post_types ) {
84
- foreach ( xmlsf()->disabled_post_types() as $post_type ) {
85
- if ( isset( $post_types[$post_type]) )
86
- unset( $post_types[$post_type] );
 
 
 
87
  }
 
 
 
 
 
 
 
 
 
 
88
 
89
- return array_filter( $post_types );
 
 
 
 
 
 
 
 
 
 
 
 
90
  }
91
 
92
  /**
93
- * Filter news post types
 
 
 
 
94
  *
95
- * @since 5.0
96
- * @param $post_types array
97
- * @return array
98
  */
99
- function xmlsf_news_filter_post_types( $post_types ) {
100
- foreach ( array('attachment','page') as $post_type ) {
101
- if ( isset( $post_types[$post_type]) )
102
- unset( $post_types[$post_type] );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
103
  }
104
 
105
- return array_filter( $post_types );
106
  }
14
  // make sure we have the proper locale setting for calculations
15
  setlocale( LC_NUMERIC, 'C' );
16
 
17
+ require XMLSF_DIR . '/models/public/shared.php';
 
18
 
19
  // set the sitemap conditional flag
20
  xmlsf()->is_sitemap = true;
29
  $request['update_post_term_cache'] = false;
30
  $request['update_post_meta_cache'] = false;
31
 
32
+ // PLUGIN COMPATIBILITIES
33
+ // Polylang
34
  $request['lang'] = '';
35
  // WPML compat
36
  global $wpml_query_filter;
39
  remove_filter( 'posts_where', array( $wpml_query_filter, 'posts_where_filter' ) );
40
  add_action( 'the_post', 'xmlsf_wpml_language_switcher' );
41
  }
42
+ // bbPress
43
+ remove_filter( 'bbp_request', 'bbp_request_feed_trap' );
44
 
45
+ // check for gz request
46
+ if ( substr($request['feed'], -3) == '.gz' ) {
47
+ $request['feed'] = substr($request['feed'], 0, -3);
48
+ xmlsf_ob_gzhandler();
49
+ }
50
+
51
+ if ( strpos($request['feed'],'sitemap-news') === 0 ) {
52
  // set the news sitemap conditional flag
53
  xmlsf()->is_news = true;
54
 
55
+ require XMLSF_DIR . '/models/public/sitemap-news.php';
56
+ $request = xmlsf_sitemap_news_parse_request( $request );
 
57
  } else {
 
58
  require_once XMLSF_DIR . '/models/public/sitemap.php';
59
+ $request = xmlsf_sitemap_parse_request( $request );
 
60
  }
61
 
62
  endif;
79
  }
80
 
81
  /**
82
+ * Ping
83
  *
84
+ * @since 5.1
85
+ * @param $se google|bing
86
+ * @param $sitemap sitemap
87
+ * @param $interval seconds
88
+ * @return string ping response|999 (postponed)
89
  */
90
+ function xmlsf_ping( $se, $sitemap, $interval ) {
91
+ if ( 'google' == $se ) {
92
+ $url = 'https://www.google.com/ping';
93
+ } elseif ( 'bing' == $se ) {
94
+ $url = 'https://www.bing.com/ping';
95
+ } else {
96
+ return '';
97
  }
98
+ $url = add_query_arg( 'sitemap', urlencode( trailingslashit( get_bloginfo( 'url' ) ) . $sitemap ), $url );
99
+
100
+ // check if we did not ping already within the interval
101
+ if ( false === get_transient( 'xmlsf_ping_'.$se.'_'.$sitemap ) ) {
102
+ // Ping !
103
+ $response = wp_remote_request( $url );
104
+ $code = wp_remote_retrieve_response_code( $response );
105
+ if ( 200 === $code ) {
106
+ set_transient( 'xmlsf_ping_'.$se.'_'.$sitemap, '', $interval );
107
+ }
108
 
109
+ if ( defined('WP_DEBUG') && WP_DEBUG == true ) {
110
+ error_log( 'Pinged '. $url .' with response code: ' . $code );
111
+ }
112
+ } else {
113
+ $code = 999;
114
+ if ( defined('WP_DEBUG') && WP_DEBUG == true ) {
115
+ error_log( 'Ping '. $se .' skipped.' );
116
+ }
117
+ }
118
+
119
+ do_action( 'xmlsf_ping', $se, $sitemap, $url, $code );
120
+
121
+ return $code;
122
  }
123
 
124
  /**
125
+ * Nginx helper purge urls
126
+ * adds sitemap urls to the purge array.
127
+ *
128
+ * @param $urls array
129
+ * @param $redis bool|false
130
  *
131
+ * @return $urls array
 
 
132
  */
133
+ function xmlsf_nginx_helper_purge_urls( $urls = array(), $redis = false ) {
134
+
135
+ if ( $redis ) {
136
+ // wildcard allowed, this makes everything simple
137
+ $urls[] = '/sitemap*.xml';
138
+ } else {
139
+ // no wildcard, go through the motions
140
+ $sitemaps = get_option( 'xmlsf_sitemaps' );
141
+
142
+ if ( !empty( $sitemaps['sitemap-news'] ) ) {
143
+ $urls[] = '/sitemap-news.xml';
144
+ }
145
+
146
+ if ( !empty( $sitemaps['sitemap'] ) ) {
147
+ $urls[] = '/sitemap.xml';
148
+ $urls[] = '/sitemap-home.xml';
149
+ $urls[] = '/sitemap-custom.xml';
150
+
151
+ require_once XMLSF_DIR . '/models/public/sitemap.php';
152
+
153
+ // add public post types sitemaps
154
+ $post_types = get_option( 'xmlsf_post_types' );
155
+ if ( is_array($post_types) )
156
+ foreach ( $post_types as $post_type => $settings ) {
157
+ $archive = !empty($settings['archive']) ? $settings['archive'] : '';
158
+ foreach ( xmlsf_get_archives($post_type,$archive) as $url )
159
+ $urls[] = parse_url( $url, PHP_URL_PATH);
160
+ };
161
+
162
+ // add public post taxonomies sitemaps
163
+ $taxonomies = get_option('xmlsf_taxonomies');
164
+ if ( is_array($taxonomies) )
165
+ foreach ( $taxonomies as $taxonomy ) {
166
+ $urls[] = parse_url( xmlsf_get_index_url('taxonomy',$taxonomy), PHP_URL_PATH);
167
+ };
168
+ }
169
  }
170
 
171
+ return $urls;
172
  }
models/public/shared.php CHANGED
File without changes
models/public/sitemap-news.php CHANGED
@@ -37,7 +37,7 @@ function xmlsf_news_filter_no_news_limits( $limits ) {
37
  *
38
  * @return mixed
39
  */
40
- function xmlsf_sitemap_news_filter_request( $request ) {
41
 
42
  // prepare for news and return modified request
43
  $options = get_option( 'xmlsf_news_tags' );
@@ -45,8 +45,8 @@ function xmlsf_sitemap_news_filter_request( $request ) {
45
  $post_types = apply_filters( 'xmlsf_news_post_types', $post_types);
46
 
47
  // disable caching
48
- define('DONOTCACHEPAGE', true);
49
- define('DONOTCACHEDB', true);
50
 
51
  // set up query filters
52
  $live = false;
37
  *
38
  * @return mixed
39
  */
40
+ function xmlsf_sitemap_news_parse_request( $request ) {
41
 
42
  // prepare for news and return modified request
43
  $options = get_option( 'xmlsf_news_tags' );
45
  $post_types = apply_filters( 'xmlsf_news_post_types', $post_types);
46
 
47
  // disable caching
48
+ if ( ! defined('DONOTCACHEPAGE') ) define('DONOTCACHEPAGE', true);
49
+ if ( ! defined('DONOTCACHEDB') ) define('DONOTCACHEDB', true);
50
 
51
  // set up query filters
52
  $live = false;
models/public/sitemap.php CHANGED
@@ -300,8 +300,8 @@ function xmlsf_get_priority( $sitemap = 'post_type', $term = '' ) {
300
  }
301
 
302
  // increase by relative comment count
303
- if ( $post->comment_count > 0 && $priority <= 0.9 ) {
304
- $priority += 0.1 + ( 0.9 - $priority ) * $post->comment_count / wp_count_comments($post->post_type)->approved;
305
  }
306
  }
307
 
@@ -375,7 +375,7 @@ function xmlsf_set_terms_args( $args ) {
375
  *
376
  * @return mixed
377
  */
378
- function xmlsf_sitemap_filter_request( $request ) {
379
 
380
  $feed = explode( '-' ,$request['feed'], 3 );
381
 
@@ -433,6 +433,31 @@ function xmlsf_sitemap_filter_request( $request ) {
433
  return $request;
434
  }
435
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
436
  /**
437
  * Get archives
438
  *
@@ -447,106 +472,36 @@ function xmlsf_get_archives( $post_type = 'post', $type = '' ) {
447
 
448
  if ( 'monthly' == $type ) :
449
 
450
- $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";
451
- $key = md5($query);
452
- $cache = wp_cache_get( 'xmlsf_get_archives' , 'general');
453
-
454
- if ( !isset( $cache[ $key ] ) ) {
455
- $arcresults = $wpdb->get_results($query);
456
- $cache[ $key ] = $arcresults;
457
- wp_cache_set( 'xmlsf_get_archives', $cache, 'general' );
458
- } else {
459
- $arcresults = $cache[ $key ];
460
- }
461
 
462
- if ( $arcresults ) {
463
- foreach ( (array) $arcresults as $arcresult ) {
464
- $return[$arcresult->year.$arcresult->month] = xmlsf_get_index_url( 'posttype', $post_type, $arcresult->year . $arcresult->month );
465
- }
466
  };
467
 
468
  elseif ( 'yearly' == $type ) :
469
 
470
- $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";
471
- $key = md5($query);
472
- $cache = wp_cache_get( 'xmlsf_get_archives' , 'general');
473
 
474
- if ( !isset( $cache[ $key ] ) ) {
475
- $arcresults = $wpdb->get_results($query);
476
- $cache[ $key ] = $arcresults;
477
- wp_cache_set( 'xmlsf_get_archives', $cache, 'general' );
478
- } else {
479
- $arcresults = $cache[ $key ];
480
- }
481
-
482
- if ( $arcresults ) {
483
- foreach ( (array) $arcresults as $arcresult) {
484
- $return[$arcresult->year] = xmlsf_get_index_url( 'posttype', $post_type, $arcresult->year );
485
- }
486
  };
487
 
488
  else :
489
 
490
- $return[0] = xmlsf_get_index_url('posttype', $post_type); // $sitemap = 'home', $type = false, $param = false
 
 
 
 
 
491
 
492
  endif;
493
 
494
  return $return;
495
  }
496
 
497
- /**
498
- * Get taxonomies
499
- * Returns an array of taxonomy names to be included in the index
500
- *
501
- * @since 5.0
502
- * @param void
503
- * @return array
504
- */
505
- function xmlsf_get_taxonomies() {
506
- $taxonomy_settings = get_option('xmlsf_taxonomy_settings');
507
- $tax_array = array();
508
- if ( !empty( $taxonomy_settings['active'] ) ) {
509
- $taxonomies = get_option('xmlsf_taxonomies');
510
- if ( is_array($taxonomies) ) {
511
- foreach ( $taxonomies as $taxonomy ) {
512
- $count = wp_count_terms( $taxonomy, array('hide_empty'=>true) );
513
- if ( !is_wp_error($count) && $count > 0 )
514
- $tax_array[] = $taxonomy;
515
- }
516
- } else {
517
- foreach ( xmlsf_public_taxonomies() as $name => $label )
518
- if ( 0 < wp_count_terms( $name, array('hide_empty'=>true) ) )
519
- $tax_array[] = $name;
520
- }
521
- }
522
- return $tax_array;
523
- }
524
-
525
- /**
526
- * Get all public (and not empty) taxonomies
527
- * Returns an array associated taxonomy object names and labels.
528
- *
529
- * @since 5.0
530
- * @param void
531
- * @return array
532
- */
533
- function xmlsf_public_taxonomies() {
534
- $tax_array = array();
535
-
536
- foreach ( (array) get_option( 'xmlsf_post_types' ) as $post_type => $settings ) {
537
- if ( empty($settings['active']) ) continue;
538
-
539
- $taxonomies = get_object_taxonomies( $post_type, 'objects' );
540
- // check each tax public flag and term count and append name to array
541
- foreach ( $taxonomies as $taxonomy ) {
542
- if ( !empty( $taxonomy->public ) && !in_array( $taxonomy->name, xmlsf()->disabled_taxonomies() ) )
543
- $tax_array[$taxonomy->name] = $taxonomy->label;
544
- }
545
- }
546
-
547
- return $tax_array;
548
- }
549
-
550
  /* -------------------------------------
551
  * MISSING WORDPRESS FUNCTIONS
552
  * ------------------------------------- */
300
  }
301
 
302
  // increase by relative comment count
303
+ if ( $post->comment_count > 0 && $priority < 1 ) {
304
+ $priority += 0.1 + ( 1 - $priority ) * $post->comment_count / wp_count_comments($post->post_type)->approved;
305
  }
306
  }
307
 
375
  *
376
  * @return mixed
377
  */
378
+ function xmlsf_sitemap_parse_request( $request ) {
379
 
380
  $feed = explode( '-' ,$request['feed'], 3 );
381
 
433
  return $request;
434
  }
435
 
436
+ /**
437
+ * Get archives from wp_cache
438
+ *
439
+ * @param string $post_type
440
+ * @param string $type
441
+ *
442
+ * @return array
443
+ */
444
+ function xmlsf_cache_get_archives( $query ) {
445
+ global $wpdb;
446
+
447
+ $key = md5($query);
448
+ $cache = wp_cache_get( 'xmlsf_get_archives' , 'general');
449
+
450
+ if ( !isset( $cache[ $key ] ) ) {
451
+ $arcresults = $wpdb->get_results($query);
452
+ $cache[ $key ] = $arcresults;
453
+ wp_cache_set( 'xmlsf_get_archives', $cache, 'general' );
454
+ } else {
455
+ $arcresults = $cache[ $key ];
456
+ }
457
+
458
+ return $arcresults;
459
+ }
460
+
461
  /**
462
  * Get archives
463
  *
472
 
473
  if ( 'monthly' == $type ) :
474
 
475
+ $query = "SELECT YEAR(post_date) as `year`, LPAD(MONTH(post_date),2,'0') as `month`, count(ID) as posts FROM {$wpdb->posts} WHERE post_type = '{$post_type}' AND post_status = 'publish' GROUP BY YEAR(post_date), MONTH(post_date) ORDER BY post_date DESC";
476
+ $arcresults = xmlsf_cache_get_archives( $query );
 
 
 
 
 
 
 
 
 
477
 
478
+ foreach ( (array) $arcresults as $arcresult ) {
479
+ $return[$arcresult->year.$arcresult->month] = xmlsf_get_index_url( 'posttype', $post_type, $arcresult->year . $arcresult->month );
 
 
480
  };
481
 
482
  elseif ( 'yearly' == $type ) :
483
 
484
+ $query = "SELECT YEAR(post_date) as `year`, count(ID) as posts FROM {$wpdb->posts} WHERE post_type = '{$post_type}' AND post_status = 'publish' GROUP BY YEAR(post_date) ORDER BY post_date DESC";
485
+ $arcresults = xmlsf_cache_get_archives( $query );
 
486
 
487
+ foreach ( (array) $arcresults as $arcresult ) {
488
+ $return[$arcresult->year] = xmlsf_get_index_url( 'posttype', $post_type, $arcresult->year );
 
 
 
 
 
 
 
 
 
 
489
  };
490
 
491
  else :
492
 
493
+ $query = "SELECT count(ID) as posts FROM {$wpdb->posts} WHERE post_type = '{$post_type}' AND post_status = 'publish' ORDER BY post_date DESC";
494
+ $arcresults = xmlsf_cache_get_archives( $query );
495
+
496
+ if ( is_object($arcresults[0]) && $arcresults[0]->posts > 0 ) {
497
+ $return[] = xmlsf_get_index_url( 'posttype', $post_type ); // $sitemap = 'home', $type = false, $param = false
498
+ };
499
 
500
  endif;
501
 
502
  return $return;
503
  }
504
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
505
  /* -------------------------------------
506
  * MISSING WORDPRESS FUNCTIONS
507
  * ------------------------------------- */
models/sitemap-news.php ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Filter news post types
5
+ *
6
+ * @since 5.0
7
+ * @param $post_types array
8
+ * @return array
9
+ */
10
+ function xmlsf_news_filter_post_types( $post_types ) {
11
+ foreach ( array('attachment','page','reply') as $post_type ) {
12
+ if ( isset( $post_types[$post_type]) )
13
+ unset( $post_types[$post_type] );
14
+ }
15
+
16
+ return array_filter( $post_types );
17
+ }
models/sitemap.php ADDED
@@ -0,0 +1,68 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Filter sitemap post types
5
+ *
6
+ * @since 5.0
7
+ * @param $post_types array
8
+ * @return array
9
+ */
10
+ function xmlsf_filter_post_types( $post_types ) {
11
+ // Always exclude attachment and reply post types (bbpress)
12
+ unset( $post_types['attachment'], $post_types['reply'] );
13
+
14
+ return array_filter( $post_types );
15
+ }
16
+
17
+ /**
18
+ * Get taxonomies
19
+ * Returns an array of taxonomy names to be included in the index
20
+ *
21
+ * @since 5.0
22
+ * @param void
23
+ * @return array
24
+ */
25
+ function xmlsf_get_taxonomies() {
26
+ $taxonomy_settings = get_option('xmlsf_taxonomy_settings');
27
+ $tax_array = array();
28
+ if ( !empty( $taxonomy_settings['active'] ) ) {
29
+ $taxonomies = get_option('xmlsf_taxonomies');
30
+ if ( is_array($taxonomies) ) {
31
+ foreach ( $taxonomies as $taxonomy ) {
32
+ $count = wp_count_terms( $taxonomy, array('hide_empty'=>true) );
33
+ if ( !is_wp_error($count) && $count > 0 )
34
+ $tax_array[] = $taxonomy;
35
+ }
36
+ } else {
37
+ foreach ( xmlsf_public_taxonomies() as $name => $label )
38
+ if ( 0 < wp_count_terms( $name, array('hide_empty'=>true) ) )
39
+ $tax_array[] = $name;
40
+ }
41
+ }
42
+ return $tax_array;
43
+ }
44
+
45
+ /**
46
+ * Get all public (and not empty) taxonomies
47
+ * Returns an array associated taxonomy object names and labels.
48
+ *
49
+ * @since 5.0
50
+ * @param void
51
+ * @return array
52
+ */
53
+ function xmlsf_public_taxonomies() {
54
+ $tax_array = array();
55
+
56
+ foreach ( (array) get_option( 'xmlsf_post_types' ) as $post_type => $settings ) {
57
+ if ( empty($settings['active']) ) continue;
58
+
59
+ $taxonomies = get_object_taxonomies( $post_type, 'objects' );
60
+ // check each tax public flag and term count and append name to array
61
+ foreach ( $taxonomies as $taxonomy ) {
62
+ if ( !empty( $taxonomy->public ) && !in_array( $taxonomy->name, xmlsf()->disabled_taxonomies() ) )
63
+ $tax_array[$taxonomy->name] = $taxonomy->label;
64
+ }
65
+ }
66
+
67
+ return $tax_array;
68
+ }
readme.txt CHANGED
@@ -4,8 +4,8 @@ Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=ravan
4
  Tags: sitemap, xml sitemap, news sitemap, sitemap.xml, robots.txt, Google, Google News, Yahoo, Bing, Yandex, Baidu, seo, feed, Polylang, WPML, image sitemap
5
  Requires at least: 4.4
6
  Requires PHP: 5.4
7
- Tested up to: 5.0
8
- Stable tag: 5.0.7
9
 
10
  XML and Google News Sitemaps to feed the hungry spiders. Multisite, WP Super Cache, Polylang and WPML compatible.
11
 
@@ -54,6 +54,16 @@ Please read the FAQ's for info on how to get your articles listed on Google News
54
  * Options to: set a different News Publication Name, include custom post types or limit inclusion to certain post categories.
55
  * Pings both Google and Bing on new publications.
56
 
 
 
 
 
 
 
 
 
 
 
57
  = Privacy / GDPR =
58
 
59
  This plugin does not collect any user or visitor data nor set browser cookies. Using this plugin should not impact your site privacy policy in any way.
@@ -279,12 +289,30 @@ Yes. In fact, it has been designed for it. Tested on WPMU 2.9.2 and WPMS 3+ both
279
 
280
  == Upgrade Notice ==
281
 
282
- = 5.0.7 =
 
 
283
 
284
- Bugfix release.
285
 
286
  == Changelog ==
287
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
288
  = 5.0.7 =
289
  * Allowed domains back to Settings > Reading
290
  * FIX static files check on activation
4
  Tags: sitemap, xml sitemap, news sitemap, sitemap.xml, robots.txt, Google, Google News, Yahoo, Bing, Yandex, Baidu, seo, feed, Polylang, WPML, image sitemap
5
  Requires at least: 4.4
6
  Requires PHP: 5.4
7
+ Tested up to: 5.1
8
+ Stable tag: 5.1
9
 
10
  XML and Google News Sitemaps to feed the hungry spiders. Multisite, WP Super Cache, Polylang and WPML compatible.
11
 
54
  * Options to: set a different News Publication Name, include custom post types or limit inclusion to certain post categories.
55
  * Pings both Google and Bing on new publications.
56
 
57
+ = Pro Features =
58
+
59
+ **[Google News Advanced](https://premium.status301.net/downloads/google-news-advanced/)**
60
+
61
+ * Multiple post types - Include more than one post type in the same News Sitemap.
62
+ * Keywords - Add the keywords tag to your News Sitemap. Keywords can be created from Tags, Categories or a dedicated Keywords taxonomy.
63
+ * Stock tickers - Add stock tickers tag to your News Sitemap. A dedicated Stock Tickers taxonomy will be available to manage them.
64
+ * Ping log - Keep a log of the latest pings to Google with exact date and response status.
65
+
66
+
67
  = Privacy / GDPR =
68
 
69
  This plugin does not collect any user or visitor data nor set browser cookies. Using this plugin should not impact your site privacy policy in any way.
289
 
290
  == Upgrade Notice ==
291
 
292
+ = 5.1 =
293
+
294
+ New filter and action hooks. Bugfixes and admin UI improvements.
295
 
 
296
 
297
  == Changelog ==
298
 
299
+ = 5.1.1 =
300
+ * FIX options page not found.
301
+
302
+ = 5.1 =
303
+ * SEOPress and Catch Box incompatibility admin messages
304
+ * FIX bbPress incompatibility
305
+ * FIX failing last modified date for taxonomy sitemaps
306
+ * FIX sitemap showing when only private posts
307
+ * FIX possible sitemaps for no longer existing post types in index
308
+ * Admin interface improvements: highlighting and scroll
309
+ * Upgrade routines in own class only to be included when needed
310
+ * Moved metabox methods to dedicated classes
311
+ * NEW Respond to .gz requests (with ob_gzhandler output buffering if needed)
312
+ * NEW filters xmlsf_disabled_taxonomies, xmlsf_news_keywords, xmlsf_news_stock_tickers
313
+ * NEW action xmlsf_ping
314
+ * NEW Tools: Ping search engines and Flush rewrite rules
315
+
316
  = 5.0.7 =
317
  * Allowed domains back to Settings > Reading
318
  * FIX static files check on activation
uninstall.php CHANGED
@@ -53,7 +53,7 @@ class XMLSitemapFeed_Uninstall {
53
  function uninstall($blog_id = false)
54
  {
55
  // remove plugin settings
56
- delete_option('xmlsf_static_files');
57
  delete_option('xmlsf_version');
58
  delete_option('xmlsf_sitemaps');
59
  delete_option('xmlsf_post_types');
@@ -66,8 +66,9 @@ class XMLSitemapFeed_Uninstall {
66
  delete_option('xmlsf_domains');
67
  delete_option('xmlsf_news_tags');
68
 
69
- // make rewrite rules update at the appropriate time
70
- delete_option('rewrite_rules');
 
71
 
72
  // Kilroy was here
73
  if ( defined('WP_DEBUG') && WP_DEBUG ) {
53
  function uninstall($blog_id = false)
54
  {
55
  // remove plugin settings
56
+ delete_transient('xmlsf_static_files');
57
  delete_option('xmlsf_version');
58
  delete_option('xmlsf_sitemaps');
59
  delete_option('xmlsf_post_types');
66
  delete_option('xmlsf_domains');
67
  delete_option('xmlsf_news_tags');
68
 
69
+ // remove filter and flush rules
70
+ remove_filter( 'rewrite_rules_array', 'xmlsf_rewrite_rules', 1, 1 );
71
+ flush_rewrite_rules();
72
 
73
  // Kilroy was here
74
  if ( defined('WP_DEBUG') && WP_DEBUG ) {
views/_generator.php CHANGED
File without changes
views/_usage.php CHANGED
File without changes
views/admin/field-news-categories.php CHANGED
File without changes
views/admin/field-news-image.php CHANGED
File without changes
views/admin/field-news-keywords.php ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <fieldset>
2
+ <legend class="screen-reader-text">
3
+ <?php _e('Keywords','xml-sitemap-feed'); ?>
4
+ </legend>
5
+ <label><?php _e('Use keywords from','xml-sitemap-feed'); ?>
6
+ <select name="" disabled="disabled">
7
+ <option value=""><?php echo translate('None'); ?></option>
8
+ </select>
9
+ </label>
10
+ <p class="description">
11
+ <?php printf( /* Translators: Sitemap tag name, Advanced plugin name */ __('%1$s are provided by the %2$s module.','xml-sitemap-feed'), __('Keywords','xml-sitemap-feed') ,'<a href="https://premium.status301.net/downloads/google-news-advanced/" target="_blank">'.__('Google News Advanced','xml-sitemap-feed').'</a>'); ?>
12
+ </p>
13
+ </fieldset>
views/admin/field-news-labels.php CHANGED
File without changes
views/admin/field-news-name.php CHANGED
File without changes
views/admin/field-news-ping-log.php ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <fieldset>
2
+ <legend class="screen-reader-text">
3
+ <?php _e('Ping log','xml-sitemap-feed'); ?>
4
+ </legend>
5
+ <p>
6
+ <label>
7
+ <input type="checkbox" id="xmlsf_news_ping_log" value="1" disabled="disabled" />
8
+ <?php _e('Enable Google News ping log', 'xml-sitemap-feed'); ?>
9
+ </label>
10
+ </p>
11
+ <p>
12
+ <label>
13
+ <?php _e('Maximum log entries','xml-sitemap-feed'); ?>
14
+ <input type="number" step="1" min="0" max="10000" id="xmlsf_news_ping_log_max" value="1000" class="medium-text" />
15
+ </label>
16
+ </p>
17
+ <p class="description">
18
+ <?php _e('Keep a log of all News Sitemap pings to Google and their responses. The log entries are stored in the database so keep the maximum number as low as is useful for you. Disabling the ping log will clear all log entries from the database.','xml-sitemap-feed'); ?>
19
+ </p>
20
+ </fieldset>
views/admin/field-news-post-type.php CHANGED
@@ -1,23 +1,15 @@
1
  <fieldset>
2
  <legend class="screen-reader-text"><?php _e('Post type','xml-sitemap-feed'); ?></legend>
3
- <?php
4
- foreach ( $post_types as $post_type ) :
5
- $obj = get_post_type_object( $post_type );
6
- if ( !is_object( $obj ) )
7
- continue;
8
- ?>
9
- <label>
10
- <input type="<?php echo $type; ?>" name="xmlsf_news_tags[post_type][]" id="xmlsf_post_type_<?php echo $obj->name; ?>" value="<?php echo $obj->name; ?>"<?php checked( in_array($obj->name, $news_post_type), true ) . disabled( !in_array($obj->name,$allowed), true ); ?> />
11
- <?php echo $obj->label; ?>
12
- </label>
13
- <br/>
14
- <?php
15
- endforeach;
16
- ?>
17
- <?php //printf(__('At least one post type must be selected. By default, the post type %s will be used.','xml-sitemap-feed'),translate('Posts')); ?>
18
- <?php if ( $do_warning ) { ?>
19
- <p class="description">
20
- <?php _e('Custom post types that do <strong>not</strong> use the post category taxonomy cannot be included as long as any category is selected below.','xml-sitemap-feed'); ?>
21
- </p>
22
- <?php } ?>
23
  </fieldset>
1
  <fieldset>
2
  <legend class="screen-reader-text"><?php _e('Post type','xml-sitemap-feed'); ?></legend>
3
+ <?php foreach ( $post_types as $post_type ) : $obj = get_post_type_object( $post_type ); if ( !is_object( $obj ) ) continue; ?>
4
+ <label>
5
+ <input type="<?php echo $type; ?>" name="xmlsf_news_tags[post_type][]" id="xmlsf_post_type_<?php echo $obj->name; ?>" value="<?php echo $obj->name; ?>"<?php checked( in_array($obj->name, $news_post_type), true ) . disabled( !in_array($obj->name, $allowed), true ); ?> />
6
+ <?php echo $obj->label; ?>
7
+ </label>
8
+ <br/>
9
+ <?php endforeach; if ( $do_warning || 'radio' == $type ) : ?>
10
+ <p class="description">
11
+ <?php if ( $do_warning ) _e( 'Custom post types that do not use the post category taxonomy, cannot be included as long as any category is selected below.', 'xml-sitemap-feed' ); ?>
12
+ <?php if ('radio' == $type) printf( /* Translators: Advanced plugin name */ __('Including multiple post types in the same News Sitemap is provided by the %s module.','xml-sitemap-feed'),'<a href="https://premium.status301.net/downloads/google-news-advanced/" target="_blank">'.__('Google News Advanced','xml-sitemap-feed').'</a>'); ?>
13
+ </p>
14
+ <?php endif; ?>
 
 
 
 
 
 
 
 
15
  </fieldset>
views/admin/field-news-stocktickers.php ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <fieldset>
2
+ <legend class="screen-reader-text">
3
+ <?php _e('Stock tickers','xml-sitemap-feed'); ?>
4
+ </legend>
5
+ <label>
6
+ <input type="checkbox" name="" id="xmlsf_news_stock_tickers" value="1" disabled="disabled" />
7
+ <?php _e('Enable stock tickers', 'xml-sitemap-feed'); ?>
8
+ </label>
9
+
10
+ <p class="description">
11
+ <?php _e('Stock tickers are relevant primarily for business articles.','xml-sitemap-feed'); ?>
12
+ <br />
13
+ <?php printf( /* Translators: Sitemap tag name, Advanced plugin name */ __('%1$s are provided by the %2$s module.','xml-sitemap-feed'), __('Stock tickers','xml-sitemap-feed') ,'<a href="https://premium.status301.net/downloads/google-news-advanced/" target="_blank">'.__('Google News Advanced','xml-sitemap-feed').'</a>'); ?>
14
+ </p>
15
+ </fieldset>
views/admin/field-ping.php CHANGED
@@ -12,5 +12,12 @@
12
  <input type="checkbox" name="xmlsf_ping[]" id="xmlsf_ping_bing" value="bing"<?php echo checked( is_array($options) && in_array('bing',$options), true, false); ?> />
13
  <?php _e('Bing & Yahoo','xml-sitemap-feed'); ?>
14
  </label>
15
-
16
  </fieldset>
 
 
 
 
 
 
 
 
12
  <input type="checkbox" name="xmlsf_ping[]" id="xmlsf_ping_bing" value="bing"<?php echo checked( is_array($options) && in_array('bing',$options), true, false); ?> />
13
  <?php _e('Bing & Yahoo','xml-sitemap-feed'); ?>
14
  </label>
 
15
  </fieldset>
16
+ <script>
17
+ jQuery( 'document' ).ready( function( $ ) {
18
+ if ( window.location.hash === '#xmlsf_ping' ) {
19
+ $( '#xmlsf_ping' ).closest( 'td' ).addClass( 'highlight' );
20
+ $( 'html, body' ).animate( { scrollTop: $("#xmlsf_ping").offset().top-40 }, 800 );
21
+ }
22
+ } );
23
+ </script>
views/admin/field-robots.php CHANGED
File without changes
views/admin/field-sitemap-custom.php CHANGED
File without changes
views/admin/field-sitemap-domains.php CHANGED
File without changes
views/admin/field-sitemap-post-type.php CHANGED
File without changes
views/admin/field-sitemap-taxonomies.php CHANGED
File without changes
views/admin/field-sitemap-taxonomy-settings.php CHANGED
File without changes
views/admin/field-sitemap-urls.php CHANGED
File without changes
views/admin/field-sitemaps.php CHANGED
@@ -29,9 +29,17 @@
29
  ?>
30
  <span class="description">
31
  &nbsp;&ndash;&nbsp;
32
- <a href="<?php echo admin_url('options-general.php'); ?>?page=xmlsf-news" id="xmlsf_news_link"><?php echo translate('Settings'); ?></a> |
33
  <a href="<?php echo $news_url; ?>" target="_blank"><?php echo translate('View'); ?></a>
34
  </span>
35
  <?php } ?>
36
 
37
  </fieldset>
 
 
 
 
 
 
 
 
29
  ?>
30
  <span class="description">
31
  &nbsp;&ndash;&nbsp;
32
+ <a href="<?php echo admin_url('options-general.php'); ?>?page=xmlsf_news" id="xmlsf_news_link"><?php echo translate('Settings'); ?></a> |
33
  <a href="<?php echo $news_url; ?>" target="_blank"><?php echo translate('View'); ?></a>
34
  </span>
35
  <?php } ?>
36
 
37
  </fieldset>
38
+ <script>
39
+ jQuery( 'document' ).ready( function( $ ) {
40
+ if ( window.location.hash === '#xmlsf_sitemaps' ) {
41
+ $( '#xmlsf_sitemaps' ).closest( 'td' ).addClass( 'highlight' );
42
+ $( 'html, body' ).animate( { scrollTop: $("#xmlsf_sitemaps").offset().top-40 }, 800 );
43
+ }
44
+ } );
45
+ </script>
views/admin/help-tab-advanced.php CHANGED
File without changes
views/admin/help-tab-allowed-domains.php CHANGED
File without changes
views/admin/help-tab-news-categories.php CHANGED
File without changes
views/admin/help-tab-news-images.php CHANGED
File without changes
views/admin/help-tab-news-keywords.php ADDED
@@ -0,0 +1,3 @@
 
 
 
1
+ <p>
2
+ <?php _e('Use a built-in or custom taxonomy to create a list of relevant keywords that describe the topic of the news article.','xml-sitemap-feed'); ?>
3
+ </p>
views/admin/help-tab-news-labels.php CHANGED
@@ -3,6 +3,5 @@
3
  </p>
4
  <p>
5
  <?php printf(__('Source labels inside a News Sitemap are no longer supported by Google News. To manage your site\'s labels, please go to the %s.','xml-sitemap-feed'),'<a href="https://news.google.com/publisher" target="_blank">'.__('Google News Publisher Center','xml-sitemap-feed').'</a>'); ?>
6
- <?php _e('The FactCheck label may only be applied if you publish stories with fact-checking content that\'s indicated by schema.org ClaimReview markup.','xml-sitemap-feed'); ?>
7
  <?php printf(__('Read more about source labels on %s','xml-sitemap-feed'),'<a href="https://support.google.com/news/publisher/answer/4582731" target="_blank">'.__('What does each source label mean?','xml-sitemap-feed').'</a>'); ?>
8
  </p>
3
  </p>
4
  <p>
5
  <?php printf(__('Source labels inside a News Sitemap are no longer supported by Google News. To manage your site\'s labels, please go to the %s.','xml-sitemap-feed'),'<a href="https://news.google.com/publisher" target="_blank">'.__('Google News Publisher Center','xml-sitemap-feed').'</a>'); ?>
 
6
  <?php printf(__('Read more about source labels on %s','xml-sitemap-feed'),'<a href="https://support.google.com/news/publisher/answer/4582731" target="_blank">'.__('What does each source label mean?','xml-sitemap-feed').'</a>'); ?>
7
  </p>
views/admin/help-tab-news-name.php CHANGED
File without changes
views/admin/help-tab-news-sidebar.php CHANGED
@@ -1,12 +1,23 @@
1
  <p>
2
  <strong><?php echo translate('For more information:'); ?></strong>
3
  </p>
4
- <p>
5
- <a href="https://support.google.com/webmasters/answer/183669" target="_blank"><?php _e( /* https://support.google.com/webmasters/answer/183669 */ 'Manage sitemaps with the Sitemaps report', 'xml-sitemap-feed' ); ?></a>
6
- </p>
7
- <p>
8
- <a href="https://support.google.com/news/publisher/answer/13369" target="_blank"><?php _e( /* https://support.google.com/news/publisher-center/answer/13369 */ 'Prevent missing or incorrect images', 'xml-sitemap-feed' ); ?></a>
9
- </p>
10
- <p>
11
- <a href="https://support.google.com/news/publisher-center/topic/9010385" target="_blank"><?php _e( /* https://support.google.com/news/publisher-center/topic/9010385 */ 'Troubleshoot an issue', 'xml-sitemap-feed' ); ?></a>
12
- </p>
 
 
 
 
 
 
 
 
 
 
 
1
  <p>
2
  <strong><?php echo translate('For more information:'); ?></strong>
3
  </p>
4
+ <ul>
5
+ <li>
6
+ <a href="https://support.google.com/news/publisher-center/answer/74288" target="_blank"><?php _e( /* https://support.google.com/news/publisher-center/answer/74288 */ 'Create a Google News sitemap', 'xml-sitemap-feed' ); ?></a>
7
+ </li>
8
+ <li>
9
+ <a href="https://support.google.com/news/publisher-center/answer/184732" target="_blank"><?php _e( /* https://support.google.com/news/publisher-center/answer/184732 */ 'Validate a News sitemap', 'xml-sitemap-feed' ); ?></a>
10
+ </li>
11
+ <li>
12
+ <a href="https://support.google.com/news/publisher-center/answer/6075793" target="_blank"><?php _e( /* https://support.google.com/news/publisher-center/answer/6075793 */ 'News sitemap errors', 'xml-sitemap-feed' ); ?></a>
13
+ </li>
14
+ <li>
15
+ <a href="https://support.google.com/news/publisher-center/topic/9010385" target="_blank"><?php _e( /* https://support.google.com/news/publisher-center/topic/9010385 */ 'Troubleshoot an issue', 'xml-sitemap-feed' ); ?></a>
16
+ </li>
17
+ <li>
18
+ <a href="https://support.google.com/news/publisher-center/answer/13369" target="_blank"><?php _e( /* https://support.google.com/news/publisher-center/answer/13369 */ 'Prevent missing or incorrect images', 'xml-sitemap-feed' ); ?></a>
19
+ </li>
20
+ <li>
21
+ <a href="https://support.google.com/news/publisher-center/answer/70871" target="_blank"><?php _e( /* https://support.google.com/news/publisher-center/answer/70871 */ 'Incorrect article date', 'xml-sitemap-feed' ); ?></a>
22
+ </li>
23
+ </ul>
views/admin/help-tab-news-stocktickers.php ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
1
+ <p>
2
+ <?php _e( 'Enabling stock tickers will create a custom taxonomy, allowing to attach stocks to individual posts.', 'xml-sitemap-feed' ); ?>
3
+ <?php _e( 'Each ticker must be prefixed by the name of its stock exchange, and must match its entry in Google Finance. For example: NASDAQ:AMAT (but not NASD:AMAT) or BOM:500325 (but not BOM:RIL).', 'xml-sitemap-feed' ); ?>
4
+ </p>
5
+ <p>
6
+ <?php _e( 'Note: Google News allows at most 5 stocks per article in the News Sitemap. The stocks must be relevant to the related news article.', 'xml-sitemap-feed' ); ?>
7
+ </p>
views/admin/help-tab-news.php CHANGED
File without changes
views/admin/help-tab-ping.php CHANGED
File without changes
views/admin/help-tab-post-types.php CHANGED
File without changes
views/admin/help-tab-robots.php CHANGED
@@ -5,3 +5,9 @@
5
  <?php _e('Only add rules here when you know what you are doing, otherwise you might break search engine access to your site.','xml-sitemap-feed'); ?>
6
  </span>
7
  </p>
 
 
 
 
 
 
5
  <?php _e('Only add rules here when you know what you are doing, otherwise you might break search engine access to your site.','xml-sitemap-feed'); ?>
6
  </span>
7
  </p>
8
+ <p>
9
+ <a href="https://www.google.com/webmasters/tools/robots-testing-tool" target="_blank" class="button"><?php _e('Open robots.txt Tester','xml-sitemap-feed'); ?></a>
10
+ </p>
11
+ <p>
12
+ <?php printf( __('For more help see %s and %s.','xml-sitemap-feed'), '<a href="https://developers.google.com/search/reference/robots_txt" target="_blank">'.__('Learn about robots.txt files','xml-sitemap-feed').'</a>','<a href="https://developers.google.com/search/reference/robots_txt" target="_blank">'.__('Robots.txt Specifications','xml-sitemap-feed').'</a>' ); ?>
13
+ </p>
views/admin/help-tab-sidebar.php CHANGED
@@ -1,9 +1,14 @@
1
  <p>
2
  <strong><?php echo translate('For more information:'); ?></strong>
3
  </p>
4
- <p>
5
- <a href="https://support.google.com/webmasters/answer/156184" target="_blank"><?php _e( /* https://support.google.com/webmasters/answer/156184 */ 'Learn more about sitemaps on Google Search Console Help', 'xml-sitemap-feed' ); ?></a>
6
- </p>
7
- <p>
8
- <a href="https://moz.com/blog/xml-sitemaps" target="_blank"><?php _e( /* https://moz.com/blog/xml-sitemaps */ 'XML Sitemaps: The Most Misunderstood Tool in the SEO\'s Toolbox', 'xml-sitemap-feed' ); ?></a>
9
- </p>
 
 
 
 
 
1
  <p>
2
  <strong><?php echo translate('For more information:'); ?></strong>
3
  </p>
4
+ <ul>
5
+ <li>
6
+ <a href="https://support.google.com/webmasters/answer/156184" target="_blank"><?php _e( /* https://support.google.com/webmasters/answer/156184 */ 'Learn more about sitemaps on Google Search Console Help', 'xml-sitemap-feed' ); ?></a>
7
+ </li>
8
+ <li>
9
+ <a href="https://support.google.com/webmasters/answer/183669" target="_blank"><?php _e( /* https://support.google.com/webmasters/answer/183669 */ 'Manage sitemaps with the Sitemaps report', 'xml-sitemap-feed' ); ?></a>
10
+ </li>
11
+ <li>
12
+ <a href="https://moz.com/blog/xml-sitemaps" target="_blank"><?php _e( /* https://moz.com/blog/xml-sitemaps */ 'XML Sitemaps: The Most Misunderstood Tool in the SEO\'s Toolbox', 'xml-sitemap-feed' ); ?></a>
13
+ </li>
14
+ </ul>
views/admin/help-tab-sitemaps.php CHANGED
File without changes
views/admin/help-tab-support.php CHANGED
File without changes
views/admin/help-tab-taxonomies.php CHANGED
File without changes
views/admin/help-tab-tools.php DELETED
@@ -1,8 +0,0 @@
1
- <p>
2
- <strong><?php echo translate('Tools'); ?></strong>
3
- </p>
4
- <form action="" method="post">
5
- <?php wp_nonce_field( XMLSF_BASENAME.'-help', '_xmlsf_help_nonce' ); ?>
6
- <input type="submit" name="xmlsf-check-conflicts" class="button button-small" value="<?php _e( 'Check for conflicts', 'xml-sitemap-feed' ); ?>" /> &nbsp;
7
- <input type="submit" name="xmlsf-clear-settings" class="button button-small" value="<?php _e( 'Reset all XML Sitemap settings', 'xml-sitemap-feed' ); ?>" onclick="javascript:return confirm('<?php _e('Clear all XML Sitemap & Google News Sitemap settings.','xml-sitemap-feed'); ?> <?php _e('This will revert all your sitemap settings to the plugin defaults.','xml-sitemap-feed'); ?>\n\n<?php echo translate('Are you sure you want to do this?'); ?>')" />
8
- </form>
 
 
 
 
 
 
 
 
views/admin/meta-box-news.php CHANGED
File without changes
views/admin/meta-box.php CHANGED
@@ -1,8 +1,8 @@
1
  <p>
2
  <label>
3
  <?php _e('Priority','xml-sitemap-feed'); ?>
4
- <input type="number" step="0.1" min="0" max="1" name="xmlsf_priority" id="xmlsf_priority" value="<?php echo $priority; ?>" class="small-text"<?php echo disabled( $disabled, true, false )?> />
5
- </label>
6
  <span class="description">
7
  <?php echo $description; ?>
8
  </span>
1
  <p>
2
  <label>
3
  <?php _e('Priority','xml-sitemap-feed'); ?>
4
+ <input type="number" step="0.1" min="0.1" max="1" name="xmlsf_priority" id="xmlsf_priority" value="<?php echo $priority; ?>" class="small-text"<?php echo disabled( $disabled, true, false )?> />
5
+ </label>
6
  <span class="description">
7
  <?php echo $description; ?>
8
  </span>
views/admin/notice-catchbox-feed-redirect.php ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <div class="notice notice-error fade is-dismissible">
2
+ <p>
3
+ <strong><?php _e('XML Sitemap & Google News','xml-sitemap-feed'); ?></strong>
4
+ </p>
5
+ <p>
6
+ <?php printf( /* Translators: Feed Redirect URL (Theme option name), Plugn name, Theme Options, Customizer (linked to Customizer page) */
7
+ __( 'The Catch Box theme option %1$s is not compatible with %2$s. Please go to %3$s in the %4$s and remove it.', 'xml-sitemap-feed'),
8
+ '<strong>' . translate('Feed Redirect URL', 'catch-box') . '</strong>',
9
+ __('XML Sitemap & Google News','xml-sitemap-feed'),
10
+ '<strong>' . translate('Theme Options', 'catch-box') . '</strong>',
11
+ '<a href="' . admin_url('customize.php') . '" target="_blank">' . translate('Customizer') . '</a>'
12
+ );
13
+ ?>
14
+ </p>
15
+ <form action="" method="post">
16
+ <?php wp_nonce_field( XMLSF_BASENAME.'-notice', '_xmlsf_notice_nonce' ); ?>
17
+ <p>
18
+ <input type="hidden" name="xmlsf-dismiss" value="catchbox_feed_redirect" />
19
+ <input type="submit" class="button button-small" name="xmlsf-dismiss-submit" value="<?php echo translate('Dismiss'); ?>" />
20
+ </p>
21
+ </form>
22
+ </div>
views/admin/notice-cleared.php DELETED
@@ -1,5 +0,0 @@
1
- <div class="notice notice-success fade is-dismissible">
2
- <p>
3
- <strong><?php _e('All XML Sitemap & Google News settings reset to the plugin defaults.','xml-sitemap-feed'); ?></strong>
4
- </p>
5
- </div>
 
 
 
 
 
views/admin/notice-deleted.php DELETED
@@ -1,5 +0,0 @@
1
- <div class="notice notice-success fade is-dismissible">
2
- <p>
3
- <strong><?php _e('File deleted.','xml-sitemap-feed'); ?></strong>
4
- </p>
5
- </div>
 
 
 
 
 
views/admin/notice-failed.php DELETED
@@ -1,8 +0,0 @@
1
- <div class="notice notice-error fade is-dismissible">
2
- <p>
3
- <strong><?php _e('Failed to delete file.','xml-sitemap-feed'); ?></strong>
4
- </p>
5
- <p>
6
- <?php _e('This is possibly due to insufficient rights. Please try via FTP or your hosting provider control panel.','xml-sitemap-feed'); ?></strong>
7
- </p>
8
- </div>
 
 
 
 
 
 
 
 
views/admin/notice-nonce-error.php DELETED
@@ -1,5 +0,0 @@
1
- <div class="notice notice-error fade is-dismissible">
2
- <p>
3
- <strong><?php echo translate('Security check failed.') ?></strong>
4
- </p>
5
- </div>
 
 
 
 
 
views/admin/notice-none-found.php DELETED
@@ -1,5 +0,0 @@
1
- <div class="notice notice-info fade is-dismissible">
2
- <p>
3
- <strong><?php _e('No conflicting static files found.','xml-sitemap-feed'); ?></strong>
4
- </p>
5
- </div>
 
 
 
 
 
views/admin/notice-not-allowed.php DELETED
@@ -1,5 +0,0 @@
1
- <div class="notice notice-error fade is-dismissible">
2
- <p>
3
- <strong><?php _e('File not in the list of allowed files!','xml-sitemap-feed'); ?></strong>
4
- </p>
5
- </div>
 
 
 
 
 
views/admin/{notice-date-redirect.php → notice-seopress-date-redirect.php} RENAMED
@@ -4,9 +4,9 @@
4
  </p>
5
  <p>
6
  <?php printf( /* translators: Date archives, Archives (linked to WP SEO plugin settings), Split by, None, Included post types (linked to Sitemap settings) */
7
- __( 'A setting in the WordPress SEO plugin causes all date based sitemaps to redirect to the main page. Please either enable <strong>%1$s</strong> under %2$s in your SEO settings or set all <strong>%3$s</strong> options to <strong>%4$s</strong> under %5$s in your XML Sitemap settings.', 'xml-sitemap-feed'),
8
- translate('Date archives','wordpress-seo'),
9
- '<a href="' . admin_url('admin.php') . '?page=wpseo_titles#top#archives">' . translate('Archives','wordpress-seo') . '</a>',
10
  __('Split by','xml-sitemap-feed'),
11
  translate('None'),
12
  '<a href="' . admin_url('options-general.php') . '?page=xmlsf">' . __('Included post types','xml-sitemap-feed') . '</a>'
@@ -16,7 +16,8 @@
16
  <form action="" method="post">
17
  <?php wp_nonce_field( XMLSF_BASENAME.'-notice', '_xmlsf_notice_nonce' ); ?>
18
  <p>
19
- <input type="submit" class="button button-small" name="xmlsf-date-dismiss" value="<?php echo translate('Dismiss'); ?>" />
 
20
  </p>
21
  </form>
22
  </div>
4
  </p>
5
  <p>
6
  <?php printf( /* translators: Date archives, Archives (linked to WP SEO plugin settings), Split by, None, Included post types (linked to Sitemap settings) */
7
+ __( 'A setting in the SEOPress plugin causes all date based sitemaps to redirect to the main page. Please either enable <strong>%1$s</strong> under %2$s in your SEO settings or set all <strong>%3$s</strong> options to <strong>%4$s</strong> under %5$s in your XML Sitemap settings.', 'xml-sitemap-feed'),
8
+ translate('Date archives','wp-seopress'),
9
+ '<a href="' . admin_url('admin.php') . '?page=seopress-titles#tab=tab_seopress_titles_archives">' . translate('Archives','wp-seopress') . '</a>',
10
  __('Split by','xml-sitemap-feed'),
11
  translate('None'),
12
  '<a href="' . admin_url('options-general.php') . '?page=xmlsf">' . __('Included post types','xml-sitemap-feed') . '</a>'
16
  <form action="" method="post">
17
  <?php wp_nonce_field( XMLSF_BASENAME.'-notice', '_xmlsf_notice_nonce' ); ?>
18
  <p>
19
+ <input type="hidden" name="xmlsf-dismiss" value="seopress_date_redirect" />
20
+ <input type="submit" class="button button-small" name="xmlsf-dismiss-submit" value="<?php echo translate('Dismiss'); ?>" />
21
  </p>
22
  </form>
23
  </div>
views/admin/notice-seopress-sitemap.php ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <div class="notice notice-error fade is-dismissible">
2
+ <p>
3
+ <strong><?php _e('XML Sitemap & Google News','xml-sitemap-feed'); ?></strong>
4
+ </p>
5
+ <p>
6
+ <?php printf( /* translators: Plugn name, Sitemap page name (linked to SEOPress plugin settings), XML Sitemap Index, Reading Settings admin page (linked to Reading settings) */
7
+ __( 'The SEOPress XML Sitemap is not compatible with %1$s. Please either disable the XML Sitemap under %2$s in your SEO settings or disable the option %3$s on %4$s.', 'xml-sitemap-feed'),
8
+ __('XML Sitemap & Google News','xml-sitemap-feed'),
9
+ '<a href="' . admin_url('admin.php') . '?page=seopress-xml-sitemap">' . translate('XML / HTML Sitemap','wp-seopress') . '</a>',
10
+ __('XML Sitemap Index','xml-sitemap-feed'),
11
+ '<a href="' . admin_url('options-reading.php') . '#xmlsf_sitemaps">' . translate('Reading Settings') . '</a>'
12
+ );
13
+ ?>
14
+ </p>
15
+ <form action="" method="post">
16
+ <?php wp_nonce_field( XMLSF_BASENAME.'-notice', '_xmlsf_notice_nonce' ); ?>
17
+ <p>
18
+ <input type="hidden" name="xmlsf-dismiss" value="seopress_sitemap" />
19
+ <input type="submit" class="button button-small" name="xmlsf-dismiss-submit" value="<?php echo translate('Dismiss'); ?>" />
20
+ </p>
21
+ </form>
22
+ </div>
views/admin/notice-static-files.php CHANGED
@@ -6,12 +6,12 @@
6
  <?php printf( /* translators: %1$s number of files, %2$s is Reading Settings URL */ _n(
7
  'The following static file has been found. Either delete it or disable the conflicting <a href="%2$s">sitemap</a>.',
8
  'The following %1$s static files have been found. Either delete them or disable the conflicting <a href="%2$s">sitemaps</a>.',
9
- $number,'xml-sitemap-feed'), number_format_i18n($number), admin_url('options-reading.php') . '#blog_public' ); ?>
10
  </p>
11
  <form action="" method="post">
12
  <?php wp_nonce_field( XMLSF_BASENAME.'-notice', '_xmlsf_notice_nonce' ); ?>
13
  <ul>
14
- <?php foreach (parent::$static_files as $name => $file) { ?>
15
  <li>
16
  <label><input type="checkbox" name="xmlsf-delete[]" value="<?php echo $name; ?>" /> <strong><?php echo $name; ?></strong> (<?php echo $file; ?>)</label>
17
  </li>
@@ -21,7 +21,7 @@
21
  <input type="submit" class="button button-small" name="xmlsf-delete-submit" value="<?php _e('Delete selected files','xml-sitemap-feed'); ?>" onclick="return confirm('<?php _e('Attempt to delete selected conflicting files.','xml-sitemap-feed'); ?>\n\n<?php echo translate('Are you sure you want to do this?'); ?>')" />
22
  &nbsp;
23
  <input type="hidden" name="xmlsf-dismiss" value="static_files" />
24
- <input type="submit" class="button button-small" name="xmlsf-static-dismiss" value="<?php echo translate('Dismiss'); ?>" />
25
  </p>
26
  </form>
27
  </div>
6
  <?php printf( /* translators: %1$s number of files, %2$s is Reading Settings URL */ _n(
7
  'The following static file has been found. Either delete it or disable the conflicting <a href="%2$s">sitemap</a>.',
8
  'The following %1$s static files have been found. Either delete them or disable the conflicting <a href="%2$s">sitemaps</a>.',
9
+ $number,'xml-sitemap-feed'), number_format_i18n($number), admin_url('options-reading.php') . '#xmlsf_sitemaps' ); ?>
10
  </p>
11
  <form action="" method="post">
12
  <?php wp_nonce_field( XMLSF_BASENAME.'-notice', '_xmlsf_notice_nonce' ); ?>
13
  <ul>
14
+ <?php foreach ( $static_files as $name => $file) { ?>
15
  <li>
16
  <label><input type="checkbox" name="xmlsf-delete[]" value="<?php echo $name; ?>" /> <strong><?php echo $name; ?></strong> (<?php echo $file; ?>)</label>
17
  </li>
21
  <input type="submit" class="button button-small" name="xmlsf-delete-submit" value="<?php _e('Delete selected files','xml-sitemap-feed'); ?>" onclick="return confirm('<?php _e('Attempt to delete selected conflicting files.','xml-sitemap-feed'); ?>\n\n<?php echo translate('Are you sure you want to do this?'); ?>')" />
22
  &nbsp;
23
  <input type="hidden" name="xmlsf-dismiss" value="static_files" />
24
+ <input type="submit" class="button button-small" name="xmlsf-dismiss-submit" value="<?php echo translate('Dismiss'); ?>" />
25
  </p>
26
  </form>
27
  </div>
views/admin/notice-wpseo-date-redirect.php CHANGED
@@ -1,23 +1,23 @@
1
  <div class="notice notice-error fade is-dismissible">
2
  <p>
3
- <strong><?php _e('XML Sitemap & Google News','xml-sitemap-feed'); ?></strong>
4
- </p>
5
- <p>
6
- <?php printf( /* translators: Date archives, Archives (linked to WP SEO plugin settings), Split by, None, Included post types (linked to Sitemap settings) */
7
- __( 'A setting in the WordPress SEO plugin causes all date based sitemaps to redirect to the main page. Please either enable <strong>%1$s</strong> under %2$s in your SEO settings or set all <strong>%3$s</strong> options to <strong>%4$s</strong> under %5$s in your XML Sitemap settings.', 'xml-sitemap-feed'),
8
- translate('Date archives','wordpress-seo'),
9
- '<a href="' . admin_url('admin.php') . '?page=wpseo_titles#top#archives">' . translate('Archives','wordpress-seo') . '</a>',
10
- __('Split by','xml-sitemap-feed'),
11
- translate('None'),
12
- '<a href="' . admin_url('options-general.php') . '?page=xmlsf">' . __('Included post types','xml-sitemap-feed') . '</a>'
13
- );
14
- ?>
15
- </p>
16
  <form action="" method="post">
17
  <?php wp_nonce_field( XMLSF_BASENAME.'-notice', '_xmlsf_notice_nonce' ); ?>
18
  <p>
19
- <input type="hidden" name="xmlsf-dismiss" value="date_redirect" />
20
- <input type="submit" class="button button-small" name="xmlsf-date-dismiss" value="<?php echo translate('Dismiss'); ?>" />
21
  </p>
22
  </form>
23
  </div>
1
  <div class="notice notice-error fade is-dismissible">
2
  <p>
3
+ <strong><?php _e('XML Sitemap & Google News','xml-sitemap-feed'); ?></strong>
4
+ </p>
5
+ <p>
6
+ <?php printf( /* translators: Date archives, Archives (linked to WP SEO plugin settings), Split by, None, Included post types (linked to Sitemap settings) */
7
+ __( 'A setting in the WordPress SEO plugin causes all date based sitemaps to redirect to the main page. Please either enable <strong>%1$s</strong> under %2$s in your SEO settings or set all <strong>%3$s</strong> options to <strong>%4$s</strong> under %5$s in your XML Sitemap settings.', 'xml-sitemap-feed'),
8
+ translate('Date archives','wordpress-seo'),
9
+ '<a href="' . admin_url('admin.php') . '?page=wpseo_titles#top#archives">' . translate('Archives','wordpress-seo') . '</a>',
10
+ __('Split by','xml-sitemap-feed'),
11
+ translate('None'),
12
+ '<a href="' . admin_url('options-general.php') . '?page=xmlsf">' . __('Included post types','xml-sitemap-feed') . '</a>'
13
+ );
14
+ ?>
15
+ </p>
16
  <form action="" method="post">
17
  <?php wp_nonce_field( XMLSF_BASENAME.'-notice', '_xmlsf_notice_nonce' ); ?>
18
  <p>
19
+ <input type="hidden" name="xmlsf-dismiss" value="wpseo_date_redirect" />
20
+ <input type="submit" class="button button-small" name="xmlsf-dismiss-submit" value="<?php echo translate('Dismiss'); ?>" />
21
  </p>
22
  </form>
23
  </div>
views/admin/notice-wpseo-sitemap.php CHANGED
@@ -8,7 +8,7 @@
8
  __('XML Sitemap & Google News','xml-sitemap-feed'),
9
  '<a href="' . admin_url('admin.php') . '?page=wpseo_dashboard#top#features">' . translate('Features','wordpress-seo') . '</a>',
10
  __('XML Sitemap Index','xml-sitemap-feed'),
11
- '<a href="' . admin_url('options-reading.php') . '#blog_public">' . translate('Reading Settings') . '</a>'
12
  );
13
  ?>
14
  </p>
8
  __('XML Sitemap & Google News','xml-sitemap-feed'),
9
  '<a href="' . admin_url('admin.php') . '?page=wpseo_dashboard#top#features">' . translate('Features','wordpress-seo') . '</a>',
10
  __('XML Sitemap Index','xml-sitemap-feed'),
11
+ '<a href="' . admin_url('options-reading.php') . '#xmlsf_sitemaps">' . translate('Reading Settings') . '</a>'
12
  );
13
  ?>
14
  </p>
views/admin/notice.php DELETED
@@ -1,26 +0,0 @@
1
- <div class="notice notice-warning fade is-dismissible">
2
- <p>
3
- <strong><?php _e('XML Sitemap & Google News','xml-sitemap-feed'); ?></strong>
4
- </p>
5
- <p>
6
- <?php printf( /* translators: %1$s number of files, %2$s is Reading Settings URL */ _n(
7
- 'The following static file has been found. Either delete it or disable the conflicting <a href="%2$s">sitemap</a>.',
8
- 'The following %1$s static files have been found. Either delete them or disable the conflicting <a href="%2$s">sitemaps</a>.',
9
- $number,'xml-sitemap-feed'), number_format_i18n($number), admin_url('options-reading.php') . '#blog_public' ); ?>
10
- </p>
11
- <form action="" method="post">
12
- <?php wp_nonce_field( XMLSF_BASENAME.'-notice', '_xmlsf_notice_nonce' ); ?>
13
- <ul>
14
- <?php foreach (parent::$static_files as $name => $file) { ?>
15
- <li>
16
- <label><input type="checkbox" name="xmlsf-delete[]" value="<?php echo $name; ?>" /> <strong><?php echo $name; ?></strong> (<?php echo $file; ?>)</label>
17
- </li>
18
- <?php } ?>
19
- </ul>
20
- <p>
21
- <input type="submit" class="button button-small" name="xmlsf-delete-submit" value="<?php _e('Delete selected files','xml-sitemap-feed'); ?>" onclick="return confirm('<?php _e('Attempt to delete selected conflicting files.','xml-sitemap-feed'); ?>\n\n<?php echo translate('Are you sure you want to do this?'); ?>')" />
22
- &nbsp;
23
- <input type="submit" class="button button-small" name="xmlsf-static-dismiss" value="<?php echo translate('Dismiss'); ?>" />
24
- </p>
25
- </form>
26
- </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
views/admin/page-sitemap-news.php CHANGED
@@ -7,19 +7,25 @@
7
 
8
  <p>
9
  <?php printf( __( 'These settings control the Google News Sitemap generated by the %s plugin.', 'xml-sitemap-feed' ), __( 'XML Sitemap & Google News', 'xml-sitemap-feed' ) ); ?>
10
- <?php printf( /* translators: Writing Settings URL */ __( 'For ping options, go to %s.', 'xml-sitemap-feed' ), '<a href="options-writing.php">'.translate('Writing Settings').'</a>' ); ?>
11
  </p>
12
 
13
- <?php do_action('xmlsf_news_settings_before'); ?>
 
 
 
 
14
 
15
  <div class="main">
16
  <form method="post" action="options.php">
17
 
18
- <?php settings_fields( 'xmlsf-news' ); ?>
19
 
20
- <?php do_settings_sections( 'xmlsf-news' ); ?>
21
 
22
- <?php do_action('xmlsf_news_settings_after'); ?>
 
 
23
 
24
  <?php submit_button(); ?>
25
 
@@ -40,7 +46,19 @@
40
  <h3><span class="dashicons dashicons-admin-tools"></span> <?php echo translate('Tools'); ?></h3>
41
  <form action="" method="post">
42
  <?php wp_nonce_field( XMLSF_BASENAME.'-help', '_xmlsf_help_nonce' ); ?>
43
- <input type="submit" name="xmlsf-check-conflicts" class="button button-small" value="<?php _e( 'Check for conflicts', 'xml-sitemap-feed' ); ?>" />
 
 
 
 
 
 
 
 
 
 
 
 
44
  </form>
45
 
46
  <?php include XMLSF_DIR . '/views/admin/sidebar-help.php'; ?>
7
 
8
  <p>
9
  <?php printf( __( 'These settings control the Google News Sitemap generated by the %s plugin.', 'xml-sitemap-feed' ), __( 'XML Sitemap & Google News', 'xml-sitemap-feed' ) ); ?>
10
+ <?php printf( /* translators: Writing Settings URL */ __( 'For ping options, go to %s.', 'xml-sitemap-feed' ), '<a href="'.admin_url('options-writing.php').'#xmlsf_ping">'.translate('Writing Settings').'</a>' ); ?>
11
  </p>
12
 
13
+ <nav class="nav-tab-wrapper">
14
+ <a href="?page=xmlsf_news&tab=general" class="nav-tab <?php echo $active_tab == 'general' ? 'nav-tab-active' : ''; ?>"><?php echo translate('General'); ?></a>
15
+ <a href="?page=xmlsf_news&tab=advanced" class="nav-tab <?php echo $active_tab == 'advanced' ? 'nav-tab-active' : ''; ?>"><?php echo translate('Advanced'); ?></a>
16
+ <?php do_action( 'xmlsf_news_nav_tabs', $active_tab ); ?>
17
+ </nav>
18
 
19
  <div class="main">
20
  <form method="post" action="options.php">
21
 
22
+ <?php do_action( 'xmlsf_news_settings_before', $active_tab ); ?>
23
 
24
+ <?php settings_fields( 'xmlsf_news_'.$active_tab ); ?>
25
 
26
+ <?php do_settings_sections( 'xmlsf_news_'.$active_tab ); ?>
27
+
28
+ <?php do_action( 'xmlsf_news_settings_after', $active_tab ); ?>
29
 
30
  <?php submit_button(); ?>
31
 
46
  <h3><span class="dashicons dashicons-admin-tools"></span> <?php echo translate('Tools'); ?></h3>
47
  <form action="" method="post">
48
  <?php wp_nonce_field( XMLSF_BASENAME.'-help', '_xmlsf_help_nonce' ); ?>
49
+ <p>
50
+ <input type="submit" name="xmlsf-check-conflicts" class="button button-small" value="<?php _e( 'Check for conflicts', 'xml-sitemap-feed' ); ?>" />
51
+ </p>
52
+ <p>
53
+ <input type="submit" name="xmlsf-flush-rewrite-rules" class="button button-small" value="<?php _e( 'Flush rewrite rules', 'xml-sitemap-feed' ); ?>" />
54
+ </p>
55
+ <p>
56
+ <input type="submit" name="xmlsf-ping-sitemap-news" class="button button-small" value="<?php _e( 'Ping Google News', 'xml-sitemap-feed' ); ?>" />
57
+ </p>
58
+ <p>
59
+ <input type="hidden" name="xmlsf-clear-settings" value="sitemap-news" />
60
+ <input type="submit" name="xmlsf-clear-settings-submit" class="button button-small button-link-delete" value="<?php _e( 'Reset settings', 'xml-sitemap-feed' ); ?>" onclick="javascript:return confirm('<?php _e('This will revert your sitemap settings to the plugin defaults.','xml-sitemap-feed'); ?>\n\n<?php echo translate('Are you sure you want to do this?'); ?>')" />
61
+ </p>
62
  </form>
63
 
64
  <?php include XMLSF_DIR . '/views/admin/sidebar-help.php'; ?>
views/admin/page-sitemap.php CHANGED
@@ -7,7 +7,7 @@
7
 
8
  <p>
9
  <?php printf( /* translators: Plugin name */ __('These settings control the XML Sitemaps generated by the %s plugin.','xml-sitemap-feed'),__('XML Sitemap & Google News','xml-sitemap-feed')); ?>
10
- <?php printf( /* translators: Writing Settings URL */ __('For ping options, go to %s.','xml-sitemap-feed'),'<a href="options-writing.php">'.translate('Writing Settings').'</a>'); ?>
11
  </p>
12
 
13
  <nav class="nav-tab-wrapper">
@@ -42,8 +42,19 @@
42
  <h3><span class="dashicons dashicons-admin-tools"></span> <?php echo translate('Tools'); ?></h3>
43
  <form action="" method="post">
44
  <?php wp_nonce_field( XMLSF_BASENAME.'-help', '_xmlsf_help_nonce' ); ?>
45
- <input type="submit" name="xmlsf-check-conflicts" class="button button-small" value="<?php _e( 'Check for conflicts', 'xml-sitemap-feed' ); ?>" /> &nbsp;
46
- <input type="submit" name="xmlsf-clear-settings" class="button button-small" value="<?php _e( 'Reset XML sitemaps', 'xml-sitemap-feed' ); ?>" onclick="javascript:return confirm('<?php _e('Clear all XML Sitemap & Google News Sitemap settings.','xml-sitemap-feed'); ?> <?php _e('This will revert all your sitemap settings to the plugin defaults.','xml-sitemap-feed'); ?>\n\n<?php echo translate('Are you sure you want to do this?'); ?>')" />
 
 
 
 
 
 
 
 
 
 
 
47
  </form>
48
 
49
  <?php include XMLSF_DIR . '/views/admin/sidebar-help.php'; ?>
7
 
8
  <p>
9
  <?php printf( /* translators: Plugin name */ __('These settings control the XML Sitemaps generated by the %s plugin.','xml-sitemap-feed'),__('XML Sitemap & Google News','xml-sitemap-feed')); ?>
10
+ <?php printf( /* translators: Writing Settings URL */ __('For ping options, go to %s.','xml-sitemap-feed'),'<a href="'.admin_url('options-writing.php').'#xmlsf_ping">'.translate('Writing Settings').'</a>'); ?>
11
  </p>
12
 
13
  <nav class="nav-tab-wrapper">
42
  <h3><span class="dashicons dashicons-admin-tools"></span> <?php echo translate('Tools'); ?></h3>
43
  <form action="" method="post">
44
  <?php wp_nonce_field( XMLSF_BASENAME.'-help', '_xmlsf_help_nonce' ); ?>
45
+ <p>
46
+ <input type="submit" name="xmlsf-check-conflicts" class="button button-small" value="<?php _e( 'Check for conflicts', 'xml-sitemap-feed' ); ?>" />
47
+ </p>
48
+ <p>
49
+ <input type="submit" name="xmlsf-flush-rewrite-rules" class="button button-small" value="<?php _e( 'Flush rewrite rules', 'xml-sitemap-feed' ); ?>" />
50
+ </p>
51
+ <p>
52
+ <input type="submit" name="xmlsf-ping-sitemap" class="button button-small" value="<?php _e( 'Ping search engines', 'xml-sitemap-feed' ); ?>" />
53
+ </p>
54
+ <p>
55
+ <input type="hidden" name="xmlsf-clear-settings" value="sitemap" />
56
+ <input type="submit" name="xmlsf-clear-settings-submit" class="button button-small button-link-delete" value="<?php _e( 'Reset settings', 'xml-sitemap-feed' ); ?>" onclick="javascript:return confirm('<?php _e('This will revert your sitemap settings to the plugin defaults.','xml-sitemap-feed'); ?>\n\n<?php echo translate('Are you sure you want to do this?'); ?>')" />
57
+ </p>
58
  </form>
59
 
60
  <?php include XMLSF_DIR . '/views/admin/sidebar-help.php'; ?>
views/admin/section-advanced-intro.php ADDED
@@ -0,0 +1,3 @@
 
 
 
1
+ <p>
2
+ <?php printf( /* Translators: Advanced options, Advanced plugin name */ __('%1$s are provided by the %2$s module.','xml-sitemap-feed'), __('Advanced options','xml-sitemap-feed') ,'<a href="https://premium.status301.net/downloads/google-news-advanced/" target="_blank">'.__('Google News Advanced','xml-sitemap-feed').'</a>'); ?>
3
+ </p>
views/admin/sidebar-contribute.php CHANGED
File without changes
views/admin/sidebar-help.php CHANGED
File without changes
views/feed-sitemap-custom.php CHANGED
File without changes
views/feed-sitemap-home.php CHANGED
File without changes
views/feed-sitemap-news.php CHANGED
@@ -40,19 +40,19 @@ $have_posts = false;
40
  // loop away!
41
  if ( have_posts() ) :
42
  while ( have_posts() ) :
43
- the_post();
44
 
45
- // check if we are not dealing with an external URL :: Thanks to Francois Deschenes :)
46
- // or if post meta says "exclude me please"
47
- if ( apply_filters(
48
- 'xmlsf_news_excluded',
49
- get_post_meta( $post->ID, '_xmlsf_news_exclude', true ),
50
- $post->ID
51
- ) || !xmlsf_is_allowed_domain( get_permalink() ) )
52
- continue;
53
 
54
- $have_posts = true;
55
- ?>
56
  <url>
57
  <loc><?php echo esc_url( get_permalink() ); ?></loc>
58
  <news:news>
@@ -64,39 +64,32 @@ if ( have_posts() ) :
64
  echo apply_filters( 'the_title_xmlsitemap', XMLSF_GOOGLE_NEWS_NAME );
65
  else
66
  echo apply_filters( 'the_title_xmlsitemap', get_bloginfo('name') ); ?></news:name>
67
- <news:language><?php echo xmlsf_get_language($post->ID); ?></news:language>
68
  </news:publication>
69
  <news:publication_date><?php
70
  echo mysql2date('Y-m-d\TH:i:s+00:00', $post->post_date_gmt, false); ?></news:publication_date>
71
  <news:title><?php echo apply_filters( 'the_title_xmlsitemap', get_the_title() ); ?></news:title>
72
-
 
73
  <?php do_action( 'xmlsf_news_tags_after' ); ?>
74
  </news:news>
75
  <?php
76
- if ( !empty($options['image']) ) :
77
- foreach ( xmlsf_get_images('news') as $image ) {
78
- if ( empty($image['loc']) )
79
- continue;
80
- ?>
81
  <image:image>
82
  <image:loc><?php echo utf8_uri_encode( $image['loc'] ); ?></image:loc>
83
- <?php
84
- if ( !empty($image['title']) ) {
85
- ?>
86
  <image:title><![CDATA[<?php echo str_replace(']]>', ']]&gt;', $image['title']); ?>]]></image:title>
87
- <?php
88
- }
89
- if ( !empty($image['caption']) ) {
90
- ?>
91
  <image:caption><![CDATA[<?php echo str_replace(']]>', ']]&gt;', $image['caption']); ?>]]></image:caption>
92
- <?php
93
- }
94
- ?>
95
  </image:image>
96
- <?php
97
- }
98
- endif;
99
- ?>
100
  </url>
101
  <?php
102
  endwhile;
40
  // loop away!
41
  if ( have_posts() ) :
42
  while ( have_posts() ) :
43
+ the_post();
44
 
45
+ // check if we are not dealing with an external URL :: Thanks to Francois Deschenes :)
46
+ // or if post meta says "exclude me please"
47
+ if ( apply_filters(
48
+ 'xmlsf_news_excluded',
49
+ get_post_meta( $post->ID, '_xmlsf_news_exclude', true ),
50
+ $post->ID
51
+ ) || !xmlsf_is_allowed_domain( get_permalink() ) )
52
+ continue;
53
 
54
+ $have_posts = true;
55
+ ?>
56
  <url>
57
  <loc><?php echo esc_url( get_permalink() ); ?></loc>
58
  <news:news>
64
  echo apply_filters( 'the_title_xmlsitemap', XMLSF_GOOGLE_NEWS_NAME );
65
  else
66
  echo apply_filters( 'the_title_xmlsitemap', get_bloginfo('name') ); ?></news:name>
67
+ <news:language><?php echo xmlsf_get_language( $post->ID ); ?></news:language>
68
  </news:publication>
69
  <news:publication_date><?php
70
  echo mysql2date('Y-m-d\TH:i:s+00:00', $post->post_date_gmt, false); ?></news:publication_date>
71
  <news:title><?php echo apply_filters( 'the_title_xmlsitemap', get_the_title() ); ?></news:title>
72
+ <news:keywords><?php echo implode( ', ', apply_filters( 'xmlsf_news_keywords', array() ) ); ?></news:keywords>
73
+ <news:stock_tickers><?php echo implode( ', ', apply_filters( 'xmlsf_news_stock_tickers', array() ) ); ?></news:stock_tickers>
74
  <?php do_action( 'xmlsf_news_tags_after' ); ?>
75
  </news:news>
76
  <?php
77
+ if ( !empty($options['image']) ) :
78
+ foreach ( xmlsf_get_images('news') as $image ) {
79
+ if ( empty($image['loc']) )
80
+ continue;
81
+ ?>
82
  <image:image>
83
  <image:loc><?php echo utf8_uri_encode( $image['loc'] ); ?></image:loc>
84
+ <?php if ( !empty($image['title']) ) { ?>
 
 
85
  <image:title><![CDATA[<?php echo str_replace(']]>', ']]&gt;', $image['title']); ?>]]></image:title>
86
+ <?php }
87
+ if ( !empty($image['caption']) ) { ?>
 
 
88
  <image:caption><![CDATA[<?php echo str_replace(']]>', ']]&gt;', $image['caption']); ?>]]></image:caption>
89
+ <?php } ?>
 
 
90
  </image:image>
91
+ <?php }
92
+ endif; ?>
 
 
93
  </url>
94
  <?php
95
  endwhile;
views/feed-sitemap-post_type.php CHANGED
File without changes
views/feed-sitemap-taxonomy.php CHANGED
File without changes
views/feed-sitemap.php CHANGED
@@ -24,7 +24,7 @@ echo '<?xml version="1.0" encoding="' . get_bloginfo('charset') . '"?>
24
  $post_types = apply_filters( 'xmlsf_post_types', get_option( 'xmlsf_post_types' ) );
25
  if ( is_array($post_types) ) :
26
  foreach ( $post_types as $post_type => $settings ) {
27
- if ( empty($settings['active']) )
28
  continue;
29
 
30
  $archive = isset($settings['archive']) ? $settings['archive'] : '';
24
  $post_types = apply_filters( 'xmlsf_post_types', get_option( 'xmlsf_post_types' ) );
25
  if ( is_array($post_types) ) :
26
  foreach ( $post_types as $post_type => $settings ) {
27
+ if ( empty($settings['active']) || ! post_type_exists( $post_type ) )
28
  continue;
29
 
30
  $archive = isset($settings['archive']) ? $settings['archive'] : '';
views/robots.php DELETED
@@ -1,19 +0,0 @@
1
- # XML Sitemap & Google News version <?php echo XMLSF_VERSION ?> - https://status301.net/wordpress-plugins/xml-sitemap-feed/
2
- <?php switch ( $case ) {
3
- case 'private' : ?>
4
- # XML Sitemaps are disabled because of this site's privacy settings.
5
-
6
- <?php break;
7
- case 'disabled' : ?>
8
- # No XML Sitemaps are enabled on this site.
9
-
10
- <?php break;
11
- default :
12
- foreach ( $sitemaps as $pretty ) { ?>
13
- Sitemap: <?php echo $url . $pretty; ?>
14
-
15
- <?php } ?>
16
-
17
- <?php break;
18
- }
19
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
views/styles/admin.css CHANGED
File without changes
views/styles/sitemap-index.xsl CHANGED
@@ -10,7 +10,7 @@
10
  <head>
11
  <title>XML Sitemap Feed - Index</title>
12
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
13
- <style type="text/css">body{font-family:"Lucida Grande","Lucida Sans Unicode",Tahoma,Verdana,sans-serif;font-size:13px}#header,#footer{padding:2px;margin:10px;font-size:8pt;color:gray}a{color:black}td{font-size:11px}th{text-align:left;padding-right:30px;font-size:11px}tr.high{background-color:whitesmoke}#footer img{vertical-align:bottom}</style>
14
  </head>
15
  <body>
16
  <h1>XML Sitemap Feed - Index</h1>
10
  <head>
11
  <title>XML Sitemap Feed - Index</title>
12
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
13
+ <style type="text/css">body{font-family:"Lucida Grande","Lucida Sans Unicode",Tahoma,Verdana,sans-serif;font-size:13px}#header,#footer{padding:2px;margin:10px;font-size:8pt;color:gray}a{color:black}td{font-size:11px}th{text-align:left;padding-right:30px;font-size:11px}tr.high{background-color:whitesmoke}#footer img{vertical-align:middle}</style>
14
  </head>
15
  <body>
16
  <h1>XML Sitemap Feed - Index</h1>
views/styles/sitemap-news.xsl CHANGED
@@ -11,7 +11,7 @@
11
  <head>
12
  <title>Google News Sitemap Feed</title>
13
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
14
- <style type="text/css">body{font-family:"Lucida Grande","Lucida Sans Unicode",Tahoma,Verdana,sans-serif;font-size:13px}#header,#footer{padding:2px;margin:10px;font-size:8pt;color:gray}a{color:black}td{font-size:11px}th{text-align:left;padding-right:30px;font-size:11px}tr.high{background-color:whitesmoke}#footer img{vertical-align:bottom}</style>
15
  </head>
16
  <body>
17
  <h1>Google News Sitemap Feed</h1>
@@ -27,6 +27,8 @@
27
  <th>Title</th>
28
  <th>Language</th>
29
  <th>Image(s)</th>
 
 
30
  <th>Publication Date (GMT)</th>
31
  </tr>
32
  <xsl:variable name="lower" select="'abcdefghijklmnopqrstuvwxyz'"/>
@@ -39,6 +41,8 @@
39
  </td>
40
  <td><xsl:value-of select="news:news/news:publication/news:language"/></td>
41
  <td><xsl:value-of select="count(image:image)"/></td>
 
 
42
  <td><xsl:value-of select="concat(substring(news:news/news:publication_date,0,11),concat(' ', substring(news:news/news:publication_date,12,8)))"/></td>
43
  </tr>
44
  </xsl:for-each>
11
  <head>
12
  <title>Google News Sitemap Feed</title>
13
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
14
+ <style type="text/css">body{font-family:"Lucida Grande","Lucida Sans Unicode",Tahoma,Verdana,sans-serif;font-size:13px}#header,#footer{padding:2px;margin:10px;font-size:8pt;color:gray}a{color:black}td{font-size:11px}th{text-align:left;padding-right:30px;font-size:11px}tr.high{background-color:whitesmoke}#footer img{vertical-align:middle}</style>
15
  </head>
16
  <body>
17
  <h1>Google News Sitemap Feed</h1>
27
  <th>Title</th>
28
  <th>Language</th>
29
  <th>Image(s)</th>
30
+ <th>Keyword(s)</th>
31
+ <th>Stock(s)</th>
32
  <th>Publication Date (GMT)</th>
33
  </tr>
34
  <xsl:variable name="lower" select="'abcdefghijklmnopqrstuvwxyz'"/>
41
  </td>
42
  <td><xsl:value-of select="news:news/news:publication/news:language"/></td>
43
  <td><xsl:value-of select="count(image:image)"/></td>
44
+ <td><xsl:value-of select="news:news/news:keywords"/></td>
45
+ <td><xsl:value-of select="news:news/news:stock_tickers"/></td>
46
  <td><xsl:value-of select="concat(substring(news:news/news:publication_date,0,11),concat(' ', substring(news:news/news:publication_date,12,8)))"/></td>
47
  </tr>
48
  </xsl:for-each>
views/styles/sitemap-taxonomy.xsl CHANGED
@@ -10,7 +10,7 @@
10
  <head>
11
  <title>XML Sitemap Feed</title>
12
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
13
- <style type="text/css">body{font-family:"Lucida Grande","Lucida Sans Unicode",Tahoma,Verdana,sans-serif;font-size:13px}#header,#footer{padding:2px;margin:10px;font-size:8pt;color:gray}a{color:black}td{font-size:11px}th{text-align:left;padding-right:30px;font-size:11px}tr.high{background-color:whitesmoke}#footer img{vertical-align:bottom}</style>
14
  </head>
15
  <body>
16
  <h1>XML Sitemap Feed</h1>
10
  <head>
11
  <title>XML Sitemap Feed</title>
12
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
13
+ <style type="text/css">body{font-family:"Lucida Grande","Lucida Sans Unicode",Tahoma,Verdana,sans-serif;font-size:13px}#header,#footer{padding:2px;margin:10px;font-size:8pt;color:gray}a{color:black}td{font-size:11px}th{text-align:left;padding-right:30px;font-size:11px}tr.high{background-color:whitesmoke}#footer img{vertical-align:middle}</style>
14
  </head>
15
  <body>
16
  <h1>XML Sitemap Feed</h1>
views/styles/sitemap.xsl CHANGED
@@ -10,7 +10,7 @@
10
  <head>
11
  <title>XML Sitemap Feed</title>
12
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
13
- <style type="text/css">body{font-family:"Lucida Grande","Lucida Sans Unicode",Tahoma,Verdana,sans-serif;font-size:13px}#header,#footer{padding:2px;margin:10px;font-size:8pt;color:gray}a{color:black}td{font-size:11px}th{text-align:left;padding-right:30px;font-size:11px}tr.high{background-color:whitesmoke}#footer img{vertical-align:bottom}</style>
14
  </head>
15
  <body>
16
  <h1>XML Sitemap Feed</h1>
10
  <head>
11
  <title>XML Sitemap Feed</title>
12
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
13
+ <style type="text/css">body{font-family:"Lucida Grande","Lucida Sans Unicode",Tahoma,Verdana,sans-serif;font-size:13px}#header,#footer{padding:2px;margin:10px;font-size:8pt;color:gray}a{color:black}td{font-size:11px}th{text-align:left;padding-right:30px;font-size:11px}tr.high{background-color:whitesmoke}#footer img{vertical-align:middle}</style>
14
  </head>
15
  <body>
16
  <h1>XML Sitemap Feed</h1>
xml-sitemap.php CHANGED
@@ -4,15 +4,15 @@ Plugin Name: XML Sitemap & Google News
4
  Plugin URI: http://status301.net/wordpress-plugins/xml-sitemap-feed/
5
  Description: Feed the hungry spiders in compliance with the XML Sitemap and Google News protocols. Happy with the results? Please leave me a <strong><a href="https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=ravanhagen%40gmail%2ecom&item_name=XML%20Sitemap%20Feed">tip</a></strong> for continued development and support. Thanks :)
6
  Text Domain: xml-sitemap-feed
7
- Version: 5.0.7
8
  Requires PHP: 5.4
9
  Author: RavanH
10
  Author URI: http://status301.net/
11
  */
12
 
13
- define( 'XMLSF_VERSION', '5.0.7' );
14
 
15
- /* Copyright 2018 RavanH
16
  http://status301.net/
17
  mailto: ravanhagen@gmail.com
18
 
@@ -30,32 +30,38 @@ define( 'XMLSF_VERSION', '5.0.7' );
30
  * AVAILABLE HOOKS
31
  * --------------------
32
  *
33
- * FILTERS
34
- * xmlsf_defaults -> Filters the default array values for different option groups.
35
- * xmlsf_allowed_domain -> Filters the response when checking the url against allowed domains.
36
- * Passes variable $url; must return true or false.
37
- * xmlsf_excluded -> Filters the response when checking the post for exclusion flags in
38
- * XML Sitemap context. Passes variable $post_id; must return true or false.
39
- * xmlsf_news_excluded -> Filters the response when checking the post for exclusion flags in
40
- * Google News sitemap context. Passes variable $post_id; must return true or false.
41
- * the_title_xmlsitemap -> Filters the Google News publication name and title, plus
42
- * the Image title and caption tags.
43
- * xmlsf_custom_urls -> Filters the custom urls array
44
- * xmlsf_custom_sitemaps -> Filters the custom sitemaps array
45
- * xmlsf_post_language -> Filters the post language tag used in the news sitemap.
46
- * Passes variable $post_id; must return a 2 or 3 letter
47
- * language ISO 639 code with the exception of zh-cn and zh-tw.
48
- * xmlsf_post_types -> Filters the post types array for the XML sitemaps index.
49
- * xmlsf_post_priority -> Filters a post priority value. Passes variables $priority and $post->ID.
50
- * Must return a float value between 0.1 and 1.0
51
- * xmlsf_term_priority -> Filters a taxonomy term priority value. Passes variables $priority and $term->slug.
52
- * Must return a float value between 0.1 and 1.0
53
- * xmlsf_news_post_types -> Filters the post types array for the Google News sitemap.
 
 
 
 
54
  *
55
- * ACTIONS
56
- * xmlsf_news_tags_after -> Fired inside the Google News Sitemap loop at the end of the news
57
- * tags, just before each closing </news:news> is generated. Can be used to
58
- * echo custom tags or trigger another action in the background.
 
 
59
  * xmlsf_news_settings_before -> Fired before the Google News Sitemap settings form
60
  * xmlsf_news_settings_after -> Fired after the Google News Sitemap settings form
61
  *
@@ -79,8 +85,12 @@ require XMLSF_DIR . '/models/global.php';
79
 
80
  require XMLSF_DIR . '/controllers/global.php';
81
 
 
82
  add_action( 'init', 'xmlsf_init' );
83
 
 
 
 
84
  register_activation_hook( __FILE__, 'xmlsf_activate' );
85
 
86
  register_deactivation_hook( __FILE__, 'xmlsf_deactivate' );
4
  Plugin URI: http://status301.net/wordpress-plugins/xml-sitemap-feed/
5
  Description: Feed the hungry spiders in compliance with the XML Sitemap and Google News protocols. Happy with the results? Please leave me a <strong><a href="https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=ravanhagen%40gmail%2ecom&item_name=XML%20Sitemap%20Feed">tip</a></strong> for continued development and support. Thanks :)
6
  Text Domain: xml-sitemap-feed
7
+ Version: 5.1
8
  Requires PHP: 5.4
9
  Author: RavanH
10
  Author URI: http://status301.net/
11
  */
12
 
13
+ define( 'XMLSF_VERSION', '5.1' );
14
 
15
+ /* Copyright 2019 RavanH
16
  http://status301.net/
17
  mailto: ravanhagen@gmail.com
18
 
30
  * AVAILABLE HOOKS
31
  * --------------------
32
  *
33
+ * FILTERS
34
+ * xmlsf_defaults -> Filters the default array values for different option groups.
35
+ * xmlsf_allowed_domain -> Filters the response when checking the url against allowed domains.
36
+ * Passes variable $url; must return true or false.
37
+ * xmlsf_excluded -> Filters the response when checking the post for exclusion flags in
38
+ * XML Sitemap context. Passes variable $post_id; must return true or false.
39
+ * xmlsf_news_excluded -> Filters the response when checking the post for exclusion flags in
40
+ * Google News sitemap context. Passes variable $post_id; must return true or false.
41
+ * xmlsf_news_keywords -> Filters the news keywords array
42
+ * xmlsf_news_stock_tickers -> Filters the news stock tickers array
43
+ * xmlsf_disabled_taxonomies -> Filters the taxonomies that should be unavailable for sitemaps
44
+ * Passes an array of taxonomies to exclude; must return an array.
45
+ * the_title_xmlsitemap -> Filters the Google News publication name and title, plus
46
+ * the Image title and caption tags.
47
+ * xmlsf_custom_urls -> Filters the custom urls array
48
+ * xmlsf_custom_sitemaps -> Filters the custom sitemaps array
49
+ * xmlsf_post_language -> Filters the post language tag used in the news sitemap.
50
+ * Passes variable $post_id; must return a 2 or 3 letter
51
+ * language ISO 639 code with the exception of zh-cn and zh-tw.
52
+ * xmlsf_post_types -> Filters the post types array for the XML sitemaps index.
53
+ * xmlsf_post_priority -> Filters a post priority value. Passes variables $priority and $post->ID.
54
+ * Must return a float value between 0.1 and 1.0
55
+ * xmlsf_term_priority -> Filters a taxonomy term priority value. Passes variables $priority and $term->slug.
56
+ * Must return a float value between 0.1 and 1.0
57
+ * xmlsf_news_post_types -> Filters the post types array for the Google News sitemap settings page.
58
  *
59
+ * ACTIONS
60
+ * xmlsf_ping -> Fires hen a search engine has been pinged. Carries four arguments:
61
+ * search engine (google|bing), sitemap name, full ping url, ping repsonse code.
62
+ * xmlsf_news_tags_after -> Fired inside the Google News Sitemap loop at the end of the news
63
+ * tags, just before each closing </news:news> is generated. Can be used to
64
+ * echo custom tags or trigger another action in the background.
65
  * xmlsf_news_settings_before -> Fired before the Google News Sitemap settings form
66
  * xmlsf_news_settings_after -> Fired after the Google News Sitemap settings form
67
  *
85
 
86
  require XMLSF_DIR . '/controllers/global.php';
87
 
88
+ // main plugin init
89
  add_action( 'init', 'xmlsf_init' );
90
 
91
+ // add rewrite rules
92
+ add_filter( 'rewrite_rules_array', 'xmlsf_rewrite_rules', 99, 1 );
93
+
94
  register_activation_hook( __FILE__, 'xmlsf_activate' );
95
 
96
  register_deactivation_hook( __FILE__, 'xmlsf_deactivate' );