- Status
- Open
- Reported for
- WPML Multilingual CMS 4.6.7
- Topic tags
- Bug
Overview of the issue
If you are using the Use directory for default language option and you add a Language Switcher Block on the root page, it erroneously points to the default language without the directory. (i.e '/' instead of '/en’).
This issue prevents users from selecting the default language on these specific pages.
Workaround
Please, make sure of having a full backup of your site before proceeding.
- Open …/wp-content/plugins/sitepress-multilingual-cms/classes/language-switcher/class-wpml-ls-model-build.php file.
- Look for line 64.
- Change:
public function get( $slot, $template_data = [] ) { $vars = []; $vars['current_language_code'] = $this->sitepress->get_current_language(); $vars['languages'] = $this->get_language_items( $slot, $template_data ); $vars['css_classes'] = $this->get_slot_css_classes( $slot ); $vars['css_classes_link'] = self::LINK_CSS_CLASS; $vars = $this->add_backward_compatibility_to_wrapper( $vars, $slot ); return $this->sanitize_vars( $vars, $this->allowed_vars ); } - For:
public function get( $slot, $template_data = [] ) { global $sitepress; $vars = []; $vars['current_language_code'] = $this->sitepress->get_current_language(); $vars['languages'] = $this->get_language_items( $slot, $template_data ); $vars['css_classes'] = $this->get_slot_css_classes( $slot ); $vars['css_classes_link'] = self::LINK_CSS_CLASS; if(true === $sitepress->get_setting( 'urls' )['directory_for_default_language'] ) { $vars['current_language_code'] = "root"; } $vars = $this->add_backward_compatibility_to_wrapper( $vars, $slot ); return $this->sanitize_vars( $vars, $this->allowed_vars ); }