envelope_response example


        $result = apply_filters( 'rest_post_dispatch', rest_ensure_response( $result )$this$request );

        // Wrap the response in an envelope if asked for.         if ( isset( $_GET['_envelope'] ) ) {
            $embed  = isset( $_GET['_embed'] ) ? rest_parse_embed_param( $_GET['_embed'] ) : false;
            $result = $this->envelope_response( $result$embed );
        }

        // Send extra data from response objects.         $headers = $result->get_headers();
        $this->send_headers( $headers );

        $code = $result->get_status();
        $this->set_status( $code );

        /** * Filters whether the REST API request has already been served. * * Allow sending the request manually - by returning true, the API result * will not be sent to the client. * * @since 4.4.0 * * @param bool $served Whether the request has already been served. * Default false. * @param WP_HTTP_Response $result Result to send to the client. Usually a `WP_REST_Response`. * @param WP_REST_Request $request Request used to generate the response. * @param WP_REST_Server $server Server instance. */
Home | Imprint | This part of the site doesn't use cookies.