WP_REST_Server::remove_header( string $key )

Removes an HTTP header from the current response.


Parameters

$key

(Required) Header key.


Source

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

	public function remove_header( $key ) {
		if ( function_exists( 'header_remove' ) ) {
			// In PHP 5.3+ there is a way to remove an already set header.
			header_remove( $key );
		} else {
			// In PHP 5.2, send an empty header, but only as a last resort to
			// override a header already sent.
			foreach ( headers_list() as $header ) {
				if ( 0 === stripos( $header, "$key:" ) ) {
					$this->send_header( $key, '' );
					break;
				}
			}
		}
	}


Changelog

Changelog
Version Description
WP-4.8.0 Introduced.