From 8bf8ccff4507fc0662e778c84894e9ce7cd14f37 Mon Sep 17 00:00:00 2001 From: Dharmesh Patel Date: Fri, 4 Oct 2024 16:00:52 +0530 Subject: [PATCH 1/5] Move login button to separate template for reuse. --- includes/admin/templates/login-button.php | 22 +++++++++++++++++++ includes/admin/templates/suggest-to-login.php | 17 ++++---------- 2 files changed, 26 insertions(+), 13 deletions(-) create mode 100644 includes/admin/templates/login-button.php diff --git a/includes/admin/templates/login-button.php b/includes/admin/templates/login-button.php new file mode 100644 index 00000000..4629a45f --- /dev/null +++ b/includes/admin/templates/login-button.php @@ -0,0 +1,22 @@ + + + + diff --git a/includes/admin/templates/suggest-to-login.php b/includes/admin/templates/suggest-to-login.php index 63e5b677..a05357fa 100644 --- a/includes/admin/templates/suggest-to-login.php +++ b/includes/admin/templates/suggest-to-login.php @@ -26,18 +26,9 @@ ?>

- - - + From 76df079332601e0063147c2f60fe90d1a14a3d19 Mon Sep 17 00:00:00 2001 From: Dharmesh Patel Date: Fri, 4 Oct 2024 16:07:01 +0530 Subject: [PATCH 2/5] 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 04403c22..5e05be8b 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 0a70f5d7..6b1e0f8d 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' ) ) { From 50dc80264152f232641ab89d8516714b73a0c595 Mon Sep 17 00:00:00 2001 From: Dharmesh Patel Date: Fri, 4 Oct 2024 16:13:51 +0530 Subject: [PATCH 3/5] remove `mc_api_key` during new login, as we are directly migrating to without logout. --- includes/class-mailchimp-admin.php | 1 + 1 file changed, 1 insertion(+) diff --git a/includes/class-mailchimp-admin.php b/includes/class-mailchimp-admin.php index 6b1e0f8d..fe0f2fd5 100644 --- a/includes/class-mailchimp-admin.php +++ b/includes/class-mailchimp-admin.php @@ -299,6 +299,7 @@ public function verify_and_save_oauth_token( $access_token, $data_center ) { $data_encryption = new Mailchimp_Data_Encryption(); // Clean up the old data. + delete_option( 'mc_api_key' ); // Deprecated API key, need to remove as part of the migration. delete_option( 'mailchimp_sf_access_token' ); delete_option( 'mailchimp_sf_auth_error' ); delete_option( 'mc_datacenter' ); From 9311a71709bdd5fd985daaca059b77ef91b30f1a Mon Sep 17 00:00:00 2001 From: Dharmesh Patel Date: Fri, 4 Oct 2024 19:12:12 +0530 Subject: [PATCH 4/5] Wording updates to migrate notice on settings page. --- includes/class-mailchimp-admin.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/includes/class-mailchimp-admin.php b/includes/class-mailchimp-admin.php index fe0f2fd5..f92ea51c 100644 --- a/includes/class-mailchimp-admin.php +++ b/includes/class-mailchimp-admin.php @@ -349,7 +349,7 @@ public function admin_notices() {

From 9135ab082054a1fb75b79248630e02adcd5b1007 Mon Sep 17 00:00:00 2001 From: Dharmesh Patel Date: Fri, 4 Oct 2024 19:21:53 +0530 Subject: [PATCH 5/5] Wording updates to migration notice. --- includes/class-mailchimp-admin.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/includes/class-mailchimp-admin.php b/includes/class-mailchimp-admin.php index f92ea51c..e5b77b20 100644 --- a/includes/class-mailchimp-admin.php +++ b/includes/class-mailchimp-admin.php @@ -368,7 +368,7 @@ public function admin_notices() { 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' ), + __( 'You are using an outdated API Key connection to Mailchimp, please migrate to the new OAuth authentication method to continue accessing your Mailchimp account by clicking the "Migrate to OAuth authentication" button on the %1$sMailchimp settings%2$s page.', 'mailchimp' ), '', '' );