diff --git a/includes/class-api.php b/includes/class-api.php index c0dded4..b3b6e9e 100644 --- a/includes/class-api.php +++ b/includes/class-api.php @@ -480,6 +480,14 @@ protected function send_request( $method, $path, $query = [], $args = [], $cache $body = json_decode( wp_remote_retrieve_body( $response ), true ); + if ( ! isset( $body['status'] ) || ! isset( $body['data'] ) ) { + return new WP_Error( + 'wp101-api', + __( 'The WP101 API request response was invalid.', 'wp101' ), + $body['data'] + ); + } + if ( 'fail' === $body['status'] ) { return new WP_Error( 'wp101-api',