Skip Navigation

Resolved

Reported for: WPML Multilingual CMS 3.1.9.5

Resolved in: 3.1.9.7

Overview of the issue

  1. Go to the menu and create one in the default language.
  2. Try to create the menu in the second language.
  3. After saving you will get a 404 error.

Workaround

This problem has been solved in WPML 3.1.9.7

You should update to the recent WPML version to fix the problem

If you don’t want or can’t update WPML, please follow these directions:

  1. Download the updated version of iclNavMenu.class.php
  2. Use it as a replacement of sitepress-multilingual-cms/inc/wp-nav-menus/iclNavMenu.class.php:
    Most likely this means you should use your FTP client and upload the file in sitepress-multilingual-cms/inc/wp-nav-menus: if you’re asked to overwrite the existing file, just do it.

In case of problems

In case you get any of these issues:

  • Fatal error: Call to undefined method SitePress::get_setting() in /wp-content/plugins/sitepress-multilingual-cms/inc/wp-nav-menus/iclNavMenu.class.php on line 121
  • PHP Fatal error: Call to undefined function wpml_prepare_in() in /wp-content/plugins/sitepress-multilingual-cms/inc/wp-nav-menus/iclNavMenu.class.php on line 548
  • A white/blank page

Take these steps:

  1. Go to “WPML” -> “Support”
  2. Click on “debug information“: you will see a gray text box, with a lot of information (it’s a json object)
  3. Copy the content of the textbox in a text file and name that file as you wish: better if you use the “json” extension, but this is not mandatory
  4. Create a new WordPress user with admin rights for me to debug the issue
  5. Install the free “Duplicator” plugin (here).
    You can use a different plugin, if you like, but the following directions are specific to Duplicator (though they can be easily adjusted for other plugins)
  6. Create a new package:
    1. Go to “Duplicator” -> “Packages”
    2. Click on “Create New”
    3. Proceed with the wizard, leaving all the default settings (if you wish, you can exclude some files you think are not needed, or that would make the package too big, like the files in “uploads” folder)
    4. Once the snapshot is ready, download both “installer” and the “package” files
  7. Create a folder and include the files at step 3 and 6.4 (that is, the text file with the debug information, the installer and the package).
  8. Zip that folder and upload it on Google Drive, Dropbox or a similar service (or upload the whole folder without zipping, and share it)
  9. Go to our support forum, and create a support ticket with the following title “Workaround issues – Saving menus in non default language leads to 404 error”: we will ask you to privately share the files you stored at step #8.

If you are using a too old version of WPML, this workaround may not work.

In these cases, you may get a white page, or this errors: PHP Fatal error:  Call to undefined function wpml_prepare_in()

To fix this specific error, please follow these steps:

  1. open

    'wp-content/plugins/sitepress-multilingual-cms/inc/functions.php'

    and search for 

    wpml_prepare_in
  2. If you can’t find it, add this at the bottom of the file:
    function wpml_prepare_in( $items, $format = '%s' ) {
     global $wpdb;
    
     $items    = (array) $items;
     $how_many = count( $items );
     if ( $how_many > 0 ) {
      $placeholders    = array_fill( 0, $how_many, $format );
      $prepared_format = implode( ",", $placeholders );
      $prepared_in     = $wpdb->prepare( $prepared_format, $items );
     } else {
      $prepared_in = "";
     }
    
     return $prepared_in;
    }

83 Responses to “Saving menus in non default language leads to 404 error”

    • Hi Roger,

      Please contact the support from our Support Forum: they will be happy to assist you.

      Thanks.

  1. Hi,

    I applied the fix but it doesn’t work, When I try to access to the menu (in native language or english) I have this error message:

    Fatal error: Call to undefined function wpml_prepare_in() in (file path of iclNavMenu.class.php) on line 548

    • Hi Yohan,

      Are you sure you are working with the most recent version of WPML?

      Anyway, I suggest you to post a new thread in our Support Forum, where you can get better help.

      Thanks.

    • Hello, maby this answer help you 🙂

      I won this error, first step update file iclNavMenu.class.php in this dir wp-content/plugins/sitepress-multilingual-cms/inc/wp-nav-menus/

      Next step you need add this code


      /**
      * Changes array of items into string of items, separated by comma and sql-escaped
      *
      * @see https://coderwall.com/p/zepnaw
      *
      * @global wpdb $wpdb
      * @param array $items items to be joined into string
      * @param string $format %s or %d
      * @return string Items separated by comma and sql-escaped
      */
      function wpml_prepare_in(array $items, $format = '%s') {
      global $wpdb;

      $how_many = count($items);
      $placeholders = array_fill(0, $how_many, $format);
      $prepared_format = implode(",", $placeholders);
      $prepared_in = $wpdb->prepare($prepared_format, $items);

      return $prepared_in;

      }

      in to bottom of the file wp-content/plugins/sitepress-multilingual-cms/inc/functions.php

      P/S You do at your own risk, Make a backup before

    • Hi Alessio,

      As I suggested in my previous reply to Yoahn, it would be better if you could post a new thread in our Support Forum.

      Thanks.

    • Hi Maira,

      The white page means there is an error which is not displayed. You need to enable the WP_DEBUG to see this error (from your wp-config.php).

      Please contact the Support Forum: they can provide you more dedicated help.

      Thanks.

  2. How do I get access to wp-content/plugins/sitepress-multilingual-cms/inc/wp-nav-menus/ ? I’m looking in the plugin editor but can’t find this file…

    • Dany, you should do that using an FTP client: is never recommended to use the plugin editor, not just because it doesn’t give access to all files, as you noticed, but because if something goes wrong, your site could become unusable and you would need to use the FTP client anyway to solve this case.

      You can use FileZilla to connect via FTP: https://filezilla-project.org/
      If you don’t know how to login to your FTP client, please contact your hosting.

  3. Hi,
    I replaced the file with Filezilla but now I got a white page, so I have to set back the old file to solve the white page.

    grtz,
    Marjet

    • Hi Marjet,

      The white page means there is an error which is not displayed. You need to enable the WP_DEBUG to see this error (from your wp-config.php).

      Please contact the Support Forum: they can provide you with faster help.

      Thanks.

    • Michel, please post a support request in our forum, where they can help you troubleshooting and solving this issue.

  4. Hi,

    When i apply this fix i get the below errors in DEBUG.

    Fatal error: Call to undefined method SitePress::get_setting() in /var/www/html/wp-content/plugins/sitepress-multilingual-cms/inc/wp-nav-menus/iclNavMenu.class.php on line 121

    Any ideas?

    • Paul,

      Please make sure to apply this fix to the most recent version of WPML: from the error it seems you’re using an outdated version of WPML.

      If this does not solve the problem, please post a support request in our forum, where you can get a faster answer.

      Thanks.