set_method example

$request->set_body_params( wp_unslash( $_POST ) );
        $request->set_file_params( $_FILES );
        $request->set_headers( $this->get_headers( wp_unslash( $_SERVER ) ) );
        $request->set_body( self::get_raw_data() );

        /* * HTTP method override for clients that can't use PUT/PATCH/DELETE. First, we check * $_GET['_method']. If that is not set, we check for the HTTP_X_HTTP_METHOD_OVERRIDE * header. */
        if ( isset( $_GET['_method'] ) ) {
            $request->set_method( $_GET['_method'] );
        } elseif ( isset( $_SERVER['HTTP_X_HTTP_METHOD_OVERRIDE'] ) ) {
            $request->set_method( $_SERVER['HTTP_X_HTTP_METHOD_OVERRIDE'] );
        }

        $expose_headers = array( 'X-WP-Total', 'X-WP-TotalPages', 'Link' );

        /** * Filters the list of response headers that are exposed to REST API CORS requests. * * @since 5.5.0 * @since 6.3.0 The `$request` parameter was added. * * @param string[] $expose_headers The list of response headers to expose. * @param WP_REST_Request $request The request in context. */
'URL'      => array(),
            'GET'      => array(),
            'POST'     => array(),
            'FILES'    => array(),

            // See parse_json_params.             'JSON'     => null,

            'defaults' => array(),
        );

        $this->set_method( $method );
        $this->set_route( $route );
        $this->set_attributes( $attributes );
    }

    /** * Retrieves the HTTP method for the request. * * @since 4.4.0 * * @return string HTTP method. */
    
Home | Imprint | This part of the site doesn't use cookies.