On this page
wp_remote_retrieve_header( array|WP_Error $response, string $header ): array|string
Retrieve a single header by name from the raw response.
Parameters
$responsearray|WP_Error Required-
HTTP response.
$headerstring Required-
Header name to retrieve value from.
Return
array|string The header(s) value(s). Array if multiple headers with the same name are retrieved.
Empty string if incorrect parameter given, or if the header doesn't exist.
Source
File: wp-includes/http.php. View all references
function wp_remote_retrieve_header( $response, $header ) {
if ( is_wp_error( $response ) || ! isset( $response['headers'] ) ) {
return '';
}
if ( isset( $response['headers'][ $header ] ) ) {
return $response['headers'][ $header ];
}
return '';
}
Related
Uses
| Uses | Description |
|---|---|
| is_wp_error() wp-includes/load.php | Checks whether the given variable is a WordPress Error. |
Used By
| Used By | Description |
|---|---|
| WP_Site_Health::check_for_page_caching() wp-admin/includes/class-wp-site-health.php | Checks if site has page cache enabled or not. |
| wp_install_maybe_enable_pretty_permalinks() wp-admin/includes/upgrade.php | Maybe enable pretty permalinks on installation. |
| download_url() wp-admin/includes/file.php | Downloads a URL to a local temporary file using the WordPress HTTP API. |
| discover_pingback_server_uri() wp-includes/comment.php | Finds a pingback server URI based on the given URL. |
Changelog
| Version | Description |
|---|---|
| 2.7.0 | Introduced. |
© 2003–2022 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/functions/wp_remote_retrieve_header