Skip to content

Commit

Permalink
Fix the issue where error responses were stored as the capabilities a…
Browse files Browse the repository at this point in the history
…rray—checks for 200 status.
  • Loading branch information
wpscholar committed Nov 13, 2023
1 parent 1199939 commit 0f443ba
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions includes/SiteCapabilities.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public function all() {
/**
* Check if a capability exists.
*
* @param string $capability Capability name.
* @param string $capability Capability name.
*
* @return bool
*/
Expand All @@ -40,7 +40,7 @@ public function exists( $capability ) {
/**
* Get the value of a capability.
*
* @param string $capability Capability name.
* @param string $capability Capability name.
*
* @return bool
*/
Expand All @@ -67,7 +67,7 @@ public function fetch() {
)
);

if ( ! is_wp_error( $response ) ) {
if ( wp_remote_retrieve_response_code( $response ) === 200 && ! is_wp_error( $response ) ) {
$body = wp_remote_retrieve_body( $response );
$data = json_decode( $body, true );
if ( $data && is_array( $data ) ) {
Expand Down

0 comments on commit 0f443ba

Please sign in to comment.