Making WordPress.org

Changeset 4567


Ignore:
Timestamp:
12/22/2016 01:57:11 AM (7 years ago)
Author:
dd32
Message:

Plugin Directory: When running on WordPress.org infrastructure, include wp_json_encode() from our API includes in the event that WordPress wasn't loaded on this request.
This fixes cases where API results were incorrectly encoded due to UTF8 issues, which ultimately caused json_encode() to fail.

See #2112

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/standalone/class-plugins-info-api.php

    r4566 r4567  
    246246            case 'json' :
    247247            case 'jsonp' :
    248                 $json = json_encode( $response );
     248                if ( ! function_exists( 'wp_json_encode' ) && defined( 'WPORGAPIPATH' ) ) {
     249                    require WPORGAPIPATH . '/includes/wp-json-encode.php';
     250                }
     251                $json = function_exists( 'wp_json_encode' ) ? wp_json_encode( $response ) : json_encode( $response );
    249252                if ( 'jsonp' == $this->format ) {
    250253                    echo "{$this->jsonp}($json)";
Note: See TracChangeset for help on using the changeset viewer.