wp_get_http_headers

Retrieve HTTP Headers from URL.

Description

(bool|string) wp_get_http_headers( (string) $url, (bool) $deprecated = false ); 

Returns (bool|string)

False on failure, headers on success.

Parameters (2)

0. $url (string)
URL to retrieve HTTP headers from.
1. $deprecated — Optional. (bool) => false
The deprecated.

Usage

  1. if ( !function_exists( 'wp_get_http_headers' ) ) { 
  2. require_once ABSPATH . WPINC . '/functions.php'; 
  3.  
  4. // URL to retrieve HTTP headers from. 
  5. $url = ''; 
  6.  
  7. // The deprecated. 
  8. $deprecated = false; 
  9.  
  10. // NOTICE! Understand what this does before running. 
  11. $result = wp_get_http_headers($url, $deprecated); 
  12.  

Defined (1)

The function is defined in the following location(s).

/wp-includes/functions.php  
  1. function wp_get_http_headers( $url, $deprecated = false ) { 
  2. if ( !empty( $deprecated ) ) 
  3. _deprecated_argument( __FUNCTION__, '2.7.0' ); 
  4.  
  5. $response = wp_safe_remote_head( $url ); 
  6.  
  7. if ( is_wp_error( $response ) ) 
  8. return false; 
  9.  
  10. return wp_remote_retrieve_headers( $response );