Skip Navigation

This thread is resolved. Here is a description of the problem and solution.

Problem:
The client was experiencing issues with menu synchronization while using WPML's WP Menus Sync feature. The synchronization process broke the header, altered the footer format, and caused menus to display incorrectly in different languages.

Solution:
This bug is happening because of a compatibility conflict with the MotoPress Hotel Booking plugin. One of the functions of this plugin always returns *en-us* as a locale. This affects how things work inside because it always switches to that value, so even if you're using a specific language like German and you make a menu, it still tries to use the English language.

We recommended the client perform a full site backup before proceeding with the workaround. The steps are as follows:

1) Navigate to the

*wp-content/plugins/motopress-hotel-booking/includes*

folder.
2) Edit the

*translation.php*

file.
3) Locate line 315.
4) Replace the existing code with the new code provided, ensuring to save the changes.

From

protected function getRestoreLanguage() {
    if ( is_admin() && ! MPHB()->isAjax() ) {            
        $locale = get_user_meta( get_current_user_id(), 'locale', true );
 
        if ( empty( $locale ) ) {
            return $this->getDefaultLanguage();
        } else {
            $language = explode( '_', $locale ); // "en" => ["en"], "ru_RU" -> ["ru", "RU"]
            return $language[0];
        }
    } else {
        return $this->getCurrentLanguage();
    }
}

To

protected function getRestoreLanguage() {
    if ( is_admin() && ! MPHB()->isAjax() ) {           
        return false;  
        $locale = get_user_meta( get_current_user_id(), 'locale', true );
 
        if ( empty( $locale ) ) {
            return $this->getDefaultLanguage();
        } else {
            $language = explode( '_', $locale ); // "en" => ["en"], "ru_RU" -> ["ru", "RU"]
            return $language[0];
        }
    } else {
        return $this->getCurrentLanguage();
    }
}

5) Clear all types of caches.

If the solution provided here does not resolve the issue or seems outdated, we encourage the client to check the related known issues, verify the version of the permanent fix, and confirm that the latest versions of themes and plugins are installed. If the problem persists, please open a new support ticket with us.

This is the technical support forum for WPML - the multilingual WordPress plugin.

Everyone can read, but only WPML clients can post here. WPML team is replying on the forum 6 days per week, 22 hours per day.

Tagged: 

This topic contains 18 replies, has 2 voices.

Last updated by Bigul 1 year, 3 months ago.

Assisted by: Bigul.

Author Posts
March 4, 2024 at 11:46 am #15369141

goncalod

Hi! Yes, most definetly. If I change my wordpress site to English by default will it solve the issue?

March 4, 2024 at 1:03 pm #15369670

Bigul
WPML Supporter since 01/2013

Languages: English (English )

Timezone: Europe/Vienna (GMT+02:00)

Hello,

Thank you for the updates. The easier solution will be to communicate with the MotoPress Hotel Booking team. Hope we can resolve it soon with their help. Please check it with them and let us know their feedback.

--
Thanks!

Bigul

March 14, 2024 at 4:55 pm #15411594

Bigul
WPML Supporter since 01/2013

Languages: English (English )

Timezone: Europe/Vienna (GMT+02:00)

Hello,

Please note that the *Bellevue* theme is not included on the WPML official compatibility list for the themes - https://wpml.org/theme/. It does not mean that this theme is not compatible with WPML, but our compatibility team has not tested it yet.

So I will consult about this with our compatibility team and get back to you soon. Please wait.

--
Thanks!

Bigul

March 19, 2024 at 4:06 pm #15427518

Bigul
WPML Supporter since 01/2013

Languages: English (English )

Timezone: Europe/Vienna (GMT+02:00)

Hello,

We have a workaround for this issue. Please try the following steps after a full site backup{mandatory} and make sure the issue exists or not.

1) Go to *wp-content/plugins/motopress-hotel-booking/includes* folder
2) Open the *translation.php* file for editing
3) Scroll down to line 315
4) Make the following changes in the code and save it

From

protected function getRestoreLanguage() {
    if ( is_admin() && ! MPHB()->isAjax() ) {            
        $locale = get_user_meta( get_current_user_id(), 'locale', true );
 
        if ( empty( $locale ) ) {
            return $this->getDefaultLanguage();
        } else {
            $language = explode( '_', $locale ); // "en" => ["en"], "ru_RU" -> ["ru", "RU"]
            return $language[0];
        }
    } else {
        return $this->getCurrentLanguage();
    }
}

To

protected function getRestoreLanguage() {
    if ( is_admin() && ! MPHB()->isAjax() ) {           
        return false;  
        $locale = get_user_meta( get_current_user_id(), 'locale', true );
 
        if ( empty( $locale ) ) {
            return $this->getDefaultLanguage();
        } else {
            $language = explode( '_', $locale ); // "en" => ["en"], "ru_RU" -> ["ru", "RU"]
            return $language[0];
        }
    } else {
        return $this->getCurrentLanguage();
    }
}

5) Clear all types of caches

--
Thanks!

Bigul