WordPress.org

Ready to get started?Download WordPress

Forums

WCM User Language Switcher
[resolved] Fatal error: json_last_error (19 posts)

  1. Jarrel
    Member
    Posted 1 year ago #

    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/jarrelgolf.com/wp-content/plugins/wcm-user-language-switcher/wcm_lang_switch.class.php 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!

    http://wordpress.org/extend/plugins/wcm-user-language-switcher/

  2. DanMo2013
    Member
    Posted 1 year ago #

    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.

  3. DanMo2013
    Member
    Posted 1 year ago #

    I am not a developer but I am looking through the plugin files
    Source file found at: https://github.com/wecodemore/wcm_lang_switch/blob/master/wcm_lang_switch.class.php

    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(
    get_available_languages()
    ,array( 'en_US' )
    ) );
    }

  4. Franz Josef Kaiser
    Member
    Plugin Author

    Posted 1 year ago #

    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!
    Kaiser.

    [1] GitHub https://github.com/wecodemore/wcm_lang_switch

  5. Franz Josef Kaiser
    Member
    Plugin Author

    Posted 1 year ago #

    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.

    <?php
    /* 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.

    [1] http://plugins.trac.wordpress.org/browser/wcm-user-language-switcher/trunk/wcm_lang_switch.class.php#L249
    [2] http://php.net/manual/en/function.json-last-error.php

  6. Franz Josef Kaiser
    Member
    Plugin Author

    Posted 1 year ago #

    After some googlefoo, it could be that the info on PHP.net 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.

  7. DanMo2013
    Member
    Posted 1 year ago #

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

    I am running php version 5.2.17

  8. Franz Josef Kaiser
    Member
    Plugin Author

    Posted 1 year ago #

    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 wp.org 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.

  9. Franz Josef Kaiser
    Member
    Plugin Author

    Posted 1 year ago #

    There's now a working version on GitHub where I fixed it. I misread the minimum required version number on PHP.net 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.

    Thanks.

  10. DanMo2013
    Member
    Posted 1 year ago #

    This is what I did:

    I went to Github: https://github.com/wecodemore/wcm_lang_switch
    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.

  11. Franz Josef Kaiser
    Member
    Plugin Author

    Posted 1 year ago #

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

    RESOLVED

  12. DanMo2013
    Member
    Posted 1 year ago #

    Yes. Thank you again.

  13. Franz Josef Kaiser
    Member
    Plugin Author

    Posted 1 year ago #

    @DanMo2013 Are you able to mark it as such? I somehow can't.

  14. DanMo2013
    Member
    Posted 1 year ago #

    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.

  15. jaybharatjay
    Member
    Posted 11 months ago #

    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
    //json_decode($string);
    //return (json_last_error() == JSON_ERROR_NONE);//PHP Version 5.3.10-1ubuntu3.6 mylocal
    }

  16. Franz Josef Kaiser
    Member
    Plugin Author

    Posted 11 months ago #

    @jaybharatjay What exactly are you trying to tell us?

  17. jaybharatjay
    Member
    Posted 11 months ago #

    I am saying if your php 5.2.x version not supporting the
    json_last_error()
    then one solution for that i.e:
    return ((is_string($string) && (is_object(json_decode($string)) || is_array(json_decode($string))))) ? true : false;

  18. Franz Josef Kaiser
    Member
    Plugin Author

    Posted 11 months ago #

    @jaybharatjay The issue is already resolved. The OP just didn't mark it as such. You can see the details on GitHub.

    Anyway: Thanks for your efforts :)

  19. jaybharatjay
    Member
    Posted 11 months ago #

    My solution is universal like for core php developer also.:)

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags

No tags yet.