Version Description
(2017-11-22) =
- Pro: Fix query by post name and alternative language always returning the post in current language (when sharing slugs)
- Pro: Fix query by taxonomy and alternative language returning empty results
- Rework how translation files are loaded in ajax on front when the user is logged (in WP 4.7+)
- Add filter 'get_objects_with_no_lang_limit'
- Force loading the admin side when using WP CLI (Props chrisschrijver)
- Fix check for terms with no language not scaling
- Fix pll_count_posts not working with multiple post types
- Fix inconsistent spacing between flag and language name in language switcher parent menu item (Props Amit Tal)
- Fix spacing between flag and language name when displaying an RTL language
- Fix get_terms not accepting comma separated values for 'lang' parameter (Props Pavlo Zhukov)
- Fix possible wrong language detected in url when using subdomains (Props Pavlo Zhukov)
- Fix double escaped query
Download this release
Release Info
Developer | Chouby |
Plugin | Polylang |
Version | 2.2.6 |
Comparing to | |
See all releases |
Code changes from version 2.2.5 to 2.2.6
- admin/admin-base.php +2 -2
- admin/admin-filters-columns.php +1 -1
- admin/admin-filters-post.php +1 -1
- admin/admin-filters-term.php +2 -1
- admin/admin-filters.php +4 -4
- admin/admin-links.php +1 -1
- admin/admin-model.php +33 -12
- admin/admin-static-pages.php +1 -1
- admin/admin.php +1 -1
- admin/view-translations-post.php +1 -1
- changelog.txt +21 -21
- css/admin.css +1 -1
- frontend/choose-lang-url.php +3 -3
- frontend/choose-lang.php +2 -2
- frontend/frontend-auto-translate.php +8 -3
- frontend/frontend-filters-links.php +2 -2
- frontend/frontend-filters-search.php +1 -1
- frontend/frontend-filters.php +22 -17
- frontend/frontend-nav-menu.php +25 -2
- include/api.php +1 -1
- include/class-polylang.php +3 -3
- include/links-abstract-domain.php +15 -0
- include/links-directory.php +1 -1
- include/links-domain.php +0 -15
- include/links-permalinks.php +3 -3
- include/links-subdomain.php +1 -17
- include/links.php +1 -1
- include/model.php +3 -3
- include/nav-menu.php +1 -1
- include/olt-manager.php +8 -6
- include/switcher.php +2 -2
- include/translated-object.php +5 -5
- include/walker-list.php +1 -1
- include/widget-calendar.php +1 -1
- modules/wpml/wpml-legacy-api.php +1 -1
- polylang.php +2 -2
- readme.txt +16 -1
- settings/settings.php +1 -1
admin/admin-base.php
CHANGED
@@ -262,7 +262,7 @@ class PLL_Admin_Base extends PLL_Base {
|
|
262 |
$this->pref_lang = empty( $this->filter_lang ) ? $this->model->get_language( $this->options['default_lang'] ) : $this->filter_lang;
|
263 |
|
264 |
/**
|
265 |
-
* Filter the preferred language on
|
266 |
* The preferred language is used for example to determine the language of a new post
|
267 |
*
|
268 |
* @since 1.2.3
|
@@ -286,7 +286,7 @@ class PLL_Admin_Base extends PLL_Base {
|
|
286 |
do_action( 'pll_language_defined', $curlang->slug, $curlang );
|
287 |
} else {
|
288 |
/** This action is documented in include/class-polylang.php */
|
289 |
-
do_action( 'pll_no_language_defined' ); // to load
|
290 |
}
|
291 |
}
|
292 |
|
262 |
$this->pref_lang = empty( $this->filter_lang ) ? $this->model->get_language( $this->options['default_lang'] ) : $this->filter_lang;
|
263 |
|
264 |
/**
|
265 |
+
* Filter the preferred language on admin side
|
266 |
* The preferred language is used for example to determine the language of a new post
|
267 |
*
|
268 |
* @since 1.2.3
|
286 |
do_action( 'pll_language_defined', $curlang->slug, $curlang );
|
287 |
} else {
|
288 |
/** This action is documented in include/class-polylang.php */
|
289 |
+
do_action( 'pll_no_language_defined' ); // to load overridden textdomains
|
290 |
}
|
291 |
}
|
292 |
|
admin/admin-filters-columns.php
CHANGED
@@ -323,7 +323,7 @@ class PLL_Admin_Filters_Columns {
|
|
323 |
|
324 |
$translations = empty( $_POST['translations'] ) ? array() : explode( ',', $_POST['translations'] ); // collect old translations
|
325 |
$translations = array_merge( $translations, $this->model->term->get_translations( (int) $_POST['term_id'] ) ); // add current translations
|
326 |
-
$translations = array_unique( $translations ); // remove
|
327 |
$translations = array_map( 'intval', $translations );
|
328 |
|
329 |
foreach ( $translations as $term_id ) {
|
323 |
|
324 |
$translations = empty( $_POST['translations'] ) ? array() : explode( ',', $_POST['translations'] ); // collect old translations
|
325 |
$translations = array_merge( $translations, $this->model->term->get_translations( (int) $_POST['term_id'] ) ); // add current translations
|
326 |
+
$translations = array_unique( $translations ); // remove duplicates
|
327 |
$translations = array_map( 'intval', $translations );
|
328 |
|
329 |
foreach ( $translations as $term_id ) {
|
admin/admin-filters-post.php
CHANGED
@@ -213,7 +213,7 @@ class PLL_Admin_Filters_Post extends PLL_Admin_Filters_Post_Base {
|
|
213 |
ob_end_clean();
|
214 |
|
215 |
ob_start();
|
216 |
-
// Use $post_ID to remember
|
217 |
wp_terms_checklist( $post_ID, array( 'taxonomy' => $taxonomy->name, 'popular_cats' => $popular_ids ) );
|
218 |
$supplemental['all'] = ob_get_contents();
|
219 |
ob_end_clean();
|
213 |
ob_end_clean();
|
214 |
|
215 |
ob_start();
|
216 |
+
// Use $post_ID to remember checked terms in case we come back to the original language
|
217 |
wp_terms_checklist( $post_ID, array( 'taxonomy' => $taxonomy->name, 'popular_cats' => $popular_ids ) );
|
218 |
$supplemental['all'] = ob_get_contents();
|
219 |
ob_end_clean();
|
admin/admin-filters-term.php
CHANGED
@@ -345,7 +345,7 @@ class PLL_Admin_Filters_Term {
|
|
345 |
* @since 0.1
|
346 |
*
|
347 |
* @param int $term_id
|
348 |
-
* @param int $tt_id term
|
349 |
* @param string $taxonomy
|
350 |
*/
|
351 |
public function save_term( $term_id, $tt_id, $taxonomy ) {
|
@@ -601,6 +601,7 @@ class PLL_Admin_Filters_Term {
|
|
601 |
}
|
602 |
|
603 |
if ( $lang = $this->get_queried_language( $taxonomies, $args ) ) {
|
|
|
604 |
$key = '_' . ( is_array( $lang ) ? implode( ',', $lang ) : $this->model->get_language( $lang )->slug );
|
605 |
$args['cache_domain'] = empty( $args['cache_domain'] ) ? 'pll' . $key : $args['cache_domain'] . $key;
|
606 |
}
|
345 |
* @since 0.1
|
346 |
*
|
347 |
* @param int $term_id
|
348 |
+
* @param int $tt_id term taxonomy id
|
349 |
* @param string $taxonomy
|
350 |
*/
|
351 |
public function save_term( $term_id, $tt_id, $taxonomy ) {
|
601 |
}
|
602 |
|
603 |
if ( $lang = $this->get_queried_language( $taxonomies, $args ) ) {
|
604 |
+
$lang = is_string( $lang ) && strpos( $lang, ',' ) ? explode( ',', $lang ) : $lang;
|
605 |
$key = '_' . ( is_array( $lang ) ? implode( ',', $lang ) : $this->model->get_language( $lang )->slug );
|
606 |
$args['cache_domain'] = empty( $args['cache_domain'] ) ? 'pll' . $key : $args['cache_domain'] . $key;
|
607 |
}
|
admin/admin-filters.php
CHANGED
@@ -26,7 +26,7 @@ class PLL_Admin_Filters extends PLL_Filters {
|
|
26 |
add_action( 'edit_user_profile_update', array( $this, 'personal_options_update' ) );
|
27 |
add_action( 'personal_options', array( $this, 'personal_options' ) );
|
28 |
|
29 |
-
//
|
30 |
// Backward compatibility WP < 4.0 *AND* Polylang < 1.6
|
31 |
add_action( '_core_updated_successfully', array( $this, 'upgrade_languages' ), 1 ); // since WP 3.3
|
32 |
|
@@ -45,7 +45,7 @@ class PLL_Admin_Filters extends PLL_Filters {
|
|
45 |
}
|
46 |
|
47 |
/**
|
48 |
-
* Modifies the widgets forms to add our language
|
49 |
*
|
50 |
* @since 0.3
|
51 |
*
|
@@ -157,7 +157,7 @@ class PLL_Admin_Filters extends PLL_Filters {
|
|
157 |
);
|
158 |
}
|
159 |
|
160 |
-
// Hidden
|
161 |
foreach ( $this->model->get_languages_list() as $lang ) {
|
162 |
$meta = $lang->slug == $this->options['default_lang'] ? 'description' : 'description_' . $lang->slug;
|
163 |
|
@@ -173,7 +173,7 @@ class PLL_Admin_Filters extends PLL_Filters {
|
|
173 |
}
|
174 |
|
175 |
/**
|
176 |
-
*
|
177 |
* only for backward compatibility WP < 4.0 *AND* Polylang < 1.6
|
178 |
*
|
179 |
* @since 0.6
|
26 |
add_action( 'edit_user_profile_update', array( $this, 'personal_options_update' ) );
|
27 |
add_action( 'personal_options', array( $this, 'personal_options' ) );
|
28 |
|
29 |
+
// Upgrades languages files after a core upgrade ( timing is important )
|
30 |
// Backward compatibility WP < 4.0 *AND* Polylang < 1.6
|
31 |
add_action( '_core_updated_successfully', array( $this, 'upgrade_languages' ), 1 ); // since WP 3.3
|
32 |
|
45 |
}
|
46 |
|
47 |
/**
|
48 |
+
* Modifies the widgets forms to add our language dropdown list
|
49 |
*
|
50 |
* @since 0.3
|
51 |
*
|
157 |
);
|
158 |
}
|
159 |
|
160 |
+
// Hidden information to modify the biography form with js
|
161 |
foreach ( $this->model->get_languages_list() as $lang ) {
|
162 |
$meta = $lang->slug == $this->options['default_lang'] ? 'description' : 'description_' . $lang->slug;
|
163 |
|
173 |
}
|
174 |
|
175 |
/**
|
176 |
+
* Upgrades languages files after a core upgrade
|
177 |
* only for backward compatibility WP < 4.0 *AND* Polylang < 1.6
|
178 |
*
|
179 |
* @since 0.6
|
admin/admin-links.php
CHANGED
@@ -30,7 +30,7 @@ class PLL_Admin_Links extends PLL_Links {
|
|
30 |
'new_lang' => $language->slug,
|
31 |
);
|
32 |
|
33 |
-
// add nonce for media as we will directly publish a new attachment from a
|
34 |
$link = wp_nonce_url( add_query_arg( $args, admin_url( 'admin.php' ) ), 'translate_media' );
|
35 |
} else {
|
36 |
$args = array(
|
30 |
'new_lang' => $language->slug,
|
31 |
);
|
32 |
|
33 |
+
// add nonce for media as we will directly publish a new attachment from a click on this link
|
34 |
$link = wp_nonce_url( add_query_arg( $args, admin_url( 'admin.php' ) ), 'translate_media' );
|
35 |
} else {
|
36 |
$args = array(
|
admin/admin-model.php
CHANGED
@@ -46,7 +46,7 @@ class PLL_Admin_Model extends PLL_Model {
|
|
46 |
// Don't want shared terms so use a different slug
|
47 |
wp_insert_term( $args['name'], 'term_language', array( 'slug' => 'pll_' . $args['slug'] ) );
|
48 |
|
49 |
-
$this->clean_languages_cache(); //
|
50 |
|
51 |
if ( ! isset( $this->options['default_lang'] ) ) {
|
52 |
// If this is the first language created, set it as default language
|
@@ -402,16 +402,31 @@ class PLL_Admin_Model extends PLL_Model {
|
|
402 |
}
|
403 |
|
404 |
/**
|
405 |
-
* Returns
|
406 |
*
|
407 |
* @since 0.9
|
|
|
408 |
*
|
409 |
-
* @
|
|
|
410 |
*/
|
411 |
-
public function get_objects_with_no_lang() {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
412 |
$posts = get_posts( array(
|
413 |
-
'numberposts' =>
|
414 |
-
'nopaging' =>
|
415 |
'post_type' => $this->get_translated_post_types(),
|
416 |
'post_status' => 'any',
|
417 |
'fields' => 'ids',
|
@@ -424,11 +439,17 @@ class PLL_Admin_Model extends PLL_Model {
|
|
424 |
),
|
425 |
) );
|
426 |
|
427 |
-
$terms =
|
428 |
-
|
429 |
-
|
430 |
-
|
431 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
432 |
|
433 |
/**
|
434 |
* Filter the list of untranslated posts ids and terms ids
|
@@ -446,7 +467,7 @@ class PLL_Admin_Model extends PLL_Model {
|
|
446 |
* @since 0.5
|
447 |
*
|
448 |
* @param string $old_slug the old language slug
|
449 |
-
* @param string $new_slug optional, the new language slug, if not set it means the
|
450 |
*/
|
451 |
public function update_translations( $old_slug, $new_slug = '' ) {
|
452 |
global $wpdb;
|
46 |
// Don't want shared terms so use a different slug
|
47 |
wp_insert_term( $args['name'], 'term_language', array( 'slug' => 'pll_' . $args['slug'] ) );
|
48 |
|
49 |
+
$this->clean_languages_cache(); // Update the languages list now !
|
50 |
|
51 |
if ( ! isset( $this->options['default_lang'] ) ) {
|
52 |
// If this is the first language created, set it as default language
|
402 |
}
|
403 |
|
404 |
/**
|
405 |
+
* Returns untranslated posts and terms ids ( used in settings )
|
406 |
*
|
407 |
* @since 0.9
|
408 |
+
* @since 2.2.6 Add the $limit argument
|
409 |
*
|
410 |
+
* @param in $limit Max number of posts or terms to return. Defaults to -1 (no limit).
|
411 |
+
* @return array Array made of an array of post ids and an array of term ids
|
412 |
*/
|
413 |
+
public function get_objects_with_no_lang( $limit = -1 ) {
|
414 |
+
global $wpdb;
|
415 |
+
|
416 |
+
/**
|
417 |
+
* Filters the max number of posts or terms to return when searching objects with no language
|
418 |
+
* This filter can be used to decrease the memory usage in case the number of objects
|
419 |
+
* without language is too big. Using a negative value is equivalent to have no limit.
|
420 |
+
*
|
421 |
+
* @since 2.2.6
|
422 |
+
*
|
423 |
+
* @param int $limit Max number of posts or terms to retrieve from the database
|
424 |
+
*/
|
425 |
+
$limit = (int) apply_filters( 'get_objects_with_no_lang_limit', $limit );
|
426 |
+
|
427 |
$posts = get_posts( array(
|
428 |
+
'numberposts' => $limit,
|
429 |
+
'nopaging' => $limit <= 0,
|
430 |
'post_type' => $this->get_translated_post_types(),
|
431 |
'post_status' => 'any',
|
432 |
'fields' => 'ids',
|
439 |
),
|
440 |
) );
|
441 |
|
442 |
+
$terms = $wpdb->get_col( sprintf( "
|
443 |
+
SELECT {$wpdb->term_taxonomy}.term_id FROM {$wpdb->term_taxonomy}
|
444 |
+
WHERE taxonomy IN ('%s')
|
445 |
+
AND {$wpdb->term_taxonomy}.term_id NOT IN (
|
446 |
+
SELECT object_id FROM {$wpdb->term_relationships} WHERE term_taxonomy_id IN (%s)
|
447 |
+
)
|
448 |
+
%s",
|
449 |
+
implode( "','", array_map( 'esc_sql', $this->get_translated_taxonomies() ) ),
|
450 |
+
implode( ',', array_map( 'intval', $this->get_languages_list( array( 'fields' => 'tl_term_taxonomy_id' ) ) ) ),
|
451 |
+
$limit > 0 ? "LIMIT {$limit}" : ''
|
452 |
+
) );
|
453 |
|
454 |
/**
|
455 |
* Filter the list of untranslated posts ids and terms ids
|
467 |
* @since 0.5
|
468 |
*
|
469 |
* @param string $old_slug the old language slug
|
470 |
+
* @param string $new_slug optional, the new language slug, if not set it means the correspondent has been deleted
|
471 |
*/
|
472 |
public function update_translations( $old_slug, $new_slug = '' ) {
|
473 |
global $wpdb;
|
admin/admin-static-pages.php
CHANGED
@@ -91,7 +91,7 @@ class PLL_Admin_Static_Pages extends PLL_Static_Pages {
|
|
91 |
}
|
92 |
|
93 |
/**
|
94 |
-
* Checks if a page is
|
95 |
*
|
96 |
* @since 2.2
|
97 |
*
|
91 |
}
|
92 |
|
93 |
/**
|
94 |
+
* Checks if a page is translated in all languages
|
95 |
*
|
96 |
* @since 2.2
|
97 |
*
|
admin/admin.php
CHANGED
@@ -103,7 +103,7 @@ class PLL_Admin extends PLL_Admin_Base {
|
|
103 |
$obj = strtolower( $class );
|
104 |
|
105 |
/**
|
106 |
-
* Filter the class to instantiate when
|
107 |
*
|
108 |
* @since 1.5
|
109 |
*
|
103 |
$obj = strtolower( $class );
|
104 |
|
105 |
/**
|
106 |
+
* Filter the class to instantiate when loading admin filters
|
107 |
*
|
108 |
* @since 1.5
|
109 |
*
|
admin/view-translations-post.php
CHANGED
@@ -39,7 +39,7 @@ if ( ! defined( 'ABSPATH' ) ) {
|
|
39 |
<?php
|
40 |
|
41 |
/**
|
42 |
-
* Fires before the translation
|
43 |
* The dynamic portion of the hook name, `$lang`, refers to the language code
|
44 |
*
|
45 |
* @since 2.1
|
39 |
<?php
|
40 |
|
41 |
/**
|
42 |
+
* Fires before the translation column is outputted in the language metabox
|
43 |
* The dynamic portion of the hook name, `$lang`, refers to the language code
|
44 |
*
|
45 |
* @since 2.1
|
changelog.txt
CHANGED
@@ -60,7 +60,7 @@ This file contains only old changelog. See readme.txt for newer versions.
|
|
60 |
* Pro: Add filter 'pll_enable_duplicate_media' for a fine control of automatic media duplication
|
61 |
* Add filter 'pll_links_model' for the links model class name
|
62 |
* Trim any starting ^ from modified rewrite rules
|
63 |
-
* Pro: Fix wrong count of plugins to
|
64 |
* Fix slashed strings translations not saved #94
|
65 |
|
66 |
= 2.1 (2017-01-25) =
|
@@ -78,7 +78,7 @@ This file contains only old changelog. See readme.txt for newer versions.
|
|
78 |
* Add functions pll_esc_html__(), pll_esc_html_e(), pll_esc_attr__() and pll_esc_attr_e() to the API (Props jegbagus) #83
|
79 |
* Pro: Fix conflict between WooCommerce shop on front and translated shop base slug
|
80 |
* Pro: Fix $wp_rewrite search base and author_base not translated #68
|
81 |
-
* Pro: Fix page preview does not log in the user when using
|
82 |
* Fix: avoid setting the language cookie on 404 pages
|
83 |
* Fix: rewrite rules order modified for custom post types archives
|
84 |
* Fix: conflict with WP All Import causing our filters to fail in "Add Media" modal when editing a post
|
@@ -139,7 +139,7 @@ This file contains only old changelog. See readme.txt for newer versions.
|
|
139 |
* Fix cases where the admin language filter is not correctly taken into account
|
140 |
* Fix paged static front pages in plain permalinks
|
141 |
* Fix paged static front pages for multiple domains (#43)
|
142 |
-
* Fix warning
|
143 |
* Fix cross domain http request for media when using multiple domains or subdomains
|
144 |
* Fix error 404 on pages when no language has been created yet
|
145 |
|
@@ -254,7 +254,7 @@ This file contains only old changelog. See readme.txt for newer versions.
|
|
254 |
|
255 |
* Revert from $_SERVER['PHP_SELF'] to $_SERVER['SCRIPT_FILENAME'] to detect if the user is on login/register/signup page
|
256 |
* Fix incompatibility introduced by WP 4.5 in Edit single taxonomy term screen
|
257 |
-
* Fix existing post
|
258 |
|
259 |
= 1.8.4 (2016-03-06) =
|
260 |
|
@@ -282,7 +282,7 @@ This file contains only old changelog. See readme.txt for newer versions.
|
|
282 |
* fix: secondary query with translated post type and untranslated taxonomy mixes languages (introduced in 1.8)
|
283 |
* fix: issue with paged static front page when hiding the default language in url
|
284 |
* fix: potential issue with cache after synchronizations
|
285 |
-
* fix: trailing slash added to canonical home url
|
286 |
|
287 |
= 1.8 (2016-01-19) =
|
288 |
|
@@ -394,7 +394,7 @@ This file contains only old changelog. See readme.txt for newer versions.
|
|
394 |
* fix: customizer menus issues introduced by changes in WP 4.1
|
395 |
* fix: strings translations are not saved when pressing enter
|
396 |
* fix: it is not possible to de-activate the translation for custom post types and taxonomies from wpml-config.xml
|
397 |
-
* fix: conflict
|
398 |
|
399 |
= 1.7.6 (2015-06-10) =
|
400 |
|
@@ -492,7 +492,7 @@ This file contains only old changelog. See readme.txt for newer versions.
|
|
492 |
|
493 |
= 1.6.5 (2015-02-18) =
|
494 |
|
495 |
-
* Add new
|
496 |
* fix: quick draft posts are always assigned the default category in the default language
|
497 |
* fix: Notice: Undefined offset: 0 in wp-includes/query.php introduced in WP 4.1
|
498 |
* fix: is_tax and is_archive are not correctly set when a custom taxonomy term is queried
|
@@ -548,7 +548,7 @@ This file contains only old changelog. See readme.txt for newer versions.
|
|
548 |
* Add error message if attempting to assign an untranslated page as static front page
|
549 |
* Add 'pll_sanitize_string_translation' filter to sanitize registered strings translations when saved
|
550 |
* Fix: change the en_US flag to US flag. The UK flag is now associated to en_GB
|
551 |
-
* Fix: change
|
552 |
* Fix home pages duplicate urls when using domains or subdomains
|
553 |
* Fix rewrite rules with front
|
554 |
* Fix: terms are always in default language when created from post bulk edit
|
@@ -613,7 +613,7 @@ This file contains only old changelog. See readme.txt for newer versions.
|
|
613 |
|
614 |
* Add Ukrainian translation contributed by [http://getvoip.com/](http://getvoip.com/)
|
615 |
* Refresh translation metaboxes (again): now translated posts are chosen from an autocomplete input field
|
616 |
-
* Categories and post tags translations are also chosen in an
|
617 |
* Better error management on languages pages
|
618 |
* Use Dashicons instead of Icomoon icons for WP 3.8+
|
619 |
* Check if translated post is readable by the current user before displaying the language switcher
|
@@ -685,7 +685,7 @@ This file contains only old changelog. See readme.txt for newer versions.
|
|
685 |
|
686 |
= 1.4 (2014-01-22) =
|
687 |
|
688 |
-
* Add
|
689 |
* Minimum WordPress version is now v3.5
|
690 |
* Refresh translations metaboxes: now translated posts are chosen in a dropdown list
|
691 |
* Check if translated archives for category, tag and post format are empty before displaying the language switcher
|
@@ -734,7 +734,7 @@ This file contains only old changelog. See readme.txt for newer versions.
|
|
734 |
|
735 |
= 1.2.3 (2013-11-17) =
|
736 |
|
737 |
-
* Avoid fatal error when
|
738 |
* Bug correction: menus locations of non default language are lost at theme deactivation
|
739 |
* Bug correction: impossible to set menus locations of non default language in some specific cases
|
740 |
* Bug correction: bbpress admin is broken
|
@@ -824,7 +824,7 @@ This version does include important changes in database. More than ever, make a
|
|
824 |
* Improve html validation
|
825 |
* Add 'raw' argument to 'pll_the_languages'
|
826 |
* Add the filter 'pll_translation_url'
|
827 |
-
* Bug correction: no language is set for a (translated custom taxonomy) term when added from a (non
|
828 |
* Bug correction: warning if 'get_terms' is called with a non-array 'include' argument (introduced in 1.1.1)
|
829 |
* Bug correction: warning if the menu language switcher has nothing to display
|
830 |
|
@@ -906,7 +906,7 @@ This version does include important changes in database. More than ever, make a
|
|
906 |
* Bug correction: notice Undefined index: media_support
|
907 |
* Bug correction: custom post types and taxonomies set in wpml-config.xml are not hidden
|
908 |
* Bug correction: get_terms cannot query multiple languages
|
909 |
-
* Bug correction: 'icl_register_string' is now
|
910 |
|
911 |
= 1.0.1 (2013-01-28) =
|
912 |
|
@@ -1027,7 +1027,7 @@ This version does include important changes in database. More than ever, make a
|
|
1027 |
|
1028 |
* Add Turkish translation contributed by [darchws](http://darch.ws/)
|
1029 |
* Add media translation support
|
1030 |
-
* Add a
|
1031 |
* Add biographical info translation
|
1032 |
* Add multiline support for string translations
|
1033 |
* Add the possibility to clean the strings translation database
|
@@ -1057,7 +1057,7 @@ This version does include important changes in database. More than ever, make a
|
|
1057 |
* Bug correction: empty string translation issue
|
1058 |
* Bug correction: 'wp_list_pages' does not filter custom post types
|
1059 |
* Bug correction: warning if posts are queried before the action 'wp_loaded' has been fired
|
1060 |
-
* Bug correction: notice in twentyten when
|
1061 |
|
1062 |
= 0.8.9 (2012-07-20) =
|
1063 |
|
@@ -1111,7 +1111,7 @@ This version does include important changes in database. More than ever, make a
|
|
1111 |
|
1112 |
* Add Danish translation contributed by [Compute](http://wordpress.org/support/profile/compute)
|
1113 |
* Add Spanish translation contributed by Curro
|
1114 |
-
* Add the possibility to add a content in a different language than the current one by setting
|
1115 |
* Add support of PATHINFO permalinks
|
1116 |
* Bug correction: secondary queries not correctly filtered by language
|
1117 |
* Bug correction: wrong archives links when using permalinks with front
|
@@ -1208,7 +1208,7 @@ This version does include important changes in database. More than ever, make a
|
|
1208 |
|
1209 |
* Add Hebrew translation contributed by [ArielK](http://www.arielk.net)
|
1210 |
* Add support for RTL languages for both frontend and admin
|
1211 |
-
* Twenty Ten and Twenty Eleven languages files are now automatically downloaded when creating a new
|
1212 |
* Improve filtering tags by language in the edit post panel
|
1213 |
* Category parent dropdown list is now filtered by language
|
1214 |
* Category parents are now synchronized between translations
|
@@ -1217,7 +1217,7 @@ This version does include important changes in database. More than ever, make a
|
|
1217 |
* Add option allowing not to show the current language in the language switcher (for both menu and widget)
|
1218 |
* Add a title attribute (and the possibility to personalize it with a filter) to flags
|
1219 |
* pll_get_post and pll_get_term second parameter is now optional and defaults to current language
|
1220 |
-
* Add pll_the_language_link filter allowing to filter translation links
|
1221 |
* The option PLL_DISPLAY_ALL is no longer supported
|
1222 |
* Bug correction: Autosave reset to default language
|
1223 |
* Bug correction: blog info not translated in feeds
|
@@ -1243,7 +1243,7 @@ This version does include important changes in database. More than ever, make a
|
|
1243 |
= 0.6 (2012-01-07) =
|
1244 |
|
1245 |
* Add Greek translation contributed by [theodotos](http://www.ubuntucy.org)
|
1246 |
-
* WordPress languages files are now automatically downloaded when creating a new
|
1247 |
* Add the possibility to change the order of the languages in the language switcher
|
1248 |
* Add the possibility to translate the site title, tagline and widgets titles
|
1249 |
* Categories, post tags, featured image, page parent, page template and menu order are now copied when adding a new translation
|
@@ -1274,7 +1274,7 @@ This version does include important changes in database. More than ever, make a
|
|
1274 |
* The nav menus can now display a language switcher
|
1275 |
* Improved performance
|
1276 |
* Optimized the calendar widget (less code and sql queries executed)
|
1277 |
-
* Added the possibility to display posts and terms with no language set (see the documentation to know how to enable this
|
1278 |
* Started the creation of a small API for theme and plugin programmers
|
1279 |
* Bug correction: when using a static front page, the page for posts does not work when using the default permalink settings
|
1280 |
* Bug correction: the search form does not work if a static front page is used
|
@@ -1312,7 +1312,7 @@ This version does include important changes in database. More than ever, make a
|
|
1312 |
* Add a documentation (in English only)
|
1313 |
* Add the possibility to hide the url language information for the default language
|
1314 |
* Add the possibility to set the admin language in the user profile
|
1315 |
-
* Add the
|
1316 |
* Add support for custom post types and custom taxonomies
|
1317 |
* Add the possibility to display flags in the language switcher
|
1318 |
* Add CSS classes to customize rendering of the language switcher
|
60 |
* Pro: Add filter 'pll_enable_duplicate_media' for a fine control of automatic media duplication
|
61 |
* Add filter 'pll_links_model' for the links model class name
|
62 |
* Trim any starting ^ from modified rewrite rules
|
63 |
+
* Pro: Fix wrong count of plugins to update
|
64 |
* Fix slashed strings translations not saved #94
|
65 |
|
66 |
= 2.1 (2017-01-25) =
|
78 |
* Add functions pll_esc_html__(), pll_esc_html_e(), pll_esc_attr__() and pll_esc_attr_e() to the API (Props jegbagus) #83
|
79 |
* Pro: Fix conflict between WooCommerce shop on front and translated shop base slug
|
80 |
* Pro: Fix $wp_rewrite search base and author_base not translated #68
|
81 |
+
* Pro: Fix page preview does not log in the user when using subdomains
|
82 |
* Fix: avoid setting the language cookie on 404 pages
|
83 |
* Fix: rewrite rules order modified for custom post types archives
|
84 |
* Fix: conflict with WP All Import causing our filters to fail in "Add Media" modal when editing a post
|
139 |
* Fix cases where the admin language filter is not correctly taken into account
|
140 |
* Fix paged static front pages in plain permalinks
|
141 |
* Fix paged static front pages for multiple domains (#43)
|
142 |
+
* Fix warning occurring when a 3rd party plugin attempts to register anything but a string in the strings translations panel
|
143 |
* Fix cross domain http request for media when using multiple domains or subdomains
|
144 |
* Fix error 404 on pages when no language has been created yet
|
145 |
|
254 |
|
255 |
* Revert from $_SERVER['PHP_SELF'] to $_SERVER['SCRIPT_FILENAME'] to detect if the user is on login/register/signup page
|
256 |
* Fix incompatibility introduced by WP 4.5 in Edit single taxonomy term screen
|
257 |
+
* Fix existing post overridden when creating a language and a conflicting plugin sets the global $post on languages pages
|
258 |
|
259 |
= 1.8.4 (2016-03-06) =
|
260 |
|
282 |
* fix: secondary query with translated post type and untranslated taxonomy mixes languages (introduced in 1.8)
|
283 |
* fix: issue with paged static front page when hiding the default language in url
|
284 |
* fix: potential issue with cache after synchronizations
|
285 |
+
* fix: trailing slash added to canonical home url outputted by Yoast SEO when using default permalinks
|
286 |
|
287 |
= 1.8 (2016-01-19) =
|
288 |
|
394 |
* fix: customizer menus issues introduced by changes in WP 4.1
|
395 |
* fix: strings translations are not saved when pressing enter
|
396 |
* fix: it is not possible to de-activate the translation for custom post types and taxonomies from wpml-config.xml
|
397 |
+
* fix: conflict with plugins using stringified json in ajax requests
|
398 |
|
399 |
= 1.7.6 (2015-06-10) =
|
400 |
|
492 |
|
493 |
= 1.6.5 (2015-02-18) =
|
494 |
|
495 |
+
* Add new correspondences between WordPress locales and Facebook locales (for WPSEO and Jetpack users)
|
496 |
* fix: quick draft posts are always assigned the default category in the default language
|
497 |
* fix: Notice: Undefined offset: 0 in wp-includes/query.php introduced in WP 4.1
|
498 |
* fix: is_tax and is_archive are not correctly set when a custom taxonomy term is queried
|
548 |
* Add error message if attempting to assign an untranslated page as static front page
|
549 |
* Add 'pll_sanitize_string_translation' filter to sanitize registered strings translations when saved
|
550 |
* Fix: change the en_US flag to US flag. The UK flag is now associated to en_GB
|
551 |
+
* Fix: change Belarusian locale from be_BY to bel to in agreement with translate.wordpress.org
|
552 |
* Fix home pages duplicate urls when using domains or subdomains
|
553 |
* Fix rewrite rules with front
|
554 |
* Fix: terms are always in default language when created from post bulk edit
|
613 |
|
614 |
* Add Ukrainian translation contributed by [http://getvoip.com/](http://getvoip.com/)
|
615 |
* Refresh translation metaboxes (again): now translated posts are chosen from an autocomplete input field
|
616 |
+
* Categories and post tags translations are also chosen in an autocomplete input field
|
617 |
* Better error management on languages pages
|
618 |
* Use Dashicons instead of Icomoon icons for WP 3.8+
|
619 |
* Check if translated post is readable by the current user before displaying the language switcher
|
685 |
|
686 |
= 1.4 (2014-01-22) =
|
687 |
|
688 |
+
* Add Traditional Chinese translation contributed by [香腸](http://sofree.cc/)
|
689 |
* Minimum WordPress version is now v3.5
|
690 |
* Refresh translations metaboxes: now translated posts are chosen in a dropdown list
|
691 |
* Check if translated archives for category, tag and post format are empty before displaying the language switcher
|
734 |
|
735 |
= 1.2.3 (2013-11-17) =
|
736 |
|
737 |
+
* Avoid fatal error when upgrading with Nextgen Gallery active
|
738 |
* Bug correction: menus locations of non default language are lost at theme deactivation
|
739 |
* Bug correction: impossible to set menus locations of non default language in some specific cases
|
740 |
* Bug correction: bbpress admin is broken
|
824 |
* Improve html validation
|
825 |
* Add 'raw' argument to 'pll_the_languages'
|
826 |
* Add the filter 'pll_translation_url'
|
827 |
+
* Bug correction: no language is set for a (translated custom taxonomy) term when added from a (non translated) custom post type edit page
|
828 |
* Bug correction: warning if 'get_terms' is called with a non-array 'include' argument (introduced in 1.1.1)
|
829 |
* Bug correction: warning if the menu language switcher has nothing to display
|
830 |
|
906 |
* Bug correction: notice Undefined index: media_support
|
907 |
* Bug correction: custom post types and taxonomies set in wpml-config.xml are not hidden
|
908 |
* Bug correction: get_terms cannot query multiple languages
|
909 |
+
* Bug correction: 'icl_register_string' is now persistent as in WPML (fixes Nextgen gallery translations which were not working)
|
910 |
|
911 |
= 1.0.1 (2013-01-28) =
|
912 |
|
1027 |
|
1028 |
* Add Turkish translation contributed by [darchws](http://darch.ws/)
|
1029 |
* Add media translation support
|
1030 |
+
* Add a persistent content language filter on admin side (WP 3.2+ required)
|
1031 |
* Add biographical info translation
|
1032 |
* Add multiline support for string translations
|
1033 |
* Add the possibility to clean the strings translation database
|
1057 |
* Bug correction: empty string translation issue
|
1058 |
* Bug correction: 'wp_list_pages' does not filter custom post types
|
1059 |
* Bug correction: warning if posts are queried before the action 'wp_loaded' has been fired
|
1060 |
+
* Bug correction: notice in twentyten when requesting a date archive with no posts
|
1061 |
|
1062 |
= 0.8.9 (2012-07-20) =
|
1063 |
|
1111 |
|
1112 |
* Add Danish translation contributed by [Compute](http://wordpress.org/support/profile/compute)
|
1113 |
* Add Spanish translation contributed by Curro
|
1114 |
+
* Add the possibility to add a content in a different language than the current one by setting explicitly the lang parameter in the secondary query
|
1115 |
* Add support of PATHINFO permalinks
|
1116 |
* Bug correction: secondary queries not correctly filtered by language
|
1117 |
* Bug correction: wrong archives links when using permalinks with front
|
1208 |
|
1209 |
* Add Hebrew translation contributed by [ArielK](http://www.arielk.net)
|
1210 |
* Add support for RTL languages for both frontend and admin
|
1211 |
+
* Twenty Ten and Twenty Eleven languages files are now automatically downloaded when creating a new language
|
1212 |
* Improve filtering tags by language in the edit post panel
|
1213 |
* Category parent dropdown list is now filtered by language
|
1214 |
* Category parents are now synchronized between translations
|
1217 |
* Add option allowing not to show the current language in the language switcher (for both menu and widget)
|
1218 |
* Add a title attribute (and the possibility to personalize it with a filter) to flags
|
1219 |
* pll_get_post and pll_get_term second parameter is now optional and defaults to current language
|
1220 |
+
* Add pll_the_language_link filter allowing to filter translation links outputted by the language switcher
|
1221 |
* The option PLL_DISPLAY_ALL is no longer supported
|
1222 |
* Bug correction: Autosave reset to default language
|
1223 |
* Bug correction: blog info not translated in feeds
|
1243 |
= 0.6 (2012-01-07) =
|
1244 |
|
1245 |
* Add Greek translation contributed by [theodotos](http://www.ubuntucy.org)
|
1246 |
+
* WordPress languages files are now automatically downloaded when creating a new language (and updated when updating WordPress)
|
1247 |
* Add the possibility to change the order of the languages in the language switcher
|
1248 |
* Add the possibility to translate the site title, tagline and widgets titles
|
1249 |
* Categories, post tags, featured image, page parent, page template and menu order are now copied when adding a new translation
|
1274 |
* The nav menus can now display a language switcher
|
1275 |
* Improved performance
|
1276 |
* Optimized the calendar widget (less code and sql queries executed)
|
1277 |
+
* Added the possibility to display posts and terms with no language set (see the documentation to know how to enable this functionality)
|
1278 |
* Started the creation of a small API for theme and plugin programmers
|
1279 |
* Bug correction: when using a static front page, the page for posts does not work when using the default permalink settings
|
1280 |
* Bug correction: the search form does not work if a static front page is used
|
1312 |
* Add a documentation (in English only)
|
1313 |
* Add the possibility to hide the url language information for the default language
|
1314 |
* Add the possibility to set the admin language in the user profile
|
1315 |
+
* Add the possibility to fill existing posts, pages, categories & tags with the default language
|
1316 |
* Add support for custom post types and custom taxonomies
|
1317 |
* Add the possibility to display flags in the language switcher
|
1318 |
* Add CSS classes to customize rendering of the language switcher
|
css/admin.css
CHANGED
@@ -148,7 +148,7 @@ td[class*='column-language_'] {
|
|
148 |
width: 1.5em;
|
149 |
}
|
150 |
|
151 |
-
/* Text
|
152 |
.pll-dir-rtl textarea,
|
153 |
.pll-dir-rtl input[type="text"] {
|
154 |
direction: rtl;
|
148 |
width: 1.5em;
|
149 |
}
|
150 |
|
151 |
+
/* Text direction in post.php and edit-tags.php */
|
152 |
.pll-dir-rtl textarea,
|
153 |
.pll-dir-rtl input[type="text"] {
|
154 |
direction: rtl;
|
frontend/choose-lang-url.php
CHANGED
@@ -3,12 +3,12 @@
|
|
3 |
/**
|
4 |
* Choose the language when the language code is added to all urls
|
5 |
* The language is set in plugins_loaded with priority 1 as done by WPML
|
6 |
-
* Some actions have to be delayed to wait for $wp_rewrite
|
7 |
*
|
8 |
* @since 1.2
|
9 |
*/
|
10 |
class PLL_Choose_Lang_Url extends PLL_Choose_lang {
|
11 |
-
protected $index = 'index.php'; // need this before $wp_rewrite is created, also
|
12 |
|
13 |
/**
|
14 |
* sets the language
|
@@ -37,7 +37,7 @@ class PLL_Choose_Lang_Url extends PLL_Choose_lang {
|
|
37 |
$requested_host = str_replace( 'www.', '', $_SERVER['HTTP_HOST'] );
|
38 |
$requested_uri = rtrim( str_replace( $this->index, '', $_SERVER['REQUEST_URI'] ), '/' ); // some PHP setups turn requests for / into /index.php in REQUEST_URI
|
39 |
|
40 |
-
// home is
|
41 |
if ( $requested_host == $host && $requested_uri == $home_path && empty( $_SERVER['QUERY_STRING'] ) ) {
|
42 |
$this->home_language();
|
43 |
add_action( 'setup_theme', array( $this, 'home_requested' ) );
|
3 |
/**
|
4 |
* Choose the language when the language code is added to all urls
|
5 |
* The language is set in plugins_loaded with priority 1 as done by WPML
|
6 |
+
* Some actions have to be delayed to wait for $wp_rewrite availability
|
7 |
*
|
8 |
* @since 1.2
|
9 |
*/
|
10 |
class PLL_Choose_Lang_Url extends PLL_Choose_lang {
|
11 |
+
protected $index = 'index.php'; // need this before $wp_rewrite is created, also hardcoded in wp-includes/rewrite.php
|
12 |
|
13 |
/**
|
14 |
* sets the language
|
37 |
$requested_host = str_replace( 'www.', '', $_SERVER['HTTP_HOST'] );
|
38 |
$requested_uri = rtrim( str_replace( $this->index, '', $_SERVER['REQUEST_URI'] ), '/' ); // some PHP setups turn requests for / into /index.php in REQUEST_URI
|
39 |
|
40 |
+
// home is requested
|
41 |
if ( $requested_host == $host && $requested_uri == $home_path && empty( $_SERVER['QUERY_STRING'] ) ) {
|
42 |
$this->home_language();
|
43 |
add_action( 'setup_theme', array( $this, 'home_requested' ) );
|
frontend/choose-lang.php
CHANGED
@@ -211,7 +211,7 @@ abstract class PLL_Choose_Lang {
|
|
211 |
}
|
212 |
|
213 |
/**
|
214 |
-
* sets the language when home page is
|
215 |
*
|
216 |
* @since 1.2
|
217 |
*/
|
@@ -271,7 +271,7 @@ abstract class PLL_Choose_Lang {
|
|
271 |
*
|
272 |
* @since 0.8.4
|
273 |
*
|
274 |
-
* @param int $post_id the post
|
275 |
*/
|
276 |
public function pre_comment_on_post( $post_id ) {
|
277 |
$this->set_language( $this->model->post->get_language( $post_id ) );
|
211 |
}
|
212 |
|
213 |
/**
|
214 |
+
* sets the language when home page is requested
|
215 |
*
|
216 |
* @since 1.2
|
217 |
*/
|
271 |
*
|
272 |
* @since 0.8.4
|
273 |
*
|
274 |
+
* @param int $post_id the post being commented
|
275 |
*/
|
276 |
public function pre_comment_on_post( $post_id ) {
|
277 |
$this->set_language( $this->model->post->get_language( $post_id ) );
|
frontend/frontend-auto-translate.php
CHANGED
@@ -163,9 +163,14 @@ class PLL_Frontend_Auto_Translate {
|
|
163 |
}
|
164 |
|
165 |
if ( ! empty( $post_types ) ) {
|
166 |
-
//
|
167 |
-
$
|
168 |
-
|
|
|
|
|
|
|
|
|
|
|
169 |
$qv['name'] = ( $id && ( $tr_id = $this->get_post( $id ) ) && $tr = get_post( $tr_id ) ) ? $tr->post_name : $qv['name'];
|
170 |
}
|
171 |
}
|
163 |
}
|
164 |
|
165 |
if ( ! empty( $post_types ) ) {
|
166 |
+
// No function to get post by name except get_posts itself
|
167 |
+
$id = $wpdb->get_var( sprintf( "
|
168 |
+
SELECT ID from {$wpdb->posts}
|
169 |
+
WHERE {$wpdb->posts}.post_type IN ( '%s' )
|
170 |
+
AND post_name='%s'",
|
171 |
+
implode( "', '", esc_sql( $post_types ) ),
|
172 |
+
esc_sql( $qv['name'] )
|
173 |
+
) );
|
174 |
$qv['name'] = ( $id && ( $tr_id = $this->get_post( $id ) ) && $tr = get_post( $tr_id ) ) ? $tr->post_name : $qv['name'];
|
175 |
}
|
176 |
}
|
frontend/frontend-filters-links.php
CHANGED
@@ -166,7 +166,7 @@ class PLL_Frontend_Filters_Links extends PLL_Filters_Links {
|
|
166 |
}
|
167 |
}
|
168 |
|
169 |
-
//
|
170 |
if ( ! empty( $urls ) && count( $urls ) > 1 ) {
|
171 |
|
172 |
// Prepare the list of languages to remove the country code
|
@@ -360,7 +360,7 @@ class PLL_Frontend_Filters_Links extends PLL_Filters_Links {
|
|
360 |
$redirect_url = $requested_url;
|
361 |
} else {
|
362 |
// First get the canonical url evaluated by WP
|
363 |
-
// Workaround a WP bug
|
364 |
$_redirect_url = ( ! $_redirect_url = redirect_canonical( $requested_url, false ) ) ? $requested_url : $_redirect_url;
|
365 |
$redirect_url = ( ! $redirect_url = redirect_canonical( $_redirect_url, false ) ) ? $_redirect_url : $redirect_url;
|
366 |
|
166 |
}
|
167 |
}
|
168 |
|
169 |
+
// Outputs the section only if there are translations ( $urls always contains self link )
|
170 |
if ( ! empty( $urls ) && count( $urls ) > 1 ) {
|
171 |
|
172 |
// Prepare the list of languages to remove the country code
|
360 |
$redirect_url = $requested_url;
|
361 |
} else {
|
362 |
// First get the canonical url evaluated by WP
|
363 |
+
// Workaround a WP bug which removes the port for some urls and get it back at second call to redirect_canonical
|
364 |
$_redirect_url = ( ! $_redirect_url = redirect_canonical( $requested_url, false ) ) ? $requested_url : $_redirect_url;
|
365 |
$redirect_url = ( ! $redirect_url = redirect_canonical( $_redirect_url, false ) ) ? $_redirect_url : $redirect_url;
|
366 |
|
frontend/frontend-filters-search.php
CHANGED
@@ -100,7 +100,7 @@ class PLL_Frontend_Filters_Search {
|
|
100 |
public function wp_print_footer_scripts() {
|
101 |
// don't use directly e[0] just in case there is somewhere else an element named 's'
|
102 |
// check before if the hidden input has not already been introduced by get_search_form ( FIXME: is there a way to improve this ) ?
|
103 |
-
// thanks to AndyDeGroo for improving the code for
|
104 |
// http://wordpress.org/support/topic/development-of-polylang-version-08?replies=6#post-2645559
|
105 |
$lang = esc_js( $this->curlang->slug );
|
106 |
$js = "//<![CDATA[
|
100 |
public function wp_print_footer_scripts() {
|
101 |
// don't use directly e[0] just in case there is somewhere else an element named 's'
|
102 |
// check before if the hidden input has not already been introduced by get_search_form ( FIXME: is there a way to improve this ) ?
|
103 |
+
// thanks to AndyDeGroo for improving the code for compatibility with old browsers
|
104 |
// http://wordpress.org/support/topic/development-of-polylang-version-08?replies=6#post-2645559
|
105 |
$lang = esc_js( $this->curlang->slug );
|
106 |
$js = "//<![CDATA[
|
frontend/frontend-filters.php
CHANGED
@@ -68,6 +68,11 @@ class PLL_Frontend_Filters extends PLL_Filters {
|
|
68 |
add_filter( 'pre_option_blogname', 'pll__', 20 );
|
69 |
add_filter( 'pre_option_blogdescription', 'pll__', 20 );
|
70 |
}
|
|
|
|
|
|
|
|
|
|
|
71 |
}
|
72 |
|
73 |
/**
|
@@ -294,31 +299,17 @@ class PLL_Frontend_Filters extends PLL_Filters {
|
|
294 |
|
295 |
/**
|
296 |
* Translates biography
|
297 |
-
* Makes sure that the correct locale is used for ajax calls when the user is logged in
|
298 |
*
|
299 |
* @since 0.9
|
300 |
*
|
301 |
-
* @param null $
|
302 |
* @param int $id User id
|
303 |
* @param string $meta_key
|
304 |
* @param bool $single Whether to return only the first value of the specified $meta_key
|
305 |
* @return null|string
|
306 |
*/
|
307 |
-
public function get_user_metadata( $
|
308 |
-
|
309 |
-
case 'description':
|
310 |
-
if ( $this->curlang->slug !== $this->options['default_lang'] ) {
|
311 |
-
$return = get_user_meta( $id, 'description_' . $this->curlang->slug, $single );
|
312 |
-
}
|
313 |
-
break;
|
314 |
-
case 'locale':
|
315 |
-
if ( Polylang::is_ajax_on_front() ) {
|
316 |
-
$return = get_locale();
|
317 |
-
}
|
318 |
-
break;
|
319 |
-
}
|
320 |
-
|
321 |
-
return $return;
|
322 |
}
|
323 |
|
324 |
/**
|
@@ -378,4 +369,18 @@ class PLL_Frontend_Filters extends PLL_Filters {
|
|
378 |
}
|
379 |
}
|
380 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
381 |
}
|
68 |
add_filter( 'pre_option_blogname', 'pll__', 20 );
|
69 |
add_filter( 'pre_option_blogdescription', 'pll__', 20 );
|
70 |
}
|
71 |
+
|
72 |
+
// FIXME test get_user_locale for backward compatibility with WP < 4.7
|
73 |
+
if ( Polylang::is_ajax_on_front() && function_exists( 'get_user_locale' ) ) {
|
74 |
+
add_filter( 'load_textdomain_mofile', array( $this, 'load_textdomain_mofile' ) );
|
75 |
+
}
|
76 |
}
|
77 |
|
78 |
/**
|
299 |
|
300 |
/**
|
301 |
* Translates biography
|
|
|
302 |
*
|
303 |
* @since 0.9
|
304 |
*
|
305 |
+
* @param null $null
|
306 |
* @param int $id User id
|
307 |
* @param string $meta_key
|
308 |
* @param bool $single Whether to return only the first value of the specified $meta_key
|
309 |
* @return null|string
|
310 |
*/
|
311 |
+
public function get_user_metadata( $null, $id, $meta_key, $single ) {
|
312 |
+
return 'description' === $meta_key && $this->curlang->slug !== $this->options['default_lang'] ? get_user_meta( $id, 'description_' . $this->curlang->slug, $single ) : $null;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
313 |
}
|
314 |
|
315 |
/**
|
369 |
}
|
370 |
}
|
371 |
}
|
372 |
+
|
373 |
+
/**
|
374 |
+
* Filters the translation files to load when doing ajax on front
|
375 |
+
* This is needed because WP the language files associated to the user locale when a user is logged in
|
376 |
+
*
|
377 |
+
* @since 2.2.6
|
378 |
+
*
|
379 |
+
* @param string $mofile Translation file name
|
380 |
+
* @return string
|
381 |
+
*/
|
382 |
+
public function load_textdomain_mofile( $mofile ) {
|
383 |
+
$user_locale = get_user_locale();
|
384 |
+
return str_replace( "{$user_locale}.mo", "{$this->curlang->locale}.mo", $mofile );
|
385 |
+
}
|
386 |
}
|
frontend/frontend-nav-menu.php
CHANGED
@@ -49,6 +49,29 @@ class PLL_Frontend_Nav_Menu extends PLL_Nav_Menu {
|
|
49 |
return ( $a->menu_order < $b->menu_order ) ? -1 : 1;
|
50 |
}
|
51 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
52 |
/**
|
53 |
* Splits the one item of backend in several items on frontend
|
54 |
* take care to menu_order as it is used later in wp_nav_menu
|
@@ -79,7 +102,7 @@ class PLL_Frontend_Nav_Menu extends PLL_Nav_Menu {
|
|
79 |
|
80 |
// parent item for dropdown
|
81 |
if ( ! empty( $options['dropdown'] ) ) {
|
82 |
-
$item->title = $
|
83 |
$item->attr_title = '';
|
84 |
$item->classes = array( 'pll-parent-menu-item' );
|
85 |
$new_items[] = $item;
|
@@ -89,7 +112,7 @@ class PLL_Frontend_Nav_Menu extends PLL_Nav_Menu {
|
|
89 |
foreach ( $the_languages as $lang ) {
|
90 |
$lang_item = clone $item;
|
91 |
$lang_item->ID = $lang_item->ID . '-' . $lang['slug']; // A unique ID
|
92 |
-
$lang_item->title = $
|
93 |
$lang_item->attr_title = '';
|
94 |
$lang_item->url = $lang['url'];
|
95 |
$lang_item->lang = $lang['locale']; // Save this for use in nav_menu_link_attributes
|
49 |
return ( $a->menu_order < $b->menu_order ) ? -1 : 1;
|
50 |
}
|
51 |
|
52 |
+
/**
|
53 |
+
* Format a language switcher menu item title based on options
|
54 |
+
*
|
55 |
+
* @since 2.2.6
|
56 |
+
*
|
57 |
+
* @param string $flag Formatted flag
|
58 |
+
* @param string $name Language name
|
59 |
+
* @param array $options Language switcher options
|
60 |
+
* @return string Formatted menu item title
|
61 |
+
*/
|
62 |
+
protected function get_item_title( $flag, $name, $options ) {
|
63 |
+
if ( $options['show_flags'] ) {
|
64 |
+
if ( $options['show_names'] ) {
|
65 |
+
$title = sprintf( '%1$s<span style="margin-%2$s:0.3em;">%3$s</span>', $flag, is_rtl() ? 'right' : 'left', esc_html( $name ) );
|
66 |
+
} else {
|
67 |
+
$title = $flag;
|
68 |
+
}
|
69 |
+
} else {
|
70 |
+
$title = esc_html( $name );
|
71 |
+
}
|
72 |
+
return $title;
|
73 |
+
}
|
74 |
+
|
75 |
/**
|
76 |
* Splits the one item of backend in several items on frontend
|
77 |
* take care to menu_order as it is used later in wp_nav_menu
|
102 |
|
103 |
// parent item for dropdown
|
104 |
if ( ! empty( $options['dropdown'] ) ) {
|
105 |
+
$item->title = $this->get_item_title( $this->curlang->flag, $this->curlang->name, $options );
|
106 |
$item->attr_title = '';
|
107 |
$item->classes = array( 'pll-parent-menu-item' );
|
108 |
$new_items[] = $item;
|
112 |
foreach ( $the_languages as $lang ) {
|
113 |
$lang_item = clone $item;
|
114 |
$lang_item->ID = $lang_item->ID . '-' . $lang['slug']; // A unique ID
|
115 |
+
$lang_item->title = $this->get_item_title( $lang['flag'], $lang['name'], $options );
|
116 |
$lang_item->attr_title = '';
|
117 |
$lang_item->url = $lang['url'];
|
118 |
$lang_item->lang = $lang['locale']; // Save this for use in nav_menu_link_attributes
|
include/api.php
CHANGED
@@ -106,7 +106,7 @@ function pll_home_url( $lang = '' ) {
|
|
106 |
* @param string $name a unique name for the string
|
107 |
* @param string $string the string to register
|
108 |
* @param string $context optional the group in which the string is registered, defaults to 'polylang'
|
109 |
-
* @param bool $multiline optional
|
110 |
*/
|
111 |
function pll_register_string( $name, $string, $context = 'polylang', $multiline = false ) {
|
112 |
if ( PLL() instanceof PLL_Admin_Base ) {
|
106 |
* @param string $name a unique name for the string
|
107 |
* @param string $string the string to register
|
108 |
* @param string $context optional the group in which the string is registered, defaults to 'polylang'
|
109 |
+
* @param bool $multiline optional whether the string table should display a multiline textarea or a single line input, defaults to single line
|
110 |
*/
|
111 |
function pll_register_string( $name, $string, $context = 'polylang', $multiline = false ) {
|
112 |
if ( PLL() instanceof PLL_Admin_Base ) {
|
include/class-polylang.php
CHANGED
@@ -106,7 +106,7 @@ class Polylang {
|
|
106 |
|
107 |
/**
|
108 |
* Defines constants
|
109 |
-
* May be
|
110 |
*
|
111 |
* @since 1.6
|
112 |
*/
|
@@ -123,7 +123,7 @@ class Polylang {
|
|
123 |
|
124 |
// Admin
|
125 |
if ( ! defined( 'PLL_ADMIN' ) ) {
|
126 |
-
define( 'PLL_ADMIN', defined( 'DOING_CRON' ) || ( is_admin() && ! PLL_AJAX_ON_FRONT ) );
|
127 |
}
|
128 |
|
129 |
// Settings page whatever the tab
|
@@ -181,7 +181,7 @@ class Polylang {
|
|
181 |
if ( ! $model->get_languages_list() ) {
|
182 |
/**
|
183 |
* Fires when no language has been defined yet
|
184 |
-
* Used to load
|
185 |
*
|
186 |
* @since 1.2
|
187 |
*/
|
106 |
|
107 |
/**
|
108 |
* Defines constants
|
109 |
+
* May be overridden by a plugin if set before plugins_loaded, 1
|
110 |
*
|
111 |
* @since 1.6
|
112 |
*/
|
123 |
|
124 |
// Admin
|
125 |
if ( ! defined( 'PLL_ADMIN' ) ) {
|
126 |
+
define( 'PLL_ADMIN', defined( 'DOING_CRON' ) || ( defined( 'WP_CLI' ) && WP_CLI ) || ( is_admin() && ! PLL_AJAX_ON_FRONT ) );
|
127 |
}
|
128 |
|
129 |
// Settings page whatever the tab
|
181 |
if ( ! $model->get_languages_list() ) {
|
182 |
/**
|
183 |
* Fires when no language has been defined yet
|
184 |
+
* Used to load overridden textdomains
|
185 |
*
|
186 |
* @since 1.2
|
187 |
*/
|
include/links-abstract-domain.php
CHANGED
@@ -24,6 +24,21 @@ abstract class PLL_Links_Abstract_Domain extends PLL_Links_Permalinks {
|
|
24 |
add_filter( 'upload_dir', array( $this, 'upload_dir' ) );
|
25 |
}
|
26 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
27 |
/**
|
28 |
* Sets the home urls
|
29 |
*
|
24 |
add_filter( 'upload_dir', array( $this, 'upload_dir' ) );
|
25 |
}
|
26 |
|
27 |
+
/**
|
28 |
+
* Returns the language based on language code in url
|
29 |
+
* links_model interface
|
30 |
+
*
|
31 |
+
* @since 1.2
|
32 |
+
* @since 2.0 add $url argument
|
33 |
+
*
|
34 |
+
* @param string $url optional, defaults to current url
|
35 |
+
* @return string language slug
|
36 |
+
*/
|
37 |
+
public function get_language_from_url( $url = '' ) {
|
38 |
+
$host = empty( $url ) ? $_SERVER['HTTP_HOST'] : parse_url( $url, PHP_URL_HOST );
|
39 |
+
return ( $lang = array_search( $host, $this->get_hosts() ) ) ? $lang : '';
|
40 |
+
}
|
41 |
+
|
42 |
/**
|
43 |
* Sets the home urls
|
44 |
*
|
include/links-directory.php
CHANGED
@@ -126,7 +126,7 @@ class PLL_Links_Directory extends PLL_Links_Permalinks {
|
|
126 |
}
|
127 |
|
128 |
/**
|
129 |
-
*
|
130 |
*
|
131 |
* @since 1.2
|
132 |
*/
|
126 |
}
|
127 |
|
128 |
/**
|
129 |
+
* Optionally removes 'language' in permalinks so that we get http://www.myblog/en/ instead of http://www.myblog/language/en/
|
130 |
*
|
131 |
* @since 1.2
|
132 |
*/
|
include/links-domain.php
CHANGED
@@ -59,21 +59,6 @@ class PLL_Links_Domain extends PLL_Links_Abstract_Domain {
|
|
59 |
return $url;
|
60 |
}
|
61 |
|
62 |
-
/**
|
63 |
-
* Returns the language based on language code in url
|
64 |
-
* links_model interface
|
65 |
-
*
|
66 |
-
* @since 1.2
|
67 |
-
* @since 2.0 add $url argument
|
68 |
-
*
|
69 |
-
* @param string $url optional, defaults to current url
|
70 |
-
* @return string language slug
|
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 |
/**
|
78 |
* Returns the home url
|
79 |
* links_model interface
|
59 |
return $url;
|
60 |
}
|
61 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
62 |
/**
|
63 |
* Returns the home url
|
64 |
* links_model interface
|
include/links-permalinks.php
CHANGED
@@ -7,7 +7,7 @@
|
|
7 |
*/
|
8 |
abstract class PLL_Links_Permalinks extends PLL_Links_Model {
|
9 |
public $using_permalinks = true;
|
10 |
-
protected $index = 'index.php'; // Need this before $wp_rewrite is created, also
|
11 |
protected $root, $use_trailing_slashes;
|
12 |
protected $always_rewrite = array( 'date', 'root', 'comments', 'search', 'author' );
|
13 |
|
@@ -42,7 +42,7 @@ abstract class PLL_Links_Permalinks extends PLL_Links_Model {
|
|
42 |
* @since 2.0.6
|
43 |
*
|
44 |
* @param string $modified_url The link to the first page
|
45 |
-
* @param string $
|
46 |
*/
|
47 |
return apply_filters( 'pll_remove_paged_from_link', preg_replace( '#\/page\/[0-9]+\/?#', $this->use_trailing_slashes ? '/' : '', $url ), $url );
|
48 |
}
|
@@ -63,7 +63,7 @@ abstract class PLL_Links_Permalinks extends PLL_Links_Model {
|
|
63 |
* @since 2.0.6
|
64 |
*
|
65 |
* @param string $modified_url The link to the paged page
|
66 |
-
* @param string $
|
67 |
* @param int $page The page number
|
68 |
*/
|
69 |
return apply_filters( 'pll_add_paged_to_link', user_trailingslashit( trailingslashit( $url ) . 'page/' . $page, 'paged' ), $url, $page );
|
7 |
*/
|
8 |
abstract class PLL_Links_Permalinks extends PLL_Links_Model {
|
9 |
public $using_permalinks = true;
|
10 |
+
protected $index = 'index.php'; // Need this before $wp_rewrite is created, also hardcoded in wp-includes/rewrite.php
|
11 |
protected $root, $use_trailing_slashes;
|
12 |
protected $always_rewrite = array( 'date', 'root', 'comments', 'search', 'author' );
|
13 |
|
42 |
* @since 2.0.6
|
43 |
*
|
44 |
* @param string $modified_url The link to the first page
|
45 |
+
* @param string $original_url The link to the original paged page
|
46 |
*/
|
47 |
return apply_filters( 'pll_remove_paged_from_link', preg_replace( '#\/page\/[0-9]+\/?#', $this->use_trailing_slashes ? '/' : '', $url ), $url );
|
48 |
}
|
63 |
* @since 2.0.6
|
64 |
*
|
65 |
* @param string $modified_url The link to the paged page
|
66 |
+
* @param string $original_url The link to the original first page
|
67 |
* @param int $page The page number
|
68 |
*/
|
69 |
return apply_filters( 'pll_add_paged_to_link', user_trailingslashit( trailingslashit( $url ) . 'page/' . $page, 'paged' ), $url, $page );
|
include/links-subdomain.php
CHANGED
@@ -62,22 +62,6 @@ class PLL_Links_Subdomain extends PLL_Links_Abstract_Domain {
|
|
62 |
return $url;
|
63 |
}
|
64 |
|
65 |
-
/**
|
66 |
-
* Returns the language based on language code in url
|
67 |
-
* links_model interface
|
68 |
-
*
|
69 |
-
* @since 1.2
|
70 |
-
* @since 2.0 add $url argument
|
71 |
-
*
|
72 |
-
* @param string $url optional, defaults to current url
|
73 |
-
* @return string language slug
|
74 |
-
*/
|
75 |
-
public function get_language_from_url( $url = '' ) {
|
76 |
-
$host = empty( $url ) ? $_SERVER['HTTP_HOST'] : parse_url( $url, PHP_URL_HOST );
|
77 |
-
$pattern = '#(' . implode( '|', $this->model->get_languages_list( array( 'fields' => 'slug' ) ) ) . ')\.#';
|
78 |
-
return preg_match( $pattern, trailingslashit( $host ), $matches ) ? $matches[1] : ''; // $matches[1] is the slug of the requested language
|
79 |
-
}
|
80 |
-
|
81 |
/**
|
82 |
* Get hosts managed on the website
|
83 |
*
|
@@ -88,7 +72,7 @@ class PLL_Links_Subdomain extends PLL_Links_Abstract_Domain {
|
|
88 |
public function get_hosts() {
|
89 |
$hosts = array();
|
90 |
foreach ( $this->model->get_languages_list() as $lang ) {
|
91 |
-
$hosts[] = parse_url( $this->home_url( $lang ), PHP_URL_HOST );
|
92 |
}
|
93 |
return $hosts;
|
94 |
}
|
62 |
return $url;
|
63 |
}
|
64 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
65 |
/**
|
66 |
* Get hosts managed on the website
|
67 |
*
|
72 |
public function get_hosts() {
|
73 |
$hosts = array();
|
74 |
foreach ( $this->model->get_languages_list() as $lang ) {
|
75 |
+
$hosts[ $lang->slug ] = parse_url( $this->home_url( $lang ), PHP_URL_HOST );
|
76 |
}
|
77 |
return $hosts;
|
78 |
}
|
include/links.php
CHANGED
@@ -27,7 +27,7 @@ class PLL_Links {
|
|
27 |
* @since 1.3
|
28 |
*
|
29 |
* @param object|string $language
|
30 |
-
* @param bool $is_search optional
|
31 |
*/
|
32 |
public function get_home_url( $language, $is_search = false ) {
|
33 |
$language = is_object( $language ) ? $language : $this->model->get_language( $language );
|
27 |
* @since 1.3
|
28 |
*
|
29 |
* @param object|string $language
|
30 |
+
* @param bool $is_search optional whether we need the home url for a search form, defaults to false
|
31 |
*/
|
32 |
public function get_home_url( $language, $is_search = false ) {
|
33 |
$language = is_object( $language ) ? $language : $this->model->get_language( $language );
|
include/model.php
CHANGED
@@ -179,7 +179,7 @@ class PLL_Model {
|
|
179 |
*
|
180 |
* @param array $clauses the list of sql clauses in terms query
|
181 |
* @param object $lang PLL_Language object
|
182 |
-
* @return array
|
183 |
*/
|
184 |
public function terms_clauses( $clauses, $lang ) {
|
185 |
if ( ! empty( $lang ) && false === strpos( $clauses['join'], 'pll_tr' ) ) {
|
@@ -250,7 +250,7 @@ class PLL_Model {
|
|
250 |
*
|
251 |
* @since 1.2
|
252 |
*
|
253 |
-
* @param bool $filter true if we should return only valid registered
|
254 |
* @return array array of registered taxonomy names for which Polylang manages languages and translations
|
255 |
*/
|
256 |
public function get_translated_taxonomies( $filter = true ) {
|
@@ -459,7 +459,7 @@ class PLL_Model {
|
|
459 |
$select = "SELECT pll_tr.term_taxonomy_id, COUNT( * ) AS num_posts FROM {$wpdb->posts}";
|
460 |
$join = $this->post->join_clause();
|
461 |
$where = " WHERE post_status = 'publish'";
|
462 |
-
$where .=
|
463 |
$where .= $this->post->where_clause( $this->get_languages_list() );
|
464 |
$groupby = ' GROUP BY pll_tr.term_taxonomy_id';
|
465 |
|
179 |
*
|
180 |
* @param array $clauses the list of sql clauses in terms query
|
181 |
* @param object $lang PLL_Language object
|
182 |
+
* @return array modified list of clauses
|
183 |
*/
|
184 |
public function terms_clauses( $clauses, $lang ) {
|
185 |
if ( ! empty( $lang ) && false === strpos( $clauses['join'], 'pll_tr' ) ) {
|
250 |
*
|
251 |
* @since 1.2
|
252 |
*
|
253 |
+
* @param bool $filter true if we should return only valid registered taxonomies
|
254 |
* @return array array of registered taxonomy names for which Polylang manages languages and translations
|
255 |
*/
|
256 |
public function get_translated_taxonomies( $filter = true ) {
|
459 |
$select = "SELECT pll_tr.term_taxonomy_id, COUNT( * ) AS num_posts FROM {$wpdb->posts}";
|
460 |
$join = $this->post->join_clause();
|
461 |
$where = " WHERE post_status = 'publish'";
|
462 |
+
$where .= sprintf( " AND {$wpdb->posts}.post_type IN ( '%s' )", join( "', '", esc_sql( $q['post_type'] ) ) );
|
463 |
$where .= $this->post->where_clause( $this->get_languages_list() );
|
464 |
$groupby = ' GROUP BY pll_tr.term_taxonomy_id';
|
465 |
|
include/nav-menu.php
CHANGED
@@ -60,7 +60,7 @@ class PLL_Nav_Menu {
|
|
60 |
}
|
61 |
|
62 |
/**
|
63 |
-
* get nav menu locations and language from a temporary
|
64 |
*
|
65 |
* @since 1.8
|
66 |
*
|
60 |
}
|
61 |
|
62 |
/**
|
63 |
+
* get nav menu locations and language from a temporary location
|
64 |
*
|
65 |
* @since 1.8
|
66 |
*
|
include/olt-manager.php
CHANGED
@@ -27,7 +27,7 @@ class PLL_OLT_Manager {
|
|
27 |
|
28 |
// Overriding load text domain only on front since WP 4.7
|
29 |
// FIXME test get_user_locale for backward compatibility with WP < 4.7
|
30 |
-
if ( is_admin() &&
|
31 |
return;
|
32 |
}
|
33 |
|
@@ -39,9 +39,11 @@ class PLL_OLT_Manager {
|
|
39 |
add_filter( 'gettext', array( $this, 'gettext' ), 10, 3 );
|
40 |
add_filter( 'gettext_with_context', array( $this, 'gettext_with_context' ), 10, 4 );
|
41 |
|
42 |
-
|
43 |
-
|
44 |
-
|
|
|
|
|
45 |
}
|
46 |
|
47 |
/**
|
@@ -72,11 +74,11 @@ class PLL_OLT_Manager {
|
|
72 |
$new_locale = get_locale();
|
73 |
|
74 |
// Don't try to save time for en_US as some users have theme written in another language
|
75 |
-
// Now we can load all
|
76 |
if ( ! empty( $this->list_textdomains ) ) {
|
77 |
|
78 |
// Since WP 4.7 we need to reset the internal cache of _get_path_to_translation when switching from any locale to en_US
|
79 |
-
// See WP_Locale_Switcher::
|
80 |
// FIXME test _get_path_to_translation for backward compatibility with WP < 4.7
|
81 |
if ( function_exists( '_get_path_to_translation' ) ) {
|
82 |
_get_path_to_translation( null, true );
|
27 |
|
28 |
// Overriding load text domain only on front since WP 4.7
|
29 |
// FIXME test get_user_locale for backward compatibility with WP < 4.7
|
30 |
+
if ( is_admin() && function_exists( 'get_user_locale' ) ) {
|
31 |
return;
|
32 |
}
|
33 |
|
39 |
add_filter( 'gettext', array( $this, 'gettext' ), 10, 3 );
|
40 |
add_filter( 'gettext_with_context', array( $this, 'gettext_with_context' ), 10, 4 );
|
41 |
|
42 |
+
if ( ! Polylang::is_ajax_on_front() ) {
|
43 |
+
// Loads text domains
|
44 |
+
add_action( 'pll_language_defined', array( $this, 'load_textdomains' ), 2 ); // After PLL_Frontend::pll_language_defined
|
45 |
+
add_action( 'pll_no_language_defined', array( $this, 'load_textdomains' ) );
|
46 |
+
}
|
47 |
}
|
48 |
|
49 |
/**
|
74 |
$new_locale = get_locale();
|
75 |
|
76 |
// Don't try to save time for en_US as some users have theme written in another language
|
77 |
+
// Now we can load all overridden text domains with the right language
|
78 |
if ( ! empty( $this->list_textdomains ) ) {
|
79 |
|
80 |
// Since WP 4.7 we need to reset the internal cache of _get_path_to_translation when switching from any locale to en_US
|
81 |
+
// See WP_Locale_Switcher::change_locale()
|
82 |
// FIXME test _get_path_to_translation for backward compatibility with WP < 4.7
|
83 |
if ( function_exists( '_get_path_to_translation' ) ) {
|
84 |
_get_path_to_translation( null, true );
|
include/switcher.php
CHANGED
@@ -15,7 +15,7 @@ class PLL_Switcher {
|
|
15 |
*
|
16 |
* @param string $type optional either 'menu' or 'widget', defaults to 'widget'
|
17 |
* @param string $key optional either 'string' or 'default', defaults to 'string'
|
18 |
-
* @return array list of switcher options
|
19 |
*/
|
20 |
static public function get_switcher_options( $type = 'widget', $key = 'string' ) {
|
21 |
$options = array(
|
@@ -182,7 +182,7 @@ class PLL_Switcher {
|
|
182 |
*
|
183 |
* @since 0.8
|
184 |
*
|
185 |
-
* @param string $html html returned/
|
186 |
* @param array $args arguments passed to the template tag
|
187 |
*/
|
188 |
$out = apply_filters( 'pll_the_languages', $walker->walk( $elements, $args ), $args );
|
15 |
*
|
16 |
* @param string $type optional either 'menu' or 'widget', defaults to 'widget'
|
17 |
* @param string $key optional either 'string' or 'default', defaults to 'string'
|
18 |
+
* @return array list of switcher options strings or default values
|
19 |
*/
|
20 |
static public function get_switcher_options( $type = 'widget', $key = 'string' ) {
|
21 |
$options = array(
|
182 |
*
|
183 |
* @since 0.8
|
184 |
*
|
185 |
+
* @param string $html html returned/outputted by the template tag
|
186 |
* @param array $args arguments passed to the template tag
|
187 |
*/
|
188 |
$out = apply_filters( 'pll_the_languages', $walker->walk( $elements, $args ), $args );
|
include/translated-object.php
CHANGED
@@ -71,7 +71,7 @@ abstract class PLL_Translated_Object {
|
|
71 |
}
|
72 |
|
73 |
/**
|
74 |
-
* Tells
|
75 |
*
|
76 |
* @since 1.8
|
77 |
*
|
@@ -176,7 +176,7 @@ abstract class PLL_Translated_Object {
|
|
176 |
$term = $this->get_object_term( $id, $this->tax_translations );
|
177 |
$translations = empty( $term ) ? array() : unserialize( $term->description );
|
178 |
|
179 |
-
// make sure we return only translations ( thus we allow plugins to store other
|
180 |
if ( is_array( $translations ) ) {
|
181 |
$translations = array_intersect_key( $translations, array_flip( $this->model->get_languages_list( array( 'fields' => 'slug' ) ) ) );
|
182 |
}
|
@@ -232,7 +232,7 @@ abstract class PLL_Translated_Object {
|
|
232 |
*
|
233 |
* @since 1.2
|
234 |
*
|
235 |
-
* @param object|array|string $lang a PLL_Language object or a comma separated list of
|
236 |
* @return string where clause
|
237 |
*/
|
238 |
public function where_clause( $lang ) {
|
@@ -242,14 +242,14 @@ abstract class PLL_Translated_Object {
|
|
242 |
// $lang is an object
|
243 |
// generally the case if the query is coming from Polylang
|
244 |
if ( is_object( $lang ) ) {
|
245 |
-
return
|
246 |
}
|
247 |
|
248 |
// $lang is a comma separated list of slugs ( or an array of slugs )
|
249 |
// generally the case is the query is coming from outside with 'lang' parameter
|
250 |
$slugs = is_array( $lang ) ? $lang : explode( ',', $lang );
|
251 |
foreach ( $slugs as $slug ) {
|
252 |
-
$languages[] = (
|
253 |
}
|
254 |
|
255 |
return ' AND pll_tr.term_taxonomy_id IN ( ' . implode( ',', $languages ) . ' )';
|
71 |
}
|
72 |
|
73 |
/**
|
74 |
+
* Tells whether to store a translation term
|
75 |
*
|
76 |
* @since 1.8
|
77 |
*
|
176 |
$term = $this->get_object_term( $id, $this->tax_translations );
|
177 |
$translations = empty( $term ) ? array() : unserialize( $term->description );
|
178 |
|
179 |
+
// make sure we return only translations ( thus we allow plugins to store other information in the array )
|
180 |
if ( is_array( $translations ) ) {
|
181 |
$translations = array_intersect_key( $translations, array_flip( $this->model->get_languages_list( array( 'fields' => 'slug' ) ) ) );
|
182 |
}
|
232 |
*
|
233 |
* @since 1.2
|
234 |
*
|
235 |
+
* @param object|array|string $lang a PLL_Language object or a comma separated list of language slug or an array of language slugs
|
236 |
* @return string where clause
|
237 |
*/
|
238 |
public function where_clause( $lang ) {
|
242 |
// $lang is an object
|
243 |
// generally the case if the query is coming from Polylang
|
244 |
if ( is_object( $lang ) ) {
|
245 |
+
return ' AND pll_tr.term_taxonomy_id = ' . absint( $lang->$tt_id );
|
246 |
}
|
247 |
|
248 |
// $lang is a comma separated list of slugs ( or an array of slugs )
|
249 |
// generally the case is the query is coming from outside with 'lang' parameter
|
250 |
$slugs = is_array( $lang ) ? $lang : explode( ',', $lang );
|
251 |
foreach ( $slugs as $slug ) {
|
252 |
+
$languages[] = absint( $this->model->get_language( $slug )->$tt_id );
|
253 |
}
|
254 |
|
255 |
return ' AND pll_tr.term_taxonomy_id IN ( ' . implode( ',', $languages ) . ' )';
|
include/walker-list.php
CHANGED
@@ -26,7 +26,7 @@ class PLL_Walker_List extends Walker {
|
|
26 |
esc_attr( $element->locale ),
|
27 |
esc_url( $element->url ),
|
28 |
$element->flag,
|
29 |
-
$args['show_flags']
|
30 |
'discard' === $args['item_spacing'] ? '' : "\t",
|
31 |
'discard' === $args['item_spacing'] ? '' : "\n"
|
32 |
);
|
26 |
esc_attr( $element->locale ),
|
27 |
esc_url( $element->url ),
|
28 |
$element->flag,
|
29 |
+
$args['show_flags'] ? sprintf( '<span style="margin-%1$s:0.3em;">%2$s</span>', is_rtl() ? 'right' : 'left', esc_html( $element->name ) ) : esc_html( $element->name ),
|
30 |
'discard' === $args['item_spacing'] ? '' : "\t",
|
31 |
'discard' === $args['item_spacing'] ? '' : "\n"
|
32 |
);
|
include/widget-calendar.php
CHANGED
@@ -5,7 +5,7 @@ if ( ! class_exists( 'WP_Widget_Calendar' ) ) {
|
|
5 |
}
|
6 |
|
7 |
/**
|
8 |
-
* obliged to rewrite the whole
|
9 |
* code base last checked with WP 4.4.2
|
10 |
* a request for making a filter on sql queries exists: http://core.trac.wordpress.org/ticket/15202
|
11 |
* method used in 0.4.x: use of the get_calendar filter and overwrite the output of get_calendar function -> not very efficient (add 4 to 5 sql queries)
|
5 |
}
|
6 |
|
7 |
/**
|
8 |
+
* obliged to rewrite the whole functionality as there is no filter on sql queries and only a filter on final output
|
9 |
* code base last checked with WP 4.4.2
|
10 |
* a request for making a filter on sql queries exists: http://core.trac.wordpress.org/ticket/15202
|
11 |
* method used in 0.4.x: use of the get_calendar filter and overwrite the output of get_calendar function -> not very efficient (add 4 to 5 sql queries)
|
modules/wpml/wpml-legacy-api.php
CHANGED
@@ -36,7 +36,7 @@ if ( ! function_exists( 'icl_get_languages' ) ) {
|
|
36 |
* id => the language id
|
37 |
* active => whether this is the active language or no, 0 or 1
|
38 |
* native_name => the language name
|
39 |
-
* missing =>
|
40 |
* translated_name => empty, does not exist in Polylang
|
41 |
* language_code => the language code ( slug )
|
42 |
* country_flag_url => the url of the flag
|
36 |
* id => the language id
|
37 |
* active => whether this is the active language or no, 0 or 1
|
38 |
* native_name => the language name
|
39 |
+
* missing => whether the translation is missing or not, 0 or 1
|
40 |
* translated_name => empty, does not exist in Polylang
|
41 |
* language_code => the language code ( slug )
|
42 |
* country_flag_url => the url of the flag
|
polylang.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
/**
|
4 |
Plugin Name: Polylang
|
5 |
Plugin URI: https://polylang.pro
|
6 |
-
Version: 2.2.
|
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.2.
|
39 |
define( 'PLL_MIN_WP_VERSION', '4.4' );
|
40 |
|
41 |
define( 'POLYLANG_FILE', __FILE__ ); // this file
|
3 |
/**
|
4 |
Plugin Name: Polylang
|
5 |
Plugin URI: https://polylang.pro
|
6 |
+
Version: 2.2.6
|
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.2.6' );
|
39 |
define( 'PLL_MIN_WP_VERSION', '4.4' );
|
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.4
|
6 |
Tested up to: 4.9
|
7 |
-
Stable tag: 2.2.
|
8 |
License: GPLv2 or later
|
9 |
|
10 |
Making WordPress multilingual
|
@@ -76,6 +76,21 @@ Don't hesitate to [give your feedback](http://wordpress.org/support/view/plugin-
|
|
76 |
|
77 |
== Changelog ==
|
78 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
79 |
= 2.2.5 (2017-11-09) =
|
80 |
|
81 |
* Update plugin updater class to 1.6.15
|
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.2.6
|
8 |
License: GPLv2 or later
|
9 |
|
10 |
Making WordPress multilingual
|
76 |
|
77 |
== Changelog ==
|
78 |
|
79 |
+
= 2.2.6 (2017-11-22) =
|
80 |
+
|
81 |
+
* Pro: Fix query by post name and alternative language always returning the post in current language (when sharing slugs)
|
82 |
+
* Pro: Fix query by taxonomy and alternative language returning empty results
|
83 |
+
* Rework how translation files are loaded in ajax on front when the user is logged (in WP 4.7+)
|
84 |
+
* Add filter 'get_objects_with_no_lang_limit'
|
85 |
+
* Force loading the admin side when using WP CLI (Props chrisschrijver)
|
86 |
+
* Fix check for terms with no language not scaling
|
87 |
+
* Fix pll_count_posts not working with multiple post types
|
88 |
+
* Fix inconsistent spacing between flag and language name in language switcher parent menu item (Props Amit Tal)
|
89 |
+
* Fix spacing between flag and language name when displaying an RTL language
|
90 |
+
* Fix get_terms not accepting comma separated values for 'lang' parameter (Props Pavlo Zhukov)
|
91 |
+
* Fix possible wrong language detected in url when using subdomains (Props Pavlo Zhukov)
|
92 |
+
* Fix double escaped query
|
93 |
+
|
94 |
= 2.2.5 (2017-11-09) =
|
95 |
|
96 |
* Update plugin updater class to 1.6.15
|
settings/settings.php
CHANGED
@@ -289,7 +289,7 @@ class PLL_Settings extends PLL_Admin_Base {
|
|
289 |
* @since 1.8
|
290 |
*/
|
291 |
public function notice_objects_with_no_lang() {
|
292 |
-
if ( ! empty( $this->options['default_lang'] ) && $this->model->get_objects_with_no_lang() ) {
|
293 |
printf(
|
294 |
'<div class="error"><p>%s <a href="%s">%s</a></p></div>',
|
295 |
esc_html__( 'There are posts, pages, categories or tags without language.', 'polylang' ),
|
289 |
* @since 1.8
|
290 |
*/
|
291 |
public function notice_objects_with_no_lang() {
|
292 |
+
if ( ! empty( $this->options['default_lang'] ) && $this->model->get_objects_with_no_lang( 1 ) ) {
|
293 |
printf(
|
294 |
'<div class="error"><p>%s <a href="%s">%s</a></p></div>',
|
295 |
esc_html__( 'There are posts, pages, categories or tags without language.', 'polylang' ),
|