wp_remote_retrieve_response_code

The timeline below displays how wordpress function wp_remote_retrieve_response_code has changed across different WordPress versions. If a version is not listed, refer to the next available version below.

WordPress Version: 6.1

/**
 * Retrieve only the response code from the raw response.
 *
 * Will return an empty string if incorrect parameter value is given.
 *
 * @since 2.7.0
 *
 * @param array|WP_Error $response HTTP response.
 * @return int|string The response code as an integer. Empty string if incorrect parameter given.
 */
function wp_remote_retrieve_response_code($response)
{
    if (is_wp_error($response) || !isset($response['response']) || !is_array($response['response'])) {
        return '';
    }
    return $response['response']['code'];
}

WordPress Version: 5.3

/**
 * Retrieve only the response code from the raw response.
 *
 * Will return an empty array if incorrect parameter value is given.
 *
 * @since 2.7.0
 *
 * @param array|WP_Error $response HTTP response.
 * @return int|string The response code as an integer. Empty string on incorrect parameter given.
 */
function wp_remote_retrieve_response_code($response)
{
    if (is_wp_error($response) || !isset($response['response']) || !is_array($response['response'])) {
        return '';
    }
    return $response['response']['code'];
}

WordPress Version: 4.1

/**
 * Retrieve only the response code from the raw response.
 *
 * Will return an empty array if incorrect parameter value is given.
 *
 * @since 2.7.0
 *
 * @param array $response HTTP response.
 * @return int|string The response code as an integer. Empty string on incorrect parameter given.
 */
function wp_remote_retrieve_response_code($response)
{
    if (is_wp_error($response) || !isset($response['response']) || !is_array($response['response'])) {
        return '';
    }
    return $response['response']['code'];
}

WordPress Version: 4.0

/**
 * Retrieve only the response code from the raw response.
 *
 * Will return an empty array if incorrect parameter value is given.
 *
 * @since 2.7.0
 *
 * @param array $response HTTP response.
 * @return string the response code. Empty string on incorrect parameter given.
 */
function wp_remote_retrieve_response_code($response)
{
    if (is_wp_error($response) || !isset($response['response']) || !is_array($response['response'])) {
        return '';
    }
    return $response['response']['code'];
}

WordPress Version: 3.7

/**
 * Retrieve only the response code from the raw response.
 *
 * Will return an empty array if incorrect parameter value is given.
 *
 * @since 2.7.0
 *
 * @param array $response HTTP response.
 * @return string the response code. Empty string on incorrect parameter given.
 */
function wp_remote_retrieve_response_code(&$response)
{
    if (is_wp_error($response) || !isset($response['response']) || !is_array($response['response'])) {
        return '';
    }
    return $response['response']['code'];
}