wp_get_http_headers() WordPress Function

The wp_get_http_headers() function is used to get the headers for a given URL. This is useful for debugging purposes or for checking the status of a given URL.

wp_get_http_headers( string $url, bool $deprecated = false ) #

Retrieve HTTP Headers from URL.


Parameters

$url

(string)(Required)URL to retrieve HTTP headers from.

$deprecated

(bool)(Optional)Not Used.

Default value: false


Top ↑

Return

(string|false) Headers on success, false on failure.


Top ↑

Source

File: wp-includes/functions.php

function wp_get_http_headers( $url, $deprecated = false ) {
	if ( ! empty( $deprecated ) ) {
		_deprecated_argument( __FUNCTION__, '2.7.0' );
	}

	$response = wp_safe_remote_head( $url );

	if ( is_wp_error( $response ) ) {
		return false;
	}

	return wp_remote_retrieve_headers( $response );
}


Top ↑

Changelog

Changelog
VersionDescription
1.5.1Introduced.

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.

Show More
Show More