|
@@ 177-183 (lines=7) @@
|
| 174 |
|
$response_code = wp_remote_retrieve_response_code( $result ); |
| 175 |
|
$body_json = json_decode( wp_remote_retrieve_body( $result ) ); |
| 176 |
|
|
| 177 |
|
if( 200 !== $response_code ) { |
| 178 |
|
if ( isset( $body_json->error ) ) { |
| 179 |
|
return new WP_Error( $body_json->error, $body_json->message ); |
| 180 |
|
} else { |
| 181 |
|
return new WP_Error( 'server_error', sprintf( __( "Request failed with code %s" ), $response_code ) ); |
| 182 |
|
} |
| 183 |
|
} |
| 184 |
|
|
| 185 |
|
if ( isset( $body_json->access_token ) ) { |
| 186 |
|
// check if this matches the existing token before replacing |
|
@@ 240-246 (lines=7) @@
|
| 237 |
|
$response_code = wp_remote_retrieve_response_code( $result ); |
| 238 |
|
$body_json = json_decode( wp_remote_retrieve_body( $result ) ); |
| 239 |
|
|
| 240 |
|
if( 200 !== $response_code ) { |
| 241 |
|
if ( isset( $body_json->error ) ) { |
| 242 |
|
return new WP_Error( $body_json->error, $body_json->message ); |
| 243 |
|
} else { |
| 244 |
|
return new WP_Error( 'server_error', sprintf( __( "Request failed with code %s" ), $response_code ) ); |
| 245 |
|
} |
| 246 |
|
} |
| 247 |
|
|
| 248 |
|
return true; |
| 249 |
|
} |