wp_get_http_headers( string $url, bool $deprecated = false ): WpOrgRequestsUtilityCaseInsensitiveDictionary|false
Retrieves HTTP Headers from URL.
Parameters
-
$url
string Required -
URL to retrieve HTTP headers from.
-
$deprecated
bool Optional -
Not Used.
Default:
false
Return
WpOrgRequestsUtilityCaseInsensitiveDictionary|false Headers on success, false on failure.
Source
File: wp-includes/functions.php
.
View all references
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 );
}
Changelog
Version | Description |
---|---|
1.5.1 | Introduced. |
User Contributed Notes
You must log in before being able to contribute a note or feedback.
Use the returned class’ (WpOrgRequestsUtilityCaseInsensitiveDictionary) methods to get usable data:
Array
(
[server] => nginx
[date] => Sat, 09 Sep 2023 04:27:52 GMT
[content-type] => text/html; charset=UTF-8
[vary] => Accept-Encoding
[strict-transport-security] => max-age=3600
[x-olaf] => ⛄[link] => Array
(
[0] => ; rel=”https://api.w.org/”
[1] => ; rel=”alternate”; type=”application/json”
[2] => ; rel=shortlink
)
[x-frame-options] => SAMEORIGIN
[content-encoding] => gzip
[x-nc] => EXPIRED ord 1
)
nginx