Version Description
(2018-03-05) =
- Pro: Fix REST requests not filtered by the requested language (introduced in 2.3).
- Pro: Fix error 404 on single posts if posts are untranslatable
- Fix translated terms unassigned from posts when deleting a term
- Fix auto translated query with taxonomy in different language returning empty results since WP 4.9 #223
- Fix conflict with a homepage option of the theme Extra
- Fix warning when filtering get_pages()
Download this release
Release Info
Developer | Chouby |
Plugin | Polylang |
Version | 2.3.2 |
Comparing to | |
See all releases |
Code changes from version 2.3.1 to 2.3.2
- admin/admin-filters-term.php +29 -0
- admin/view-translations-term.php +1 -1
- changelog.txt +110 -0
- frontend/choose-lang.php +1 -1
- frontend/frontend-auto-translate.php +22 -0
- frontend/frontend-filters.php +28 -11
- frontend/frontend.php +11 -17
- include/class-polylang.php +20 -5
- include/filters.php +2 -1
- modules/sync/sync-tax.php +21 -0
- polylang.php +2 -2
- readme.txt +10 -111
admin/admin-filters-term.php
CHANGED
@@ -9,6 +9,7 @@ class PLL_Admin_Filters_Term {
|
|
9 |
public $links, $model, $options, $curlang, $filter_lang, $pref_lang;
|
10 |
protected $pre_term_name; // Used to store the term name before creating a slug if needed
|
11 |
protected $post_id; // Used to store the current post_id when bulk editing posts
|
|
|
12 |
|
13 |
/**
|
14 |
* Constructor: setups filters and actions
|
@@ -51,6 +52,8 @@ class PLL_Admin_Filters_Term {
|
|
51 |
|
52 |
// Filters categories and post tags by language
|
53 |
add_filter( 'terms_clauses', array( $this, 'terms_clauses' ), 10, 3 );
|
|
|
|
|
54 |
|
55 |
// Allows to get the default categories in all languages
|
56 |
add_filter( 'option_default_category', array( $this, 'option_default_category' ) );
|
@@ -571,6 +574,10 @@ class PLL_Admin_Filters_Term {
|
|
571 |
return false;
|
572 |
}
|
573 |
|
|
|
|
|
|
|
|
|
574 |
// If get_terms is queried with a 'lang' parameter
|
575 |
if ( isset( $args['lang'] ) ) {
|
576 |
return $args['lang'];
|
@@ -623,6 +630,28 @@ class PLL_Admin_Filters_Term {
|
|
623 |
return ! empty( $lang ) ? $this->model->terms_clauses( $clauses, $lang ) : $clauses; // adds our clauses to filter by current language
|
624 |
}
|
625 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
626 |
/**
|
627 |
* Hack to avoid displaying delete link for the default category in all languages
|
628 |
* Also returns the default category in the right language when called from wp_delete_term
|
9 |
public $links, $model, $options, $curlang, $filter_lang, $pref_lang;
|
10 |
protected $pre_term_name; // Used to store the term name before creating a slug if needed
|
11 |
protected $post_id; // Used to store the current post_id when bulk editing posts
|
12 |
+
private $tax_query_lang;
|
13 |
|
14 |
/**
|
15 |
* Constructor: setups filters and actions
|
52 |
|
53 |
// Filters categories and post tags by language
|
54 |
add_filter( 'terms_clauses', array( $this, 'terms_clauses' ), 10, 3 );
|
55 |
+
add_action( 'parse_query', array( $this, 'set_tax_query_lang' ) );
|
56 |
+
add_action( 'posts_selection', array( $this, 'unset_tax_query_lang' ) );
|
57 |
|
58 |
// Allows to get the default categories in all languages
|
59 |
add_filter( 'option_default_category', array( $this, 'option_default_category' ) );
|
574 |
return false;
|
575 |
}
|
576 |
|
577 |
+
if ( isset( $this->tax_query_lang ) ) {
|
578 |
+
$args['lang'] = $this->tax_query_lang;
|
579 |
+
}
|
580 |
+
|
581 |
// If get_terms is queried with a 'lang' parameter
|
582 |
if ( isset( $args['lang'] ) ) {
|
583 |
return $args['lang'];
|
630 |
return ! empty( $lang ) ? $this->model->terms_clauses( $clauses, $lang ) : $clauses; // adds our clauses to filter by current language
|
631 |
}
|
632 |
|
633 |
+
/**
|
634 |
+
* Sets the WP_Term_Query language when doing a WP_Query
|
635 |
+
* Needed since WP 4.9
|
636 |
+
*
|
637 |
+
* @since 2.3.2
|
638 |
+
*
|
639 |
+
* @param object $query WP_Query object
|
640 |
+
*/
|
641 |
+
public function set_tax_query_lang( $query ) {
|
642 |
+
$this->tax_query_lang = isset( $query->query_vars['lang'] ) ? $query->query_vars['lang'] : '';
|
643 |
+
}
|
644 |
+
|
645 |
+
/**
|
646 |
+
* Removes the WP_Term_Query language filter for WP_Query
|
647 |
+
* Needed since WP 4.9
|
648 |
+
*
|
649 |
+
* @since 2.3.2
|
650 |
+
*/
|
651 |
+
public function unset_tax_query_lang() {
|
652 |
+
unset( $this->tax_query_lang );
|
653 |
+
}
|
654 |
+
|
655 |
/**
|
656 |
* Hack to avoid displaying delete link for the default category in all languages
|
657 |
* Also returns the default category in the right language when called from wp_delete_term
|
admin/view-translations-term.php
CHANGED
@@ -48,7 +48,7 @@ else {
|
|
48 |
?>
|
49 |
<tr>
|
50 |
<th class = "pll-language-column">
|
51 |
-
<span class = "pll-translation-flag"><?php echo $language->flag; ?></span>
|
52 |
<?php
|
53 |
printf(
|
54 |
'<span class="pll-language-name%1$s">%2$s</span>',
|
48 |
?>
|
49 |
<tr>
|
50 |
<th class = "pll-language-column">
|
51 |
+
<span class = "pll-translation-flag"><?php echo $language->flag ? $language->flag : esc_html( $language->slug ); ?></span>
|
52 |
<?php
|
53 |
printf(
|
54 |
'<span class="pll-language-name%1$s">%2$s</span>',
|
changelog.txt
CHANGED
@@ -2,6 +2,116 @@
|
|
2 |
|
3 |
This file contains only old changelog. See readme.txt for newer versions.
|
4 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
5 |
= 2.1.6 (2017-07-17) =
|
6 |
|
7 |
* Pro: fix duplicate post button not working in PHP 7.1
|
2 |
|
3 |
This file contains only old changelog. See readme.txt for newer versions.
|
4 |
|
5 |
+
= 2.2.8 (2018-01-09) =
|
6 |
+
|
7 |
+
* Pro: Fix: Impossible to link past events by translation in The Events Calendar
|
8 |
+
* Disallow to delete translations of the default term for all taxonomies
|
9 |
+
* Fix: Auto add pages adds WooCommerce pages in default language to menus in all languages
|
10 |
+
* Fix most used tag cloud in Tags metabox in WP4.9+. Props Pär Thernström. #208
|
11 |
+
|
12 |
+
= 2.2.7 (2017-11-30) =
|
13 |
+
|
14 |
+
* Fix queries by taxonomy broken since WP 4.9
|
15 |
+
* Fix PHP notice in icl_object_id()
|
16 |
+
|
17 |
+
= 2.2.6 (2017-11-22) =
|
18 |
+
|
19 |
+
* Pro: Fix query by post name and alternative language always returning the post in current language (when sharing slugs)
|
20 |
+
* Pro: Fix query by taxonomy and alternative language returning empty results
|
21 |
+
* Rework how translation files are loaded in ajax on front when the user is logged (in WP 4.7+)
|
22 |
+
* Add filter 'get_objects_with_no_lang_limit'
|
23 |
+
* Force loading the admin side when using WP CLI (Props chrisschrijver)
|
24 |
+
* Fix check for terms with no language not scaling
|
25 |
+
* Fix pll_count_posts not working with multiple post types
|
26 |
+
* Fix inconsistent spacing between flag and language name in language switcher parent menu item (Props Amit Tal)
|
27 |
+
* Fix spacing between flag and language name when displaying an RTL language
|
28 |
+
* Fix get_terms not accepting comma separated values for 'lang' parameter (Props Pavlo Zhukov)
|
29 |
+
* Fix possible wrong language detected in url when using subdomains (Props Pavlo Zhukov)
|
30 |
+
* Fix double escaped query
|
31 |
+
|
32 |
+
= 2.2.5 (2017-11-09) =
|
33 |
+
|
34 |
+
* Update plugin updater class to 1.6.15
|
35 |
+
* Add $link in cache key of links filters
|
36 |
+
* Add support for 'nav_menu' post type in wpml_object_id
|
37 |
+
* Fix conflict with Timber (introduced in 2.2.4)
|
38 |
+
|
39 |
+
= 2.2.4 (2017-10-26) =
|
40 |
+
|
41 |
+
* Pro: Fix unknown language not redirected to default when using multiple domains
|
42 |
+
* Pro: Fix empty 'lang' query var not deactivating the language query filter
|
43 |
+
* Pro: Fix conflict with The Events Calendar and Visual Composer when used together
|
44 |
+
* Add new filter `pll_hide_archive_translation_url` #174
|
45 |
+
* Add support for undocumented and deprecated WPML functions `wpml_object_id_filter` and `icl_get_current_language`
|
46 |
+
* Fix 'orderby' and 'order' in `wpml_active_languages`. Needs WP 4.7+
|
47 |
+
* Fix `icl_get_languages` not returning all languages when skip_missing = 0. Props Loïc Blascos
|
48 |
+
* Fix `pll_translate_string` not working on admin #178
|
49 |
+
* Fix PHP Warning in widget video in WP 4.9
|
50 |
+
* Fix query using 'any' post type not filtered per language (introduced in 2.2)
|
51 |
+
* Fix untranslatable string in About metabox. Props Farhad Sakhaei
|
52 |
+
* Fix error with PHP 7.1 and Duplicate Post. Props Enea Scerba
|
53 |
+
* Fix query auto translation not active in ajax requests on frontend
|
54 |
+
* Fix query auto translation for 'postname' and 'pagename'
|
55 |
+
* Fix terms query auto translation not working for 'include' when no taxonomy is provided (WP 4.5+)
|
56 |
+
|
57 |
+
= 2.2.3 (2017-09-24) =
|
58 |
+
|
59 |
+
* Fix editor removed on pages (introduced in 2.2.2)
|
60 |
+
|
61 |
+
= 2.2.2 (2017-09-22) =
|
62 |
+
|
63 |
+
* Pro: Fix Duplicate post button not working when the user meta has been corrupted
|
64 |
+
* Fix PHP notice with the plugin Members #175
|
65 |
+
* Fix page template select displayed when editing a translated page for posts
|
66 |
+
* Fix incompatibility with WP 4.8.2 (placeholder %1$s in prepare)
|
67 |
+
|
68 |
+
= 2.2.1 (2017-08-30) =
|
69 |
+
|
70 |
+
* Pro: partially refactor REST API classes
|
71 |
+
* Pro: Fix duplicate content user meta not removed from DB when uninstalling the plugin
|
72 |
+
* Fix strings translations not removed from DB when uninstalling the plugin
|
73 |
+
* Fix incorrect translation files loaded in ajax on front when the user is logged in (WP 4.7+)
|
74 |
+
* Fix widget language dropdown removed when saving a widget (introduced in 2.2)
|
75 |
+
* Fix queries with negative values for the 'cat' parameter (introduced in 2.2 for queries made on frontend)
|
76 |
+
* Fix performance issue in combination with some plugins when the language is set from the content (introduced in 2.2)
|
77 |
+
|
78 |
+
= 2.2 (2017-08-16) =
|
79 |
+
|
80 |
+
* Pro: Add support for the REST API
|
81 |
+
* Pro: Add integration with The Events Calendar
|
82 |
+
* Pro: Refactor ACF Pro integration for post metas and integrate term metas
|
83 |
+
* Pro: Ask confirmation if synchronizing a post overwrites an existing translation
|
84 |
+
* Pro: Separate sync post logic from interface
|
85 |
+
* Pro: Fix 'Detect browser language' option automatically deactivated
|
86 |
+
* Pro: Fix redirect to 404 when the 'page' slug translation includes non alphanumeric characters.
|
87 |
+
* Pro: Fix untranslated post type archive slug
|
88 |
+
* Pro: Fix ACF taxonomy fields not copied when the taxonomy is not translated #156
|
89 |
+
* Pro: Fix fatal error with ACF4
|
90 |
+
* Support a different content text direction in admin #45
|
91 |
+
* Add support for wildcards and 'copy-once' attribute in wpml-config.xml
|
92 |
+
* Add minimal support for the filters 'wpml_display_language_names' and 'icl_ls_languages'
|
93 |
+
* Improve compatibility with the plugin WordPress MU Domain Mapping #116
|
94 |
+
* Improve speed of the sticky posts filter #41
|
95 |
+
* Remove redirect_lang option for multiple domains and subdomains
|
96 |
+
* Use secure cookie when using SSL
|
97 |
+
* Allow to copy/sync term metas with the filter 'pll_copy_term_metas'
|
98 |
+
* Filter ajax requests in term.php according to the term language
|
99 |
+
* Add error message in customizer when setting an untranslated static front page #47
|
100 |
+
* Load static page class only if we are using a static front page
|
101 |
+
* Refactor parse_query filters to use the same code on frontend and admin
|
102 |
+
* Don't use add_language_to_link in filters
|
103 |
+
* Move ajaxPrefilter footer script on top
|
104 |
+
* Use wp_doing_ajax() instead of DOING_AJAX constant
|
105 |
+
* Fix queries custom tax not excluded from language filter on admin
|
106 |
+
* Fix WP translation not loaded when the language is set from the content on multisite.
|
107 |
+
* Fix the list of core post types in PLL_OLT_Manager for WP 4.7+
|
108 |
+
* Fix post name and tag slug incorrectly sanitized for German and Danish
|
109 |
+
* Fix lang attribute in dropdowns
|
110 |
+
* Fix wpml_permalink filter #139
|
111 |
+
* Fix WPML constants undefined on backend #151
|
112 |
+
* Fix a conflict with the plugin Custom Permalinks #143
|
113 |
+
* Fix menu location unexpectedly unset
|
114 |
+
|
115 |
= 2.1.6 (2017-07-17) =
|
116 |
|
117 |
* Pro: fix duplicate post button not working in PHP 7.1
|
frontend/choose-lang.php
CHANGED
@@ -306,7 +306,7 @@ abstract class PLL_Choose_Lang {
|
|
306 |
// sets is_home on translated home page when it displays posts
|
307 |
// is_home must be true on page 2, 3... too
|
308 |
// as well as when searching an empty string: http://wordpress.org/support/topic/plugin-polylang-polylang-breaks-search-in-spun-theme
|
309 |
-
|
310 |
$lang = $this->model->get_language( $lang );
|
311 |
$this->set_language( $lang ); // sets the language now otherwise it will be too late to filter sticky posts !
|
312 |
$query->is_home = true;
|
306 |
// sets is_home on translated home page when it displays posts
|
307 |
// is_home must be true on page 2, 3... too
|
308 |
// as well as when searching an empty string: http://wordpress.org/support/topic/plugin-polylang-polylang-breaks-search-in-spun-theme
|
309 |
+
elseif ( ( count( $query->query ) == 1 || ( is_paged() && count( $query->query ) == 2 ) || ( isset( $query->query['s'] ) && ! $query->query['s'] ) ) && $lang = get_query_var( 'lang' ) ) {
|
310 |
$lang = $this->model->get_language( $lang );
|
311 |
$this->set_language( $lang ); // sets the language now otherwise it will be too late to filter sticky posts !
|
312 |
$query->is_home = true;
|
frontend/frontend-auto-translate.php
CHANGED
@@ -22,6 +22,8 @@ class PLL_Frontend_Auto_Translate {
|
|
22 |
|
23 |
add_action( 'pre_get_posts', array( $this, 'pre_get_posts' ) ); // after main Polylang filter
|
24 |
add_filter( 'get_terms_args', array( $this, 'get_terms_args' ), 10, 2 );
|
|
|
|
|
25 |
}
|
26 |
|
27 |
/**
|
@@ -223,6 +225,26 @@ class PLL_Frontend_Auto_Translate {
|
|
223 |
return $args;
|
224 |
}
|
225 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
226 |
/**
|
227 |
* Translates tax queries
|
228 |
* Compatible with nested tax queries introduced in WP 4.1
|
22 |
|
23 |
add_action( 'pre_get_posts', array( $this, 'pre_get_posts' ) ); // after main Polylang filter
|
24 |
add_filter( 'get_terms_args', array( $this, 'get_terms_args' ), 10, 2 );
|
25 |
+
add_action( 'parse_query', array( $this, 'remove_terms_filter' ) );
|
26 |
+
add_action( 'posts_selection', array( $this, 'add_terms_filter' ) );
|
27 |
}
|
28 |
|
29 |
/**
|
225 |
return $args;
|
226 |
}
|
227 |
|
228 |
+
/**
|
229 |
+
* Remove terms filter when doing a WP_Query
|
230 |
+
* Needed since WP 4.9
|
231 |
+
*
|
232 |
+
* @since 2.3.2
|
233 |
+
*/
|
234 |
+
public function remove_terms_filter() {
|
235 |
+
remove_filter( 'get_terms_args', array( $this, 'get_terms_args' ), 10, 2 );
|
236 |
+
}
|
237 |
+
|
238 |
+
/**
|
239 |
+
* Add terms filter back after a WP_Query
|
240 |
+
* Needed since WP 4.9
|
241 |
+
*
|
242 |
+
* @since 2.3.2
|
243 |
+
*/
|
244 |
+
public function add_terms_filter() {
|
245 |
+
add_filter( 'get_terms_args', array( $this, 'get_terms_args' ), 10, 2 );
|
246 |
+
}
|
247 |
+
|
248 |
/**
|
249 |
* Translates tax queries
|
250 |
* Compatible with nested tax queries introduced in WP 4.1
|
frontend/frontend-filters.php
CHANGED
@@ -6,6 +6,7 @@
|
|
6 |
* @since 1.2
|
7 |
*/
|
8 |
class PLL_Frontend_Filters extends PLL_Filters {
|
|
|
9 |
|
10 |
/**
|
11 |
* Constructor: setups filters and actions
|
@@ -28,6 +29,8 @@ class PLL_Frontend_Filters extends PLL_Filters {
|
|
28 |
|
29 |
// Filters categories and post tags by language
|
30 |
add_filter( 'terms_clauses', array( $this, 'terms_clauses' ), 10, 3 );
|
|
|
|
|
31 |
|
32 |
// Rewrites archives links to filter them by language
|
33 |
add_filter( 'getarchives_join', array( $this, 'getarchives_join' ), 10, 2 );
|
@@ -129,6 +132,9 @@ class PLL_Frontend_Filters extends PLL_Filters {
|
|
129 |
* @return array
|
130 |
*/
|
131 |
public function get_terms_args( $args ) {
|
|
|
|
|
|
|
132 |
$lang = isset( $args['lang'] ) ? $args['lang'] : $this->curlang->slug;
|
133 |
$key = '_' . ( is_array( $lang ) ? implode( ',', $lang ) : $lang );
|
134 |
$args['cache_domain'] = empty( $args['cache_domain'] ) ? 'pll' . $key : $args['cache_domain'] . $key;
|
@@ -152,21 +158,32 @@ class PLL_Frontend_Filters extends PLL_Filters {
|
|
152 |
return $clauses;
|
153 |
}
|
154 |
|
155 |
-
// Ugly hack to fix the issue introduced by WP 4.9. See also https://core.trac.wordpress.org/ticket/42104
|
156 |
-
if ( version_compare( $GLOBALS['wp_version'], '4.9', '>=' ) ) {
|
157 |
-
$traces = version_compare( PHP_VERSION, '5.2.5', '>=' ) ? debug_backtrace( false ) : debug_backtrace();
|
158 |
-
|
159 |
-
// PHP 7 does not include call_user_func
|
160 |
-
$n = version_compare( PHP_VERSION, '7', '>=' ) ? 5 : 6;
|
161 |
-
if ( isset( $traces[ $n ]['function'] ) && 'transform_query' === $traces[ $n ]['function'] ) {
|
162 |
-
return $clauses;
|
163 |
-
}
|
164 |
-
}
|
165 |
-
|
166 |
// Adds our clauses to filter by language
|
167 |
return $this->model->terms_clauses( $clauses, isset( $args['lang'] ) ? $args['lang'] : $this->curlang );
|
168 |
}
|
169 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
170 |
/**
|
171 |
* Modifies the sql request for wp_get_archives to filter by the current language
|
172 |
*
|
6 |
* @since 1.2
|
7 |
*/
|
8 |
class PLL_Frontend_Filters extends PLL_Filters {
|
9 |
+
private $tax_query_lang;
|
10 |
|
11 |
/**
|
12 |
* Constructor: setups filters and actions
|
29 |
|
30 |
// Filters categories and post tags by language
|
31 |
add_filter( 'terms_clauses', array( $this, 'terms_clauses' ), 10, 3 );
|
32 |
+
add_action( 'parse_query', array( $this, 'set_tax_query_lang' ) );
|
33 |
+
add_action( 'posts_selection', array( $this, 'unset_tax_query_lang' ) );
|
34 |
|
35 |
// Rewrites archives links to filter them by language
|
36 |
add_filter( 'getarchives_join', array( $this, 'getarchives_join' ), 10, 2 );
|
132 |
* @return array
|
133 |
*/
|
134 |
public function get_terms_args( $args ) {
|
135 |
+
if ( isset( $this->tax_query_lang ) ) {
|
136 |
+
$args['lang'] = $this->tax_query_lang;
|
137 |
+
}
|
138 |
$lang = isset( $args['lang'] ) ? $args['lang'] : $this->curlang->slug;
|
139 |
$key = '_' . ( is_array( $lang ) ? implode( ',', $lang ) : $lang );
|
140 |
$args['cache_domain'] = empty( $args['cache_domain'] ) ? 'pll' . $key : $args['cache_domain'] . $key;
|
158 |
return $clauses;
|
159 |
}
|
160 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
161 |
// Adds our clauses to filter by language
|
162 |
return $this->model->terms_clauses( $clauses, isset( $args['lang'] ) ? $args['lang'] : $this->curlang );
|
163 |
}
|
164 |
|
165 |
+
/**
|
166 |
+
* Sets the WP_Term_Query language when doing a WP_Query
|
167 |
+
* Needed since WP 4.9
|
168 |
+
*
|
169 |
+
* @since 2.3.2
|
170 |
+
*
|
171 |
+
* @param object $query WP_Query object
|
172 |
+
*/
|
173 |
+
public function set_tax_query_lang( $query ) {
|
174 |
+
$this->tax_query_lang = isset( $query->query_vars['lang'] ) ? $query->query_vars['lang'] : '';
|
175 |
+
}
|
176 |
+
|
177 |
+
/**
|
178 |
+
* Removes the WP_Term_Query language filter for WP_Query
|
179 |
+
* Needed since WP 4.9
|
180 |
+
*
|
181 |
+
* @since 2.3.2
|
182 |
+
*/
|
183 |
+
public function unset_tax_query_lang() {
|
184 |
+
unset( $this->tax_query_lang );
|
185 |
+
}
|
186 |
+
|
187 |
/**
|
188 |
* Modifies the sql request for wp_get_archives to filter by the current language
|
189 |
*
|
frontend/frontend.php
CHANGED
@@ -56,25 +56,19 @@ class PLL_Frontend extends PLL_Base {
|
|
56 |
public function init() {
|
57 |
$this->links = new PLL_Frontend_Links( $this );
|
58 |
|
59 |
-
//
|
60 |
-
if (
|
61 |
-
|
62 |
-
|
63 |
-
} else {
|
64 |
-
// Static front page and page for posts
|
65 |
-
if ( 'page' === get_option( 'show_on_front' ) ) {
|
66 |
-
$this->static_pages = new PLL_Frontend_Static_Pages( $this );
|
67 |
-
}
|
68 |
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
|
75 |
-
|
76 |
-
|
77 |
-
}
|
78 |
}
|
79 |
|
80 |
/**
|
56 |
public function init() {
|
57 |
$this->links = new PLL_Frontend_Links( $this );
|
58 |
|
59 |
+
// Static front page and page for posts
|
60 |
+
if ( 'page' === get_option( 'show_on_front' ) ) {
|
61 |
+
$this->static_pages = new PLL_Frontend_Static_Pages( $this );
|
62 |
+
}
|
|
|
|
|
|
|
|
|
|
|
63 |
|
64 |
+
// Setup the language chooser
|
65 |
+
$c = array( 'Content', 'Url', 'Url', 'Domain' );
|
66 |
+
$class = 'PLL_Choose_Lang_' . $c[ $this->options['force_lang'] ];
|
67 |
+
$this->choose_lang = new $class( $this );
|
68 |
+
$this->choose_lang->init();
|
69 |
|
70 |
+
// Need to load nav menu class early to correctly define the locations in the customizer when the language is set from the content
|
71 |
+
$this->nav_menu = new PLL_Frontend_Nav_Menu( $this );
|
|
|
72 |
}
|
73 |
|
74 |
/**
|
include/class-polylang.php
CHANGED
@@ -141,6 +141,24 @@ class Polylang {
|
|
141 |
}
|
142 |
}
|
143 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
144 |
/**
|
145 |
* Polylang initialization
|
146 |
* setups models and separate admin and frontend
|
@@ -178,12 +196,9 @@ class Polylang {
|
|
178 |
|
179 |
if ( PLL_SETTINGS ) {
|
180 |
$polylang = new PLL_Settings( $links_model );
|
181 |
-
}
|
182 |
-
elseif ( PLL_ADMIN ) {
|
183 |
$polylang = new PLL_Admin( $links_model );
|
184 |
-
}
|
185 |
-
// Do nothing on frontend if no language is defined
|
186 |
-
elseif ( $model->get_languages_list() && empty( $_GET['deactivate-polylang'] ) ) {
|
187 |
$polylang = new PLL_Frontend( $links_model );
|
188 |
}
|
189 |
|
141 |
}
|
142 |
}
|
143 |
|
144 |
+
/**
|
145 |
+
* Should we activate Polylang on front
|
146 |
+
*
|
147 |
+
* @since 2.3.2
|
148 |
+
*
|
149 |
+
* @param object $model
|
150 |
+
* @return bool
|
151 |
+
*/
|
152 |
+
protected function is_active_on_front( $model ) {
|
153 |
+
// Do nothing on frontend if no language is defined
|
154 |
+
// Or if it is a REST request and the compatibility class is not present
|
155 |
+
return $model->get_languages_list() &&
|
156 |
+
empty( $_GET['deactivate-polylang'] ) && (
|
157 |
+
class_exists( 'PLL_REST_Translated_Object' ) ||
|
158 |
+
false === strpos( str_replace( 'index.php', '', $_SERVER['REQUEST_URI'] ), '/' . rest_get_url_prefix() . '/' )
|
159 |
+
);
|
160 |
+
}
|
161 |
+
|
162 |
/**
|
163 |
* Polylang initialization
|
164 |
* setups models and separate admin and frontend
|
196 |
|
197 |
if ( PLL_SETTINGS ) {
|
198 |
$polylang = new PLL_Settings( $links_model );
|
199 |
+
} elseif ( PLL_ADMIN ) {
|
|
|
200 |
$polylang = new PLL_Admin( $links_model );
|
201 |
+
} elseif ( $this->is_active_on_front( $model ) ) {
|
|
|
|
|
202 |
$polylang = new PLL_Frontend( $links_model );
|
203 |
}
|
204 |
|
include/filters.php
CHANGED
@@ -154,7 +154,8 @@ class PLL_Filters {
|
|
154 |
),
|
155 |
);
|
156 |
|
157 |
-
|
|
|
158 |
$pages = get_pages( $args );
|
159 |
}
|
160 |
|
154 |
),
|
155 |
);
|
156 |
|
157 |
+
// Take care that 'exclude' argument accepts integer or strings too
|
158 |
+
$args['exclude'] = array_merge( wp_parse_id_list( $args['exclude'] ), get_posts( $r ) );
|
159 |
$pages = get_pages( $args );
|
160 |
}
|
161 |
|
modules/sync/sync-tax.php
CHANGED
@@ -20,6 +20,8 @@ class PLL_Sync_Tax {
|
|
20 |
|
21 |
add_action( 'set_object_terms', array( $this, 'set_object_terms' ), 10, 5 );
|
22 |
add_action( 'pll_save_term', array( $this, 'create_term' ), 10, 3 );
|
|
|
|
|
23 |
}
|
24 |
|
25 |
/**
|
@@ -226,4 +228,23 @@ class PLL_Sync_Tax {
|
|
226 |
}
|
227 |
}
|
228 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
229 |
}
|
20 |
|
21 |
add_action( 'set_object_terms', array( $this, 'set_object_terms' ), 10, 5 );
|
22 |
add_action( 'pll_save_term', array( $this, 'create_term' ), 10, 3 );
|
23 |
+
add_action( 'pre_delete_term', array( $this, 'pre_delete_term' ) );
|
24 |
+
add_action( 'delete_term', array( $this, 'delete_term' ) );
|
25 |
}
|
26 |
|
27 |
/**
|
228 |
}
|
229 |
}
|
230 |
}
|
231 |
+
|
232 |
+
/**
|
233 |
+
* Deactivate the synchronization of terms before deleting a term
|
234 |
+
* to avoid translated terms to be removed from translated posts
|
235 |
+
*
|
236 |
+
* @since 2.3.2
|
237 |
+
*/
|
238 |
+
public function pre_delete_term() {
|
239 |
+
remove_action( 'set_object_terms', array( $this, 'set_object_terms' ), 10, 5 );
|
240 |
+
}
|
241 |
+
|
242 |
+
/**
|
243 |
+
* Re-activate the synchronization of terms after a term is deleted
|
244 |
+
*
|
245 |
+
* @since 2.3.2
|
246 |
+
*/
|
247 |
+
public function delete_term() {
|
248 |
+
add_action( 'set_object_terms', array( $this, 'set_object_terms' ), 10, 5 );
|
249 |
+
}
|
250 |
}
|
polylang.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
/**
|
4 |
Plugin Name: Polylang
|
5 |
Plugin URI: https://polylang.pro
|
6 |
-
Version: 2.3.
|
7 |
Author: Frédéric Demarle
|
8 |
Author uri: https://polylang.pro
|
9 |
Description: Adds multilingual capability to WordPress
|
@@ -53,7 +53,7 @@ if ( defined( 'POLYLANG_BASENAME' ) ) {
|
|
53 |
}
|
54 |
} else {
|
55 |
// Go on loading the plugin
|
56 |
-
define( 'POLYLANG_VERSION', '2.3.
|
57 |
define( 'PLL_MIN_WP_VERSION', '4.4' );
|
58 |
|
59 |
define( 'POLYLANG_FILE', __FILE__ ); // this file
|
3 |
/**
|
4 |
Plugin Name: Polylang
|
5 |
Plugin URI: https://polylang.pro
|
6 |
+
Version: 2.3.2
|
7 |
Author: Frédéric Demarle
|
8 |
Author uri: https://polylang.pro
|
9 |
Description: Adds multilingual capability to WordPress
|
53 |
}
|
54 |
} else {
|
55 |
// Go on loading the plugin
|
56 |
+
define( 'POLYLANG_VERSION', '2.3.2' );
|
57 |
define( 'PLL_MIN_WP_VERSION', '4.4' );
|
58 |
|
59 |
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.4
|
6 |
Tested up to: 4.9
|
7 |
-
Stable tag: 2.3.
|
8 |
License: GPLv2 or later
|
9 |
|
10 |
Making WordPress multilingual
|
@@ -76,6 +76,15 @@ Don't hesitate to [give your feedback](http://wordpress.org/support/view/plugin-
|
|
76 |
|
77 |
== Changelog ==
|
78 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
79 |
= 2.3.1 (2018-02-15) =
|
80 |
|
81 |
* Pro: Fix GET REST request with slug parameter deleting the post slug
|
@@ -108,114 +117,4 @@ Don't hesitate to [give your feedback](http://wordpress.org/support/view/plugin-
|
|
108 |
* Fix home page not correctly loaded when adding a query var
|
109 |
* Fix: Impossible to change the language code when the language code is also a WordPress locale.
|
110 |
|
111 |
-
= 2.2.8 (2018-01-09) =
|
112 |
-
|
113 |
-
* Pro: Fix: Impossible to link past events by translation in The Events Calendar
|
114 |
-
* Disallow to delete translations of the default term for all taxonomies
|
115 |
-
* Fix: Auto add pages adds WooCommerce pages in default language to menus in all languages
|
116 |
-
* Fix most used tag cloud in Tags metabox in WP4.9+. Props Pär Thernström. #208
|
117 |
-
|
118 |
-
= 2.2.7 (2017-11-30) =
|
119 |
-
|
120 |
-
* Fix queries by taxonomy broken since WP 4.9
|
121 |
-
* Fix PHP notice in icl_object_id()
|
122 |
-
|
123 |
-
= 2.2.6 (2017-11-22) =
|
124 |
-
|
125 |
-
* Pro: Fix query by post name and alternative language always returning the post in current language (when sharing slugs)
|
126 |
-
* Pro: Fix query by taxonomy and alternative language returning empty results
|
127 |
-
* Rework how translation files are loaded in ajax on front when the user is logged (in WP 4.7+)
|
128 |
-
* Add filter 'get_objects_with_no_lang_limit'
|
129 |
-
* Force loading the admin side when using WP CLI (Props chrisschrijver)
|
130 |
-
* Fix check for terms with no language not scaling
|
131 |
-
* Fix pll_count_posts not working with multiple post types
|
132 |
-
* Fix inconsistent spacing between flag and language name in language switcher parent menu item (Props Amit Tal)
|
133 |
-
* Fix spacing between flag and language name when displaying an RTL language
|
134 |
-
* Fix get_terms not accepting comma separated values for 'lang' parameter (Props Pavlo Zhukov)
|
135 |
-
* Fix possible wrong language detected in url when using subdomains (Props Pavlo Zhukov)
|
136 |
-
* Fix double escaped query
|
137 |
-
|
138 |
-
= 2.2.5 (2017-11-09) =
|
139 |
-
|
140 |
-
* Update plugin updater class to 1.6.15
|
141 |
-
* Add $link in cache key of links filters
|
142 |
-
* Add support for 'nav_menu' post type in wpml_object_id
|
143 |
-
* Fix conflict with Timber (introduced in 2.2.4)
|
144 |
-
|
145 |
-
= 2.2.4 (2017-10-26) =
|
146 |
-
|
147 |
-
* Pro: Fix unknown language not redirected to default when using multiple domains
|
148 |
-
* Pro: Fix empty 'lang' query var not deactivating the language query filter
|
149 |
-
* Pro: Fix conflict with The Events Calendar and Visual Composer when used together
|
150 |
-
* Add new filter `pll_hide_archive_translation_url` #174
|
151 |
-
* Add support for undocumented and deprecated WPML functions `wpml_object_id_filter` and `icl_get_current_language`
|
152 |
-
* Fix 'orderby' and 'order' in `wpml_active_languages`. Needs WP 4.7+
|
153 |
-
* Fix `icl_get_languages` not returning all languages when skip_missing = 0. Props Loïc Blascos
|
154 |
-
* Fix `pll_translate_string` not working on admin #178
|
155 |
-
* Fix PHP Warning in widget video in WP 4.9
|
156 |
-
* Fix query using 'any' post type not filtered per language (introduced in 2.2)
|
157 |
-
* Fix untranslatable string in About metabox. Props Farhad Sakhaei
|
158 |
-
* Fix error with PHP 7.1 and Duplicate Post. Props Enea Scerba
|
159 |
-
* Fix query auto translation not active in ajax requests on frontend
|
160 |
-
* Fix query auto translation for 'postname' and 'pagename'
|
161 |
-
* Fix terms query auto translation not working for 'include' when no taxonomy is provided (WP 4.5+)
|
162 |
-
|
163 |
-
= 2.2.3 (2017-09-24) =
|
164 |
-
|
165 |
-
* Fix editor removed on pages (introduced in 2.2.2)
|
166 |
-
|
167 |
-
= 2.2.2 (2017-09-22) =
|
168 |
-
|
169 |
-
* Pro: Fix Duplicate post button not working when the user meta has been corrupted
|
170 |
-
* Fix PHP notice with the plugin Members #175
|
171 |
-
* Fix page template select displayed when editing a translated page for posts
|
172 |
-
* Fix incompatibility with WP 4.8.2 (placeholder %1$s in prepare)
|
173 |
-
|
174 |
-
= 2.2.1 (2017-08-30) =
|
175 |
-
|
176 |
-
* Pro: partially refactor REST API classes
|
177 |
-
* Pro: Fix duplicate content user meta not removed from DB when uninstalling the plugin
|
178 |
-
* Fix strings translations not removed from DB when uninstalling the plugin
|
179 |
-
* Fix incorrect translation files loaded in ajax on front when the user is logged in (WP 4.7+)
|
180 |
-
* Fix widget language dropdown removed when saving a widget (introduced in 2.2)
|
181 |
-
* Fix queries with negative values for the 'cat' parameter (introduced in 2.2 for queries made on frontend)
|
182 |
-
* Fix performance issue in combination with some plugins when the language is set from the content (introduced in 2.2)
|
183 |
-
|
184 |
-
= 2.2 (2017-08-16) =
|
185 |
-
|
186 |
-
* Pro: Add support for the REST API
|
187 |
-
* Pro: Add integration with The Events Calendar
|
188 |
-
* Pro: Refactor ACF Pro integration for post metas and integrate term metas
|
189 |
-
* Pro: Ask confirmation if synchronizing a post overwrites an existing translation
|
190 |
-
* Pro: Separate sync post logic from interface
|
191 |
-
* Pro: Fix 'Detect browser language' option automatically deactivated
|
192 |
-
* Pro: Fix redirect to 404 when the 'page' slug translation includes non alphanumeric characters.
|
193 |
-
* Pro: Fix untranslated post type archive slug
|
194 |
-
* Pro: Fix ACF taxonomy fields not copied when the taxonomy is not translated #156
|
195 |
-
* Pro: Fix fatal error with ACF4
|
196 |
-
* Support a different content text direction in admin #45
|
197 |
-
* Add support for wildcards and 'copy-once' attribute in wpml-config.xml
|
198 |
-
* Add minimal support for the filters 'wpml_display_language_names' and 'icl_ls_languages'
|
199 |
-
* Improve compatibility with the plugin WordPress MU Domain Mapping #116
|
200 |
-
* Improve speed of the sticky posts filter #41
|
201 |
-
* Remove redirect_lang option for multiple domains and subdomains
|
202 |
-
* Use secure cookie when using SSL
|
203 |
-
* Allow to copy/sync term metas with the filter 'pll_copy_term_metas'
|
204 |
-
* Filter ajax requests in term.php according to the term language
|
205 |
-
* Add error message in customizer when setting an untranslated static front page #47
|
206 |
-
* Load static page class only if we are using a static front page
|
207 |
-
* Refactor parse_query filters to use the same code on frontend and admin
|
208 |
-
* Don't use add_language_to_link in filters
|
209 |
-
* Move ajaxPrefilter footer script on top
|
210 |
-
* Use wp_doing_ajax() instead of DOING_AJAX constant
|
211 |
-
* Fix queries custom tax not excluded from language filter on admin
|
212 |
-
* Fix WP translation not loaded when the language is set from the content on multisite.
|
213 |
-
* Fix the list of core post types in PLL_OLT_Manager for WP 4.7+
|
214 |
-
* Fix post name and tag slug incorrectly sanitized for German and Danish
|
215 |
-
* Fix lang attribute in dropdowns
|
216 |
-
* Fix wpml_permalink filter #139
|
217 |
-
* Fix WPML constants undefined on backend #151
|
218 |
-
* Fix a conflict with the plugin Custom Permalinks #143
|
219 |
-
* Fix menu location unexpectedly unset
|
220 |
-
|
221 |
See [changelog.txt](https://plugins.svn.wordpress.org/polylang/trunk/changelog.txt) for older changelog
|
4 |
Tags: multilingual, bilingual, translate, translation, language, multilanguage, international, localization
|
5 |
Requires at least: 4.4
|
6 |
Tested up to: 4.9
|
7 |
+
Stable tag: 2.3.2
|
8 |
License: GPLv2 or later
|
9 |
|
10 |
Making WordPress multilingual
|
76 |
|
77 |
== Changelog ==
|
78 |
|
79 |
+
= 2.3.2 (2018-03-05) =
|
80 |
+
|
81 |
+
* Pro: Fix REST requests not filtered by the requested language (introduced in 2.3).
|
82 |
+
* Pro: Fix error 404 on single posts if posts are untranslatable
|
83 |
+
* Fix translated terms unassigned from posts when deleting a term
|
84 |
+
* Fix auto translated query with taxonomy in different language returning empty results since WP 4.9 #223
|
85 |
+
* Fix conflict with a homepage option of the theme Extra
|
86 |
+
* Fix warning when filtering get_pages()
|
87 |
+
|
88 |
= 2.3.1 (2018-02-15) =
|
89 |
|
90 |
* Pro: Fix GET REST request with slug parameter deleting the post slug
|
117 |
* Fix home page not correctly loaded when adding a query var
|
118 |
* Fix: Impossible to change the language code when the language code is also a WordPress locale.
|
119 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
120 |
See [changelog.txt](https://plugins.svn.wordpress.org/polylang/trunk/changelog.txt) for older changelog
|