WordPress.org

Make WordPress Core

Ticket #35666: 35666.3.diff

File 35666.3.diff, 1.9 KB (added by westonruter, 5 years ago)
  • src/wp-includes/functions.php

    diff --git src/wp-includes/functions.php src/wp-includes/functions.php
    index e3f2560..c6a8b39 100644
    function _ajax_wp_die_handler( $message, $title = '', $args = array() ) { 
    28752875        );
    28762876        $r = wp_parse_args( $args, $defaults );
    28772877
    2878         if ( ! headers_sent() ) {
     2878        if ( ! headers_sent() && ( 0 === ob_get_level() || 0 === ob_get_length() ) ) {
    28792879                status_header( $r['response'] );
    28802880        }
    28812881        if ( is_scalar( $message ) )
    function _wp_json_prepare_data( $data ) { 
    31003100 *                           then print and die.
    31013101 * @param int   $status_code The HTTP status code to output.
    31023102 */
    3103 function wp_send_json( $response, $status_code = 200 ) {
     3103function wp_send_json( $response, $status_code = null ) {
    31043104        @header( 'Content-Type: application/json; charset=' . get_option( 'blog_charset' ) );
    3105         status_header( $status_code );
     3105        if ( null !== $status_code ) {
     3106                status_header( $status_code );
     3107        }
    31063108        echo wp_json_encode( $response );
    31073109        if ( wp_doing_ajax() )
    31083110                wp_die();
    function wp_send_json( $response, $status_code = 200 ) { 
    31193121 * @param mixed $data        Data to encode as JSON, then print and die.
    31203122 * @param int   $status_code The HTTP status code to output.
    31213123 */
    3122 function wp_send_json_success( $data = null, $status_code = 200 ) {
     3124function wp_send_json_success( $data = null, $status_code = null ) {
    31233125        $response = array( 'success' => true );
    31243126
    31253127        if ( isset( $data ) )
    function wp_send_json_success( $data = null, $status_code = 200 ) { 
    31433145 * @param mixed $data        Data to encode as JSON, then print and die.
    31443146 * @param int   $status_code The HTTP status code to output.
    31453147 */
    3146 function wp_send_json_error( $data = null, $status_code = 200 ) {
     3148function wp_send_json_error( $data = null, $status_code = null ) {
    31473149        $response = array( 'success' => false );
    31483150
    31493151        if ( isset( $data ) ) {