Version Description
(2019-07-03) =
- Pro: Fix Yoast SEO sitemap for inactive languages when using subdomains or multiple domains
- Fix fatal error in combination with Yoast SEO and Social Warfare
- Fix post type archive url in Yoast SEO sitemap
Download this release
Release Info
Developer | Chouby |
Plugin | Polylang |
Version | 2.6.1 |
Comparing to | |
See all releases |
Code changes from version 2.6 to 2.6.1
- modules/plugins/wpseo.php +72 -28
- polylang.php +2 -2
- readme.txt +7 -1
modules/plugins/wpseo.php
CHANGED
@@ -2,6 +2,7 @@
|
|
2 |
|
3 |
/**
|
4 |
* Manages the compatibility with Yoast SEO
|
|
|
5 |
*
|
6 |
* @since 2.3
|
7 |
*/
|
@@ -26,13 +27,13 @@ class PLL_WPSEO {
|
|
26 |
if ( PLL()->options['force_lang'] > 1 ) {
|
27 |
add_filter( 'wpseo_enable_xml_sitemap_transient_caching', '__return_false' ); // Disable cache! otherwise WPSEO keeps only one domain (thanks to Junaid Bhura)
|
28 |
add_filter( 'home_url', array( $this, 'wpseo_home_url' ), 10, 2 ); // Fix home_url
|
|
|
29 |
} else {
|
30 |
// Get all terms in all languages when the language is set from the content or directory name
|
31 |
add_filter( 'get_terms_args', array( $this, 'wpseo_remove_terms_filter' ) );
|
|
|
32 |
}
|
33 |
|
34 |
-
add_action( 'pre_get_posts', array( $this, 'before_sitemap' ), 0 ); // Needs to be fired before WPSEO_Sitemaps::redirect()
|
35 |
-
|
36 |
add_filter( 'pll_home_url_white_list', array( $this, 'wpseo_home_url_white_list' ) );
|
37 |
add_action( 'wpseo_opengraph', array( $this, 'wpseo_ogp' ), 2 );
|
38 |
add_filter( 'wpseo_canonical', array( $this, 'wpseo_canonical' ) );
|
@@ -206,21 +207,61 @@ class PLL_WPSEO {
|
|
206 |
return $args;
|
207 |
}
|
208 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
209 |
/**
|
210 |
* Add filters before the sitemap is evaluated and outputed
|
211 |
*
|
212 |
* @since 2.6
|
|
|
|
|
213 |
*/
|
214 |
-
public function before_sitemap() {
|
215 |
-
$type =
|
216 |
|
217 |
// Add the post post type archives in all languages to the sitemap
|
218 |
// Add the homepages for all languages to the sitemap when the front page displays posts
|
219 |
-
if ( $type && pll_is_translated_post_type( $type ) && ( 'post' !== $type ||
|
220 |
add_filter( "wpseo_sitemap_{$type}_content", array( $this, 'add_post_type_archive' ) );
|
221 |
}
|
222 |
}
|
223 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
224 |
/**
|
225 |
* Adds the home and post type archives urls for all (active) languages to the sitemap
|
226 |
*
|
@@ -230,30 +271,33 @@ class PLL_WPSEO {
|
|
230 |
* @return string
|
231 |
*/
|
232 |
public function add_post_type_archive( $str ) {
|
233 |
-
|
234 |
-
|
235 |
-
$
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
} elseif ( ! empty( PLL()->options['hide_default'] ) ) {
|
243 |
-
// The home url is of course already added by WPSEO
|
244 |
-
$languages = wp_list_filter( PLL()->model->get_languages_list(), array( 'slug' => pll_default_language() ), 'NOT' );
|
245 |
-
}
|
246 |
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
257 |
}
|
258 |
|
259 |
return $str;
|
2 |
|
3 |
/**
|
4 |
* Manages the compatibility with Yoast SEO
|
5 |
+
* Version tested: 11.5
|
6 |
*
|
7 |
* @since 2.3
|
8 |
*/
|
27 |
if ( PLL()->options['force_lang'] > 1 ) {
|
28 |
add_filter( 'wpseo_enable_xml_sitemap_transient_caching', '__return_false' ); // Disable cache! otherwise WPSEO keeps only one domain (thanks to Junaid Bhura)
|
29 |
add_filter( 'home_url', array( $this, 'wpseo_home_url' ), 10, 2 ); // Fix home_url
|
30 |
+
add_action( 'setup_theme', array( $this, 'maybe_deactivate_sitemap' ) ); // Deactivate sitemaps for inactive languages.
|
31 |
} else {
|
32 |
// Get all terms in all languages when the language is set from the content or directory name
|
33 |
add_filter( 'get_terms_args', array( $this, 'wpseo_remove_terms_filter' ) );
|
34 |
+
add_action( 'pre_get_posts', array( $this, 'before_sitemap' ), 0 ); // Needs to be fired before WPSEO_Sitemaps::redirect()
|
35 |
}
|
36 |
|
|
|
|
|
37 |
add_filter( 'pll_home_url_white_list', array( $this, 'wpseo_home_url_white_list' ) );
|
38 |
add_action( 'wpseo_opengraph', array( $this, 'wpseo_ogp' ), 2 );
|
39 |
add_filter( 'wpseo_canonical', array( $this, 'wpseo_canonical' ) );
|
207 |
return $args;
|
208 |
}
|
209 |
|
210 |
+
/**
|
211 |
+
* Deactivates the sitemap for inactive languages when using subdomains or multiple domains
|
212 |
+
*
|
213 |
+
* @since 2.6.1
|
214 |
+
*/
|
215 |
+
public function maybe_deactivate_sitemap() {
|
216 |
+
global $wpseo_sitemaps;
|
217 |
+
|
218 |
+
if ( isset( $wpseo_sitemaps ) ) {
|
219 |
+
$active_languages = $this->wpseo_get_active_languages();
|
220 |
+
if ( ! empty( $active_languages ) && ! in_array( pll_current_language(), $active_languages ) ) {
|
221 |
+
remove_action( 'pre_get_posts', array( $wpseo_sitemaps, 'redirect' ), 1 );
|
222 |
+
}
|
223 |
+
}
|
224 |
+
}
|
225 |
+
|
226 |
/**
|
227 |
* Add filters before the sitemap is evaluated and outputed
|
228 |
*
|
229 |
* @since 2.6
|
230 |
+
*
|
231 |
+
* @param object $query Instance of WP_Query being filtered.
|
232 |
*/
|
233 |
+
public function before_sitemap( $query ) {
|
234 |
+
$type = $query->get( 'sitemap' );
|
235 |
|
236 |
// Add the post post type archives in all languages to the sitemap
|
237 |
// Add the homepages for all languages to the sitemap when the front page displays posts
|
238 |
+
if ( $type && pll_is_translated_post_type( $type ) && ( 'post' !== $type || ! get_option( 'page_on_front' ) ) ) {
|
239 |
add_filter( "wpseo_sitemap_{$type}_content", array( $this, 'add_post_type_archive' ) );
|
240 |
}
|
241 |
}
|
242 |
|
243 |
+
/**
|
244 |
+
* Generates a post type archive sitemap url
|
245 |
+
*
|
246 |
+
* @since 2.6.1
|
247 |
+
*
|
248 |
+
* @param string $link The url.
|
249 |
+
* @param string $post_type The post type name.
|
250 |
+
* @return string Formatted sitemap url.
|
251 |
+
*/
|
252 |
+
protected function format_sitemap_url( $link, $post_type ) {
|
253 |
+
global $wpseo_sitemaps;
|
254 |
+
|
255 |
+
return $wpseo_sitemaps->renderer->sitemap_url(
|
256 |
+
array(
|
257 |
+
'loc' => $link,
|
258 |
+
'mod' => WPSEO_Sitemaps::get_last_modified_gmt( $post_type ),
|
259 |
+
'pri' => 1,
|
260 |
+
'chf' => 'daily',
|
261 |
+
)
|
262 |
+
);
|
263 |
+
}
|
264 |
+
|
265 |
/**
|
266 |
* Adds the home and post type archives urls for all (active) languages to the sitemap
|
267 |
*
|
271 |
* @return string
|
272 |
*/
|
273 |
public function add_post_type_archive( $str ) {
|
274 |
+
$post_type = substr( substr( current_filter(), 14 ), 0, -8 );
|
275 |
+
$post_type_obj = get_post_type_object( $post_type );
|
276 |
+
$languages = wp_list_filter( PLL()->model->get_languages_list(), array( 'active' => false ), 'NOT' );
|
277 |
+
|
278 |
+
if ( 'post' === $post_type ) {
|
279 |
+
if ( ! empty( PLL()->options['hide_default'] ) ) {
|
280 |
+
// The home url is of course already added by WPSEO.
|
281 |
+
$languages = wp_list_filter( $languages, array( 'slug' => pll_default_language() ), 'NOT' );
|
282 |
+
}
|
|
|
|
|
|
|
|
|
283 |
|
284 |
+
foreach ( $languages as $lang ) {
|
285 |
+
$str .= $this->format_sitemap_url( pll_home_url( $lang->slug ), $post_type );
|
286 |
+
}
|
287 |
+
} elseif ( $post_type_obj->has_archive ) {
|
288 |
+
// Exclude cases where a post type archive is attached to a page (ex: WooCommerce).
|
289 |
+
$slug = ( true === $post_type_obj->has_archive ) ? $post_type_obj->rewrite['slug'] : $post_type_obj->has_archive;
|
290 |
+
|
291 |
+
if ( ! get_page_by_path( $slug ) ) {
|
292 |
+
// The post type archive in the current language is already added by WPSEO.
|
293 |
+
$languages = wp_list_filter( $languages, array( 'slug' => pll_current_language() ), 'NOT' );
|
294 |
+
|
295 |
+
foreach ( $languages as $lang ) {
|
296 |
+
PLL()->curlang = $lang; // Switch the language to get the correct archive link.
|
297 |
+
$link = get_post_type_archive_link( $post_type );
|
298 |
+
$str .= $this->format_sitemap_url( $link, $post_type );
|
299 |
+
}
|
300 |
+
}
|
301 |
}
|
302 |
|
303 |
return $str;
|
polylang.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
/**
|
4 |
Plugin Name: Polylang
|
5 |
Plugin URI: https://polylang.pro
|
6 |
-
Version: 2.6
|
7 |
Author: WP SYNTEX
|
8 |
Author uri: https://polylang.pro
|
9 |
Description: Adds multilingual capability to WordPress
|
@@ -51,7 +51,7 @@ if ( defined( 'POLYLANG_BASENAME' ) ) {
|
|
51 |
}
|
52 |
} else {
|
53 |
// Go on loading the plugin
|
54 |
-
define( 'POLYLANG_VERSION', '2.6' );
|
55 |
define( 'PLL_MIN_WP_VERSION', '4.7' );
|
56 |
|
57 |
define( 'POLYLANG_FILE', __FILE__ ); // this file
|
3 |
/**
|
4 |
Plugin Name: Polylang
|
5 |
Plugin URI: https://polylang.pro
|
6 |
+
Version: 2.6.1
|
7 |
Author: WP SYNTEX
|
8 |
Author uri: https://polylang.pro
|
9 |
Description: Adds multilingual capability to WordPress
|
51 |
}
|
52 |
} else {
|
53 |
// Go on loading the plugin
|
54 |
+
define( 'POLYLANG_VERSION', '2.6.1' );
|
55 |
define( 'PLL_MIN_WP_VERSION', '4.7' );
|
56 |
|
57 |
define( 'POLYLANG_FILE', __FILE__ ); // this file
|
readme.txt
CHANGED
@@ -4,7 +4,7 @@ Donate link: https://polylang.pro
|
|
4 |
Tags: multilingual, bilingual, translate, translation, language, multilanguage, international, localization
|
5 |
Requires at least: 4.7
|
6 |
Tested up to: 5.2
|
7 |
-
Stable tag: 2.6
|
8 |
License: GPLv3 or later
|
9 |
|
10 |
Making WordPress multilingual
|
@@ -76,6 +76,12 @@ Don't hesitate to [give your feedback](http://wordpress.org/support/view/plugin-
|
|
76 |
|
77 |
== Changelog ==
|
78 |
|
|
|
|
|
|
|
|
|
|
|
|
|
79 |
= 2.6 (2019-06-26) =
|
80 |
|
81 |
* Pro: Remove all languages files. All translations are now maintained on TranslationsPress
|
4 |
Tags: multilingual, bilingual, translate, translation, language, multilanguage, international, localization
|
5 |
Requires at least: 4.7
|
6 |
Tested up to: 5.2
|
7 |
+
Stable tag: 2.6.1
|
8 |
License: GPLv3 or later
|
9 |
|
10 |
Making WordPress multilingual
|
76 |
|
77 |
== Changelog ==
|
78 |
|
79 |
+
= 2.6.1 (2019-07-03) =
|
80 |
+
|
81 |
+
* Pro: Fix Yoast SEO sitemap for inactive languages when using subdomains or multiple domains
|
82 |
+
* Fix fatal error in combination with Yoast SEO and Social Warfare
|
83 |
+
* Fix post type archive url in Yoast SEO sitemap
|
84 |
+
|
85 |
= 2.6 (2019-06-26) =
|
86 |
|
87 |
* Pro: Remove all languages files. All translations are now maintained on TranslationsPress
|