From 76df079332601e0063147c2f60fe90d1a14a3d19 Mon Sep 17 00:00:00 2001 From: Dharmesh Patel Date: Fri, 4 Oct 2024 16:07:01 +0530 Subject: [PATCH] Add notice with migrate button on settings page to migrate to oAuth authentiacation. --- assets/css/admin.css | 18 ++++++++++ includes/class-mailchimp-admin.php | 54 ++++++++++++++++++++---------- 2 files changed, 55 insertions(+), 17 deletions(-) diff --git a/assets/css/admin.css b/assets/css/admin.css index 04403c2..5e05be8 100644 --- a/assets/css/admin.css +++ b/assets/css/admin.css @@ -523,6 +523,24 @@ body.toplevel_page_mailchimp_sf_options #footer-upgrade { clear: both; } +.migrate-to-oauth-wrapper { + margin: 1em 0; +} + +.migrate-to-oauth-wrapper .button.mailchimp-sf-button { + padding: 9px 16px; + line-height: 14px; +} + +.migrate-to-oauth-wrapper button.button.mailchimp-sf-button:disabled { + padding: 6px 16px; +} + +.migrate-to-oauth-wrapper button.button.mailchimp-sf-button svg { + width: 20px; + height: 20px; +} + .button.mailchimp-sf-button.button-secondary.small { background-color: transparent; } diff --git a/includes/class-mailchimp-admin.php b/includes/class-mailchimp-admin.php index 0a70f5d..6b1e0f8 100644 --- a/includes/class-mailchimp-admin.php +++ b/includes/class-mailchimp-admin.php @@ -338,29 +338,49 @@ public function admin_notices() { if ( ! current_user_can( 'manage_options' ) ) { return; } + $current_screen = get_current_screen(); // Display a deprecation notice if the user is using an API key to connect with Mailchimp. if ( get_option( 'mc_api_key', '' ) && ! get_option( 'mailchimp_sf_access_token', '' ) && mailchimp_sf_should_display_form() ) { - ?> -
-

- tag, %2$s - tag */ - __( '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 "Log in" button on the %1$splugin settings%2$s page.', 'mailchimp' ), - '', - '' - ); - - echo wp_kses( $message, array( 'a' => array( 'href' => array() ) ) ); - ?> -

-
- id ) { + ?> +
+

+ +

+
+ +
+
+ +
+

+ tag, %2$s - tag */ + __( 'Heads up! It looks like you\'re using an API key to connect with Mailchimp, which is now deprecated. Please migrate to new OAuth authentication by clicking the "Migrate to OAuth authentication" button on the %1$splugin settings%2$s page.', 'mailchimp' ), + '', + '' + ); + + echo wp_kses( $message, array( 'a' => array( 'href' => array() ) ) ); + ?> +

+
+ id ) { $api = mailchimp_sf_get_api(); if ( $api && 'waiting' === get_option( 'mailchimp_sf_waiting_for_login' ) ) {