Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified .wordpress-org/screenshot-6.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified .wordpress-org/screenshot-7.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified .wordpress-org/screenshot-8.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed .wordpress-org/screenshot-9.jpg
Binary file not shown.
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,16 @@ All notable changes to this project will be documented in this file, per [the Ke

## [Unreleased] - TBD

## [1.9.0] - 2025-06-04

### Added

- New user synchronization feature that allows syncing WordPress users to Mailchimp (props [@iamdharmesh](https://github.com/iamdharmesh), [@jeffpaul](https://github.com/jeffpaul), [@dkotter](https://github.com/dkotter), [@qasumitbagthariya](https://github.com/qasumitbagthariya) via [#156](https://github.com/mailchimp/wordpress/pull/156)).

### Changed

- Improved the enqueueing of JavaScript scripts and styles (props [@iamdharmesh](https://github.com/iamdharmesh), [@dkotter](https://github.com/dkotter), [@qasumitbagthariya](https://github.com/qasumitbagthariya) via [#161](https://github.com/mailchimp/wordpress/pull/161)).

## [1.8.0] - 2025-05-08

**Note that this release bumps the WordPress minimum version from 6.3 to 6.4.**
Expand Down Expand Up @@ -313,6 +323,7 @@ All notable changes to this project will be documented in this file, per [the Ke
- Security and various other improvements

[Unreleased]: https://github.com/mailchimp/wordpress/compare/main...develop
[1.9.0]: https://github.com/mailchimp/wordpress/compare/1.8.0...1.9.0
[1.8.0]: https://github.com/mailchimp/wordpress/compare/1.7.0...1.8.0
[1.7.0]: https://github.com/mailchimp/wordpress/compare/1.6.3...1.7.0
[1.6.3]: https://github.com/mailchimp/wordpress/compare/1.6.2...1.6.3
Expand Down
20 changes: 10 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ Starting in version 1.6.0, authentication has changed to use OAuth. As part of t

With no additional configuration, we use the standard `LOGGED_IN_KEY` and `LOGGED_IN_SALT` constants that are normally set in your site's `wp-config.php` file. Some sites make use of security plugins that rotate these constants on a periodic basis. When this happens, we won't be able to decrypt the access token and you’ll need to reconnect your Mailchimp account to generate a new access token.

To prevent such issues, it is recommended to define two additional constants in your site's `wp-config.php` file: `MAILCHIMP_SF_ENCRYPTION_KEY` and `MAILCHIMP_SF_ENCRYPTION_SALT`. These constants should consist of a combination of characters, preferably at least 32 characters long. Once set, these values should not be changed. For strong values, you can copy some of the values from [here](https://api.wordpress.org/secret-key/1.1/salt/) and use them. You'll end up with additional code like the following in your `wp-config.php` file:
To prevent such issues, it is recommended to define two additional constants in your site's `wp-config.php` file: `MAILCHIMP_SF_ENCRYPTION_KEY` and `MAILCHIMP_SF_ENCRYPTION_SALT`. These constants should consist of a combination of characters, preferably at least 32 characters long. Once set, these values should not be changed. For strong values, you can copy some of the values from the [WordPress Secret Key Generator](https://api.wordpress.org/secret-key/1.1/salt/) and use them. You'll end up with additional code like the following in your `wp-config.php` file:

```php
define( 'MAILCHIMP_SF_ENCRYPTION_KEY', 'put your unique phrase here' );
Expand All @@ -49,23 +49,21 @@ This section describes how to install the plugin and get started using it.

![Connecting your Mailchimp account to WordPress via OAuth.](https://github.com/mailchimp/wordpress/blob/develop/.wordpress-org/screenshot-4.jpg?raw=true)

![Creating a new Mailchimp account.](https://github.com/mailchimp/wordpress/blob/develop/.wordpress-org/screenshot-9.jpg?raw=true)
![Creating a new Mailchimp account.](https://github.com/mailchimp/wordpress/blob/develop/.wordpress-org/screenshot-7.jpg?raw=true)

4. Click the Log in button and proceed through the OAuth flow, logging in to your Mailchimp account and authorizing the application. If you don't have an acccount, instead click the "Create an account" button to create one.

![Logged in to your Mailchimp account and selecting a list to connect to.](https://github.com/mailchimp/wordpress/blob/develop/.wordpress-org/screenshot-5.jpg?raw=true)

5. Select the list where you want to send new Mailchimp subscribers.

![Configuring your Signup Form display format (optional).](https://github.com/mailchimp/wordpress/blob/develop/.wordpress-org/screenshot-6.jpg?raw=true)

6. Optional: Turn **Merge Fields** and **Groups** on or off. Navigate to **Appearance**, and click **Widgets**. Drag the Mailchimp Widget into one of your Widget Areas.

![Configuring extra fields on your Signup Form (optional).](https://github.com/mailchimp/wordpress/blob/develop/.wordpress-org/screenshot-7.jpg?raw=true)
![Configuring extra fields on your Signup Form (optional).](https://github.com/mailchimp/wordpress/blob/develop/.wordpress-org/screenshot-6.jpg?raw=true)

7. Optional: adjust frontend site display with available CSS options.
7. Optional: turn on user synchronization to sync WordPress users to Mailchimp.

![CSS options for styling your Signup Form.](https://github.com/mailchimp/wordpress/blob/develop/.wordpress-org/screenshot-8.jpg?raw=true)
![Configuring user synchronization settings.](https://github.com/mailchimp/wordpress/blob/develop/.wordpress-org/screenshot-8.jpg?raw=true)

## Upgrading

Expand All @@ -88,23 +86,25 @@ You need to ensure that the fields are enabled both in your Mailchimp account (A
Internationalization (i18n) is available on GlotPress at [https://translate.wordpress.org/projects/wp-plugins/mailchimp/](https://translate.wordpress.org/projects/wp-plugins/mailchimp/). Any assistance [translating the plugin](https://translate.wordpress.org/projects/wp-plugins/mailchimp/) is greatly appreciated!

## E2E tests

The `tests` directory contains end-to-end tests for the project, utilizing Cypress to run tests in an environment created using wp-env.

### Pre-requisites

- Node.js v20
- Docker
- Create an account in [Mailchimp](https://mailchimp.com/)

### Run E2E tests in local

1. Run `npm install`.
2. Run `npm run build`.
3. Run `npm run env:start`.
4. Duplicate the `.env.test.sample` file and rename `.env.test`. Populate this file with your own Mailchimp account credentials.
- **NOTE:** Use a test account that does not require 2FA. 2FA will fail some of the tests.
5. Set your Mailchimp account up
- Name the audience in your Mailchimp test account "10up". Required for `settings.test.js`.
- Enable all merge fields. From your Mailchimp account home page -> `/audience/settings/` -> Edit merge fields/tags -> Set all merge fields to "visible". Required for `settings.test.js`.

- Name the audience in your Mailchimp test account "10up". Required for `settings.test.js`.
- Enable all merge fields. From your Mailchimp account home page -> `/audience/settings/` -> Edit merge fields/tags -> Set all merge fields to "visible". Required for `settings.test.js`.
6. Run `npm run cypress:run`. You can also run `npm run cypress:open` to run tests in UI mode.

## Support Level
Expand Down
3 changes: 2 additions & 1 deletion assets/css/admin.css
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ table.mc-widefat, .mailchimp-sf-user-sync-page table.form-table {
}

.mailchimp-sf-user-sync-page table.form-table {
display: block;
border-collapse: separate;
border-spacing: 0px;
}

.mailchimp-sf-user-sync-page table.form-table tr:first-child,
Expand Down
52 changes: 26 additions & 26 deletions includes/admin/class-mailchimp-user-sync.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,30 +13,30 @@
/**
* Class Mailchimp_User_Sync
*
* @since x.x.x
* @since 1.9.0
*/
class Mailchimp_User_Sync {

/**
* The option name.
*
* @since x.x.x
* @since 1.9.0
* @var string
*/
protected $option_name = 'mailchimp_sf_user_sync_settings';

/**
* The errors option name.
*
* @since x.x.x
* @since 1.9.0
* @var string
*/
protected $errors_option_name = 'mailchimp_sf_user_sync_errors';

/**
* The background process.
*
* @since x.x.x
* @since 1.9.0
* @var Mailchimp_User_Sync_Background_Process
*/
protected $background_process;
Expand Down Expand Up @@ -83,7 +83,7 @@ public function init() {
/**
* Register the user sync settings.
*
* @since x.x.x
* @since 1.9.0
*/
public function register_settings() {
$args = array(
Expand All @@ -96,7 +96,7 @@ public function register_settings() {
/**
* Setup the fields and sections.
*
* @since x.x.x
* @since 1.9.0
*/
public function setup_fields_sections() {
$section_id = $this->option_name . '_section';
Expand Down Expand Up @@ -171,7 +171,7 @@ public function setup_fields_sections() {
/**
* Get the user sync settings.
*
* @since x.x.x
* @since 1.9.0
* @param string|null $key The key to get.
* @return array|null The user sync settings.
*/
Expand All @@ -198,15 +198,15 @@ public function get_user_sync_settings( $key = null ) {
/**
* Sanitize the user sync settings.
*
* @since x.x.x
* @since 1.9.0
* @param array $new_settings The settings to sanitize.
* @return array The sanitized settings.
*/
public function sanitize_user_sync_settings( $new_settings ) {
$settings = $this->get_user_sync_settings();
$settings['enable_user_sync'] = isset( $new_settings['enable_user_sync'] ) ? 1 : 0;
$settings['enable_user_sync'] = ( isset( $new_settings['enable_user_sync'] ) && 1 === absint( $new_settings['enable_user_sync'] ) ) ? 1 : 0;
$settings['user_roles'] = isset( $new_settings['user_roles'] ) ? array_map( 'sanitize_text_field', $new_settings['user_roles'] ) : array();
$settings['existing_contacts_only'] = isset( $new_settings['existing_contacts_only'] ) ? 1 : 0;
$settings['existing_contacts_only'] = ( isset( $new_settings['existing_contacts_only'] ) && 1 === absint( $new_settings['existing_contacts_only'] ) ) ? 1 : 0;
$settings['subscriber_status'] = isset( $new_settings['subscriber_status'] ) ? sanitize_text_field( $new_settings['subscriber_status'] ) : 'pending';

return $settings;
Expand All @@ -215,7 +215,7 @@ public function sanitize_user_sync_settings( $new_settings ) {
/**
* Render the user roles field.
*
* @since x.x.x
* @since 1.9.0
*/
public function user_roles_field() {
$settings = $this->get_user_sync_settings( 'user_roles' );
Expand Down Expand Up @@ -248,7 +248,7 @@ public function user_roles_field() {
/**
* Render the enable user sync field.
*
* @since x.x.x
* @since 1.9.0
*/
public function enable_user_sync_field() {
$value = $this->get_user_sync_settings( 'enable_user_sync' );
Expand All @@ -269,7 +269,7 @@ public function enable_user_sync_field() {
/**
* Render the subscriber status field.
*
* @since x.x.x
* @since 1.9.0
*/
public function subscriber_status_field() {
$settings = $this->get_user_sync_settings( 'subscriber_status' );
Expand Down Expand Up @@ -335,7 +335,7 @@ public function subscriber_status_field() {
/**
* Render the existing contacts only field.
*
* @since x.x.x
* @since 1.9.0
*/
public function existing_contacts_only_field() {
$settings = $this->get_user_sync_settings();
Expand All @@ -351,7 +351,7 @@ public function existing_contacts_only_field() {
/**
* Render the sync all users field.
*
* @since x.x.x
* @since 1.9.0
*/
public function sync_all_users_button() {
$start_sync_url = wp_nonce_url( add_query_arg( 'action', 'mailchimp_sf_start_user_sync', admin_url( 'admin-post.php' ) ), 'mailchimp_sf_start_user_sync', 'mailchimp_sf_start_user_sync_nonce' );
Expand All @@ -368,7 +368,7 @@ public function sync_all_users_button() {
/**
* Start the user sync.
*
* @since x.x.x
* @since 1.9.0
*/
public function start_user_sync() {
if (
Expand Down Expand Up @@ -445,7 +445,7 @@ public function start_user_sync() {
/**
* Cancel the user sync.
*
* @since x.x.x
* @since 1.9.0
*/
public function cancel_user_sync() {
if (
Expand Down Expand Up @@ -479,7 +479,7 @@ public function cancel_user_sync() {
/**
* Skip the user sync cta.
*
* @since x.x.x
* @since 1.9.0
*/
public function skip_user_sync_cta() {
if (
Expand Down Expand Up @@ -579,7 +579,7 @@ public function render_notices() {
/**
* Get the total users.
*
* @since x.x.x
* @since 1.9.0
* @return int The total users.
*/
public function get_users_count() {
Expand All @@ -601,7 +601,7 @@ public function get_users_count() {
/**
* Get the user sync status.
*
* @since x.x.x
* @since 1.9.0
*/
public function render_user_sync_status() {
$is_syncing = $this->background_process->in_progress();
Expand All @@ -622,7 +622,7 @@ public function render_user_sync_status() {
/**
* Render the user sync start cta.
*
* @since x.x.x
* @since 1.9.0
*/
public function render_user_sync_start_cta() {
// Check if the cta is already shown.
Expand Down Expand Up @@ -680,7 +680,7 @@ public function render_user_sync_start_cta() {
/**
* Get the user sync progress.
*
* @since x.x.x
* @since 1.9.0
*/
public function render_user_sync_progress() {
$is_syncing = $this->background_process->in_progress();
Expand Down Expand Up @@ -755,7 +755,7 @@ public function get_user_sync_status() {
/**
* Get the user sync errors.
*
* @since x.x.x
* @since 1.9.0
* @return array The user sync errors.
*/
public function get_user_sync_errors() {
Expand All @@ -765,7 +765,7 @@ public function get_user_sync_errors() {
/**
* Set the user sync errors.
*
* @since x.x.x
* @since 1.9.0
* @param array $errors The user sync errors.
*/
public function set_user_sync_errors( $errors ) {
Expand All @@ -781,7 +781,7 @@ public function set_user_sync_errors( $errors ) {
/**
* Delete the user sync error.
*
* @since x.x.x
* @since 1.9.0
*
* @param string $id The id of the user sync error.
*/
Expand All @@ -804,7 +804,7 @@ public function delete_user_sync_errors( $id ) {
* Render the user sync errors.
* Note: This is only renders last 100 records.
*
* @since x.x.x
* @since 1.9.0
*/
public function render_user_sync_errors() {
$errors = $this->get_user_sync_errors();
Expand Down
2 changes: 1 addition & 1 deletion includes/class-mailchimp-admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -560,7 +560,7 @@ public function create_account_page() {
/**
* Render the settings page.
*
* @since x.x.x
* @since 1.9.0
*
* @return void
*/
Expand Down
2 changes: 1 addition & 1 deletion includes/class-mailchimp-user-sync-backgroud-process.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
/**
* Class Mailchimp_User_Sync_Background_Process
*
* @since x.x.x
* @since 1.9.0
*/
class Mailchimp_User_Sync_Background_Process {

Expand Down
4 changes: 2 additions & 2 deletions mailchimp.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* Plugin URI: https://mailchimp.com/help/connect-or-disconnect-list-subscribe-for-wordpress/
* Description: Add a Mailchimp signup form block, widget or shortcode to your WordPress site.
* Text Domain: mailchimp
* Version: 1.8.0
* Version: 1.9.0
* Requires at least: 6.4
* Requires PHP: 7.0
* PHP tested up to: 8.3
Expand Down Expand Up @@ -67,7 +67,7 @@ function () {
use function Mailchimp\WordPress\Includes\Admin\{admin_notice_error, admin_notice_success};

// Version constant for easy CSS refreshes
define( 'MCSF_VER', '1.8.0' );
define( 'MCSF_VER', '1.9.0' );

// What's our permission (capability) threshold
define( 'MCSF_CAP_THRESHOLD', 'manage_options' );
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@mailchimp/wordpress",
"version": "1.8.0",
"version": "1.9.0",
"description": "Add a Mailchimp signup form widget to your WordPress site.",
"homepage": "https://github.com/mailchimp/wordpress",
"bugs": {
Expand Down
Loading