• Hello. I have read several mentions of this error but most of the ways to resolve the issue include removing or changing some code. I am not a programmer and only have limited knowledge of HTML so how can I resolve this issue?

    The full error reads –
    Fatal error: Call to undefined function wp_json_encode() in /homepages/38/d104341871/htdocs/clickandbuilds/MitiMitiTaperia/wp-admin/includes/misc.php on line 668

    I cannot access the dashboard or edit any pages and cannot even see the page with code to remove/edit line 668. Any advice would be greatly appreciated.

    Thanks in advance.

Viewing 3 replies - 1 through 3 (of 3 total)
  • C W (VYSO)

    (@cyril-washbrook)

    This is a problem that quite a few people have experienced. You can start by trying to reinstall WordPress manually. Download the latest version of WordPress and carefully follow the steps on this page.

    If that’s the only method you are missing, here is the source code.
    Maybe just add it to the file?

    function wp_json_encode( $data, $options = 0, $depth = 512 ) {
        /*
         * json_encode() has had extra params added over the years.
         * $options was added in 5.3, and $depth in 5.5.
         * We need to make sure we call it with the correct arguments.
         */
        if ( version_compare( PHP_VERSION, '5.5', '>=' ) ) {
            $args = array( $data, $options, $depth );
        } elseif ( version_compare( PHP_VERSION, '5.3', '>=' ) ) {
            $args = array( $data, $options );
        } else {
            $args = array( $data );
        }
    
        $json = call_user_func_array( 'json_encode', $args );
    
        // If json_encode() was successful, no need to do more sanity checking.
        // ... unless we're in an old version of PHP, and json_encode() returned
        // a string containing 'null'. Then we need to do more sanity checking.
        if ( false !== $json && ( version_compare( PHP_VERSION, '5.5', '>=' ) || false === strpos( $json, 'null' ) ) )  {
            return $json;
        }
    
        try {
            $args[0] = _wp_json_sanity_check( $data, $depth );
        } catch ( Exception $e ) {
            return false;
        }
    
        return call_user_func_array( 'json_encode', $args );
    }
    Golden Lion Solutions

    (@golden-lion-solutions)

    travinum1 – thank you so much!!!! you saved my website!!! after weeks of searching and trying different things, my site is finally fixed thanks to you!!

    thanks a lot!

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Fatal error: Call to undefined function wp_json_encode() in’ is closed to new replies.