Skip to content

Commit

Permalink
Remove class property that isn't used. If a GET request gives us an e…
Browse files Browse the repository at this point in the history
…rror, return that so we can display it
  • Loading branch information
dkotter committed Jul 1, 2024
1 parent 85009c7 commit 6b0f662
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 8 deletions.
11 changes: 4 additions & 7 deletions lib/mailchimp/mailchimp.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,6 @@ class MailChimp_API {
*/
public $key;

/**
* The API key
*
* @var string
*/
public $api_key;

/**
* The API url
*
Expand Down Expand Up @@ -101,6 +94,10 @@ public function get( $endpoint, $count = 10, $fields = array() ) {

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

if ( is_wp_error( $request ) ) {
return $request;
}

if ( is_array( $request ) && 200 === $request['response']['code'] ) {
return json_decode( $request['body'], true );
} elseif ( is_array( $request ) && $request['response']['code'] ) {
Expand Down
2 changes: 1 addition & 1 deletion mailchimp.php
Original file line number Diff line number Diff line change
Expand Up @@ -1223,7 +1223,7 @@ function mailchimp_sf_verify_key( $api ) {

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

0 comments on commit 6b0f662

Please sign in to comment.