diff --git a/.wordpress-org/screenshot-6.jpg b/.wordpress-org/screenshot-6.jpg index 16f9ac38..a44493a9 100644 Binary files a/.wordpress-org/screenshot-6.jpg and b/.wordpress-org/screenshot-6.jpg differ diff --git a/.wordpress-org/screenshot-7.jpg b/.wordpress-org/screenshot-7.jpg index a44493a9..acae7b87 100644 Binary files a/.wordpress-org/screenshot-7.jpg and b/.wordpress-org/screenshot-7.jpg differ diff --git a/.wordpress-org/screenshot-8.jpg b/.wordpress-org/screenshot-8.jpg index 51c943a4..263d7bb3 100644 Binary files a/.wordpress-org/screenshot-8.jpg and b/.wordpress-org/screenshot-8.jpg differ diff --git a/.wordpress-org/screenshot-9.jpg b/.wordpress-org/screenshot-9.jpg deleted file mode 100644 index acae7b87..00000000 Binary files a/.wordpress-org/screenshot-9.jpg and /dev/null differ diff --git a/CHANGELOG.md b/CHANGELOG.md index 8a8936d5..14233180 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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.** @@ -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 diff --git a/README.md b/README.md index 4ac44d34..c558fd8f 100644 --- a/README.md +++ b/README.md @@ -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' ); @@ -49,7 +49,7 @@ 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. @@ -57,15 +57,13 @@ This section describes how to install the plugin and get started using it. 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 @@ -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 diff --git a/assets/css/admin.css b/assets/css/admin.css index 4f1b1840..6a50d400 100644 --- a/assets/css/admin.css +++ b/assets/css/admin.css @@ -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, diff --git a/includes/admin/class-mailchimp-user-sync.php b/includes/admin/class-mailchimp-user-sync.php index eefa0c12..cab21f09 100644 --- a/includes/admin/class-mailchimp-user-sync.php +++ b/includes/admin/class-mailchimp-user-sync.php @@ -13,14 +13,14 @@ /** * 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'; @@ -28,7 +28,7 @@ class Mailchimp_User_Sync { /** * The errors option name. * - * @since x.x.x + * @since 1.9.0 * @var string */ protected $errors_option_name = 'mailchimp_sf_user_sync_errors'; @@ -36,7 +36,7 @@ class Mailchimp_User_Sync { /** * The background process. * - * @since x.x.x + * @since 1.9.0 * @var Mailchimp_User_Sync_Background_Process */ protected $background_process; @@ -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( @@ -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'; @@ -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. */ @@ -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; @@ -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' ); @@ -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' ); @@ -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' ); @@ -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(); @@ -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' ); @@ -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 ( @@ -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 ( @@ -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 ( @@ -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() { @@ -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(); @@ -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. @@ -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(); @@ -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() { @@ -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 ) { @@ -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. */ @@ -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(); diff --git a/includes/class-mailchimp-admin.php b/includes/class-mailchimp-admin.php index a3803e33..819a1523 100644 --- a/includes/class-mailchimp-admin.php +++ b/includes/class-mailchimp-admin.php @@ -560,7 +560,7 @@ public function create_account_page() { /** * Render the settings page. * - * @since x.x.x + * @since 1.9.0 * * @return void */ diff --git a/includes/class-mailchimp-user-sync-backgroud-process.php b/includes/class-mailchimp-user-sync-backgroud-process.php index 98e370bc..abd38211 100644 --- a/includes/class-mailchimp-user-sync-backgroud-process.php +++ b/includes/class-mailchimp-user-sync-backgroud-process.php @@ -13,7 +13,7 @@ /** * Class Mailchimp_User_Sync_Background_Process * - * @since x.x.x + * @since 1.9.0 */ class Mailchimp_User_Sync_Background_Process { diff --git a/mailchimp.php b/mailchimp.php index cf8a461a..08ff6a06 100644 --- a/mailchimp.php +++ b/mailchimp.php @@ -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 @@ -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' ); diff --git a/package-lock.json b/package-lock.json index d5ab0b57..2deffe89 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@mailchimp/wordpress", - "version": "1.8.0", + "version": "1.9.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@mailchimp/wordpress", - "version": "1.8.0", + "version": "1.9.0", "license": "GPL-2.0-or-later", "dependencies": { "@wordpress/block-editor": "^13.2.0", diff --git a/package.json b/package.json index 357a852a..47a99b34 100644 --- a/package.json +++ b/package.json @@ -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": { diff --git a/readme.txt b/readme.txt index de51b749..3de1bf31 100644 --- a/readme.txt +++ b/readme.txt @@ -2,7 +2,7 @@ Contributors: Mailchimp Tags: mailchimp, email, newsletter, signup, marketing Tested up to: 6.8 -Stable tag: 1.8.0 +Stable tag: 1.9.0 License: GPL-2.0-or-later License URI: https://spdx.org/licenses/GPL-2.0-or-later.html @@ -61,7 +61,7 @@ This section describes how to install the plugin and get started using it. 4. Click the Log in button and proceed through the OAuth flow, logging in to your Mailchimp account and authorizing the application. 5. Select the list where you want to send new Mailchimp subscribers. 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. -7. Optional: adjust frontend site display with available CSS options. +7. Optional: turn on user synchronization to sync WordPress users to Mailchimp. == Upgrading == @@ -74,13 +74,16 @@ If you are upgrading to version 1.2.1 and you used the widget in your sidebar pr 3. Mailchimp List Subscribe Form block previewing sign up form headers, fields, and button. 4. Connecting your Mailchimp account to WordPress via OAuth. 5. Logged in to your Mailchimp account and selecting a list to connect to. -6. Configuring your Signup Form display format (optional). -7. Configuring extra fields on your Signup Form (optional). -8. CSS options for styling your Signup Form. -9. Creating a new Mailchimp account. +6. Configuring extra fields on your Signup Form (optional). +7. Creating a new Mailchimp account. +8. Configuring user synchronization settings. == Changelog == += 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.** @@ -161,11 +164,6 @@ If you are upgrading to version 1.2.1 and you used the widget in your sidebar pr * **Fixed:** Ensure the custom block and shortcode both have consistent spacing (props [@dkotter](https://github.com/dkotter), [@qasumitbagthariya](https://github.com/qasumitbagthariya), [@nateconley](https://github.com/nateconley), [@vikrampm1](https://github.com/vikrampm1) via [#41](https://github.com/mailchimp/wordpress/pull/41)). * **Fixed:** Address some PHP warnings when a form submission happens (props [@iamdharmesh](https://github.com/iamdharmesh), [@dkotter](https://github.com/dkotter), [@qasumitbagthariya](https://github.com/qasumitbagthariya) via [#54](https://github.com/mailchimp/wordpress/pull/54)). -= 1.5.8 - 2022-09-26 = -* **Changed:** Updated `readme.txt` link. -* **Fixed:* PHP warning for merge tags. -* **Fixed:** Double slashes on resources being loaded. - [View historical changelog details here](https://github.com/mailchimp/wordpress/blob/develop/CHANGELOG.md). == Upgrade Notice ==