Skip to content

Commit 4175774

Browse files
committed
Add admin notice for the API key deprecation.
1 parent 8cb0929 commit 4175774

File tree

1 file changed

+24
-1
lines changed

1 file changed

+24
-1
lines changed

includes/class-mailchimp-admin.php

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,9 +196,32 @@ public function verify_and_save_oauth_token( $access_token, $data_center ) {
196196
* @since x.x.x
197197
*/
198198
public function admin_notices() {
199+
if ( ! current_user_can( 'manage_options' ) ) {
200+
return;
201+
}
202+
203+
// Display a deprecation notice if the user is using an API key to connect with Mailchimp.
204+
if ( get_option( 'mc_api_key', '' ) && ! get_option( 'mailchimp_sf_access_token', '' ) && mailchimp_sf_should_display_form() ) {
205+
?>
206+
<div class="notice notice-warning is-dismissible">
207+
<p>
208+
<?php
209+
$message = sprintf(
210+
/* translators: Placeholders: %1$s - <a> tag, %2$s - </a> tag */
211+
__( 'Heads up! It looks like you\'re using an API key to connect with Mailchimp, which is now deprecated. Please log out and reconnect your Mailchimp account using the new OAuth authentication by clicking the "Connect Account" button on the %1$splugin settings%2$s page.', 'mailchimp' ),
212+
'<a href="' . esc_url( admin_url( 'admin.php?page=mailchimp_sf_options' ) ) . '">',
213+
'</a>'
214+
);
215+
216+
echo wp_kses( $message, array( 'a' => array( 'href' => array() ) ) );
217+
?>
218+
</p>
219+
</div>
220+
<?php
221+
}
222+
199223
if (
200224
! get_option( 'mailchimp_sf_auth_error', false ) ||
201-
! current_user_can( 'manage_options' ) ||
202225
! get_option( 'mailchimp_sf_access_token', '' )
203226
) {
204227
return;

0 commit comments

Comments
 (0)