Slightly tidier handling of bad responses in `render_featured`.

This commit is contained in:
And Finally 2021-11-10 17:24:14 +00:00
parent a40ed95c0f
commit b7520f3d9a
1 changed files with 7 additions and 1 deletions

View File

@ -94,8 +94,14 @@ class WC_Admin_Addons {
}
$response_code = intval( wp_remote_retrieve_response_code( $raw_featured ) );
if ( 200 !== $response_code ) {
self::output_empty();
return;
}
$featured = json_decode( wp_remote_retrieve_body( $raw_featured ) );
if ( empty( $featured ) || ! is_array( $featured ) || 200 !== $response_code ) {
if ( empty( $featured ) || ! is_array( $featured ) ) {
self::output_empty();
return;