| Server IP : 52.25.153.185 / Your IP : 216.73.217.117 Web Server : Apache System : Linux ip-172-26-6-158 5.10.0-45-cloud-amd64 #1 SMP Debian 5.10.259-1 (2026-07-02) x86_64 User : daemon ( 1) PHP Version : 8.1.10 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : OFF Directory : /bitnami/wordpress/wp-content/plugins/code-snippets/php/Utils/ |
Upload File : |
<?php
/**
* A collection of utilities for handling REST requests and responses.
*
* @package Code_Snippets
*/
namespace Code_Snippets\Utils;
use WP_Error;
/**
* Unpack JSON data from a request response.
*
* @param array|WP_Error $response Response from wp_request_*.
*
* @return array<string, mixed>|null Associative array of JSON data on success, null on failure.
*/
function unpack_response_body( $response ): ?array {
$body = wp_remote_retrieve_body( $response );
if ( $body ) {
$json = json_decode( $body, true );
return is_array( $json ) ? $json : null;
}
return null;
}