WordPress.org

Make WordPress Core

Ticket #36358: 36358-patch2-_wp_json_prepare_data.patch

File 36358-patch2-_wp_json_prepare_data.patch, 1.3 KB (added by jrf, 6 years ago)
  • src/wp-includes/functions.php

    From fced7be5798fc694796c1446c4316711184417b8 Mon Sep 17 00:00:00 2001
    From: jrfnl <github_nospam@adviesenzo.nl>
    Date: Mon, 28 Mar 2016 18:33:06 +0200
    Subject: [PATCH] Fix _wp_json_prepare_data() was called too late.
    
    ---
     src/wp-includes/functions.php | 7 ++++---
     1 file changed, 4 insertions(+), 3 deletions(-)
    
    diff --git a/src/wp-includes/functions.php b/src/wp-includes/functions.php
    index 0e720ee..6d8e3b6 100644
    a b function _scalar_wp_die_handler( $message = '' ) { 
    28482848 * @return string|false The JSON encoded string, or false if it cannot be encoded.
    28492849 */
    28502850function wp_json_encode( $data, $options = 0, $depth = 512 ) {
     2851
     2852        // Prepare the data for JSON serialization.
     2853        $data = _wp_json_prepare_data( $data );
     2854
    28512855        /*
    28522856         * json_encode() has had extra params added over the years.
    28532857         * $options was added in 5.3, and $depth in 5.5.
    function wp_json_encode( $data, $options = 0, $depth = 512 ) { 
    28612865                $args = array( $data );
    28622866        }
    28632867
    2864         // Prepare the data for JSON serialization.
    2865         $data = _wp_json_prepare_data( $data );
    2866 
    28672868        $json = @call_user_func_array( 'json_encode', $args );
    28682869
    28692870        // If json_encode() was successful, no need to do more sanity checking.