Version Description
Polylang 1.2 introduced major internal changes. More than ever, make a database backup before upgrading from 1.1.6 or older! If you are using a version older than 0.8, please ugrade to 0.9.8 before ugrading to 1.2.4
=
Download this release
Release Info
Developer | Chouby |
Plugin | Polylang |
Version | 1.2.4 |
Comparing to | |
See all releases |
Code changes from version 1.2.3 to 1.2.4
- admin/admin-filters-columns.php +12 -5
- admin/admin-filters-term.php +2 -2
- admin/admin-filters.php +1 -1
- admin/admin.php +7 -3
- admin/view-translations-media.php +1 -1
- admin/view-translations-post.php +8 -2
- admin/view-translations-term.php +10 -12
- frontend/frontend-filters-search.php +5 -9
- frontend/frontend-filters.php +9 -0
- frontend/frontend-links.php +1 -1
- frontend/frontend-nav-menu.php +25 -29
- frontend/frontend.php +9 -7
- include/model.php +5 -2
- include/switcher.php +2 -2
- include/wpml-compat.php +5 -4
- polylang.php +2 -2
- readme.txt +12 -4
admin/admin-filters-columns.php
CHANGED
@@ -117,7 +117,7 @@ class PLL_Admin_Filters_Columns {
|
|
117 |
printf('<a class="%1$s" title="%2$s" href="%3$s"></a>',
|
118 |
$id == $post_id ? 'pll_icon_tick' : 'pll_icon_edit',
|
119 |
esc_attr(get_post($id)->post_title),
|
120 |
-
esc_url(get_edit_post_link($id
|
121 |
);
|
122 |
|
123 |
// link to add a new translation
|
@@ -194,8 +194,8 @@ class PLL_Admin_Filters_Columns {
|
|
194 |
if (false === strpos($column, 'language_') || !($lang = $inline ? $this->model->get_language($_POST['inline_lang_choice']) : $this->model->get_term_language($term_id)))
|
195 |
return;
|
196 |
|
197 |
-
$post_type = isset($GLOBALS['post_type']) ? $GLOBALS['post_type'] : $
|
198 |
-
$taxonomy = isset($GLOBALS['taxonomy']) ? $GLOBALS['taxonomy'] : $
|
199 |
$language = $this->model->get_language(substr($column, 9));
|
200 |
|
201 |
if ($column == $this->get_first_language_column())
|
@@ -210,10 +210,17 @@ class PLL_Admin_Filters_Columns {
|
|
210 |
);
|
211 |
|
212 |
// link to add a new translation
|
213 |
-
else
|
|
|
|
|
|
|
|
|
|
|
|
|
214 |
printf('<a class="pll_icon_add" title="%1$s" href="%2$s"></a>',
|
215 |
__('Add new translation', 'polylang'),
|
216 |
-
esc_url(admin_url(
|
217 |
);
|
|
|
218 |
}
|
219 |
}
|
117 |
printf('<a class="%1$s" title="%2$s" href="%3$s"></a>',
|
118 |
$id == $post_id ? 'pll_icon_tick' : 'pll_icon_edit',
|
119 |
esc_attr(get_post($id)->post_title),
|
120 |
+
esc_url(get_edit_post_link($id))
|
121 |
);
|
122 |
|
123 |
// link to add a new translation
|
194 |
if (false === strpos($column, 'language_') || !($lang = $inline ? $this->model->get_language($_POST['inline_lang_choice']) : $this->model->get_term_language($term_id)))
|
195 |
return;
|
196 |
|
197 |
+
$post_type = isset($GLOBALS['post_type']) ? $GLOBALS['post_type'] : $_REQUEST['post_type']; // 2nd case for quick edit
|
198 |
+
$taxonomy = isset($GLOBALS['taxonomy']) ? $GLOBALS['taxonomy'] : $_REQUEST['taxonomy'];
|
199 |
$language = $this->model->get_language(substr($column, 9));
|
200 |
|
201 |
if ($column == $this->get_first_language_column())
|
210 |
);
|
211 |
|
212 |
// link to add a new translation
|
213 |
+
else {
|
214 |
+
$args = array(
|
215 |
+
'taxonomy' => $taxonomy,
|
216 |
+
'post_type' => $post_type,
|
217 |
+
'from_tag' => $term_id,
|
218 |
+
'new_lang' => $language->slug
|
219 |
+
);
|
220 |
printf('<a class="pll_icon_add" title="%1$s" href="%2$s"></a>',
|
221 |
__('Add new translation', 'polylang'),
|
222 |
+
esc_url(add_query_arg($args, admin_url('edit-tags.php')))
|
223 |
);
|
224 |
+
}
|
225 |
}
|
226 |
}
|
admin/admin-filters-term.php
CHANGED
@@ -59,8 +59,8 @@ class PLL_Admin_Filters_Term {
|
|
59 |
*/
|
60 |
public function add_term_form() {
|
61 |
$taxonomy = $_GET['taxonomy'];
|
|
|
62 |
$lang = isset($_GET['new_lang']) ? $this->model->get_language($_GET['new_lang']) : $this->pref_lang;
|
63 |
-
|
64 |
$dropdown = new PLL_Walker_Dropdown();
|
65 |
|
66 |
printf('
|
@@ -90,7 +90,7 @@ class PLL_Admin_Filters_Term {
|
|
90 |
$term_id = $tag->term_id;
|
91 |
$lang = $this->model->get_term_language($term_id);
|
92 |
$taxonomy = $tag->taxonomy;
|
93 |
-
|
94 |
$dropdown = new PLL_Walker_Dropdown();
|
95 |
|
96 |
printf('
|
59 |
*/
|
60 |
public function add_term_form() {
|
61 |
$taxonomy = $_GET['taxonomy'];
|
62 |
+
$post_type = isset($GLOBALS['post_type']) ? $GLOBALS['post_type'] : $_REQUEST['post_type'];
|
63 |
$lang = isset($_GET['new_lang']) ? $this->model->get_language($_GET['new_lang']) : $this->pref_lang;
|
|
|
64 |
$dropdown = new PLL_Walker_Dropdown();
|
65 |
|
66 |
printf('
|
90 |
$term_id = $tag->term_id;
|
91 |
$lang = $this->model->get_term_language($term_id);
|
92 |
$taxonomy = $tag->taxonomy;
|
93 |
+
$post_type = isset($GLOBALS['post_type']) ? $GLOBALS['post_type'] : $_REQUEST['post_type'];
|
94 |
$dropdown = new PLL_Walker_Dropdown();
|
95 |
|
96 |
printf('
|
admin/admin-filters.php
CHANGED
@@ -55,7 +55,7 @@ class PLL_Admin_Filters {
|
|
55 |
*/
|
56 |
public function in_widget_form($widget) {
|
57 |
$dropdown = new PLL_Walker_Dropdown();
|
58 |
-
printf('<p><label for="%1$s">%2$s%3$s</label></p>',
|
59 |
esc_attr( $widget->id.'_lang_choice'),
|
60 |
__('The widget is displayed for:', 'polylang'),
|
61 |
$dropdown->walk(
|
55 |
*/
|
56 |
public function in_widget_form($widget) {
|
57 |
$dropdown = new PLL_Walker_Dropdown();
|
58 |
+
printf('<p><label for="%1$s">%2$s %3$s</label></p>',
|
59 |
esc_attr( $widget->id.'_lang_choice'),
|
60 |
__('The widget is displayed for:', 'polylang'),
|
61 |
$dropdown->walk(
|
admin/admin.php
CHANGED
@@ -145,9 +145,13 @@ class PLL_Admin extends PLL_Base {
|
|
145 |
$this->pref_lang = apply_filters('pll_admin_preferred_language', $this->pref_lang);
|
146 |
|
147 |
// inform that the admin language has been set
|
148 |
-
|
149 |
-
$
|
150 |
-
|
|
|
|
|
|
|
|
|
151 |
}
|
152 |
|
153 |
/*
|
145 |
$this->pref_lang = apply_filters('pll_admin_preferred_language', $this->pref_lang);
|
146 |
|
147 |
// inform that the admin language has been set
|
148 |
+
// only if the admin language is one of the Polylang defined language
|
149 |
+
if ($curlang = $this->model->get_language(get_locale())) {
|
150 |
+
$GLOBALS['text_direction'] = $curlang->is_rtl ? 'rtl' : 'ltr'; // force text direction according to language setting
|
151 |
+
do_action('pll_language_defined', $curlang->slug, $curlang);
|
152 |
+
}
|
153 |
+
else
|
154 |
+
do_action('pll_no_language_defined'); // to load overriden textdomains
|
155 |
}
|
156 |
|
157 |
/*
|
admin/view-translations-media.php
CHANGED
@@ -58,7 +58,7 @@ else { // WP 3.5+ ?>
|
|
58 |
'<td><input type="hidden" name="media_tr_lang[%s]" value="%d" /><a href="%s">%s</a></td>',
|
59 |
esc_attr($language->slug),
|
60 |
esc_attr($translation_id),
|
61 |
-
esc_url(
|
62 |
__('Edit','polylang')
|
63 |
);
|
64 |
}
|
58 |
'<td><input type="hidden" name="media_tr_lang[%s]" value="%d" /><a href="%s">%s</a></td>',
|
59 |
esc_attr($language->slug),
|
60 |
esc_attr($translation_id),
|
61 |
+
esc_url(get_edit_post_link($translation_id)),
|
62 |
__('Edit','polylang')
|
63 |
);
|
64 |
}
|
admin/view-translations-post.php
CHANGED
@@ -26,15 +26,21 @@
|
|
26 |
esc_attr($value)
|
27 |
);
|
28 |
if ($lang) {
|
|
|
|
|
|
|
|
|
|
|
|
|
29 |
$link = $value ?
|
30 |
sprintf(
|
31 |
'<a href="%1$s">%2$s</a>',
|
32 |
-
esc_url(
|
33 |
__('Edit','polylang')
|
34 |
) :
|
35 |
sprintf(
|
36 |
'<a href="%1$s">%2$s</a>',
|
37 |
-
esc_url(admin_url('post-new.php
|
38 |
__('Add new','polylang')
|
39 |
);?>
|
40 |
<td><?php echo $link ?><td><?php
|
26 |
esc_attr($value)
|
27 |
);
|
28 |
if ($lang) {
|
29 |
+
$args = array(
|
30 |
+
'post_type' => $post_type,
|
31 |
+
'from_post' => $post_ID,
|
32 |
+
'new_lang' => $language->slug
|
33 |
+
);
|
34 |
+
|
35 |
$link = $value ?
|
36 |
sprintf(
|
37 |
'<a href="%1$s">%2$s</a>',
|
38 |
+
esc_url(get_edit_post_link($value)),
|
39 |
__('Edit','polylang')
|
40 |
) :
|
41 |
sprintf(
|
42 |
'<a href="%1$s">%2$s</a>',
|
43 |
+
esc_url(add_query_arg($args, admin_url('post-new.php'))),
|
44 |
__('Add new','polylang')
|
45 |
);?>
|
46 |
<td><?php echo $link ?><td><?php
|
admin/view-translations-term.php
CHANGED
@@ -48,17 +48,19 @@ else {
|
|
48 |
echo '<td>'.__('No untranslated term', 'polylang').'</td>';
|
49 |
|
50 |
// do not display the add new link in add term form ($term_id not set !!!)
|
51 |
-
if (isset($term_id))
|
|
|
|
|
|
|
|
|
|
|
|
|
52 |
printf(
|
53 |
'<td class="tr-edit-column"><a href="%1$s">%2$s</a></td>',
|
54 |
-
esc_url(admin_url(
|
55 |
-
'edit-tags.php?taxonomy=%1$s&from_tag=%2$d&new_lang=%3$s',
|
56 |
-
$taxonomy,
|
57 |
-
$term_id,
|
58 |
-
$language->slug
|
59 |
-
))),
|
60 |
__('Add new','polylang')
|
61 |
);
|
|
|
62 |
}
|
63 |
|
64 |
// a translation exists
|
@@ -72,11 +74,7 @@ else {
|
|
72 |
if (isset($term_id))
|
73 |
printf(
|
74 |
'<td class="tr-edit-column"><a href="%1$s">%2$s</a></td>',
|
75 |
-
esc_url(
|
76 |
-
'edit-tags.php?action=edit&taxonomy=%1$s&tag_ID=%2$d',
|
77 |
-
$taxonomy,
|
78 |
-
$translation->term_id
|
79 |
-
))),
|
80 |
__('Edit','polylang')
|
81 |
);
|
82 |
} ?>
|
48 |
echo '<td>'.__('No untranslated term', 'polylang').'</td>';
|
49 |
|
50 |
// do not display the add new link in add term form ($term_id not set !!!)
|
51 |
+
if (isset($term_id)) {
|
52 |
+
$args = array(
|
53 |
+
'taxonomy' => $taxonomy,
|
54 |
+
'post_type' => $post_type,
|
55 |
+
'from_tag' => $term_id,
|
56 |
+
'new_lang' => $language->slug
|
57 |
+
);
|
58 |
printf(
|
59 |
'<td class="tr-edit-column"><a href="%1$s">%2$s</a></td>',
|
60 |
+
esc_url(add_query_arg($args, admin_url('edit-tags.php'))),
|
|
|
|
|
|
|
|
|
|
|
61 |
__('Add new','polylang')
|
62 |
);
|
63 |
+
}
|
64 |
}
|
65 |
|
66 |
// a translation exists
|
74 |
if (isset($term_id))
|
75 |
printf(
|
76 |
'<td class="tr-edit-column"><a href="%1$s">%2$s</a></td>',
|
77 |
+
esc_url(get_edit_term_link($translation->term_id, $taxonomy, $post_type)),
|
|
|
|
|
|
|
|
|
78 |
__('Edit','polylang')
|
79 |
);
|
80 |
} ?>
|
frontend/frontend-filters-search.php
CHANGED
@@ -47,7 +47,7 @@ class PLL_Frontend_Filters_Search {
|
|
47 |
// take care to modify only the url in the <form> tag
|
48 |
preg_match('#<form.+>#', $form, $matches);
|
49 |
$old = reset($matches);
|
50 |
-
$new =
|
51 |
$form = str_replace($old, $new, $form);
|
52 |
}
|
53 |
else
|
@@ -75,14 +75,10 @@ class PLL_Frontend_Filters_Search {
|
|
75 |
* @param object $wp_admin_bar
|
76 |
*/
|
77 |
public function admin_bar_search_menu($wp_admin_bar) {
|
78 |
-
$form =
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
</form>',
|
83 |
-
esc_url(get_option('home')),
|
84 |
-
__('Search')
|
85 |
-
);
|
86 |
|
87 |
$wp_admin_bar->add_menu(array(
|
88 |
'parent' => 'top-secondary',
|
47 |
// take care to modify only the url in the <form> tag
|
48 |
preg_match('#<form.+>#', $form, $matches);
|
49 |
$old = reset($matches);
|
50 |
+
$new = preg_replace('#' . $this->links->home . '\/?#', $this->links->get_home_url('', true), $old);
|
51 |
$form = str_replace($old, $new, $form);
|
52 |
}
|
53 |
else
|
75 |
* @param object $wp_admin_bar
|
76 |
*/
|
77 |
public function admin_bar_search_menu($wp_admin_bar) {
|
78 |
+
$form = '<form action="' . esc_url( home_url( '/' ) ) . '" method="get" id="adminbarsearch">';
|
79 |
+
$form .= '<input class="adminbar-input" name="s" id="adminbar-search" type="text" value="" maxlength="150" />';
|
80 |
+
$form .= '<input type="submit" class="adminbar-button" value="' . __('Search') . '"/>';
|
81 |
+
$form .= '</form>';
|
|
|
|
|
|
|
|
|
82 |
|
83 |
$wp_admin_bar->add_menu(array(
|
84 |
'parent' => 'top-secondary',
|
frontend/frontend-filters.php
CHANGED
@@ -65,6 +65,15 @@ class PLL_Frontend_Filters {
|
|
65 |
add_action('save_post', array(&$this, 'save_post'), 200, 2);
|
66 |
add_action('create_term', array(&$this, 'save_term'), 10, 3);
|
67 |
add_action('edit_term', array(&$this, 'save_term'), 10, 3);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
68 |
}
|
69 |
|
70 |
/*
|
65 |
add_action('save_post', array(&$this, 'save_post'), 200, 2);
|
66 |
add_action('create_term', array(&$this, 'save_term'), 10, 3);
|
67 |
add_action('edit_term', array(&$this, 'save_term'), 10, 3);
|
68 |
+
|
69 |
+
// support theme customizer
|
70 |
+
// FIXME of course does not work if 'transport' is set to 'postMessage'
|
71 |
+
if (isset($_POST['wp_customize'], $_POST['customized'])) {
|
72 |
+
add_filter('pre_option_page_on_front', 'pll_get_post', 20);
|
73 |
+
add_filter('pre_option_page_for_post', 'pll_get_post', 20);
|
74 |
+
add_filter('pre_option_blogname', 'pll__', 20);
|
75 |
+
add_filter('pre_option_blogdescription', 'pll__', 20);
|
76 |
+
}
|
77 |
}
|
78 |
|
79 |
/*
|
frontend/frontend-links.php
CHANGED
@@ -84,7 +84,7 @@ class PLL_Frontend_Links extends PLL_Links {
|
|
84 |
return $this->links[$link];
|
85 |
|
86 |
return $this->links[$link] = $tax == 'post_format' ?
|
87 |
-
$this->links_model->add_language_to_link($link, $this->get_term_language($term->term_id)) : parent::term_link($link, $term, $tax);
|
88 |
}
|
89 |
|
90 |
/*
|
84 |
return $this->links[$link];
|
85 |
|
86 |
return $this->links[$link] = $tax == 'post_format' ?
|
87 |
+
$this->links_model->add_language_to_link($link, $this->model->get_term_language($term->term_id)) : parent::term_link($link, $term, $tax);
|
88 |
}
|
89 |
|
90 |
/*
|
frontend/frontend-nav-menu.php
CHANGED
@@ -22,10 +22,7 @@ class PLL_Frontend_Nav_Menu {
|
|
22 |
add_filter('nav_menu_link_attributes', array(&$this, 'nav_menu_link_attributes'), 10, 3);
|
23 |
|
24 |
// filters menus by language
|
25 |
-
|
26 |
-
add_action('pll_language_defined', array(&$this, 'customizer_locations')); // theme customizer
|
27 |
-
else
|
28 |
-
add_filter('theme_mod_nav_menu_locations', array($this, 'nav_menu_locations'), 20);
|
29 |
}
|
30 |
|
31 |
/*
|
@@ -138,36 +135,35 @@ class PLL_Frontend_Nav_Menu {
|
|
138 |
* @return array|bool modified list of nav menus locations
|
139 |
*/
|
140 |
public function nav_menu_locations($menus) {
|
141 |
-
if (is_array($menus))
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
147 |
}
|
148 |
|
149 |
-
|
150 |
-
|
|
|
151 |
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
* @since 1.2
|
156 |
-
*/
|
157 |
-
public function customizer_locations() {
|
158 |
-
$customized = json_decode($_POST['customized']);
|
159 |
-
|
160 |
-
if (is_object($customized)) {
|
161 |
-
foreach ($customized as $key => $c) {
|
162 |
-
if (false !== strpos($key, 'nav_menu_locations[')) {
|
163 |
-
$loc = substr(trim($key, ']'), 19);
|
164 |
-
if (($pos = strpos($loc, '___')) && substr($loc, $pos+3) == $this->curlang->slug) {
|
165 |
-
$loc = 'nav_menu_locations[' . substr($loc, 0, $pos) . ']';
|
166 |
-
$customized->$loc = $c;
|
167 |
-
}
|
168 |
}
|
169 |
}
|
170 |
-
$_POST['customized'] = json_encode($customized);
|
171 |
}
|
|
|
172 |
}
|
173 |
}
|
22 |
add_filter('nav_menu_link_attributes', array(&$this, 'nav_menu_link_attributes'), 10, 3);
|
23 |
|
24 |
// filters menus by language
|
25 |
+
add_filter('theme_mod_nav_menu_locations', array($this, 'nav_menu_locations'), 20);
|
|
|
|
|
|
|
26 |
}
|
27 |
|
28 |
/*
|
135 |
* @return array|bool modified list of nav menus locations
|
136 |
*/
|
137 |
public function nav_menu_locations($menus) {
|
138 |
+
if (is_array($menus)) {
|
139 |
+
// support for theme customizer
|
140 |
+
// let's look for multilingual menu locations directly in $_POST as tehre are not in customizer object
|
141 |
+
if (isset($_POST['wp_customize'], $_POST['customized'])) {
|
142 |
+
$customized = json_decode(wp_unslash($_POST['customized']));
|
143 |
+
|
144 |
+
if (is_object($customized)) {
|
145 |
+
foreach ($customized as $key => $c) {
|
146 |
+
if (false !== strpos($key, 'nav_menu_locations[')) {
|
147 |
+
$loc = substr(trim($key, ']'), 19);
|
148 |
+
if (($pos = strpos($loc, '___')) && substr($loc, $pos+3) == $this->curlang->slug) {
|
149 |
+
$loc = substr($loc, 0, $pos);
|
150 |
+
$menus[$loc] = $c;
|
151 |
+
}
|
152 |
+
}
|
153 |
+
}
|
154 |
+
}
|
155 |
}
|
156 |
|
157 |
+
// otherwise get multilingual menu locations from DB
|
158 |
+
else {
|
159 |
+
$theme = get_option('stylesheet');
|
160 |
|
161 |
+
foreach ($menus as $loc => $menu) {
|
162 |
+
if (!empty($this->options['nav_menus'][$theme][$loc][$this->curlang->slug]))
|
163 |
+
$menus[$loc] = $this->options['nav_menus'][$theme][$loc][$this->curlang->slug];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
164 |
}
|
165 |
}
|
|
|
166 |
}
|
167 |
+
return $menus;
|
168 |
}
|
169 |
}
|
frontend/frontend.php
CHANGED
@@ -74,10 +74,18 @@ class PLL_Frontend extends PLL_Base{
|
|
74 |
public function parse_query($query) {
|
75 |
$qv = $query->query_vars;
|
76 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
77 |
// allow filtering recent posts and secondary queries by the current language
|
78 |
// take care not to break queries for non visible post types such as nav_menu_items
|
79 |
// do not filter if lang is set to an empty value
|
80 |
-
|
|
|
81 |
$query->set('lang', $this->curlang->slug);
|
82 |
|
83 |
// modifies query vars when the language is queried
|
@@ -98,12 +106,6 @@ class PLL_Frontend extends PLL_Base{
|
|
98 |
unset($query->queried_object);
|
99 |
}
|
100 |
}
|
101 |
-
|
102 |
-
// to avoid conflict beetwen taxonomies
|
103 |
-
if (isset($query->tax_query->queries))
|
104 |
-
foreach ($query->tax_query->queries as $tax)
|
105 |
-
if (pll_is_translated_taxonomy($tax['taxonomy']))
|
106 |
-
unset($query->query_vars['lang']);
|
107 |
}
|
108 |
|
109 |
/*
|
74 |
public function parse_query($query) {
|
75 |
$qv = $query->query_vars;
|
76 |
|
77 |
+
// to avoid conflict beetwen taxonomies
|
78 |
+
$has_tax = false;
|
79 |
+
if (isset($query->tax_query->queries))
|
80 |
+
foreach ($query->tax_query->queries as $tax)
|
81 |
+
if (pll_is_translated_taxonomy($tax['taxonomy']))
|
82 |
+
$has_tax = true;
|
83 |
+
|
84 |
// allow filtering recent posts and secondary queries by the current language
|
85 |
// take care not to break queries for non visible post types such as nav_menu_items
|
86 |
// do not filter if lang is set to an empty value
|
87 |
+
// do not filter single page and translated taxonomies
|
88 |
+
if (/*$query->is_home &&*/ !empty($this->curlang) && !isset($qv['lang']) && !$has_tax && empty($qv['page_id']) && empty($qv['pagename']) && (empty($qv['post_type']) || $this->model->is_translated_post_type($qv['post_type'])))
|
89 |
$query->set('lang', $this->curlang->slug);
|
90 |
|
91 |
// modifies query vars when the language is queried
|
106 |
unset($query->queried_object);
|
107 |
}
|
108 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
109 |
}
|
110 |
|
111 |
/*
|
include/model.php
CHANGED
@@ -279,9 +279,12 @@ class PLL_Model {
|
|
279 |
* @return bool|int post id or term id of the translation, flase if there is none
|
280 |
*/
|
281 |
public function get_translation($type, $id, $lang) {
|
|
|
|
|
|
|
282 |
$translations = $this->get_translations($type, $id);
|
283 |
-
|
284 |
-
return isset($translations[$slug]) ? (int) $translations[$slug] : false;
|
285 |
}
|
286 |
|
287 |
/*
|
279 |
* @return bool|int post id or term id of the translation, flase if there is none
|
280 |
*/
|
281 |
public function get_translation($type, $id, $lang) {
|
282 |
+
if (!$lang = $this->get_language($lang))
|
283 |
+
return false;
|
284 |
+
|
285 |
$translations = $this->get_translations($type, $id);
|
286 |
+
|
287 |
+
return isset($translations[$lang->slug]) ? (int) $translations[$lang->slug] : false;
|
288 |
}
|
289 |
|
290 |
/*
|
include/switcher.php
CHANGED
@@ -52,8 +52,8 @@ class PLL_Switcher {
|
|
52 |
$classes = array('lang-item', 'lang-item-' . esc_attr($id), 'lang-item-' . esc_attr($slug));
|
53 |
|
54 |
if ($current_lang = pll_current_language() == $slug) {
|
55 |
-
if ($hide_current)
|
56 |
-
continue; // hide current language
|
57 |
else
|
58 |
$classes[] = 'current-lang';
|
59 |
}
|
52 |
$classes = array('lang-item', 'lang-item-' . esc_attr($id), 'lang-item-' . esc_attr($slug));
|
53 |
|
54 |
if ($current_lang = pll_current_language() == $slug) {
|
55 |
+
if ($hide_current && !$dropdown)
|
56 |
+
continue; // hide current language except for dropdown
|
57 |
else
|
58 |
$classes[] = 'current-lang';
|
59 |
}
|
include/wpml-compat.php
CHANGED
@@ -7,17 +7,18 @@
|
|
7 |
* defines two WPML constants once the language has been defined
|
8 |
* the compatibility with WPML is not perfect on admin side as the constants are defined
|
9 |
* in 'setup_theme' by Polylang (based on user info) and 'plugins_loaded' by WPML (based on cookie)
|
|
|
10 |
*
|
11 |
* @since 0.9.5
|
12 |
*/
|
13 |
function pll_define_wpml_constants() {
|
14 |
$code = PLL_ADMIN ? get_user_meta(get_current_user_id(), 'pll_filter_content', true) : pll_current_language();
|
15 |
|
16 |
-
if(!defined('ICL_LANGUAGE_CODE'))
|
17 |
-
define('ICL_LANGUAGE_CODE',
|
18 |
|
19 |
-
if(!defined('ICL_LANGUAGE_NAME'))
|
20 |
-
define('ICL_LANGUAGE_NAME',
|
21 |
}
|
22 |
|
23 |
add_action('pll_language_defined', 'pll_define_wpml_constants');
|
7 |
* defines two WPML constants once the language has been defined
|
8 |
* the compatibility with WPML is not perfect on admin side as the constants are defined
|
9 |
* in 'setup_theme' by Polylang (based on user info) and 'plugins_loaded' by WPML (based on cookie)
|
10 |
+
* moreover I believe that WPML can set ICL_LANGUAGE_CODE to 'all' which I dont want to do with Polylang
|
11 |
*
|
12 |
* @since 0.9.5
|
13 |
*/
|
14 |
function pll_define_wpml_constants() {
|
15 |
$code = PLL_ADMIN ? get_user_meta(get_current_user_id(), 'pll_filter_content', true) : pll_current_language();
|
16 |
|
17 |
+
if(!defined('ICL_LANGUAGE_CODE') && !empty($code))
|
18 |
+
define('ICL_LANGUAGE_CODE', $code);
|
19 |
|
20 |
+
if(!defined('ICL_LANGUAGE_NAME') && !empty($code))
|
21 |
+
define('ICL_LANGUAGE_NAME', $GLOBALS['polylang']->model->get_language($code)->name);
|
22 |
}
|
23 |
|
24 |
add_action('pll_language_defined', 'pll_define_wpml_constants');
|
polylang.php
CHANGED
@@ -2,7 +2,7 @@
|
|
2 |
/*
|
3 |
Plugin Name: Polylang
|
4 |
Plugin URI: http://polylang.wordpress.com/
|
5 |
-
Version: 1.2.
|
6 |
Author: Frédéric Demarle
|
7 |
Description: Adds multilingual capability to WordPress
|
8 |
Text Domain: polylang
|
@@ -29,7 +29,7 @@ Domain Path: /languages
|
|
29 |
*
|
30 |
*/
|
31 |
|
32 |
-
define('POLYLANG_VERSION', '1.2.
|
33 |
define('PLL_MIN_WP_VERSION', '3.1');
|
34 |
|
35 |
define('POLYLANG_BASENAME', plugin_basename(__FILE__)); // plugin name as known by WP
|
2 |
/*
|
3 |
Plugin Name: Polylang
|
4 |
Plugin URI: http://polylang.wordpress.com/
|
5 |
+
Version: 1.2.4
|
6 |
Author: Frédéric Demarle
|
7 |
Description: Adds multilingual capability to WordPress
|
8 |
Text Domain: polylang
|
29 |
*
|
30 |
*/
|
31 |
|
32 |
+
define('POLYLANG_VERSION', '1.2.4');
|
33 |
define('PLL_MIN_WP_VERSION', '3.1');
|
34 |
|
35 |
define('POLYLANG_BASENAME', plugin_basename(__FILE__)); // plugin name as known by WP
|
readme.txt
CHANGED
@@ -4,7 +4,7 @@ Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_i
|
|
4 |
Tags: multilingual, bilingual, translate, translation, language, multilanguage, international, localization
|
5 |
Requires at least: 3.1
|
6 |
Tested up to: 3.7.1
|
7 |
-
Stable tag: 1.2.
|
8 |
License: GPLv2 or later
|
9 |
|
10 |
Polylang adds multilingual content management support to WordPress.
|
@@ -15,7 +15,7 @@ Polylang 1.2 introduces major internal changes. More than ever, make a database
|
|
15 |
|
16 |
= Features =
|
17 |
|
18 |
-
Polylang allows you to create a bilingual or multilingual WordPress site. You write posts, pages and create categories and post tags as usual, and then define the language for each of them. The translation of a post, whether it is in the default language or not, is optional. The translation has to be done by the site editor as Polylang not integrate any automatic or professional translation service.
|
19 |
|
20 |
* You can use as many languages as you want. RTL language scripts are supported. WordPress languages files are automatically downloaded and updated.
|
21 |
* You can translate posts, pages, media, categories, post tags, menus, widgets... Custom post types, custom taxonomies, sticky posts and post formats, RSS feeds and all default WordPress widgets are supported.
|
@@ -63,11 +63,19 @@ See http://polylang.wordpress.com/documentation/contribute/
|
|
63 |
|
64 |
== Upgrade Notice ==
|
65 |
|
66 |
-
= 1.2.
|
67 |
-
Polylang 1.2 introduced major internal changes. More than ever, make a database backup before upgrading from 1.1.6 or older! If you are using a version older than 0.8, please ugrade to 0.9.8 before ugrading to 1.2.
|
68 |
|
69 |
== Changelog ==
|
70 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
71 |
= 1.2.3 (2013-11-17) =
|
72 |
|
73 |
* Avoid fatal error when ugrading with Nextgen Gallery active
|
4 |
Tags: multilingual, bilingual, translate, translation, language, multilanguage, international, localization
|
5 |
Requires at least: 3.1
|
6 |
Tested up to: 3.7.1
|
7 |
+
Stable tag: 1.2.4
|
8 |
License: GPLv2 or later
|
9 |
|
10 |
Polylang adds multilingual content management support to WordPress.
|
15 |
|
16 |
= Features =
|
17 |
|
18 |
+
Polylang allows you to create a bilingual or multilingual WordPress site. You write posts, pages and create categories and post tags as usual, and then define the language for each of them. The translation of a post, whether it is in the default language or not, is optional. The translation has to be done by the site editor as Polylang does not integrate any automatic or professional translation service.
|
19 |
|
20 |
* You can use as many languages as you want. RTL language scripts are supported. WordPress languages files are automatically downloaded and updated.
|
21 |
* You can translate posts, pages, media, categories, post tags, menus, widgets... Custom post types, custom taxonomies, sticky posts and post formats, RSS feeds and all default WordPress widgets are supported.
|
63 |
|
64 |
== Upgrade Notice ==
|
65 |
|
66 |
+
= 1.2.4 =
|
67 |
+
Polylang 1.2 introduced major internal changes. More than ever, make a database backup before upgrading from 1.1.6 or older! If you are using a version older than 0.8, please ugrade to 0.9.8 before ugrading to 1.2.4
|
68 |
|
69 |
== Changelog ==
|
70 |
|
71 |
+
= 1.2.4 (2013-11-28) =
|
72 |
+
|
73 |
+
* Better support for theme customizer
|
74 |
+
* Bug correction: admin bar search does not filter by language
|
75 |
+
* Bug correction: possible conflict on secondary query when querying taxonomies or single page
|
76 |
+
* Bug correction: post type is not included in url when editing or adding a term translation
|
77 |
+
* Bug correction: various warnings and PHP notices
|
78 |
+
|
79 |
= 1.2.3 (2013-11-17) =
|
80 |
|
81 |
* Avoid fatal error when ugrading with Nextgen Gallery active
|