Problem in mobile device
-
Hello everyone. I have creaed a website and I am using your plugin. I have created a custom shortcode to create language switcher and use it in elementor menus.
At desktop it works really well but when in mobile it does not work for every link.
The code I have in the functions.php follows:
add_shortcode('lang_link', 'trpc_custom_language_switcher_link', 10);
function trpc_custom_language_switcher_link(){
if ( apply_filters( 'trp_allow_tp_to_run', true ) ){
$languages = trp_custom_language_switcher();
$html = '';
$current_language = get_locale();
foreach ($languages as $name => $item) {
if($item['language_code'] == $current_language){continue;}
if($current_language == 'el'){
$html .= $item['current_page_url'];
}else{
$cur = $item['current_page_url'];
$html .= trpc_get_url_for_language('el',$cur);
}
}
return $html;
}
}
function strip_language_code($url, $language_code) {
// Construct the pattern to match the language code
$pattern = "/\/" . preg_quote($language_code, '/') . "\//";
// Use preg_replace to remove the language code
$cleaned_url = preg_replace($pattern, '/', $url);
return $cleaned_url;
}
function trpc_get_url_for_language($lang = null, $url = null) {
if ( ! class_exists('TRP_Translate_Press') )
return $url;
$trp = TRP_Translate_Press::get_trp_instance();
$url_converter = $trp->get_component( 'url_converter' );
return esc_url( $url_converter->get_url_for_language( $lang, $url, '' ) );
}I use the langlink shortcode .When in mobile and when in greek everything works but when I visit the place in english the “EL” link does not work. Can you please help me?
Thanks in advance
Viewing 5 replies - 1 through 5 (of 5 total)
Viewing 5 replies - 1 through 5 (of 5 total)
- You must be logged in to reply to this topic.