Skip Navigation

Resolved

Reported for: WPML Multilingual CMS 4.4.4

Resolved in: 4.4.9

Overview of the issue

In some language configurations with the latest release of WPML, the Elementor editor does not load, and it gives the following error in the browser console:

/en/wp-json/elementor/v1/globals:1 Failed to load resource: the server responded with a status of 404 (Not Found)

Some other plugins or themes may also experience 404 or 500 errors codes in the browser console when using the Language URL Format: Languages In Directories

Workaround

Our development team has fixed the issue and the fix will be shipped with the upcoming WPML release.

In the meantime, you can use the following workaround to fix the issue on your site:

  1. Backup your WordPress site files and database.
  2. Using FTP, navigate to wp-content/plugins/sitepress-multilingual-cms/classes/url-handling/converter/strategy/class-wpml-url-converter-subdir-strategy.php
  3. Replace this code snippet:
    private function get_language_of_current_dir( $language_code, $value_if_default_language = null ) {
    		if ( ! $this->use_directory_for_default_lang && $language_code === $this->default_language ) {
    			return $value_if_default_language;
    		}
    
    		return $language_code;
    	}
    

    with:

    private function get_language_of_current_dir( $language_code, $value_if_default_language = null ) {
    		/** @var SitePress $sitepress */
    		global $sitepress;
    		$defaultLang = $sitepress->get_default_language();
    
    		if ( ! $this->use_directory_for_default_lang && $language_code === $defaultLang ) {
    			return $value_if_default_language;
    		}
    
    		return $language_code;
    	}
    

Please note: while this workaround fixes the issue with Elementor editor not loading correctly, some users may be experiencing the same bug but coming from other plugins. In this case, please open a support ticket mentioning this erratum.

8 Responses to “REST API 404 and 500 Errors Affecting Elementor and Other Plugins”

  1. Hi

    This fix enables us to use elementor and redirection plugin again.
    Thanks.

    WPML itself now shows an issue on /wp-admin/admin.php?page=sitepress-multilingual-cms%2Fmenu%2Fsupport.php claiming the rest API is disabled, which is not true.

    • Hi,

      Yes, the REST API status can sometimes be incorrect due to a number of factors that can be different for every user. This is why we always double check to make sure the REST API is actually not working when we see that status.

      Thank you for the update!

  2. Sadly the newer fix brings the problem back in our case.
    404 error on: https://www.magikweb.ca/fr/wp-json/contact-form-7/v1/contact-forms/119/refill

    We put add_filter( 'rest_url', [ $this, 'convertRestUrl' ] ); back in comments for now.

    • Thanks for reporting this. Can you please please open a support ticket so that we can have a closer look into the issue?

  3. Same issue here on a multisite, where this issue appears only for old users. Newly added users do not have this issue.
    When can we expect to see a fix being released?

    Thank you very much and have great christmas holidays.

    • Hello there,

      We don’t have an ETA yet but our developers are working on it. In the meantime, you can use the workaround for the moment.
      We will keep you updated.

      Happy holidays for you too! 🙂
      Regards