wp_remote_retrieve_response_code

Retrieve only the response code from the raw response.

Description

(int|string) wp_remote_retrieve_response_code( (array) $response ); 

Will return an empty array if incorrect parameter value is given.

Returns (int|string)

The response code as an integer. Empty string on incorrect parameter given.

Parameters (1)

0. $response (array)
HTTP response.

Usage

  1. if ( !function_exists( 'wp_remote_retrieve_response_code' ) ) { 
  2. require_once ABSPATH . WPINC . '/http.php'; 
  3.  
  4. // HTTP response. 
  5. $response = array(); 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = wp_remote_retrieve_response_code($response); 
  9.  

Defined (1)

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

/wp-includes/http.php  
  1. function wp_remote_retrieve_response_code( $response ) { 
  2. if ( is_wp_error($response) || ! isset($response['response']) || ! is_array($response['response'])) 
  3. return ''; 
  4.  
  5. return $response['response']['code'];