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

Send a JSON response back to an Ajax upload request.


Parameters Parameters

$success

(bool) (Required) True for a success, false otherwise.

$is_html4

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

Default value: false

$data

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

Default value: null


Source Source

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

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.
	 * See https://core.trac.wordpress.org/ticket/31037
	 */
	} else {
		echo wp_json_encode( $response );

		wp_die();
	}
}


Top ↑

Changelog Changelog

Changelog
Version Description
2.3.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.