WP_REST_Request::__construct() WordPress Method

This method initializes a new WP_REST_Request object. It takes two parameters: $method - The HTTP method for the request. This can be 'GET', 'POST', 'PUT', 'PATCH', or 'DELETE'. $route - The REST API route for the request. This should be a string in the format '/path/to/resource'.

WP_REST_Request::__construct( string $method = '', string $route = '', array $attributes = array() ) #

Constructor.


Parameters

$method

(string)(Optional) Request method.

Default value: ''

$route

(string)(Optional) Request route.

Default value: ''

$attributes

(array)(Optional) Request attributes.

Default value: array()


Top ↑

Source

File: wp-includes/rest-api/class-wp-rest-request.php

	public function __construct( $method = '', $route = '', $attributes = array() ) {
		$this->params = array(
			'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 );
	}


Top ↑

Changelog

Changelog
VersionDescription
4.4.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.