Skip to content

Commit 57c0058

Browse files
committed
Addressed improvements feedback.
1 parent b433be3 commit 57c0058

File tree

5 files changed

+18
-2
lines changed

5 files changed

+18
-2
lines changed

includes/class-mailchimp-admin.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ public function admin_notices() {
206206

207207
// Display a notice if the access token is invalid/revoked.
208208
?>
209-
<div class="notice notice-warning is-dismissible">
209+
<div class="notice notice-error is-dismissible">
210210
<p>
211211
<?php
212212
$message = sprintf(

lib/mailchimp/mailchimp.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ public function get( $endpoint, $count = 10, $fields = array() ) {
122122
}
123123

124124
if ( is_array( $request ) && 200 === $request['response']['code'] ) {
125+
delete_option( 'mailchimp_sf_auth_error' );
125126
return json_decode( $request['body'], true );
126127
} elseif ( is_array( $request ) && $request['response']['code'] ) {
127128
// Check if Access Token is invalid/revoked.
@@ -168,6 +169,7 @@ public function post( $endpoint, $body, $method = 'POST' ) {
168169
$request = wp_remote_post( $url, $args );
169170

170171
if ( is_array( $request ) && 200 === $request['response']['code'] ) {
172+
delete_option( 'mailchimp_sf_auth_error' );
171173
return json_decode( $request['body'], true );
172174
} else {
173175
if ( is_wp_error( $request ) ) {

mailchimp.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1395,3 +1395,13 @@ function mailchimp_sf_get_access_token() {
13951395

13961396
return $access_token;
13971397
}
1398+
1399+
/**
1400+
* Should display Mailchimp Signup form.
1401+
*
1402+
* @since x.x.x
1403+
* @return bool
1404+
*/
1405+
function mailchimp_sf_should_display_form() {
1406+
return mailchimp_sf_get_api() && ! get_option( 'mailchimp_sf_auth_error' );
1407+
}

mailchimp_widget.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@
1212
* @return void
1313
*/
1414
function mailchimp_sf_signup_form( $args = array() ) {
15+
// Check if we should display the form.
16+
if ( ! mailchimp_sf_should_display_form() ) {
17+
return;
18+
}
1519

1620
$before_title = isset( $args['before_title'] ) ? $args['before_title'] : '';
1721
$after_title = isset( $args['after_title'] ) ? $args['after_title'] : '';

views/setup_page.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
?>
99
<div class="wrap">
10-
10+
<hr class="wp-header-end">
1111
<div class="mailchimp-header">
1212
<svg xmlns="http://www.w3.org/2000/svg" aria-label="<?php esc_attr_e( 'Mailchimp Freddie', 'mailchimp' ); ?>" width="40" height="40" fill="none" viewBox="0 0 40 40">
1313
<title><?php esc_html_e( 'Mailchimp Freddie', 'mailchimp' ); ?></title>

0 commit comments

Comments
 (0)