WP_REST_Request::get_header_as_array()publicWP 4.4.0

Retrieves header values from the request.

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

Хуков нет.

Возвращает

Массив|null. List of string values if set, null otherwise.

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

$WP_REST_Request = new WP_REST_Request();
$WP_REST_Request->get_header_as_array( $key );
$key(строка) (обязательный)
Header name, will be canonicalized to lowercase.

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

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

Код WP_REST_Request::get_header_as_array() WP 6.5.2

public function get_header_as_array( $key ) {
	$key = $this->canonicalize_header_name( $key );

	if ( ! isset( $this->headers[ $key ] ) ) {
		return null;
	}

	return $this->headers[ $key ];
}