WP_REST_Server::envelope_response PHP Méthode

envelope_response() public méthode

The enveloping technique is used to work around browser/client compatibility issues. Essentially, it converts the full HTTP response to data instead.
Since: 4.4.0
public envelope_response ( WP_REST_Response $response, boolean $embed ) : WP_REST_Response
$response WP_REST_Response Response object.
$embed boolean Whether links should be embedded.
Résultat WP_REST_Response New response with wrapped data
    public function envelope_response($response, $embed)
        $envelope = array('body' => $this->response_to_data($response, $embed), 'status' => $response->get_status(), 'headers' => $response->get_headers());
         * Filters the enveloped form of a response.
         * @since 4.4.0
         * @param array            $envelope Envelope data.
         * @param WP_REST_Response $response Original response data.
        $envelope = apply_filters('rest_envelope_response', $envelope, $response);
        // Ensure it's still a response and return.
        return rest_ensure_response($envelope);