bp_attachments_json_response( bool $success, bool $is_html4 = false, mixed $data = null )

Send a JSON response back to an Ajax upload request.

Description

Parameters

$success

(Required) True for a success, false otherwise.

$is_html4

(Optional) True if the Plupload runtime used is html4, false otherwise.

Default value: false

$data

(Optional) Data to encode as JSON, then print and die.

Default value: null

Source

File: bp-core/bp-core-attachments.php

995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
function bp_attachments_json_response( $success, $is_html4 = false, $data = null ) {
    $response = array( 'success' => $success );
 
    if ( isset( $data ) ) {
        $response['data'] = $data;
    }
 
    // Send regular json response.
    if ( ! $is_html4 ) {
        wp_send_json( $response );
 
    /**
     * Send specific json response
     * the html4 Plupload handler requires a text/html content-type for older IE.
     */
    } else {
        echo wp_json_encode( $response );
 
        wp_die();
    }
}

Changelog

Changelog
Version Description
BuddyPress 2.3.0 Introduced.

Questions?

We're always happy to help with code or other questions you might have! Search our developer docs, contact support, or connect with our sales team.