Skip to content

Commit 6b0f662

Browse files
committed
Remove class property that isn't used. If a GET request gives us an error, return that so we can display it
1 parent 85009c7 commit 6b0f662

File tree

2 files changed

+5
-8
lines changed

2 files changed

+5
-8
lines changed

lib/mailchimp/mailchimp.php

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,6 @@ class MailChimp_API {
1717
*/
1818
public $key;
1919

20-
/**
21-
* The API key
22-
*
23-
* @var string
24-
*/
25-
public $api_key;
26-
2720
/**
2821
* The API url
2922
*
@@ -101,6 +94,10 @@ public function get( $endpoint, $count = 10, $fields = array() ) {
10194

10295
$request = wp_remote_get( $url, $args );
10396

97+
if ( is_wp_error( $request ) ) {
98+
return $request;
99+
}
100+
104101
if ( is_array( $request ) && 200 === $request['response']['code'] ) {
105102
return json_decode( $request['body'], true );
106103
} elseif ( is_array( $request ) && $request['response']['code'] ) {

mailchimp.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1223,7 +1223,7 @@ function mailchimp_sf_verify_key( $api ) {
12231223

12241224
// Might as well set this data if we have it already.
12251225
$valid_roles = array( 'owner', 'admin', 'manager' );
1226-
if ( in_array( $user['role'], $valid_roles, true ) ) {
1226+
if ( isset( $user['role'] ) && in_array( $user['role'], $valid_roles, true ) ) {
12271227
update_option( 'mc_api_key', $api->key );
12281228
update_option( 'mc_user', $user );
12291229
update_option( 'mc_datacenter', $api->datacenter );

0 commit comments

Comments
 (0)