To fix this lastest reported bug, I have added code to the uwp_get_page_link function in /includes/helpers/permalinks.php
Original function:
function uwp_get_page_link($page_type) {
$page = new UsersWP_Pages();
return $page->get_page_link($page_type);
}
Modified function (for polylang)
function uwp_get_page_link($page_type) {
$page = new UsersWP_Pages();
$url = $page->get_page_link($page_type);
$post_id = url_to_postid( $url ); // find id from url
$trans_id = pll_get_post( $post_id); // find correct id
$trans_url = get_permalink($trans_id); // get permalink from id
return $trans_url;
}
This does not work on login menu link though, still main language link.
If you based the page links on ID of page instead of permalinks, this might fix the problem.
EDIT
A simpler change can be made upstream in /inludes/class-pages.php, at end of file.
Original code
if ($page_id) {
if (uwp_is_wpml()) {
$wpml_page_id = uwp_wpml_object_id($page_id, 'page', true, ICL_LANGUAGE_CODE);
if (!empty($wpml_page_id)) {
$page_id = $wpml_page_id;
}
}
$link = $page_id;
if($get_link){
$link = get_permalink($page_id);
}
}
Changed code
if ($page_id) {
if (uwp_is_wpml()) {
$wpml_page_id = uwp_wpml_object_id($page_id, 'page', true, ICL_LANGUAGE_CODE);
if (!empty($wpml_page_id)) {
$page_id = $wpml_page_id;
}
}
// added polylang code
if (class_exists('Polylang')){
$page_id = pll_get_post( $page_id);
}
$link = $page_id;
if($get_link){
$link = get_permalink($page_id);
}
}
Still does not change Login menu url.
-
This reply was modified 5 years, 6 months ago by efrap.
-
This reply was modified 5 years, 6 months ago by efrap.
-
This reply was modified 5 years, 6 months ago by t-p.