Version Description
(2019-12-11) =
- Pro: Fix conflict with JetThemesCore from Crocoblock
- Fix: better detection of REST requests when using plain permalinks
- Fix usage of deprecated action wpmu_new_blog in WP 5.1+
- Fix PHP notices with PHP 7.4
Download this release
Release Info
Developer | Chouby |
Plugin | Polylang |
Version | 2.6.8 |
Comparing to | |
See all releases |
Code changes from version 2.6.7 to 2.6.8
- include/class-polylang.php +12 -1
- include/crud-posts.php +1 -0
- include/license.php +7 -1
- include/links-model.php +6 -3
- install/install-base.php +21 -2
- modules/sync/sync-tax.php +6 -1
- polylang.php +2 -2
- readme.txt +8 -1
include/class-polylang.php
CHANGED
@@ -137,6 +137,7 @@ class Polylang {
|
|
137 |
* @return bool
|
138 |
*/
|
139 |
public static function is_rest_request() {
|
|
|
140 |
$home_path = trim( wp_parse_url( home_url(), PHP_URL_PATH ), '/' );
|
141 |
$home_path_regex = sprintf( '|^%s|i', preg_quote( $home_path, '|' ) );
|
142 |
|
@@ -146,7 +147,12 @@ class Polylang {
|
|
146 |
$req_uri = str_replace( 'index.php', '', $req_uri );
|
147 |
$req_uri = trim( $req_uri, '/' );
|
148 |
|
149 |
-
|
|
|
|
|
|
|
|
|
|
|
150 |
}
|
151 |
|
152 |
/**
|
@@ -197,6 +203,11 @@ class Polylang {
|
|
197 |
}
|
198 |
}
|
199 |
|
|
|
|
|
|
|
|
|
|
|
200 |
// Make sure that this filter is *always* added before PLL_Model::get_languages_list() is called for the first time
|
201 |
add_filter( 'pll_languages_list', array( 'PLL_Static_Pages', 'pll_languages_list' ), 2, 2 ); // Before PLL_Links_Model
|
202 |
|
137 |
* @return bool
|
138 |
*/
|
139 |
public static function is_rest_request() {
|
140 |
+
// Handle pretty permalinks.
|
141 |
$home_path = trim( wp_parse_url( home_url(), PHP_URL_PATH ), '/' );
|
142 |
$home_path_regex = sprintf( '|^%s|i', preg_quote( $home_path, '|' ) );
|
143 |
|
147 |
$req_uri = str_replace( 'index.php', '', $req_uri );
|
148 |
$req_uri = trim( $req_uri, '/' );
|
149 |
|
150 |
+
// And also test rest_route query string parameter is not empty for plain permalinks.
|
151 |
+
$query_string = array();
|
152 |
+
wp_parse_str( wp_parse_url( pll_get_requested_url(), PHP_URL_QUERY ), $query_string );
|
153 |
+
$rest_route = isset( $query_string['rest_route'] ) ? trim( $query_string['rest_route'], '/' ) : false;
|
154 |
+
|
155 |
+
return 0 === strpos( $req_uri, rest_get_url_prefix() . '/' ) || ! empty( $rest_route );
|
156 |
}
|
157 |
|
158 |
/**
|
203 |
}
|
204 |
}
|
205 |
|
206 |
+
// In some edge cases, it's possible that no options were found in the database. Load default options as we need some.
|
207 |
+
if ( ! $options ) {
|
208 |
+
$options = PLL_Install::get_default_options();
|
209 |
+
}
|
210 |
+
|
211 |
// Make sure that this filter is *always* added before PLL_Model::get_languages_list() is called for the first time
|
212 |
add_filter( 'pll_languages_list', array( 'PLL_Static_Pages', 'pll_languages_list' ), 2, 2 ); // Before PLL_Links_Model
|
213 |
|
include/crud-posts.php
CHANGED
@@ -121,6 +121,7 @@ class PLL_CRUD_Posts {
|
|
121 |
|
122 |
$term_ids = array_combine( $terms, $terms );
|
123 |
$languages = array_map( array( $this->model->term, 'get_language' ), $term_ids );
|
|
|
124 |
$languages = wp_list_pluck( $languages, 'slug' );
|
125 |
$wrong_terms = array_diff( $languages, array( $lang->slug ) );
|
126 |
|
121 |
|
122 |
$term_ids = array_combine( $terms, $terms );
|
123 |
$languages = array_map( array( $this->model->term, 'get_language' ), $term_ids );
|
124 |
+
$languages = array_filter( $languages ); // Remove terms without language.
|
125 |
$languages = wp_list_pluck( $languages, 'slug' );
|
126 |
$wrong_terms = array_diff( $languages, array( $lang->slug ) );
|
127 |
|
include/license.php
CHANGED
@@ -132,7 +132,13 @@ class PLL_License {
|
|
132 |
*/
|
133 |
private function api_request( $request ) {
|
134 |
$licenses = get_option( 'polylang_licenses' );
|
135 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
136 |
|
137 |
if ( ! empty( $this->license_key ) ) {
|
138 |
// Data to send in our API request
|
132 |
*/
|
133 |
private function api_request( $request ) {
|
134 |
$licenses = get_option( 'polylang_licenses' );
|
135 |
+
|
136 |
+
if ( is_array( $licenses ) ) {
|
137 |
+
unset( $licenses[ $this->id ] );
|
138 |
+
} else {
|
139 |
+
$licenses = array();
|
140 |
+
}
|
141 |
+
unset( $this->license_data );
|
142 |
|
143 |
if ( ! empty( $this->license_key ) ) {
|
144 |
// Data to send in our API request
|
include/links-model.php
CHANGED
@@ -76,9 +76,12 @@ abstract class PLL_Links_Model {
|
|
76 |
* @param object $language
|
77 |
*/
|
78 |
protected function set_home_url( $language ) {
|
79 |
-
|
80 |
-
|
81 |
-
|
|
|
|
|
|
|
82 |
}
|
83 |
|
84 |
/**
|
76 |
* @param object $language
|
77 |
*/
|
78 |
protected function set_home_url( $language ) {
|
79 |
+
// We should always have a default language here, except, temporarily, in PHPUnit tests. The test here protects against PHP notices.
|
80 |
+
if ( isset( $this->options['default_lang'] ) ) {
|
81 |
+
$search_url = $this->home_url( $language );
|
82 |
+
$home_url = empty( $language->page_on_front ) || $this->options['redirect_lang'] ? $search_url : $this->front_page_url( $language );
|
83 |
+
$language->set_home_url( $search_url, $home_url );
|
84 |
+
}
|
85 |
}
|
86 |
|
87 |
/**
|
install/install-base.php
CHANGED
@@ -22,8 +22,13 @@ class PLL_Install_Base {
|
|
22 |
register_activation_hook( $plugin_basename, array( $this, 'activate' ) );
|
23 |
register_deactivation_hook( $plugin_basename, array( $this, 'deactivate' ) );
|
24 |
|
25 |
-
// Blog creation on multisite
|
26 |
-
|
|
|
|
|
|
|
|
|
|
|
27 |
}
|
28 |
|
29 |
/**
|
@@ -103,8 +108,22 @@ class PLL_Install_Base {
|
|
103 |
// Can be overriden in child class
|
104 |
}
|
105 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
106 |
/**
|
107 |
* Blog creation on multisite ( to set default options )
|
|
|
108 |
*
|
109 |
* @since 0.9.4
|
110 |
*
|
22 |
register_activation_hook( $plugin_basename, array( $this, 'activate' ) );
|
23 |
register_deactivation_hook( $plugin_basename, array( $this, 'deactivate' ) );
|
24 |
|
25 |
+
// Blog creation on multisite.
|
26 |
+
if ( version_compare( $GLOBALS['wp_version'], '5.1', '<' ) ) {
|
27 |
+
// FIXME: Backward compatibility with WP < 5.1.
|
28 |
+
add_action( 'wpmu_new_blog', array( $this, 'wpmu_new_blog' ), 5 ); // Before WP attempts to send mails which can break on some PHP versions
|
29 |
+
} else {
|
30 |
+
add_action( 'wp_insert_site', array( $this, 'new_site' ) );
|
31 |
+
}
|
32 |
}
|
33 |
|
34 |
/**
|
108 |
// Can be overriden in child class
|
109 |
}
|
110 |
|
111 |
+
/**
|
112 |
+
* Site creation on multisite ( to set default options )
|
113 |
+
*
|
114 |
+
* @since 2.6.8
|
115 |
+
*
|
116 |
+
* @param WP_Site $new_site New site object.
|
117 |
+
*/
|
118 |
+
public function new_site( $new_site ) {
|
119 |
+
switch_to_blog( $new_site->id );
|
120 |
+
$this->_activate();
|
121 |
+
restore_current_blog();
|
122 |
+
}
|
123 |
+
|
124 |
/**
|
125 |
* Blog creation on multisite ( to set default options )
|
126 |
+
* Backward compatibility with WP < 5.1
|
127 |
*
|
128 |
* @since 0.9.4
|
129 |
*
|
modules/sync/sync-tax.php
CHANGED
@@ -163,7 +163,12 @@ class PLL_Sync_Tax {
|
|
163 |
} else {
|
164 |
// No permission to synchronize, so let's synchronize in reverse order
|
165 |
$orig_lang = array_search( $object_id, $tr_ids );
|
166 |
-
$tr_terms =
|
|
|
|
|
|
|
|
|
|
|
167 |
if ( is_array( $tr_terms ) ) {
|
168 |
$tr_terms = wp_list_pluck( $tr_terms, 'term_id' );
|
169 |
$this->copy_object_terms( $tr_id, $object_id, $orig_lang, $tr_terms, $taxonomy, $append );
|
163 |
} else {
|
164 |
// No permission to synchronize, so let's synchronize in reverse order
|
165 |
$orig_lang = array_search( $object_id, $tr_ids );
|
166 |
+
$tr_terms = get_the_terms( $tr_id, $taxonomy );
|
167 |
+
|
168 |
+
if ( false === $tr_terms ) {
|
169 |
+
$tr_terms = array();
|
170 |
+
}
|
171 |
+
|
172 |
if ( is_array( $tr_terms ) ) {
|
173 |
$tr_terms = wp_list_pluck( $tr_terms, 'term_id' );
|
174 |
$this->copy_object_terms( $tr_id, $object_id, $orig_lang, $tr_terms, $taxonomy, $append );
|
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 |
define( 'PLL_MIN_PHP_VERSION', '5.6' );
|
57 |
|
3 |
/**
|
4 |
Plugin Name: Polylang
|
5 |
Plugin URI: https://polylang.pro
|
6 |
+
Version: 2.6.8
|
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.8' );
|
55 |
define( 'PLL_MIN_WP_VERSION', '4.7' );
|
56 |
define( 'PLL_MIN_PHP_VERSION', '5.6' );
|
57 |
|
readme.txt
CHANGED
@@ -5,7 +5,7 @@ Tags: multilingual, bilingual, translate, translation, language, multilanguage,
|
|
5 |
Requires at least: 4.7
|
6 |
Tested up to: 5.3
|
7 |
Requires PHP: 5.6
|
8 |
-
Stable tag: 2.6.
|
9 |
License: GPLv3 or later
|
10 |
|
11 |
Making WordPress multilingual
|
@@ -77,6 +77,13 @@ Don't hesitate to [give your feedback](http://wordpress.org/support/view/plugin-
|
|
77 |
|
78 |
== Changelog ==
|
79 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
80 |
= 2.6.7 (2019-11-14) =
|
81 |
|
82 |
* Require PHP 5.6
|
5 |
Requires at least: 4.7
|
6 |
Tested up to: 5.3
|
7 |
Requires PHP: 5.6
|
8 |
+
Stable tag: 2.6.8
|
9 |
License: GPLv3 or later
|
10 |
|
11 |
Making WordPress multilingual
|
77 |
|
78 |
== Changelog ==
|
79 |
|
80 |
+
= 2.6.8 (2019-12-11) =
|
81 |
+
|
82 |
+
* Pro: Fix conflict with JetThemesCore from Crocoblock
|
83 |
+
* Fix: better detection of REST requests when using plain permalinks
|
84 |
+
* Fix usage of deprecated action wpmu_new_blog in WP 5.1+
|
85 |
+
* Fix PHP notices with PHP 7.4
|
86 |
+
|
87 |
= 2.6.7 (2019-11-14) =
|
88 |
|
89 |
* Require PHP 5.6
|