Version Description
(2016-09-22) Five years after! =
- Pro: Fix conflict with WPBakery Visual Composer
- Pro: Fix conflict between multiple domains SSO and FORCE_SSL_ADMIN
- Pro: Fix duplicated fields not displayed in new translation in ACF Pro 5.4+
- Add Tibetan and Silesian to the predefined languages list
- Remove duplicated strings from the strings translations (even when they have a different name or group)
- The languages and translations of custom post types and taxonomies are no more activated by default at activation
- Allow to deactivate auto translation in secondary by setting 'lang' to an empty value
- Fix: invalidate the cache of PLL_MO ids when adding a new language
- Fix: don't filter secondary queries when editing a post in an untranslated post type
Download this release
Release Info
Developer | Chouby |
Plugin | Polylang |
Version | 2.0.5 |
Comparing to | |
See all releases |
Code changes from version 2.0.4 to 2.0.5
- admin/admin-base.php +2 -2
- admin/admin-strings.php +1 -1
- flags/tibet.png +0 -0
- frontend/frontend-auto-translate.php +1 -1
- include/links-domain.php +9 -7
- include/links-model.php +1 -1
- include/mo.php +11 -0
- install/install.php +2 -2
- polylang.php +2 -2
- readme.txt +13 -1
- settings/flags.php +1 -0
- settings/languages.php +2 -0
- settings/settings-cpt.php +16 -12
admin/admin-base.php
CHANGED
@@ -175,7 +175,7 @@ class PLL_Admin_Base extends PLL_Base {
|
|
175 |
$this->curlang = $this->model->post->get_language( (int) $_REQUEST['pll_post_id'] );
|
176 |
} elseif ( 'post.php' === $GLOBALS['pagenow'] && isset( $_GET['post'] ) && is_numeric( $_GET['post'] ) ) {
|
177 |
$this->curlang = $this->model->post->get_language( (int) $_GET['post'] );
|
178 |
-
} elseif ( 'post-new.php' === $GLOBALS['pagenow'] ) {
|
179 |
$this->curlang = empty( $_GET['new_lang'] ) ? $this->pref_lang : $this->model->get_language( $_GET['new_lang'] );
|
180 |
}
|
181 |
|
@@ -183,7 +183,7 @@ class PLL_Admin_Base extends PLL_Base {
|
|
183 |
// FIXME 'edit-tags.php' for backward compatibility with WP < 4.5
|
184 |
elseif ( in_array( $GLOBALS['pagenow'], array( 'edit-tags.php', 'term.php' ) ) && isset( $_GET['tag_ID'] ) ) {
|
185 |
$this->curlang = $this->model->term->get_language( (int) $_GET['tag_ID'] );
|
186 |
-
} elseif ( 'edit-tags.php' === $GLOBALS['pagenow'] ) {
|
187 |
if ( ! empty( $_GET['new_lang'] ) ) {
|
188 |
$this->curlang = $this->model->get_language( $_GET['new_lang'] );
|
189 |
} elseif ( empty( $this->curlang ) ) {
|
175 |
$this->curlang = $this->model->post->get_language( (int) $_REQUEST['pll_post_id'] );
|
176 |
} elseif ( 'post.php' === $GLOBALS['pagenow'] && isset( $_GET['post'] ) && is_numeric( $_GET['post'] ) ) {
|
177 |
$this->curlang = $this->model->post->get_language( (int) $_GET['post'] );
|
178 |
+
} elseif ( 'post-new.php' === $GLOBALS['pagenow'] && ( empty( $_GET['post_type'] ) || $this->model->is_translated_post_type( $_GET['post_type'] ) ) ) {
|
179 |
$this->curlang = empty( $_GET['new_lang'] ) ? $this->pref_lang : $this->model->get_language( $_GET['new_lang'] );
|
180 |
}
|
181 |
|
183 |
// FIXME 'edit-tags.php' for backward compatibility with WP < 4.5
|
184 |
elseif ( in_array( $GLOBALS['pagenow'], array( 'edit-tags.php', 'term.php' ) ) && isset( $_GET['tag_ID'] ) ) {
|
185 |
$this->curlang = $this->model->term->get_language( (int) $_GET['tag_ID'] );
|
186 |
+
} elseif ( 'edit-tags.php' === $GLOBALS['pagenow'] && isset( $_GET['taxonomy'] ) && $this->model->is_translated_taxonomy( $_GET['taxonomy'] ) ) {
|
187 |
if ( ! empty( $_GET['new_lang'] ) ) {
|
188 |
$this->curlang = $this->model->get_language( $_GET['new_lang'] );
|
189 |
} elseif ( empty( $this->curlang ) ) {
|
admin/admin-strings.php
CHANGED
@@ -38,7 +38,7 @@ class PLL_Admin_Strings {
|
|
38 |
|
39 |
$to_register = compact( 'name', 'string', 'context', 'multiline' );
|
40 |
if ( ! in_array( $to_register, self::$strings ) && $to_register['string'] ) {
|
41 |
-
self::$strings[] = $to_register;
|
42 |
}
|
43 |
}
|
44 |
|
38 |
|
39 |
$to_register = compact( 'name', 'string', 'context', 'multiline' );
|
40 |
if ( ! in_array( $to_register, self::$strings ) && $to_register['string'] ) {
|
41 |
+
self::$strings[ md5( $string ) ] = $to_register;
|
42 |
}
|
43 |
}
|
44 |
|
flags/tibet.png
ADDED
Binary file
|
frontend/frontend-auto-translate.php
CHANGED
@@ -59,7 +59,7 @@ class PLL_Frontend_Auto_Translate {
|
|
59 |
global $wpdb;
|
60 |
$qv = &$query->query_vars;
|
61 |
|
62 |
-
if ( $query->is_main_query() ||
|
63 |
return;
|
64 |
}
|
65 |
|
59 |
global $wpdb;
|
60 |
$qv = &$query->query_vars;
|
61 |
|
62 |
+
if ( $query->is_main_query() || isset( $qv['lang'] ) || ( ! empty( $qv['post_type'] ) && ! $this->model->is_translated_post_type( $qv['post_type'] ) ) ) {
|
63 |
return;
|
64 |
}
|
65 |
|
include/links-domain.php
CHANGED
@@ -19,6 +19,8 @@ class PLL_Links_Domain extends PLL_Links_Abstract_Domain {
|
|
19 |
public function __construct( &$model ) {
|
20 |
parent::__construct( $model );
|
21 |
|
|
|
|
|
22 |
// Filrer the site url ( mainly to get the correct login form )
|
23 |
add_filter( 'site_url', array( $this, 'site_url' ) );
|
24 |
}
|
@@ -35,8 +37,8 @@ class PLL_Links_Domain extends PLL_Links_Abstract_Domain {
|
|
35 |
* @return string modified url
|
36 |
*/
|
37 |
public function add_language_to_link( $url, $lang ) {
|
38 |
-
if ( ! empty( $lang ) && ! empty( $this->
|
39 |
-
$url = str_replace( $this->home, $this->
|
40 |
}
|
41 |
return $url;
|
42 |
}
|
@@ -51,8 +53,8 @@ class PLL_Links_Domain extends PLL_Links_Abstract_Domain {
|
|
51 |
* @return string modified url
|
52 |
*/
|
53 |
public function remove_language_from_link( $url ) {
|
54 |
-
if ( ! empty( $this->
|
55 |
-
$url =
|
56 |
}
|
57 |
return $url;
|
58 |
}
|
@@ -69,7 +71,7 @@ class PLL_Links_Domain extends PLL_Links_Abstract_Domain {
|
|
69 |
*/
|
70 |
public function get_language_from_url( $url = '' ) {
|
71 |
$host = empty( $url ) ? $_SERVER['HTTP_HOST'] : parse_url( $url, PHP_URL_HOST );
|
72 |
-
return ( $lang = array_search(
|
73 |
}
|
74 |
|
75 |
/**
|
@@ -94,8 +96,8 @@ class PLL_Links_Domain extends PLL_Links_Abstract_Domain {
|
|
94 |
*/
|
95 |
public function get_hosts() {
|
96 |
$hosts = array();
|
97 |
-
foreach ( $this->options['domains'] as $domain ) {
|
98 |
-
$hosts[] = parse_url( $domain, PHP_URL_HOST );
|
99 |
}
|
100 |
return $hosts;
|
101 |
}
|
19 |
public function __construct( &$model ) {
|
20 |
parent::__construct( $model );
|
21 |
|
22 |
+
$this->hosts = $this->get_hosts();
|
23 |
+
|
24 |
// Filrer the site url ( mainly to get the correct login form )
|
25 |
add_filter( 'site_url', array( $this, 'site_url' ) );
|
26 |
}
|
37 |
* @return string modified url
|
38 |
*/
|
39 |
public function add_language_to_link( $url, $lang ) {
|
40 |
+
if ( ! empty( $lang ) && ! empty( $this->hosts[ $lang->slug ] ) ) {
|
41 |
+
$url = str_replace( '://' . parse_url( $this->home, PHP_URL_HOST ), '://' . $this->hosts[ $lang->slug ], $url );
|
42 |
}
|
43 |
return $url;
|
44 |
}
|
53 |
* @return string modified url
|
54 |
*/
|
55 |
public function remove_language_from_link( $url ) {
|
56 |
+
if ( ! empty( $this->hosts ) ) {
|
57 |
+
$url = preg_replace( '#:\/\/(' . implode( '|', $this->hosts ) . ')#', '://' . parse_url( $this->home, PHP_URL_HOST ), $url );
|
58 |
}
|
59 |
return $url;
|
60 |
}
|
71 |
*/
|
72 |
public function get_language_from_url( $url = '' ) {
|
73 |
$host = empty( $url ) ? $_SERVER['HTTP_HOST'] : parse_url( $url, PHP_URL_HOST );
|
74 |
+
return ( $lang = array_search( $host , $this->hosts ) ) ? $lang : '';
|
75 |
}
|
76 |
|
77 |
/**
|
96 |
*/
|
97 |
public function get_hosts() {
|
98 |
$hosts = array();
|
99 |
+
foreach ( $this->options['domains'] as $lang => $domain ) {
|
100 |
+
$hosts[ $lang ] = parse_url( $domain, PHP_URL_HOST );
|
101 |
}
|
102 |
return $hosts;
|
103 |
}
|
include/links-model.php
CHANGED
@@ -127,6 +127,6 @@ abstract class PLL_Links_Model {
|
|
127 |
* @return array
|
128 |
*/
|
129 |
public function allowed_redirect_hosts( $hosts ) {
|
130 |
-
return array_unique( array_merge( $hosts, $this->get_hosts() ) );
|
131 |
}
|
132 |
}
|
127 |
* @return array
|
128 |
*/
|
129 |
public function allowed_redirect_hosts( $hosts ) {
|
130 |
+
return array_unique( array_merge( $hosts, array_values( $this->get_hosts() ) ) );
|
131 |
}
|
132 |
}
|
include/mo.php
CHANGED
@@ -16,6 +16,8 @@ class PLL_MO extends MO {
|
|
16 |
if ( ! post_type_exists( 'polylang_mo' ) ) {
|
17 |
$labels = array( 'name' => __( 'Strings translations', 'polylang' ) );
|
18 |
register_post_type( 'polylang_mo', array( 'labels' => $labels, 'rewrite' => false, 'query_var' => false, '_pll' => true ) );
|
|
|
|
|
19 |
}
|
20 |
}
|
21 |
|
@@ -88,4 +90,13 @@ class PLL_MO extends MO {
|
|
88 |
// The mo id for a language can be transiently empty
|
89 |
return isset( $ids[ 'polylang_mo_' . $lang->term_id ] ) ? $ids[ 'polylang_mo_' . $lang->term_id ]->ID : null;
|
90 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
91 |
}
|
16 |
if ( ! post_type_exists( 'polylang_mo' ) ) {
|
17 |
$labels = array( 'name' => __( 'Strings translations', 'polylang' ) );
|
18 |
register_post_type( 'polylang_mo', array( 'labels' => $labels, 'rewrite' => false, 'query_var' => false, '_pll' => true ) );
|
19 |
+
|
20 |
+
add_action( 'pll_add_language', array( $this, 'clean_cache' ) );
|
21 |
}
|
22 |
}
|
23 |
|
90 |
// The mo id for a language can be transiently empty
|
91 |
return isset( $ids[ 'polylang_mo_' . $lang->term_id ] ) ? $ids[ 'polylang_mo_' . $lang->term_id ]->ID : null;
|
92 |
}
|
93 |
+
|
94 |
+
/**
|
95 |
+
* Invalidate the cache when adding a new language
|
96 |
+
*
|
97 |
+
* @since 2.0.5
|
98 |
+
*/
|
99 |
+
public function clean_cache() {
|
100 |
+
wp_cache_delete( 'polylang_mo_ids' );
|
101 |
+
}
|
102 |
}
|
install/install.php
CHANGED
@@ -48,8 +48,8 @@ class PLL_Install extends PLL_Install_Base {
|
|
48 |
'media_support' => 1, // support languages and translation for media by default
|
49 |
'uninstall' => 0, // do not remove data when uninstalling Polylang
|
50 |
'sync' => array(), // synchronisation is disabled by default ( was the opposite before 1.2 )
|
51 |
-
'post_types' =>
|
52 |
-
'taxonomies' =>
|
53 |
'domains' => array(),
|
54 |
'version' => POLYLANG_VERSION,
|
55 |
);
|
48 |
'media_support' => 1, // support languages and translation for media by default
|
49 |
'uninstall' => 0, // do not remove data when uninstalling Polylang
|
50 |
'sync' => array(), // synchronisation is disabled by default ( was the opposite before 1.2 )
|
51 |
+
'post_types' => array(),
|
52 |
+
'taxonomies' => array(),
|
53 |
'domains' => array(),
|
54 |
'version' => POLYLANG_VERSION,
|
55 |
);
|
polylang.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
/*
|
4 |
Plugin Name: Polylang
|
5 |
Plugin URI: https://polylang.pro
|
6 |
-
Version: 2.0.
|
7 |
Author: Frédéric Demarle
|
8 |
Author uri: https://polylang.pro
|
9 |
Description: Adds multilingual capability to WordPress
|
@@ -35,7 +35,7 @@ if ( ! defined( 'ABSPATH' ) ) {
|
|
35 |
exit; // don't access directly
|
36 |
};
|
37 |
|
38 |
-
define( 'POLYLANG_VERSION', '2.0.
|
39 |
define( 'PLL_MIN_WP_VERSION', '4.0' );
|
40 |
|
41 |
define( 'POLYLANG_FILE', __FILE__ ); // this file
|
3 |
/*
|
4 |
Plugin Name: Polylang
|
5 |
Plugin URI: https://polylang.pro
|
6 |
+
Version: 2.0.5
|
7 |
Author: Frédéric Demarle
|
8 |
Author uri: https://polylang.pro
|
9 |
Description: Adds multilingual capability to WordPress
|
35 |
exit; // don't access directly
|
36 |
};
|
37 |
|
38 |
+
define( 'POLYLANG_VERSION', '2.0.5' );
|
39 |
define( 'PLL_MIN_WP_VERSION', '4.0' );
|
40 |
|
41 |
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.0
|
6 |
Tested up to: 4.6
|
7 |
-
Stable tag: 2.0.
|
8 |
License: GPLv2 or later
|
9 |
|
10 |
Making WordPress multilingual
|
@@ -77,6 +77,18 @@ Don't hesitate to [give your feedback](http://wordpress.org/support/view/plugin-
|
|
77 |
|
78 |
== Changelog ==
|
79 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
80 |
= 2.0.4 (2016-09-06) =
|
81 |
|
82 |
* Add Gujarati to the predefined languages list
|
4 |
Tags: multilingual, bilingual, translate, translation, language, multilanguage, international, localization
|
5 |
Requires at least: 4.0
|
6 |
Tested up to: 4.6
|
7 |
+
Stable tag: 2.0.5
|
8 |
License: GPLv2 or later
|
9 |
|
10 |
Making WordPress multilingual
|
77 |
|
78 |
== Changelog ==
|
79 |
|
80 |
+
= 2.0.5 (2016-09-22) Five years after! =
|
81 |
+
|
82 |
+
* Pro: Fix conflict with WPBakery Visual Composer
|
83 |
+
* Pro: Fix conflict between multiple domains SSO and FORCE_SSL_ADMIN
|
84 |
+
* Pro: Fix duplicated fields not displayed in new translation in ACF Pro 5.4+
|
85 |
+
* Add Tibetan and Silesian to the predefined languages list
|
86 |
+
* Remove duplicated strings from the strings translations (even when they have a different name or group)
|
87 |
+
* The languages and translations of custom post types and taxonomies are no more activated by default at activation
|
88 |
+
* Allow to deactivate auto translation in secondary by setting 'lang' to an empty value
|
89 |
+
* Fix: invalidate the cache of PLL_MO ids when adding a new language
|
90 |
+
* Fix: don't filter secondary queries when editing a post in an untranslated post type
|
91 |
+
|
92 |
= 2.0.4 (2016-09-06) =
|
93 |
|
94 |
* Add Gujarati to the predefined languages list
|
settings/flags.php
CHANGED
@@ -228,6 +228,7 @@ $flags = array(
|
|
228 |
'tf' => __( 'French Southern Territories', 'polylang' ),
|
229 |
'tg' => __( 'Togo', 'polylang' ),
|
230 |
'th' => __( 'Thailand', 'polylang' ),
|
|
|
231 |
'tj' => __( 'Tajikistan', 'polylang' ),
|
232 |
'tk' => __( 'Tokelau', 'polylang' ),
|
233 |
'tl' => __( 'Timor-Leste', 'polylang' ),
|
228 |
'tf' => __( 'French Southern Territories', 'polylang' ),
|
229 |
'tg' => __( 'Togo', 'polylang' ),
|
230 |
'th' => __( 'Thailand', 'polylang' ),
|
231 |
+
'tibet' => __( 'Tibet', 'polylang' ),
|
232 |
'tj' => __( 'Tajikistan', 'polylang' ),
|
233 |
'tk' => __( 'Tokelau', 'polylang' ),
|
234 |
'tl' => __( 'Timor-Leste', 'polylang' ),
|
settings/languages.php
CHANGED
@@ -23,6 +23,7 @@ $languages = array(
|
|
23 |
'bel' => array( 'be', 'bel', 'Беларуская мова', 'ltr', 'by' ),
|
24 |
'bg_BG' => array( 'bg', 'bg_BG', 'български', 'ltr', 'bg' ),
|
25 |
'bn_BD' => array( 'bn', 'bn_BD', 'বাংলা', 'ltr', 'bd' ),
|
|
|
26 |
'bs_BA' => array( 'bs', 'bs_BA', 'Bosanski', 'ltr', 'ba' ),
|
27 |
'ca' => array( 'ca', 'ca', 'Català', 'ltr', 'catalonia' ),
|
28 |
'ceb' => array( 'ceb', 'ceb', 'Cebuano', 'ltr', 'ph' ),
|
@@ -105,6 +106,7 @@ $languages = array(
|
|
105 |
'sr_RS' => array( 'sr', 'sr_RS', 'Српски језик', 'ltr', 'rs' ),
|
106 |
'su_ID' => array( 'su', 'su_ID', 'Basa Sunda', 'ltr', 'id' ),
|
107 |
'sv_SE' => array( 'sv', 'sv_SE', 'Svenska', 'ltr', 'se' ),
|
|
|
108 |
'ta_LK' => array( 'ta', 'ta_LK', 'தமிழ்', 'ltr', 'lk' ),
|
109 |
'th' => array( 'th', 'th', 'ไทย', 'ltr', 'th' ),
|
110 |
'tl' => array( 'tl', 'tl', 'Tagalog', 'ltr', 'ph' ),
|
23 |
'bel' => array( 'be', 'bel', 'Беларуская мова', 'ltr', 'by' ),
|
24 |
'bg_BG' => array( 'bg', 'bg_BG', 'български', 'ltr', 'bg' ),
|
25 |
'bn_BD' => array( 'bn', 'bn_BD', 'বাংলা', 'ltr', 'bd' ),
|
26 |
+
'bo' => array( 'bo', 'bo', 'བོད་སྐད', 'ltr', 'tibet' ),
|
27 |
'bs_BA' => array( 'bs', 'bs_BA', 'Bosanski', 'ltr', 'ba' ),
|
28 |
'ca' => array( 'ca', 'ca', 'Català', 'ltr', 'catalonia' ),
|
29 |
'ceb' => array( 'ceb', 'ceb', 'Cebuano', 'ltr', 'ph' ),
|
106 |
'sr_RS' => array( 'sr', 'sr_RS', 'Српски језик', 'ltr', 'rs' ),
|
107 |
'su_ID' => array( 'su', 'su_ID', 'Basa Sunda', 'ltr', 'id' ),
|
108 |
'sv_SE' => array( 'sv', 'sv_SE', 'Svenska', 'ltr', 'se' ),
|
109 |
+
'szl' => array( 'szl', 'szl', 'Ślōnskŏ gŏdka', 'ltr', 'pl' ),
|
110 |
'ta_LK' => array( 'ta', 'ta_LK', 'தமிழ்', 'ltr', 'lk' ),
|
111 |
'th' => array( 'th', 'th', 'ไทย', 'ltr', 'th' ),
|
112 |
'tl' => array( 'tl', 'tl', 'Tagalog', 'ltr', 'ph' ),
|
settings/settings-cpt.php
CHANGED
@@ -55,12 +55,14 @@ class PLL_Settings_CPT extends PLL_Settings_Module {
|
|
55 |
<ul class="pll-inline-block-list"><?php
|
56 |
foreach ( $this->post_types as $post_type ) {
|
57 |
$pt = get_post_type_object( $post_type );
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
|
|
|
|
64 |
}?>
|
65 |
</ul>
|
66 |
<p class="description"><?php esc_html_e( 'Activate languages and translations for custom post types.', 'polylang' );?></p><?php
|
@@ -71,12 +73,14 @@ class PLL_Settings_CPT extends PLL_Settings_Module {
|
|
71 |
<ul class="pll-inline-block-list"><?php
|
72 |
foreach ( $this->taxonomies as $taxonomy ) {
|
73 |
$tax = get_taxonomy( $taxonomy );
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
|
|
|
|
80 |
}?>
|
81 |
</ul>
|
82 |
<p class="description"><?php esc_html_e( 'Activate languages and translations for custom taxonomies.', 'polylang' );?></p><?php
|
55 |
<ul class="pll-inline-block-list"><?php
|
56 |
foreach ( $this->post_types as $post_type ) {
|
57 |
$pt = get_post_type_object( $post_type );
|
58 |
+
if ( ! empty( $pt ) ) {
|
59 |
+
printf(
|
60 |
+
'<li><label><input name="post_types[%s]" type="checkbox" value="1" %s /> %s</label></li>',
|
61 |
+
esc_attr( $post_type ),
|
62 |
+
in_array( $post_type, $this->options['post_types'] ) ? 'checked="checked"' :'',
|
63 |
+
esc_html( $pt->labels->name )
|
64 |
+
);
|
65 |
+
}
|
66 |
}?>
|
67 |
</ul>
|
68 |
<p class="description"><?php esc_html_e( 'Activate languages and translations for custom post types.', 'polylang' );?></p><?php
|
73 |
<ul class="pll-inline-block-list"><?php
|
74 |
foreach ( $this->taxonomies as $taxonomy ) {
|
75 |
$tax = get_taxonomy( $taxonomy );
|
76 |
+
if ( ! empty( $tax ) ) {
|
77 |
+
printf(
|
78 |
+
'<li><label><input name="taxonomies[%s]" type="checkbox" value="1" %s /> %s</label></li>',
|
79 |
+
esc_attr( $taxonomy ),
|
80 |
+
in_array( $taxonomy, $this->options['taxonomies'] ) ? 'checked="checked"' :'',
|
81 |
+
esc_html( $tax->labels->name )
|
82 |
+
);
|
83 |
+
}
|
84 |
}?>
|
85 |
</ul>
|
86 |
<p class="description"><?php esc_html_e( 'Activate languages and translations for custom taxonomies.', 'polylang' );?></p><?php
|