send_headers 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. */
public function main( $query_args = '' ) {
        $this->init();

        $parsed = $this->parse_request( $query_args );

        if ( $parsed ) {
            $this->query_posts();
            $this->handle_404();
            $this->register_globals();
        }

        $this->send_headers();

        /** * Fires once the WordPress environment has been set up. * * @since 2.1.0 * * @param WP $wp Current WordPress environment instance (passed by reference). */
        do_action_ref_array( 'wp', array( &$this ) );
    }
}
Home | Imprint | This part of the site doesn't use cookies.