WP_REST_Request::set_headers()publicWP 4.4.0

Sets headers on the request.

Метод класса: WP_REST_Request{}

Хуков нет.

Возвращает

null. Ничего (null).

Использование

$WP_REST_Request = new WP_REST_Request();
$WP_REST_Request->set_headers( $headers, $override );
$headers(массив) (обязательный)
Map of header name to value.
$override(true|false)
If true, replace the request's headers. Otherwise, merge with existing.
По умолчанию: true

Список изменений

С версии 4.4.0 Введена.

Код WP_REST_Request::set_headers() WP 6.5.2

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

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