diff --git a/includes/class-xmlsitemapfeed.php b/includes/class-xmlsitemapfeed.php index 25cb096..9128dcf 100644 --- a/includes/class-xmlsitemapfeed.php +++ b/includes/class-xmlsitemapfeed.php @@ -849,6 +849,17 @@ public function rewrite_rules($wp_rewrite) $wp_rewrite->rules = $xmlsf_rules + $wp_rewrite->rules; } + public function wpml_language_switcher() { + // WPML: switch language + // @see https://wpml.org/wpml-hook/wpml_post_language_details/ + global $sitepress,$post; + if( isset($sitepress) ) { + $post_language = apply_filters( 'wpml_post_language_details', NULL, $post->ID ); + $sitepress->switch_lang($post_language['language_code']); + } + + } + /** * REQUEST FILTER */ @@ -866,14 +877,11 @@ public function filter_request( $request ) // Polylang compat $request['lang'] = ''; // WPML compat - global $wpml_query_filter,$wpml_url_filters; - if ( isset($wpml_query_filter) && isset($wpml_url_filters) && is_object($wpml_query_filter) && is_object($wpml_url_filters) ) { + global $wpml_query_filter; + if ( isset($wpml_query_filter) && is_object($wpml_query_filter) ) { remove_filter( 'posts_join', array( $wpml_query_filter, 'posts_join_filter' ) ); remove_filter( 'posts_where', array( $wpml_query_filter, 'posts_where_filter' ) ); - remove_filter( 'post_link', array( $wpml_url_filters, 'permalink_filter' ), 1 ); - remove_filter( 'post_type_link', array( $wpml_url_filters, 'permalink_filter' ), 1 ); - remove_filter( 'page_link', array( $wpml_url_filters, 'permalink_filter_root' ), 1 ); - remove_filter( 'page_link', array( $wpml_url_filters, 'permalink_filter' ), 1 ); + add_action( 'the_post', array( $this, 'wpml_language_switcher' ) ); } if ( $request['feed'] == 'sitemap-news' ) { @@ -926,13 +934,12 @@ public function filter_request( $request ) $request['taxonomy'] = $taxonomy; // WPML compat - global $sitepress,$wpml_url_converter; - if ( isset($sitepress) && isset($wpml_url_converter) && is_object($sitepress) && is_object($wpml_url_converter) ) { + global $sitepress; + if ( isset($sitepress) && is_object($sitepress) ) { remove_filter( 'get_terms_args', array($sitepress, 'get_terms_args_filter') ); remove_filter( 'get_term', array($sitepress,'get_term_adjust_id'), 1 ); remove_filter( 'terms_clauses', array($sitepress,'terms_clauses') ); - remove_filter( 'category_link', array($sitepress, 'category_link_adjust_id'), 1 ); - remove_filter( 'term_link', array($wpml_url_converter, 'tax_permalink_filter'), 1 ); + $sitepress->switch_lang('all'); } return $request; diff --git a/readme.txt b/readme.txt index 8829a28..5b2dd36 100644 --- a/readme.txt +++ b/readme.txt @@ -4,7 +4,7 @@ Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=ravan Tags: sitemap, xml sitemap, news sitemap, sitemap.xml, robots.txt, Google, Google News, Yahoo, Bing, , Yandex, Baidu, seo, feed, Polylang, WPML, image sitemap Requires at least: 3.2 Tested up to: 4.5 -Stable tag: 4.7.3 +Stable tag: 4.7.4 XML and Google News Sitemaps to feed the hungry spiders. Multisite, WP Super Cache, Polylang and WPML compatible. @@ -294,11 +294,14 @@ Thanks for sharing your translation :) == Upgrade Notice == -= 4.7.3 = -Improved Polylang and WPML compatibility. Various bug fixes. += 4.7.4 = +WPML compatibility bug fix. == Changelog == += 4.7.4 = +* Another WPML compat issue fixed, special thanks to hermes3por3 + = 4.7.3 = * NEW: xmlsf_excluded filter * IMPROVEMENT: Polylang and WPML compatibility issues diff --git a/xml-sitemap.php b/xml-sitemap.php index 243f99e..40368d9 100644 --- a/xml-sitemap.php +++ b/xml-sitemap.php @@ -4,7 +4,7 @@ Plugin URI: http://status301.net/wordpress-plugins/xml-sitemap-feed/ Description: Feed the hungry spiders in compliance with the XML Sitemap and Google News protocols. Happy with the results? Please leave me a tip for continued development and support. Thanks :) Text Domain: xml-sitemap-feed -Version: 4.7.3 +Version: 4.7.4 Author: RavanH Author URI: http://status301.net/ */ @@ -28,22 +28,22 @@ * -------------------- * * FILTERS - * xmlsf_defaults -> Filters the default array values for different option groups. - * xmlsf_allowed_domain -> Filters the response when checking the url against allowed domains. + * xmlsf_defaults -> Filters the default array values for different option groups. + * xmlsf_allowed_domain -> Filters the response when checking the url against allowed domains. * Passes variable $url; must return true or false. - * xmlsf_excluded -> Filters the response when checking the post for exclusion flags. + * xmlsf_excluded -> Filters the response when checking the post for exclusion flags. * Passes variable $post_id; must return true or false. - * the_title_xmlsitemap -> Filters the Google News publication name, title and keywords + * the_title_xmlsitemap -> Filters the Google News publication name, title and keywords * plus the Image title and caption tags - * xmlsf_custom_urls -> Filters the custom urls array - * xmlsf_custom_sitemaps -> Filters the custom sitemaps array + * xmlsf_custom_urls -> Filters the custom urls array + * xmlsf_custom_sitemaps -> Filters the custom sitemaps array * * ACTIONS - * xmlsf_news_tags_after -> Fired inside the Google News Sitemap loop at the end of the news + * xmlsf_news_tags_after -> Fired inside the Google News Sitemap loop at the end of the news * tags, just before each closing is generated. Can be used to * echo custom tags or trigger another action in the background. * - * feel free to request, suggest or submit more :) + * Feel free to request, suggest or submit more :) */ if ( ! defined( 'WPINC' ) ) die;