Skip Navigation

Resolved

Reported for: WPML Multilingual CMS 3.6.3

Resolved in: 3.7.0

Overview of the issue

When you update to WPML 3.6.x you might encounter the following error:

PHP Fatal error:  Call to undefined function wp_get_upload_dir() in /public_html/wp-content/plugins/sitepress-multilingual-cms/classes/language-switcher/class-wpml-ls-templates.php on line 316

This error is caused when using an old version of WordPress. The function wp_get_upload_dir() was introduced in WordPress 4.5 version as you can read here

Workaround

This issue will be fixed in the upcoming version of WPML.

As a workaround, use the following steps:

  1. Edit the class-wpml-ls-templates.php file in the ../wp-content/plugins/sitepress-multilingual-cms/classes/language-switcher/ folder.
  2. On line 316, replace:
    $uploads = wp_get_upload_dir();
    with
    $uploads = wp_upload_dir( null, false );

11 Responses to “Call to undefined function wp_get_upload_dir()”

  1. Hi, it is not the same error, written so :

    Fatal error: Uncaught Error: Call to undefined function mysql_error() in /homepages/23/d515997560/htdocs/1/htdocs/wordpress/wp-content/plugins/sitepress-multilingual-cms/inc/sitepress-schema.php:310 Stack trace: #0 /homepages/23/d515997560/htdocs/1/htdocs/wordpress/wp-includes/class-wp-hook.php(298): icl_sitepress_activate(”) #1 /homepages/23/d515997560/htdocs/1/htdocs/wordpress/wp-includes/class-wp-hook.php(323): WP_Hook->apply_filters(”, Array) #2 /homepages/23/d515997560/htdocs/1/htdocs/wordpress/wp-includes/plugin.php(453): WP_Hook->do_action(Array) #3 /homepages/23/d515997560/htdocs/1/htdocs/wordpress/wp-admin/plugins.php(166): do_action(‘activate_sitepr…’) #4 {main} thrown in /homepages/23/d515997560/htdocs/1/htdocs/wordpress/wp-content/plugins/sitepress-multilingual-cms/inc/sitepress-schema.php on line 310

    Should I process in the same condition than over ?

    WP 4.7.2
    WPML 3.1.4
    twentytwelve theme

    Thank you, Pierre

    • Hello, Pierre
      You seem to be having quite an old version of WPML.
      Please note that the current release is WPML 3.6.3, and you are using WPML 3.1.4.
      It is recommended that yo use the latest version of WPML with WordPress 4.7.2 as version 3.1.4 is too old and may not be entirely compatible with all of the changes introduced in WordPress.

  2. Hi, I installed plugin, to one of my website http://www.namailt.lt/
    and I got it:

    Fatal error: Call to undefined function wp_get_upload_dir() in /home/namailt/domains/namailt.lt/public_html/wp-content/plugins/sitepress-multilingual-cms/classes/language-switcher/class-wpml-ls-templates.php on line 316

    I can’t now visit my website, and I can’t sign in my wordpress template, what’s next???

  3. I just installed all various WPML plugins and deactived this Poly…plugin, now I get this note here

    Fatal error: Call to undefined function wp_get_upload_dir() in /www/htdocs/w0138b50/countrypumpkinexploringtheworld.de/wp-content/plugins/sitepress-multilingual-cms/classes/language-switcher/class-wpml-ls-templates.php on line 316

    I cannot even open my website and I cannot go to a dashboard or anything.

    Thank you for help!!

    • It also seems to have got me a virus or something, either way I have lost my admin and website and I am not even able to update WordPress..

      Please Help :)!!

      • WPML will never got you “a virus or something” if it was downloaded either from our installer or from this site.
        I already responded to you on a way to fix the problems in my reply from before.

    • Hello,
      The quickest way to fix this problem is by applying the patch that is mentioned here in this post above.
      You can do that via FTP or your hosting panel.
      If you have troubles applying this, it would be better that you open a new ticket in our forum so that our specialists can help you fixing this.
      *They can ask you for credentials. Please do not provide credentials until they ask you and they activate the private reply in the forum.

      • Hello,

        I updated the plugin and I have the same problem: Fatal error: Call to undefined function wp_get_upload_dir() in /htdocs/wp-content/plugins/sitepress-multilingual-cms/classes/language-switcher/class-wpml-ls-templates.php on line 316

        My WordPress version is 4.0.16.

        I tried via FTP but the thing is that ../sitepress-multilingual-cms/.. folder is missing.

        How to proceed to get this solved??

        Thank you

        • Hello enrique,
          If you are getting that error, then you should follow the path in the error – /htdocs/wp-content/plugins/sitepress-multilingual-cms/classes/language-switcher/class-wpml-ls-templates.php
          Perhpas you are looking in the incorrect directory for the plugin.