WP_REST_Request::set_headers( array $headers, bool $override = true )

In this article

Sets headers on the request.

Parameters

$headersarrayrequired
Map of header name to value.
$overridebooloptional
If true, replace the request’s headers. Otherwise, merge with existing.

Default:true

Source

public function set_headers( $headers, $override = true ) {
	if ( true === $override ) {
		$this->headers = array();
	}

	foreach ( $headers as $key => $value ) {
		$this->set_header( $key, $value );
	}
}

Changelog

VersionDescription
4.4.0Introduced.

User Contributed Notes

You must log in before being able to contribute a note or feedback.