Skip to content

Commit 8ae03f8

Browse files
committed
Merge branch 'develop'
2 parents d7ed3cc + 2a844b7 commit 8ae03f8

11 files changed

+198
-111
lines changed

.github/workflows/codeql-analysis.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,12 @@ jobs:
3737
uses: actions/checkout@v4
3838

3939
- name: Initialize CodeQL
40-
uses: github/codeql-action/init@v2
40+
uses: github/codeql-action/init@v3
4141
with:
4242
languages: ${{ matrix.language }}
4343

4444
- name: Autobuild
45-
uses: github/codeql-action/autobuild@v2
45+
uses: github/codeql-action/autobuild@v3
4646

4747
- name: Perform CodeQL Analysis
48-
uses: github/codeql-action/analyze@v2
48+
uses: github/codeql-action/analyze@v3

CHANGELOG.md

+12
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,18 @@ All notable changes to this project will be documented in this file, per [the Ke
44

55
## [Unreleased] - TBD
66

7+
## [1.6.1] - 2024-10-14
8+
### Changed
9+
- Improved migration flow from API Key to OAuth authentication for a better user experience (props [@iamdharmesh](https://github.com/iamdharmesh), [@jeffpaul](https://github.com/jeffpaul), [@dkotter](https://github.com/dkotter), [@qasumitbagthariya](https://github.com/qasumitbagthariya) via [#67](https://github.com/mailchimp/wordpress/pull/67)).
10+
- Updated the menu SVG icon (props [@dkotter](https://github.com/dkotter), [@jeffpaul](https://github.com/jeffpaul) via [#65](https://github.com/mailchimp/wordpress/pull/65)).
11+
12+
### Fixed
13+
- Ensure that the settings remain persistent between logging out of the account and logging in again (props [@iamdharmesh](https://github.com/iamdharmesh), [@jeffpaul](https://github.com/jeffpaul), [@dkotter](https://github.com/dkotter), [@qasumitbagthariya](https://github.com/qasumitbagthariya) via [#66](https://github.com/mailchimp/wordpress/pull/66)).
14+
15+
### Security
16+
- Bump `serve-static` from 1.15.0 to 1.16.2 and `express` from 4.19.2 to 4.21.0 (props [@dependabot](https://github.com/apps/dependabot), [@dkotter](https://github.com/dkotter) via [#55](https://github.com/mailchimp/wordpress/pull/55)).
17+
- Bump `webpack` from 5.91.0 to 5.94.0 (props [@dependabot](https://github.com/apps/dependabot), [@dkotter](https://github.com/dkotter) via [#59](https://github.com/mailchimp/wordpress/pull/59)).
18+
719
## [1.6.0] - 2024-09-24
820
**Note this version increased the WordPress minimum version to 6.1 and the PHP minimum version to 7.0.**
921

CREDITS.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ The following individuals are responsible for curating the list of issues, respo
1212

1313
Thank you to all the people who have already contributed to this repository via bug reports, code, design, ideas, project management, translation, testing, etc.
1414

15-
[Mailchimp (@mailchimp)](https://github.com/mailchimp), [Crowd Favorite (@crowdfavorite)](https://github.com/crowdfavorite), [Matthew Richmond (@bigdawggi)](https://github.com/bigdawggi), [Devin Reams (@devinreams)](https://github.com/devinreams), [Alex King (@alexkingorg)](https://github.com/alexkingorg), [Jesse (@jessedp)](https://github.com/jessedp), [Andrew Ellis]([email protected]), [Evan Anderson (@ejdanderson)](https://github.com/ejdanderson), [Webb Henderson (@emerywebster)](https://github.com/emerywebster), [Steven Mathias (@ssmathias)](https://github.com/ssmathias), [Jonathan D. Johnson (@jondavidjohn)](https://github.com/jondavidjohn), [Ross Tweedie (@digitales)](https://github.com/digitales), [(@mcwill)](https://github.com/mcwill), [Andrew Austin (@andrewjaustin)](https://github.com/andrewjaustin), [Marc Queralt i Bassa (@MarcQueralt)](https://github.com/MarcQueralt), [Chris Mospaw (@mospaw)](https://github.com/mospaw), [Jonas Stensved (@jstensved)](https://github.com/jstensved), [netboy]([email protected]), [Lenin]([email protected]), [Bauke Zwaan (@baukezwaan)](https://github.com/baukezwaan), [Jascha Ehrenreich (@jaeh)](https://github.com/jaeh), [Chris Wilcoxson (@slushman)](https://github.com/slushman), [Luke Watts (@thisislawatts)](https://github.com/thisislawatts), [Glenn Ansley (@glennansley)](https://github.com/glennansley), [SiteGround](http://www.siteground.com/wordpress-hosting.htm), [Peter Kahoun](http://kahi.cz/), [Jan Lund](), [Michael Jaekel](), [Ιωάννης Δημοφέρλιας (John Dimoferlias)](), [Tomás Nader](), [Claudia Mansilla](http://cricava.com/), [Helen Urbanik](http://www.motomaania.ee/), [Maxime Toulliou](http://www.maximetoulliou.com/), [שגיב בית](http://www.sagive.co.il), [Okostobi](), [Stefan Des](http://www.stefandes.com), [백선기 (SK Baek)](), [Alexander Roterud aka Defrag](http://www.tigerpews.com), [Filip Stas](http://suddenelfilio.net/), [Maria Manoela Porto](), [Tiago Faria](http://xroot.org), [Alexandru Armin Roșu](), [Илья](http://fatcow.com), [Sebastian Johnsson](http://www.agiley.se/), [Hakan E.](http://kazancexpert.com/), [Josh Grosser (@jgrosser-intuit)](https://github.com/jgrosser-intuit), [10up (@10up)](https://github.com/10up), [Nate Conley (@nateconley)](https://github.com/nateconley), [Darin Kotter (@dkotter)](https://github.com/dkotter), [Jeffrey Paul (@jeffpaul)](https://github.com/jeffpaul), [Eddie Shrake (@eddieshrake)](https://github.com/eddieshrake), [Sumit Bagthariya (@qasumitbagthariya)](https://github.com/qasumitbagthariya), [Vikram Moparthy (@vikrampm1)](https://github.com/vikrampm1), [Dharmesh Patel (@iamdharmesh)](https://github.com/iamdharmesh).
15+
[Mailchimp (@mailchimp)](https://github.com/mailchimp), [Crowd Favorite (@crowdfavorite)](https://github.com/crowdfavorite), [Matthew Richmond (@bigdawggi)](https://github.com/bigdawggi), [Devin Reams (@devinreams)](https://github.com/devinreams), [Alex King (@alexkingorg)](https://github.com/alexkingorg), [Jesse (@jessedp)](https://github.com/jessedp), [Andrew Ellis]([email protected]), [Evan Anderson (@ejdanderson)](https://github.com/ejdanderson), [Webb Henderson (@emerywebster)](https://github.com/emerywebster), [Steven Mathias (@ssmathias)](https://github.com/ssmathias), [Jonathan D. Johnson (@jondavidjohn)](https://github.com/jondavidjohn), [Ross Tweedie (@digitales)](https://github.com/digitales), [(@mcwill)](https://github.com/mcwill), [Andrew Austin (@andrewjaustin)](https://github.com/andrewjaustin), [Marc Queralt i Bassa (@MarcQueralt)](https://github.com/MarcQueralt), [Chris Mospaw (@mospaw)](https://github.com/mospaw), [Jonas Stensved (@jstensved)](https://github.com/jstensved), [netboy]([email protected]), [Lenin]([email protected]), [Bauke Zwaan (@baukezwaan)](https://github.com/baukezwaan), [Jascha Ehrenreich (@jaeh)](https://github.com/jaeh), [Chris Wilcoxson (@slushman)](https://github.com/slushman), [Luke Watts (@thisislawatts)](https://github.com/thisislawatts), [Glenn Ansley (@glennansley)](https://github.com/glennansley), [SiteGround](http://www.siteground.com/wordpress-hosting.htm), [Peter Kahoun](http://kahi.cz/), [Jan Lund](), [Michael Jaekel](), [Ιωάννης Δημοφέρλιας (John Dimoferlias)](), [Tomás Nader](), [Claudia Mansilla](http://cricava.com/), [Helen Urbanik](http://www.motomaania.ee/), [Maxime Toulliou](http://www.maximetoulliou.com/), [שגיב בית](http://www.sagive.co.il), [Okostobi](), [Stefan Des](http://www.stefandes.com), [백선기 (SK Baek)](), [Alexander Roterud aka Defrag](http://www.tigerpews.com), [Filip Stas](http://suddenelfilio.net/), [Maria Manoela Porto](), [Tiago Faria](http://xroot.org), [Alexandru Armin Roșu](), [Илья](http://fatcow.com), [Sebastian Johnsson](http://www.agiley.se/), [Hakan E.](http://kazancexpert.com/), [Josh Grosser (@jgrosser-intuit)](https://github.com/jgrosser-intuit), [10up (@10up)](https://github.com/10up), [Nate Conley (@nateconley)](https://github.com/nateconley), [Darin Kotter (@dkotter)](https://github.com/dkotter), [Jeffrey Paul (@jeffpaul)](https://github.com/jeffpaul), [Eddie Shrake (@eddieshrake)](https://github.com/eddieshrake), [Sumit Bagthariya (@qasumitbagthariya)](https://github.com/qasumitbagthariya), [Vikram Moparthy (@vikrampm1)](https://github.com/vikrampm1), [Dharmesh Patel (@iamdharmesh)](https://github.com/iamdharmesh), [GitHub Dependabot (@dependabot)](https://github.com/apps/dependabot).
1616

1717
## Libraries
1818

assets/css/admin.css

+18
Original file line numberDiff line numberDiff line change
@@ -523,6 +523,24 @@ body.toplevel_page_mailchimp_sf_options #footer-upgrade {
523523
clear: both;
524524
}
525525

526+
.migrate-to-oauth-wrapper {
527+
margin: 1em 0;
528+
}
529+
530+
.migrate-to-oauth-wrapper .button.mailchimp-sf-button {
531+
padding: 9px 16px;
532+
line-height: 14px;
533+
}
534+
535+
.migrate-to-oauth-wrapper button.button.mailchimp-sf-button:disabled {
536+
padding: 6px 16px;
537+
}
538+
539+
.migrate-to-oauth-wrapper button.button.mailchimp-sf-button svg {
540+
width: 20px;
541+
height: 20px;
542+
}
543+
526544
.button.mailchimp-sf-button.button-secondary.small {
527545
background-color: transparent;
528546
}
+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?php
2+
/**
3+
* Suggest to login template
4+
*
5+
* @package Mailchimp
6+
*/
7+
8+
$button_text = $login_button_text ?? __( 'Log in', 'mailchimp' );
9+
?>
10+
<button id="mailchimp_sf_oauth_connect" class="button mailchimp-sf-button">
11+
<span class="mailchimp-sf-loading hidden">
12+
<svg class="animate-spin" width="24" height="24" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24">
13+
<circle class="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" stroke-width="4"></circle>
14+
<path class="opacity-75" fill="currentColor" d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"></path>
15+
</svg>
16+
</span>
17+
<?php echo esc_html( $button_text ); ?>
18+
</button>
19+
<p class="mailchimp-sf-oauth-error error-field" style="display:none;"></p>
20+
<div id="mailchimp-sf-popup-blocked-modal" style="display:none;">
21+
<p><?php esc_html_e( 'Please allow your browser to show popups for this page.', 'mailchimp' ); ?></p>
22+
</div>

includes/admin/templates/suggest-to-login.php

+4-13
Original file line numberDiff line numberDiff line change
@@ -26,18 +26,9 @@
2626
?>
2727
</p>
2828

29-
<button id="mailchimp_sf_oauth_connect" class="button mailchimp-sf-button">
30-
<span class="mailchimp-sf-loading hidden">
31-
<svg class="animate-spin" width="24" height="24" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24">
32-
<circle class="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" stroke-width="4"></circle>
33-
<path class="opacity-75" fill="currentColor" d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"></path>
34-
</svg>
35-
</span>
36-
<?php esc_html_e( 'Log in', 'mailchimp' ); ?>
37-
</button>
38-
<p class="mailchimp-sf-oauth-error error-field" style="display:none;"></p>
39-
<div id="mailchimp-sf-popup-blocked-modal" style="display:none;">
40-
<p><?php esc_html_e( 'Please allow your browser to show popups for this page.', 'mailchimp' ); ?></p>
41-
</div>
29+
<?php
30+
// Login button.
31+
include_once MCSF_DIR . 'includes/admin/templates/login-button.php'; // phpcs:ignore PEAR.Files.IncludingFile.UseRequireOnce
32+
?>
4233
</div>
4334
</div>

includes/class-mailchimp-admin.php

+54-18
Original file line numberDiff line numberDiff line change
@@ -299,15 +299,31 @@ public function verify_and_save_oauth_token( $access_token, $data_center ) {
299299
$data_encryption = new Mailchimp_Data_Encryption();
300300

301301
// Clean up the old data.
302+
delete_option( 'mc_api_key' ); // Deprecated API key, need to remove as part of the migration.
302303
delete_option( 'mailchimp_sf_access_token' );
303304
delete_option( 'mailchimp_sf_auth_error' );
304305
delete_option( 'mc_datacenter' );
305306

306307
update_option( 'mailchimp_sf_access_token', $data_encryption->encrypt( $access_token ) );
307308
update_option( 'mc_datacenter', sanitize_text_field( $data_center ) );
308309
update_option( 'mc_user', $this->sanitize_data( $user ) );
309-
return true;
310310

311+
// Clear Mailchimp List ID if saved list is not available.
312+
$lists = $api->get( 'lists', 100, array( 'fields' => 'lists.id' ) );
313+
if ( ! is_wp_error( $lists ) ) {
314+
$lists = $lists['lists'] ?? array();
315+
$saved_list_id = get_option( 'mc_list_id' );
316+
$list_ids = array_map(
317+
function ( $ele ) {
318+
return $ele['id'];
319+
},
320+
$lists
321+
);
322+
if ( ! in_array( $saved_list_id, $list_ids, true ) ) {
323+
delete_option( 'mc_list_id' );
324+
}
325+
}
326+
return true;
311327
} else {
312328
$msg = esc_html__( 'API Key must belong to "Owner", "Admin", or "Manager."', 'mailchimp' );
313329
return new WP_Error( 'mailchimp-sf-invalid-role', $msg );
@@ -323,29 +339,49 @@ public function admin_notices() {
323339
if ( ! current_user_can( 'manage_options' ) ) {
324340
return;
325341
}
342+
$current_screen = get_current_screen();
326343

327344
// Display a deprecation notice if the user is using an API key to connect with Mailchimp.
328345
if ( get_option( 'mc_api_key', '' ) && ! get_option( 'mailchimp_sf_access_token', '' ) && mailchimp_sf_should_display_form() ) {
329-
?>
330-
<div class="notice notice-warning is-dismissible">
331-
<p>
332-
<?php
333-
$message = sprintf(
334-
/* translators: Placeholders: %1$s - <a> tag, %2$s - </a> tag */
335-
__( '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' ),
336-
'<a href="' . esc_url( admin_url( 'admin.php?page=mailchimp_sf_options' ) ) . '">',
337-
'</a>'
338-
);
339-
340-
echo wp_kses( $message, array( 'a' => array( 'href' => array() ) ) );
341-
?>
342-
</p>
343-
</div>
344-
<?php
346+
347+
if ( $current_screen && 'toplevel_page_mailchimp_sf_options' === $current_screen->id ) {
348+
?>
349+
<div class="notice notice-warning">
350+
<p>
351+
<?php
352+
esc_html_e( 'You are using an outdated API Key connection to Mailchimp, please migrate to the new OAuth authentication method to continue accessing your Mailchimp account.', 'mailchimp' );
353+
?>
354+
</p>
355+
<div class="migrate-to-oauth-wrapper">
356+
<?php
357+
// Migrate button.
358+
$login_button_text = __( 'Migrate to OAuth authentication', 'mailchimp' );
359+
include_once MCSF_DIR . 'includes/admin/templates/login-button.php'; // phpcs:ignore PEAR.Files.IncludingFile.UseRequireOnce
360+
?>
361+
</div>
362+
</div>
363+
<?php
364+
} else {
365+
?>
366+
<div class="notice notice-warning is-dismissible">
367+
<p>
368+
<?php
369+
$message = sprintf(
370+
/* translators: Placeholders: %1$s - <a> tag, %2$s - </a> tag */
371+
__( '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' ),
372+
'<a href="' . esc_url( admin_url( 'admin.php?page=mailchimp_sf_options' ) ) . '">',
373+
'</a>'
374+
);
375+
376+
echo wp_kses( $message, array( 'a' => array( 'href' => array() ) ) );
377+
?>
378+
</p>
379+
</div>
380+
<?php
381+
}
345382
}
346383

347384
// Display a notice if the user is waiting for the login to complete.
348-
$current_screen = get_current_screen();
349385
if ( $current_screen && 'toplevel_page_mailchimp_sf_options' === $current_screen->id ) {
350386
$api = mailchimp_sf_get_api();
351387
if ( $api && 'waiting' === get_option( 'mailchimp_sf_waiting_for_login' ) ) {

0 commit comments

Comments
 (0)