Support » Plugin: WCM User Language Switcher » Fatal error: json_last_error

  • Resolved Jarrel


    I´m desperate!

    I downloaded plugin to translate my Swedish homepage to English, but when I activated the program I just got a massage saying:

    Fatal error: Call to undefined function json_last_error() in /home/userA/a1319300/public_html/ on line 249

    Now I can´t do anything with my wordpress page!!! What am I suppose to do? How can I undefine the function json_lasr_error? Call line 249… what?

    Please help!

Viewing 15 replies - 1 through 15 (of 18 total)
  • Jarrel

    I am in the same spot you were my fatal error reads:

    Fatal error: Call to undefined function json_last_error() in /home/content/c/a/m/cambiame/html/wordpress/wp-content/plugins/wcm-user-language-switcher/wcm_lang_switch.class.php on line 249

    Were you able to fix your your problem?

    If so, what did you do?

    I need help.

    I am not a developer but I am looking through the plugin files
    Source file found at:

    I’m pasting this here in case this helps someone to figure out the problem faster.

    This is what I see at line 249 of ‘…/wcm_lang_switch.class.php’:

    return apply_filters( ‘wcm_get_langs’, array_merge(

    You can see the code around line 249 below:

    * Get Languages
    * @since 0.3
    * @return array
    public function get_langs()
    return apply_filters( ‘wcm_get_langs’, array_merge(
    ,array( ‘en_US’ )
    ) );

    Plugin Author Franz Josef Kaiser


    Hi Jarrel & DanMo2013

    Sorry to say, but we’ve completely missed out your error report. We will investigate this today and get back to you. Please – in the meantime – just go to GitHub [1] where the development versions are and download a working copy.

    The error itself is just a typo. Nothing to worry about.

    Thanks for your reports!

    [1] GitHub

    Plugin Author Franz Josef Kaiser


    I checked source [1] after reading Jarrels note about the missing function “json_lasr_error” and tought we had a typo, but this is clearly not the case. Now the function “json_last_error()” was introduced to PHP with version 5 [2].

    Could you please check what PHP version you got? Simply install the following plugin or check your admin account at your hoster (or ask them). The minimum required version for WordPress itself currently is 5.2.1 and for this plugin it’s 5.0.0. So far I think you both just haven’t got a current PHP version running.

    /* Plugin Name: Show PHP Version after footer */
    add_action( 'shutdown', 'wcm_show_php_version' );
    function wcm_show_php_version()
        if ( version_compare( PHP_VERSION, '5.0.0', '>=' ) )
            printf( 'I am using PHP 5, my version is: %s', PHP_VERSION );

    Please come back with more info.


    Plugin Author Franz Josef Kaiser


    After some googlefoo, it could be that the info on about the version when json_last_error() was introduced (5.0.0) is simply wrong and this function was introduced with (5.3.0). Please come back with more info and we’ll alter the error check according to your report. Thanks.

    Wish you a nice Sunday.

    Franz thanks for your quick reply and for helping us out.

    I am running php version 5.2.17

    Plugin Author Franz Josef Kaiser


    Ok, I’ll try to find a way around it and push a working version to GitHub. You’ll be able to work with this one and an update for the version will follow. We anyway wanted to do one as we got plenty of changes and improvements already built in on GitHub that aren’t in the current .org version.

    Plugin Author Franz Josef Kaiser


    There’s now a working version on GitHub where I fixed it. I misread the minimum required version number on for json_last_error() and it is indeed only available for people running PHP 5.3.0+.

    Please do a test of the new version and report your outcome at this issue.


    This is what I did:

    I went to Github:
    registered in Github
    downloaded the zip folder for wcm_lang_switch

    unzipped the folder and I changed the name of the folder from “wcm_lang_switch-master” to “wcm-user-language-switcher”

    Used ftp to remove the existing wcm_lang_switch folder (found under WordPress/plugins/wcm-user-language-switcher and replaced it with the one downloaded from github.

    I cleared the recent history in my browser (cookies, cache) and refreshed my browser.

    Now I can see the label “English” on the top of the page, on the admin bar.

    So, it seems to work.

    Thanks for fixing this.

    Wish you a nice Sunday.

    Plugin Author Franz Josef Kaiser


    You’re welcome. Could we switch this to resolved now?


    Yes. Thank you again.

    Plugin Author Franz Josef Kaiser


    @danmo2013 Are you able to mark it as such? I somehow can’t.

    It may be that since Jarrel started the support request, he or she is the one that has the option to set it to Resolved.

    function isJson($string) {
    return ((is_string($string) && (is_object(json_decode($string)) || is_array(json_decode($string))))) ? true : false;//PHP Version 5.2.17 server
    //return (json_last_error() == JSON_ERROR_NONE);//PHP Version 5.3.10-1ubuntu3.6 mylocal

    Plugin Author Franz Josef Kaiser


    @jaybharatjay What exactly are you trying to tell us?

Viewing 15 replies - 1 through 15 (of 18 total)
  • The topic ‘Fatal error: json_last_error’ is closed to new replies.