XML Sitemap & Google News feeds - Version 4.7.3

Version Description

Improved Polylang and WPML compatibility. Various bug fixes.

=

Download this release

Release Info

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

Code changes from version 4.7.1 to 4.7.3

.gitignore DELETED
@@ -1,18 +0,0 @@
1
- *.log
2
- .htaccess
3
- sitemap.xml
4
- sitemap.xml.gz
5
- wp-config.php
6
- wp-content/advanced-cache.php
7
- wp-content/backup-db/
8
- wp-content/backups/
9
- wp-content/blogs.dir/
10
- wp-content/cache/
11
- wp-content/upgrade/
12
- wp-content/uploads/
13
- wp-content/wp-cache-config.php
14
- wp-content/plugins/hello.php
15
-
16
- /readme.html
17
- /license.txt
18
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
includes/class-xmlsitemapfeed-admin.php CHANGED
@@ -678,7 +678,11 @@ jQuery( document ).ready( function() {
678
  //sanitize callback functions
679
 
680
  public function sanitize_robots_settings($new) {
681
- if(is_array($new)) $new = array_shift(array_filter($new));
 
 
 
 
682
  return trim(strip_tags($new));
683
  }
684
 
@@ -707,7 +711,7 @@ jQuery( document ).ready( function() {
707
  $old = parent::get_post_types();
708
  $defaults = parent::defaults('post_types');
709
  $sanitized = $new;
710
-
711
  foreach ($new as $post_type => $settings) {
712
  // when post types are (de)activated, set transient to flush rewrite rules
713
  if ( ( !empty($old[$post_type]['active']) && empty($settings['active']) ) || ( empty($old[$post_type]['active']) && !empty($settings['active']) ) )
@@ -744,11 +748,17 @@ jQuery( document ).ready( function() {
744
  public function sanitize_custom_sitemaps_settings($new) {
745
  $old = parent::get_custom_sitemaps();
746
  $callback = create_function('$a','return filter_var($a,FILTER_VALIDATE_URL);');
747
- if(is_array($new)) $new = array_shift(array_filter($new));
748
- $input_arr = explode("\n",trim(strip_tags($new)));
749
- $sanitized = array();
750
 
751
- foreach ($input_arr as $line) {
 
 
 
 
 
 
 
 
 
752
  $line = filter_var(esc_url(trim($line)),FILTER_VALIDATE_URL,FILTER_FLAG_PATH_REQUIRED);
753
  if(!empty($line))
754
  $sanitized[] = $line;
@@ -759,12 +769,19 @@ jQuery( document ).ready( function() {
759
 
760
  public function sanitize_urls_settings($new) {
761
  $old = parent::get_urls();
762
- if(is_array($new)) $new = array_shift(array_filter($new));
763
- $input_arr = explode("\n",trim(strip_tags($new)));
 
 
 
 
 
 
 
764
  $sanitized = array();
765
  $callback = create_function('$a','return filter_var($a,FILTER_VALIDATE_URL) || is_numeric($a);');
766
 
767
- foreach ($input_arr as $line) {
768
  if(empty($line))
769
  continue;
770
 
@@ -792,10 +809,16 @@ jQuery( document ).ready( function() {
792
 
793
  public function sanitize_domains_settings($new) {
794
  $default = parent::domain();
795
- if(is_array($new)) $new = array_shift(array_filter($new));
796
- $input = explode("\n",trim(strip_tags($new)));
797
- $sanitized = array();
798
 
 
 
 
 
 
 
 
 
 
799
  foreach ($input as $line) {
800
  $line = trim($line);
801
  $parsed_url = parse_url(trim(filter_var($line,FILTER_SANITIZE_URL)));
678
  //sanitize callback functions
679
 
680
  public function sanitize_robots_settings($new) {
681
+ // clean up input
682
+ if(is_array($new)) {
683
+ $new = array_filter($new);
684
+ $new = reset($new);
685
+ }
686
  return trim(strip_tags($new));
687
  }
688
 
711
  $old = parent::get_post_types();
712
  $defaults = parent::defaults('post_types');
713
  $sanitized = $new;
714
+
715
  foreach ($new as $post_type => $settings) {
716
  // when post types are (de)activated, set transient to flush rewrite rules
717
  if ( ( !empty($old[$post_type]['active']) && empty($settings['active']) ) || ( empty($old[$post_type]['active']) && !empty($settings['active']) ) )
748
  public function sanitize_custom_sitemaps_settings($new) {
749
  $old = parent::get_custom_sitemaps();
750
  $callback = create_function('$a','return filter_var($a,FILTER_VALIDATE_URL);');
 
 
 
751
 
752
+ // clean up input
753
+ if(is_array($new)) {
754
+ $new = array_filter($new);
755
+ $new = reset($new);
756
+ }
757
+ $input = $new ? explode("\n",trim(strip_tags($new))) : array();
758
+
759
+ // build sanitized output
760
+ $sanitized = array();
761
+ foreach ($input as $line) {
762
  $line = filter_var(esc_url(trim($line)),FILTER_VALIDATE_URL,FILTER_FLAG_PATH_REQUIRED);
763
  if(!empty($line))
764
  $sanitized[] = $line;
769
 
770
  public function sanitize_urls_settings($new) {
771
  $old = parent::get_urls();
772
+
773
+ // clean up input
774
+ if(is_array($new)) {
775
+ $new = array_filter($new);
776
+ $new = reset($new);
777
+ }
778
+ $input = $new ? explode("\n",trim(strip_tags($new))) : array();
779
+
780
+ // build sanitized output
781
  $sanitized = array();
782
  $callback = create_function('$a','return filter_var($a,FILTER_VALIDATE_URL) || is_numeric($a);');
783
 
784
+ foreach ($input as $line) {
785
  if(empty($line))
786
  continue;
787
 
809
 
810
  public function sanitize_domains_settings($new) {
811
  $default = parent::domain();
 
 
 
812
 
813
+ // clean up input
814
+ if(is_array($new)) {
815
+ $new = array_filter($new);
816
+ $new = reset($new);
817
+ }
818
+ $input = $new ? explode("\n",trim(strip_tags($new))) : array();
819
+
820
+ // build sanitized output
821
+ $sanitized = array();
822
  foreach ($input as $line) {
823
  $line = trim($line);
824
  $parsed_url = parse_url(trim(filter_var($line,FILTER_SANITIZE_URL)));
includes/class-xmlsitemapfeed.php CHANGED
@@ -43,7 +43,8 @@ class XMLSitemapFeed {
43
  private $lastmodified; // unused at the moment
44
  private $postmodified = array();
45
  private $termmodified = array();
46
- private $blogpage;
 
47
  private $images = array();
48
 
49
  // make some private parts public ;)
@@ -370,33 +371,67 @@ class XMLSitemapFeed {
370
  ) ? (array)$return[$type]['tags'] : array();
371
  }
372
 
373
- public function is_home($id)
374
  {
375
- if ( empty($this->blogpage) ) {
376
- $blogpage = get_option('page_for_posts');
 
 
 
 
 
 
 
 
 
 
 
 
 
377
 
 
 
 
 
 
 
 
 
 
378
  if ( !empty($blogpage) ) {
379
- global $polylang,$sitepress; // Polylang and WPML compat
380
- if ( isset($polylang) && is_object($polylang) && isset($polylang->model) && is_object($polylang->model) && method_exists($polylang->model, 'get_translations') )
381
- $this->blogpage = $polylang->model->get_translations('post', $blogpage);
382
- if ( isset($sitepress) && is_object($sitepress) && method_exists($sitepress, 'get_languages') && method_exists($sitepress, 'get_object_id') )
383
- foreach ( array_keys ( $sitepress->get_languages(false,true) ) as $term )
384
- $this->blogpage[] = $sitepress->get_object_id($id,'page',false,$term);
385
- else
386
- $this->blogpage = array($blogpage);
387
- } else {
388
- $this->blogpage = array('-1');
389
  }
390
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
391
 
392
- return in_array($id,$this->blogpage);
 
 
393
  }
394
 
395
  /**
396
  * TEMPLATE FUNCTIONS
397
  */
398
 
399
- public function modified($sitemap = 'post_type', $term = '')
400
  {
401
  if ('post_type' == $sitemap) :
402
 
@@ -471,7 +506,7 @@ class XMLSitemapFeed {
471
  endif;
472
  }
473
 
474
- public function get_images($sitemap = '')
475
  {
476
  global $post;
477
  if ( empty($this->images[$post->ID]) ) {
@@ -510,13 +545,13 @@ class XMLSitemapFeed {
510
  return ( isset($this->images[$post->ID]) ) ? $this->images[$post->ID] : false;
511
  }
512
 
513
- public function get_lastmod($sitemap = 'post_type', $term = '')
514
  {
515
  $return = trim(mysql2date('Y-m-d\TH:i:s+00:00', $this->modified($sitemap,$term), false));
516
  return !empty($return) ? "\t<lastmod>".$return."</lastmod>\r\n\t" : '';
517
  }
518
 
519
- public function get_changefreq($sitemap = 'post_type', $term = '')
520
  {
521
  $modified = trim($this->modified($sitemap,$term));
522
 
@@ -540,7 +575,7 @@ class XMLSitemapFeed {
540
  return $changefreq;
541
  }
542
 
543
- public function get_priority($sitemap = 'post_type', $term = '')
544
  {
545
  if ( 'post_type' == $sitemap ) :
546
  global $post;
@@ -571,7 +606,7 @@ class XMLSitemapFeed {
571
  $priority_value = floatval($defaults[$post->post_type]['priority']);
572
 
573
  // reduce by age
574
- // NOTE : home/blog page gets same treatment as sticky post
575
  if ( is_sticky($post->ID) || $this->is_home($post->ID) )
576
  $priority = $priority_value;
577
  else
@@ -622,39 +657,41 @@ class XMLSitemapFeed {
622
  {
623
  $urls = array();
624
 
625
- global $polylang,$sitepress; // Polylang and WPML compat
626
-
627
- if ( isset($polylang) && is_object($polylang) && method_exists($polylang, 'get_languages') && method_exists($polylang, 'get_home_url') )
628
- foreach ($polylang->get_languages_list() as $term)
629
- $urls[] = $polylang->get_home_url($term);
630
- elseif ( isset($sitepress) && is_object($sitepress) && method_exists($sitepress, 'get_languages') && method_exists($sitepress, 'language_url') )
 
 
 
631
  foreach ( array_keys ( $sitepress->get_languages(false,true) ) as $term )
632
  $urls[] = $sitepress->language_url($term);
633
- else
634
  $urls[] = home_url();
 
635
 
636
  return $urls;
637
  }
638
 
639
- public function get_excluded($post_type)
640
  {
641
- $exclude = array();
642
-
643
- if ( $post_type == 'page' and $id = get_option('page_on_front') ) { // use 'and' here for precedence of the assignement operator, thanks @kitchin
644
- global $polylang,$sitepress; // Polylang and WPML compat
645
- if ( isset($polylang) && is_object($polylang) && isset($polylang->model) && is_object($polylang->model) && method_exists($polylang->model, 'get_translations') )
646
- $exclude += $polylang->model->get_translations('post', $id);
647
- if ( isset($sitepress) && is_object($sitepress) && method_exists($sitepress, 'get_languages') && method_exists($sitepress, 'get_object_id') )
648
- foreach ( array_keys ( $sitepress->get_languages(false,true) ) as $term )
649
- $exclude[] = $sitepress->get_object_id($id,'page',false,$term);
650
  else
651
- $exclude[] = $id;
652
  }
653
 
654
- return $exclude;
 
 
655
  }
656
 
657
- public function is_allowed_domain($url)
658
  {
659
  $domains = $this->get_domains();
660
  $return = false;
@@ -669,7 +706,7 @@ class XMLSitemapFeed {
669
  }
670
  }
671
 
672
- return apply_filters( 'xmlsf_allowed_domain', $return );
673
  }
674
 
675
  public function get_index_url( $sitemap = 'home', $type = false, $param = false )
@@ -715,18 +752,15 @@ class XMLSitemapFeed {
715
  // WPML compat
716
  global $sitepress;
717
  if ( isset($sitepress) && is_object($sitepress) && method_exists($sitepress, 'get_language_for_element') ) {
718
- $post_type = get_query_var( 'post_type', 'post' );
719
  $language = $sitepress->get_language_for_element( $id, 'post_'.$post_type[0] );
720
  //apply_filters( 'wpml_element_language_code', null, array( 'element_id' => $id, 'element_type' => $post_type ) );
721
  }
722
 
723
  // Polylang
724
- if ( taxonomy_exists('language') ) {
725
- $lang = get_the_terms($id,'language');
726
- if ( is_array($lang) ) {
727
- $lang = reset($lang);
728
- $language = is_object($lang) ? $lang->slug : $language;
729
- }
730
  }
731
 
732
  return !empty($language) ? $language : $this->blog_language;
@@ -828,7 +862,19 @@ class XMLSitemapFeed {
828
  $request['cache_results'] = false;
829
  $request['update_post_term_cache'] = false;
830
  $request['update_post_meta_cache'] = false;
831
- $request['lang'] = ''; // Polylang
 
 
 
 
 
 
 
 
 
 
 
 
832
 
833
  if ( $request['feed'] == 'sitemap-news' ) {
834
  $defaults = $this->defaults('news_tags');
@@ -849,12 +895,6 @@ class XMLSitemapFeed {
849
  add_filter('post_limits', array($this, 'filter_no_news_limits'));
850
  }
851
 
852
- global $wpml_query_filter; // WPML compat
853
- if ( isset($wpml_query_filter) && is_object($wpml_query_filter) ) {
854
- remove_filter( 'posts_join', array( $wpml_query_filter, 'posts_join_filter' ) );
855
- remove_filter( 'posts_where', array( $wpml_query_filter, 'posts_where_filter' ) );
856
- }
857
-
858
  // post type
859
  $request['post_type'] = $news_post_type;
860
 
@@ -874,12 +914,6 @@ class XMLSitemapFeed {
874
  $request['post_type'] = $post_type['name'];
875
  $request['orderby'] = 'modified';
876
 
877
- global $wpml_query_filter; // WPML compat
878
- if ( isset($wpml_query_filter) && is_object($wpml_query_filter) ) {
879
- remove_filter('posts_join', array($wpml_query_filter, 'posts_join_filter'));
880
- remove_filter('posts_where', array($wpml_query_filter, 'posts_where_filter'));
881
- }
882
-
883
  return $request;
884
  }
885
  }
@@ -892,11 +926,13 @@ class XMLSitemapFeed {
892
  $request['taxonomy'] = $taxonomy;
893
 
894
  // WPML compat
895
- global $sitepress;
896
- if ( isset($sitepress) && is_object($sitepress) ) {
897
- remove_filter('get_terms_args', array($sitepress, 'get_terms_args_filter'));
898
- remove_filter('get_term', array($sitepress,'get_term_adjust_id'));
899
- remove_filter('terms_clauses', array($sitepress,'terms_clauses'));
 
 
900
  }
901
 
902
  return $request;
@@ -942,7 +978,7 @@ class XMLSitemapFeed {
942
  load_template( dirname( __FILE__ ) . '/feed-sitemap-news.php' );
943
  }
944
 
945
- // set up the news sitemap template
946
  public function load_template_custom()
947
  {
948
  load_template( dirname( __FILE__ ) . '/feed-sitemap-custom.php' );
@@ -1075,7 +1111,7 @@ class XMLSitemapFeed {
1075
  }
1076
  }
1077
 
1078
- function cache_flush($new_status, $old_status)
1079
  {
1080
  // are we moving the post in or out of published status?
1081
  if ( $new_status == 'publish' || $old_status == 'publish' ) {
@@ -1142,7 +1178,7 @@ class XMLSitemapFeed {
1142
  * INITIALISATION
1143
  */
1144
 
1145
- public function upgrade($old_version)
1146
  {
1147
  // rewrite rules not available on plugins_loaded
1148
  // and don't flush rules from init as Polylang chokes on that
@@ -1292,7 +1328,7 @@ class XMLSitemapFeed {
1292
  include_once( dirname( __FILE__ ) . '/class-xmlsitemapfeed-admin.php' );
1293
  }
1294
 
1295
- public function flush_rules($hard = false)
1296
  {
1297
  // did you flush already?
1298
  if ($this->yes_mother)
43
  private $lastmodified; // unused at the moment
44
  private $postmodified = array();
45
  private $termmodified = array();
46
+ private $frontpages = null;
47
+ private $blogpages = null;
48
  private $images = array();
49
 
50
  // make some private parts public ;)
371
  ) ? (array)$return[$type]['tags'] : array();
372
  }
373
 
374
+ private function get_translations( $post_id )
375
  {
376
+ $translation_ids = array();
377
+ // Polylang compat
378
+ if ( function_exists('pll_get_post_translations') ) {
379
+ $translations = pll_get_post_translations($post_id);
380
+ foreach ( $translations as $slug => $id )
381
+ if ( $post_id != $id ) $translation_ids[] = $id;
382
+ }
383
+ // WPML compat
384
+ global $sitepress;
385
+ if ( isset($sitepress) && is_object($sitepress) && method_exists($sitepress, 'get_languages') && method_exists($sitepress, 'get_object_id') ) {
386
+ foreach ( array_keys ( $sitepress->get_languages(false,true) ) as $term ) {
387
+ $id = $sitepress->get_object_id($post_id,'page',false,$term);
388
+ if ( $post_id != $id ) $translation_ids[] = $id;
389
+ }
390
+ }
391
 
392
+ return $translation_ids;
393
+ }
394
+
395
+ private function get_blogpages()
396
+ {
397
+ if ( null === $this->blogpages ) :
398
+ $blogpages = array();
399
+ if ( 'page' == get_option('show_on_front') ) {
400
+ $blogpage = (int)get_option('page_for_posts');
401
  if ( !empty($blogpage) ) {
402
+ $blogpages = array_merge( (array)$blogpage, $this->get_translations($blogpage) );
 
 
 
 
 
 
 
 
 
403
  }
404
  }
405
+ $this->blogpages = $blogpages;
406
+ endif;
407
+
408
+ return $this->blogpages;
409
+ }
410
+
411
+ private function get_frontpages()
412
+ {
413
+ if ( null === $this->frontpages ) :
414
+ $frontpages = array();
415
+ if ( 'page' == get_option('show_on_front') ) {
416
+ $frontpage = (int)get_option('page_on_front');
417
+ $frontpages = array_merge( (array)$frontpage, $this->get_translations($frontpage) );
418
+ }
419
+ $this->frontpages = $frontpages;
420
+ endif;
421
+
422
+ return $this->frontpages;
423
+ }
424
 
425
+ private function is_home( $id )
426
+ {
427
+ return in_array( $id, $this->get_blogpages() );
428
  }
429
 
430
  /**
431
  * TEMPLATE FUNCTIONS
432
  */
433
 
434
+ public function modified( $sitemap = 'post_type', $term = '' )
435
  {
436
  if ('post_type' == $sitemap) :
437
 
506
  endif;
507
  }
508
 
509
+ public function get_images( $sitemap = '' )
510
  {
511
  global $post;
512
  if ( empty($this->images[$post->ID]) ) {
545
  return ( isset($this->images[$post->ID]) ) ? $this->images[$post->ID] : false;
546
  }
547
 
548
+ public function get_lastmod( $sitemap = 'post_type', $term = '' )
549
  {
550
  $return = trim(mysql2date('Y-m-d\TH:i:s+00:00', $this->modified($sitemap,$term), false));
551
  return !empty($return) ? "\t<lastmod>".$return."</lastmod>\r\n\t" : '';
552
  }
553
 
554
+ public function get_changefreq( $sitemap = 'post_type', $term = '' )
555
  {
556
  $modified = trim($this->modified($sitemap,$term));
557
 
575
  return $changefreq;
576
  }
577
 
578
+ public function get_priority( $sitemap = 'post_type', $term = '' )
579
  {
580
  if ( 'post_type' == $sitemap ) :
581
  global $post;
606
  $priority_value = floatval($defaults[$post->post_type]['priority']);
607
 
608
  // reduce by age
609
+ // NOTE : home/blog page gets same treatment as sticky post, i.e. no reduction by age
610
  if ( is_sticky($post->ID) || $this->is_home($post->ID) )
611
  $priority = $priority_value;
612
  else
657
  {
658
  $urls = array();
659
 
660
+ global $sitepress; // Polylang and WPML compat
661
+ if ( function_exists('pll_the_languages') ) {
662
+ $languages = pll_the_languages( array( 'raw' => 1 ) );
663
+ if ( is_array($languages) )
664
+ foreach ( $languages as $language )
665
+ $urls[] = pll_home_url( $language['slug'] );
666
+ else
667
+ $urls[] = home_url();
668
+ } elseif ( isset($sitepress) && is_object($sitepress) && method_exists($sitepress, 'get_languages') && method_exists($sitepress, 'language_url') ) {
669
  foreach ( array_keys ( $sitepress->get_languages(false,true) ) as $term )
670
  $urls[] = $sitepress->language_url($term);
671
+ } else {
672
  $urls[] = home_url();
673
+ }
674
 
675
  return $urls;
676
  }
677
 
678
+ public function is_excluded( $post_id = null )
679
  {
680
+ // no ID, try and get it from global post object
681
+ if ( null == $post_id ) {
682
+ global $post;
683
+ if ( is_object($post) && isset($post->ID))
684
+ $post_id = $post->ID;
 
 
 
 
685
  else
686
+ return false;
687
  }
688
 
689
+ $excluded = get_post_meta($post_id,'_xmlsf_exclude',true) || in_array($post_id,$this->get_frontpages()) ? true : false;
690
+
691
+ return apply_filters( 'xmlsf_excluded', $excluded, $post_id );
692
  }
693
 
694
+ public function is_allowed_domain( $url )
695
  {
696
  $domains = $this->get_domains();
697
  $return = false;
706
  }
707
  }
708
 
709
+ return apply_filters( 'xmlsf_allowed_domain', $return, $url );
710
  }
711
 
712
  public function get_index_url( $sitemap = 'home', $type = false, $param = false )
752
  // WPML compat
753
  global $sitepress;
754
  if ( isset($sitepress) && is_object($sitepress) && method_exists($sitepress, 'get_language_for_element') ) {
755
+ $post_type = get_query_var( 'post_type', 'post' ); // is $post_type always an array here??
756
  $language = $sitepress->get_language_for_element( $id, 'post_'.$post_type[0] );
757
  //apply_filters( 'wpml_element_language_code', null, array( 'element_id' => $id, 'element_type' => $post_type ) );
758
  }
759
 
760
  // Polylang
761
+ if ( function_exists('pll_get_post_language') ) {
762
+ $lang = pll_get_post_language( $id, 'slug' );
763
+ $language = !empty($lang) ? $lang : $language;
 
 
 
764
  }
765
 
766
  return !empty($language) ? $language : $this->blog_language;
862
  $request['cache_results'] = false;
863
  $request['update_post_term_cache'] = false;
864
  $request['update_post_meta_cache'] = false;
865
+
866
+ // Polylang compat
867
+ $request['lang'] = '';
868
+ // WPML compat
869
+ global $wpml_query_filter,$wpml_url_filters;
870
+ if ( isset($wpml_query_filter) && isset($wpml_url_filters) && is_object($wpml_query_filter) && is_object($wpml_url_filters) ) {
871
+ remove_filter( 'posts_join', array( $wpml_query_filter, 'posts_join_filter' ) );
872
+ remove_filter( 'posts_where', array( $wpml_query_filter, 'posts_where_filter' ) );
873
+ remove_filter( 'post_link', array( $wpml_url_filters, 'permalink_filter' ), 1 );
874
+ remove_filter( 'post_type_link', array( $wpml_url_filters, 'permalink_filter' ), 1 );
875
+ remove_filter( 'page_link', array( $wpml_url_filters, 'permalink_filter_root' ), 1 );
876
+ remove_filter( 'page_link', array( $wpml_url_filters, 'permalink_filter' ), 1 );
877
+ }
878
 
879
  if ( $request['feed'] == 'sitemap-news' ) {
880
  $defaults = $this->defaults('news_tags');
895
  add_filter('post_limits', array($this, 'filter_no_news_limits'));
896
  }
897
 
 
 
 
 
 
 
898
  // post type
899
  $request['post_type'] = $news_post_type;
900
 
914
  $request['post_type'] = $post_type['name'];
915
  $request['orderby'] = 'modified';
916
 
 
 
 
 
 
 
917
  return $request;
918
  }
919
  }
926
  $request['taxonomy'] = $taxonomy;
927
 
928
  // WPML compat
929
+ global $sitepress,$wpml_url_converter;
930
+ if ( isset($sitepress) && isset($wpml_url_converter) && is_object($sitepress) && is_object($wpml_url_converter) ) {
931
+ remove_filter( 'get_terms_args', array($sitepress, 'get_terms_args_filter') );
932
+ remove_filter( 'get_term', array($sitepress,'get_term_adjust_id'), 1 );
933
+ remove_filter( 'terms_clauses', array($sitepress,'terms_clauses') );
934
+ remove_filter( 'category_link', array($sitepress, 'category_link_adjust_id'), 1 );
935
+ remove_filter( 'term_link', array($wpml_url_converter, 'tax_permalink_filter'), 1 );
936
  }
937
 
938
  return $request;
978
  load_template( dirname( __FILE__ ) . '/feed-sitemap-news.php' );
979
  }
980
 
981
+ // set up the custom sitemap template
982
  public function load_template_custom()
983
  {
984
  load_template( dirname( __FILE__ ) . '/feed-sitemap-custom.php' );
1111
  }
1112
  }
1113
 
1114
+ function cache_flush( $new_status, $old_status )
1115
  {
1116
  // are we moving the post in or out of published status?
1117
  if ( $new_status == 'publish' || $old_status == 'publish' ) {
1178
  * INITIALISATION
1179
  */
1180
 
1181
+ public function upgrade( $old_version )
1182
  {
1183
  // rewrite rules not available on plugins_loaded
1184
  // and don't flush rules from init as Polylang chokes on that
1328
  include_once( dirname( __FILE__ ) . '/class-xmlsitemapfeed-admin.php' );
1329
  }
1330
 
1331
+ public function flush_rules( $hard = false )
1332
  {
1333
  // did you flush already?
1334
  if ($this->yes_mother)
includes/feed-sitemap-post_type.php CHANGED
@@ -20,9 +20,8 @@ echo '<?xml version="1.0" encoding="' . get_bloginfo('charset') . '"?>
20
  <urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" ';
21
 
22
  global $xmlsf;
23
- $post_type = get_query_var('post_type');
24
 
25
- foreach ( $xmlsf->do_tags($post_type) as $tag => $setting )
26
  $$tag = $setting;
27
 
28
  echo !empty($image) ? '
@@ -37,9 +36,6 @@ echo !empty($image) ? '
37
  echo '">
38
  ';
39
 
40
- // any ID's we need to exclude?
41
- $excluded = $xmlsf->get_excluded($post_type);
42
-
43
  // set empty sitemap flag
44
  $have_posts = false;
45
 
@@ -48,11 +44,9 @@ if ( have_posts() ) :
48
  while ( have_posts() ) :
49
  the_post();
50
 
51
- // check if page is in the exclusion list (like front page)
52
  // or if we are not dealing with an external URL :: Thanks to Francois Deschenes :)
53
- // or if post meta says "exclude me please"
54
- $exclude = get_post_meta( $post->ID, '_xmlsf_exclude', true );
55
- if ( !empty($exclude) || !$xmlsf->is_allowed_domain(get_permalink()) || in_array($post->ID, $excluded) )
56
  continue;
57
 
58
  $have_posts = true;
20
  <urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" ';
21
 
22
  global $xmlsf;
 
23
 
24
+ foreach ( $xmlsf->do_tags( get_query_var('post_type') ) as $tag => $setting )
25
  $$tag = $setting;
26
 
27
  echo !empty($image) ? '
36
  echo '">
37
  ';
38
 
 
 
 
39
  // set empty sitemap flag
40
  $have_posts = false;
41
 
44
  while ( have_posts() ) :
45
  the_post();
46
 
47
+ // check if page is in the exclusion list (like front page or post meta)
48
  // or if we are not dealing with an external URL :: Thanks to Francois Deschenes :)
49
+ if ( $xmlsf->is_excluded($post->ID) || !$xmlsf->is_allowed_domain(get_permalink()) )
 
 
50
  continue;
51
 
52
  $have_posts = true;
readme.txt CHANGED
@@ -4,7 +4,7 @@ Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=ravan
4
  Tags: sitemap, xml sitemap, news sitemap, sitemap.xml, robots.txt, Google, Google News, Yahoo, Bing, , Yandex, Baidu, seo, feed, Polylang, WPML, image sitemap
5
  Requires at least: 3.2
6
  Tested up to: 4.5
7
- Stable tag: 4.7.1
8
 
9
  XML and Google News Sitemaps to feed the hungry spiders. Multisite, WP Super Cache, Polylang and WPML compatible.
10
 
@@ -294,13 +294,16 @@ Thanks for sharing your translation :)
294
 
295
  == Upgrade Notice ==
296
 
297
- = 4.7.1 =
298
- WPML and PHP 5.3 compatibility.
299
 
300
  == Changelog ==
301
 
302
- = 4.7.1 =
303
- * PHP 5.3 compatibility fix
 
 
 
304
 
305
  = 4.7 =
306
  * WPML compatibility
4
  Tags: sitemap, xml sitemap, news sitemap, sitemap.xml, robots.txt, Google, Google News, Yahoo, Bing, , Yandex, Baidu, seo, feed, Polylang, WPML, image sitemap
5
  Requires at least: 3.2
6
  Tested up to: 4.5
7
+ Stable tag: 4.7.3
8
 
9
  XML and Google News Sitemaps to feed the hungry spiders. Multisite, WP Super Cache, Polylang and WPML compatible.
10
 
294
 
295
  == Upgrade Notice ==
296
 
297
+ = 4.7.3 =
298
+ Improved Polylang and WPML compatibility. Various bug fixes.
299
 
300
  == Changelog ==
301
 
302
+ = 4.7.3 =
303
+ * NEW: xmlsf_excluded filter
304
+ * IMPROVEMENT: Polylang and WPML compatibility issues
305
+ * FIX: "Only variables should be passed by reference" strict warning
306
+ * FIX: PHP 5.3 compatibility
307
 
308
  = 4.7 =
309
  * WPML compatibility
xml-sitemap.php CHANGED
@@ -4,7 +4,7 @@ Plugin Name: XML Sitemap & Google News feeds
4
  Plugin URI: http://status301.net/wordpress-plugins/xml-sitemap-feed/
5
  Description: Feed the hungry spiders in compliance with the XML Sitemap and Google News protocols. Happy with the results? Please leave me a <strong><a href="https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=ravanhagen%40gmail%2ecom&item_name=XML%20Sitemap%20Feed&item_number=4%2e0&no_shipping=0&tax=0&bn=PP%2dDonationsBF&charset=UTF%2d8&lc=us">tip</a></strong> for continued development and support. Thanks :)
6
  Text Domain: xml-sitemap-feed
7
- Version: 4.7.1
8
  Author: RavanH
9
  Author URI: http://status301.net/
10
  */
@@ -30,7 +30,9 @@ Author URI: http://status301.net/
30
  * FILTERS
31
  * xmlsf_defaults -> Filters the default array values for different option groups.
32
  * xmlsf_allowed_domain -> Filters the response when checking the url against allowed domains.
33
- * Can be true or false.
 
 
34
  * the_title_xmlsitemap -> Filters the Google News publication name, title and keywords
35
  * plus the Image title and caption tags
36
  * xmlsf_custom_urls -> Filters the custom urls array
@@ -50,7 +52,7 @@ if ( ! defined( 'WPINC' ) ) die;
50
  * CONSTANTS
51
  * -------------------- */
52
 
53
- define('XMLSF_VERSION', '4.7.1');
54
 
55
  define('XMLSF_PLUGIN_BASENAME', plugin_basename(__FILE__));
56
 
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&item_number=4%2e0&no_shipping=0&tax=0&bn=PP%2dDonationsBF&charset=UTF%2d8&lc=us">tip</a></strong> for continued development and support. Thanks :)
6
  Text Domain: xml-sitemap-feed
7
+ Version: 4.7.3
8
  Author: RavanH
9
  Author URI: http://status301.net/
10
  */
30
  * FILTERS
31
  * xmlsf_defaults -> Filters the default array values for different option groups.
32
  * xmlsf_allowed_domain -> Filters the response when checking the url against allowed domains.
33
+ * Passes variable $url; must return true or false.
34
+ * xmlsf_excluded -> Filters the response when checking the post for exclusion flags.
35
+ * Passes variable $post_id; must return true or false.
36
  * the_title_xmlsitemap -> Filters the Google News publication name, title and keywords
37
  * plus the Image title and caption tags
38
  * xmlsf_custom_urls -> Filters the custom urls array
52
  * CONSTANTS
53
  * -------------------- */
54
 
55
+ define('XMLSF_VERSION', '4.7.3');
56
 
57
  define('XMLSF_PLUGIN_BASENAME', plugin_basename(__FILE__));
58