diff --git a/change_log.txt b/change_log.txt index 90868e5..2c644fb 100644 --- a/change_log.txt +++ b/change_log.txt @@ -1,288 +1,322 @@ -# 4.6 | 2019-03-22 - - Added support for Marketing Permissions (GDPR) fields. - - -# 4.5 | 2018-12-19 - - Fixed new tags not being added when updating existing list member. - - -# 4.4 | 2018-10-29 - - Added support for MailChimp contact tags. - - -# 4.3 | 2018-03-27 - - Added security enhancements. - - Added GPL to plugin header. - - Updated API library to public property in support of MailChimp block. - - Updated Plugin URI and Author URI to use https. - - Fixed the MailChimp API returning a validation error for list date fields set to the DD/MM/YYYY format. - - Fixed existing member retaining a status of cleaned or transactional instead of changing to pending or subscribed. - - Fixed birthday and date merge fields not being sent in the defined date format. - - Fixed an issue with the member status on resubscription to the list. - - Fixed PHP notice if the interests are not returned by the MailChimp API for the existing member. - - Fixed issue with css file that was being enqueued in every page. - - -# 4.2 | 2017-04-03 - - Added additional logging when checking if a user's subscription status. - - Added existing member object as sixth parameter of "gform_mailchimp_subscription" filter. - - Fixed PHP warning when attempting to check for existing interests when member did not belong to any interest categories. - - Fixed Fatal error that happened in certain situations. - - Fixed existing interest categories not being properly associated to subscription object. - - Fixed an issue with subscriptions not being created due to empty merge fields. - - Fixed an issue which could prevent the feed groups being converted to interest categories when upgrading from older versions of the add-on. - - Fixed inability to use double opt-in with existing memebers. - - Fixed API response error handling; API key was incorrectly shown as valid when a 403 Forbidden error was returned. - - Fixed an issue with the field value used for interest category logic evaluation. - - Restored GFMailChimp::get_group_setting_key() for use when upgrading from older versions of MailChimp Add-On. - - Restored double opt-in support for members who are being resubscribed to a list they are unsubscribed from. - - Disabled double opt-in support for members who are being resubscribed to a list they are unsubscribed from. (Member will be automatically subscribed to the list. This is a temporary workaround for an issue with the MailChimp API.) - - Re-introduced support for "gform_mailchimp_keep_existing_groups" filter. - - -# 4.1 | 2017-01-03 - - Added additional error logging when creating a subscription. - - Added support for configuring a note to be added to the subscriber. - - Fixed a fatal error during feed processing when a list field is mapped to an entry property. - - Fixed an issue where an Invalid Resource error would occur if the subscribers merge_fields property was included in the request when empty. - - Fixed an issue with the note being urlencoded during merge tag processing. - - Fixed users not being subscribed due to incorrect address formatting. - - Increased number of merge fields returned for a list. - - Updated feed processing to bypass override empty fields check for address fields. - - Updated maximum number of category interests returned by the API. - - Updated maximum number of interest groups returned by API. - - Updated merge fields field map to only allow Address fields to be mapped to MailChimp address merge fields. - - Updated strings for translations. - - Updated subscription object to use existing member status where possible. - - -# 4.0 | 2016-12-20 - - Added gform_mailchimp_subscription filter to modify subscription object. - - Removed 3.0 upgrade page. - - Removed send welcome email as feed settings option. - - Updated API requests to use MailChimp API 3.0. - - -# 3.7.5 | 2016-11-29 - - Fixed strings for translations - - -# 3.7.4 | 2016-09-16 - - Fixed an issue with multi-input fields available for use with groups logic not including the inputs (i.e. Name and Address). - - -# 3.7.3 | 2016-05-06 - - Updated the MailChimp API to support the WP_PROXY_HOST and WP_PROXY_PORT constants when configuring the cURL options. - - -# 3.7.2 | 2016-03-11 - - Fixed an issue which was preventing feed processing aborting early if there is an issue with the MailChimp API. - - -# 3.7.1 | 2015-09-23 - - Fixed an issue where the cached settings were not cleared when the add-on was uninstalled. - - Fixed a rare issue for some server environments where several groups could be assigned the same settings key causing js issues in the feed editor. - - Fixed an issue where the cached group setting keys could be lost when updating the API key on the plugin settings tab. - - -# 3.7 | 2015-08-24 - - Added form and field specific versions of the gform_mailchimp_field_value filter. - - Added logging of group condition evaluation. - - Added $transaction, either Update or Subscribe, as the fifth parameter of the gform_mailchimp_args_pre_subscribe filter. - - Updated minimum Gravity Forms version to 1.9.3. - - Updated 'Opt-In Condition' setting label to 'Conditional Logic'. - - Updated feed processing to use get_field_value() when retrieving mapped field values, enabling support for GF_Field::get_value_export with GF 1.9.12.4 and later. - - Updated to use GF_Field::is_conditional_logic_supported to determine which field types should be listed in the group condition fields drop down. - - Fixed an issue with the feed list page if the API key not valid. - - Fixed an issue with the location of the gform_mailchimp_args_pre_subscribe filter. - - Fixed an issue with the upgrade routine which caused it run even if a pre-framework version hadn't been installed. - - Remove plugin settings header and add line break after plugin settings description. - - -# 3.6 | 2015-04-20 - - Added filter to allow changing parameters to the API method that returns the MailChimp Lists. - - Added Spanish (es_ES) translation. - - Fixed a low severity security vulnerability in the admin area which could be exploited by authenticated users with form administration permissions. - - Fixed an issue with the members existing groups being lost if no new groups were selected and gform_mailchimp_keep_existing_groups is true. - - -# 3.5 | 2015-02-03 - - Updated required version of Gravity Forms to 1.8.17. - - Fixed an issue with Address fields where MailChimp would ignore the passed string if it did not contain the street address, city, state, or zip. - - -# 3.4 | 2015-02-02 - - Added support for the middle name input when preparing Name field values. - - Updated required version of Gravity Forms to 1.9. - - Fixed an issue causing checkbox fields not to be mapped under certain conditions. - - Fixed fatal error with PHP < 5.4. - - -# 3.3 | 2015-01-30 - - Updated logging statements. - - Updated the gform_mailchimp_field_value filter to have an additional parameter which includes the name of the custom mapped field. - - Fixed issue causing address not to be mapped properly under certain scenarios. - - Fixed Notice. - - Fixed an issue with the concatenated string for Checkbox fields not being cleared before the next field is processed. - - Fixed a warning when MailChimp interest groups aren't enabled on the list. - - -# 3.2 | 2014-12-08 - - Added hook to allow args to be changed before sending submission to MailChimp. - add_filter( 'gform_mailchimp_args_pre_subscribe', 'override_mailchimp_params', 10, 4 ); - function override_mailchimp_params( $params, $form, $entry, $feed ) { - // do stuff - - return $params; - } - - Added hook to select whether empty mapped fields should override existing values on Mailchimp; defaults to override. - add_filter('gform_mailchimp_override_empty_fields', '__return_false' ); - - Fixed issue where existing groups were not maintained for users already subscribed. - - Fixed notice messages. - - Fixed fatal error displayed on certain situations. - - -# 3.1 | 2014-11-21 - - Fixed issue where grouping assignment was not working for already subscribed users - - Fixed issue where a fatal error is displayed in certain situations - - Fixed issue with upgrade that caused configuration not to be copied over in certain situations - - -# 3.0 | 2014-11-04 - - Added integration with Add-On Framework - - Added support for sending selected checkboxes as a concatenated string - - Updated POT file - - Updated required version of Gravity Forms to 1.8.17 - - Updated to MailChimp API version 2.0. - - Updated files removing closing php tag at the end. - - Fixed a warning when MailChimp interest groups aren't enabled on the list. - - -# 2.2 | 2013-06-19 - - Updated phone number when set to standard format "(###)### - ####" to send in required format of ###-###-#### - - -# 2.1 | 2013-03-26 - - Added Name (Full) as an option to the field mapping list when the form has a Name field set to Normal or Extended format - - -# 2.0 | 2013-03-07 - - Fixed PHP warnings when no API key was set - - Added the gform_mailchimp_field_value filter to enable the value to be modified before being sent to the MailChimp API. - - Added entry meta to the list of available field mappings - - Fixed issue with group conditional logic not displaying all possible operators and value drop down correctly - - Fixed issue with special character in main group name - - Fixed issue with group conditional logic with non-selection field types - - Added new hook "gform_mailchimp_allow_resubscription" which allows disabling support for resubscription - add_filter('gform_mailchimp_allow_resubscription', '__return_false()'); - - Fixed issue saving group settings in admin when sub groups have the same name - - -# 1.9 | 2012-11-28 - - Updated Group logic to keep existing groups. - - Added filter to change logic back to overriding groups - add_filter("gform_mailchimp_keep_existing_groups", "__return_false"); - - Updated to treat members as if they were a new subscribe request when currently set to a status on MailChimp's side of unsubscribed, pending, cleaned - - Fixed issue with special characters in MailChimp Group names causing issues when creating feed. - - - -# 1.8 | 2012-10-24 - - Fixed issue with GetFieldValues() when used with groups; was returning full select when only options were required - - Fixed notices - - Fixed group names (commas in names are treated by MailChimp as a delimiter indicating multiple groups) - - -# 1.7 | 2012-07-03 - - Fixed issue with some Mapped Fields not being passed (Entry Date, User IP, Source Url, Form Title) - - Added new conditional logic options (greater than, less than, contains starts with, ends with) and support for other conditional fields - - Fixed notices - - Fixed issue when testing if email is already in the list - - -# 1.6.3 | 2012-03-13 - - Added logging - - Fixed notices - - Fixed issue with single quotes on feed edit screen creating javascript errors - - -# 1.6.2 | 2012-03-01 - - Fixed issue with sack script being initialized with an incorrect admin url. - - Fixed issue that causing conflicts with feeds created by older versions of the plugin - - -# 1.6.1 | 2012-01-20 - - Fixed issue that caused warnings to be displayed on feeds created by older versions. - - -# 1.6 | 2012-01-05 - - Fixed issue where RG_CURRENT_PAGE constant was not available when GF is deactivated - - Fixed noticed caused where $api variable not declared - - Added support for MaiChimp Groups so that subscribers can be assigned to a group when added to a list. - - Added Form Title to the list of fields to be mapped - - Updated procedure that gets the MailChimp lists so that more than 25 lists are returned (up to 100). - - Added integration with PayPal so that subscribers can be added only when payment is received - - -# 1.5 | 2011-06-23 - - Updated API Wrapper to 1.3 (mini) - - Removed blank strings from POT file to prevent error messages in Poedit - - -# 1.4 | 2011-04-25 - - Cleaned up notices - - Fixed issue when using Opt-in condition on a field with multiple single quote characters in the label - - Fixed issue when creating a feed using forms with HTML markup in field labels - - -# 1.3.4 - - Cleaned up notices - - -# 1.3.3 - - Added "Cancel" button to Edit page and updated "Save" and "Update" button verbiage - - -# 1.3.2 | 2011-02-06 - - Fixed issue with MailChimp lists being displayed as blank values. Taking into account different data formats returned by the API - - -# 1.3.1 | 2010-12-15 - - Using new MailChimp PHP API wrapper (v. 1.2.6) when authenticating via an API Key - - -# 1.3 | 2010-12-15 - - Added support for authentication via MailChimp API Key - - -# 1.2 | 2010-12-15 - - Fixed issue with automatic upgrade on WP 3.0 - - -# 1.1 - - Adding MailChimp capabilities to admin role upon plugin activation - - -# 1.0.beta-2 - - Added MailChimp icon - - Renamed "Contact List" to "MailChimp List" - - -# 1.0.beta-1 - - Changed text on list page when settings haven't been configured - - Created POT file - - -# 0.2 | 2010-12-15 - - Map Fields column headers to ?List Fields? and ?Form Fields? and bol - - Rename button to "Save Feed" for a new feed and "Update Feed" for an existing one - - Settings page subnavigation to look like "Edit Forms" subnav (i.e. All | Active | Inactive) with no pipe at the end - - Try adding menu item between Entries and Settings - - Move "Add Feed" to top right (like posts page) and rename to "Add new" - - -# 0.1 | 2010-12-15 - - Split logic from Feeds Add-On - - Implemented automatic upgrade - - Implemented list page checkboxes (for bulk actions) - - Implemented active/inactive icons on list page +### 5.2 | 2023-02-15 +- Added Gravity Forms license key to oAuth process. +- Added support for async (background) feed processing to improve form submission performance. +- Fixed an issue that prevents the Marketing Permission setting from being applied to users in certain situations. +- Fixed an issue where the opt-in email is not sending to already pending members when they resubscribe. + +### 5.1 | 2022-05-11 +- Fixed an issue where the save settings button isn't visible when creating or editing a feed. +- Fixed a display issue with some conditional logic feed settings. +- Fixed an issue where API calls are being made on all admin pages when checking for deprecated keys. + + +### 5.0 | 2021-09-29 +- Updated the authorization flow to connect to the Mailchimp API via Oauth. + + +### 4.9 | 2021-04-28 +- Fixed an issue where conditional logic is not correctly identifying matching selections when forms contain a multi-select field. +- Fixed an issue where the add-on icon is missing on the form settings screen in Gravity Forms 2.5. + + +### 4.8 | 2020-09-09 +- Added support for Gravity Forms 2.5. +- Fixed birthday merge fields no longer being sent in the correct format expected by the Mailchimp API. + + +### 4.7 | 2020-03-24 +- Added translations for Hebrew, Hindi, Japanese, and Turkish. +- Added support for feed duplication. +- Updated stylesheets to use minified versions. +- Updated strings containing MailChimp to Mailchimp and list(s) to audience(s). +- Fixed a PHP error which could occur when using the http_request_timeout filter with WP 5.1+. + + +### 4.6 | 2019-03-22 +- Added support for Marketing Permissions (GDPR) fields. + + +### 4.5 | 2018-12-19 +- Fixed new tags not being added when updating existing list member. + + +### 4.4 | 2018-10-29 +- Added support for MailChimp contact tags. + + +### 4.3 | 2018-03-27 +- Added security enhancements. +- Added GPL to plugin header. +- Updated API library to public property in support of MailChimp block. +- Updated Plugin URI and Author URI to use https. +- Fixed the MailChimp API returning a validation error for list date fields set to the DD/MM/YYYY format. +- Fixed existing member retaining a status of cleaned or transactional instead of changing to pending or subscribed. +- Fixed birthday and date merge fields not being sent in the defined date format. +- Fixed an issue with the member status on resubscription to the list. +- Fixed PHP notice if the interests are not returned by the MailChimp API for the existing member. +- Fixed issue with css file that was being enqueued in every page. + + +### 4.2 | 2017-04-03 +- Added additional logging when checking if a user's subscription status. +- Added existing member object as sixth parameter of *gform_mailchimp_subscription* filter. +- Fixed PHP warning when attempting to check for existing interests when member did not belong to any interest categories. +- Fixed Fatal error that happened in certain situations. +- Fixed existing interest categories not being properly associated to subscription object. +- Fixed an issue with subscriptions not being created due to empty merge fields. +- Fixed an issue which could prevent the feed groups being converted to interest categories when upgrading from older versions of the add-on. +- Fixed inability to use double opt-in with existing members. +- Fixed API response error handling; API key was incorrectly shown as valid when a 403 Forbidden error was returned. +- Fixed an issue with the field value used for interest category logic evaluation. +- Restored GFMailChimp::get_group_setting_key() for use when upgrading from older versions of MailChimp Add-On. +- Restored double opt-in support for members who are being resubscribed to a list they are unsubscribed from. +- Disabled double opt-in support for members who are being resubscribed to a list they are unsubscribed from. (Member will be automatically subscribed to the list. This is a temporary workaround for an issue with the MailChimp API.) +- Re-introduced support for *gform_mailchimp_keep_existing_groups* filter. + + +### 4.1 | 2017-01-03 +- Added additional error logging when creating a subscription. +- Added support for configuring a note to be added to the subscriber. +- Fixed a fatal error during feed processing when a list field is mapped to an entry property. +- Fixed an issue where an Invalid Resource error would occur if the subscribers merge_fields property was included in the request when empty. +- Fixed an issue with the note being urlencoded during merge tag processing. +- Fixed users not being subscribed due to incorrect address formatting. +- Increased number of merge fields returned for a list. +- Updated feed processing to bypass override empty fields check for address fields. +- Updated maximum number of category interests returned by the API. +- Updated maximum number of interest groups returned by API. +- Updated merge fields field map to only allow Address fields to be mapped to MailChimp address merge fields. +- Updated strings for translations. +- Updated subscription object to use existing member status where possible. + + +### 4.0 | 2016-12-20 +- Added *gform_mailchimp_subscription* filter to modify subscription object. +- Removed 3.0 upgrade page. +- Removed send welcome email as feed settings option. +- Updated API requests to use MailChimp API 3.0. + + +### 3.7.5 | 2016-11-29 +- Fixed strings for translations. + + +### 3.7.4 | 2016-09-16 +- Fixed an issue with multi-input fields available for use with groups logic not including the inputs (i.e. Name and Address). + + +### 3.7.3 | 2016-05-06 +- Updated the MailChimp API to support the WP_PROXY_HOST and WP_PROXY_PORT constants when configuring the cURL options. + + +### 3.7.2 | 2016-03-11 +- Fixed an issue which was preventing feed processing aborting early if there is an issue with the MailChimp API. + + +### 3.7.1 | 2015-09-23 +- Fixed an issue where the cached settings were not cleared when the add-on was uninstalled. +- Fixed a rare issue for some server environments where several groups could be assigned the same settings key causing js issues in the feed editor. +- Fixed an issue where the cached group setting keys could be lost when updating the API key on the plugin settings tab. + + +### 3.7 | 2015-08-24 +- Added form and field specific versions of the *gform_mailchimp_field_value* filter. +- Added logging of group condition evaluation. +- Added $transaction, either Update or Subscribe, as the fifth parameter of the *gform_mailchimp_args_pre_subscribe* filter. +- Updated minimum Gravity Forms version to 1.9.3. +- Updated 'Opt-In Condition' setting label to 'Conditional Logic'. +- Updated feed processing to use get_field_value() when retrieving mapped field values, enabling support for GF_Field::get_value_export with GF 1.9.12.4 and later. +- Updated to use GF_Field::is_conditional_logic_supported to determine which field types should be listed in the group condition fields drop down. +- Fixed an issue with the feed list page if the API key not valid. +- Fixed an issue with the location of the *gform_mailchimp_args_pre_subscribe* filter. +- Fixed an issue with the upgrade routine which caused it run even if a pre-framework version hadn't been installed. +- Remove plugin settings header and add line break after plugin settings description. + + +### 3.6 | 2015-04-20 +- Added filter to allow changing parameters to the API method that returns the MailChimp Lists. +- Added Spanish (es_ES) translation. +- Fixed a low severity security vulnerability in the admin area which could be exploited by authenticated users with form administration permissions. +- Fixed an issue with the members existing groups being lost if no new groups were selected and *gform_mailchimp_keep_existing_groups* is true. + + +### 3.5 | 2015-02-03 +- Updated required version of Gravity Forms to 1.8.17. +- Fixed an issue with Address fields where MailChimp would ignore the passed string if it did not contain the street address, city, state, or zip. + + +### 3.4 | 2015-02-02 +- Added support for the middle name input when preparing Name field values. +- Updated required version of Gravity Forms to 1.9. +- Fixed an issue causing checkbox fields not to be mapped under certain conditions. +- Fixed fatal error with PHP < 5.4. + + +### 3.3 | 2015-01-30 +- Updated logging statements. +- Updated the *gform_mailchimp_field_value filter* to have an additional parameter which includes the name of the custom mapped field. +- Fixed issue causing address not to be mapped properly under certain scenarios. +- Fixed Notice. +- Fixed an issue with the concatenated string for Checkbox fields not being cleared before the next field is processed. +- Fixed a warning when MailChimp interest groups aren't enabled on the list. + + +### 3.2 | 2014-12-08 +- Added hook to allow args to be changed before sending submission to MailChimp. + add_filter( 'gform_mailchimp_args_pre_subscribe', 'override_mailchimp_params', 10, 4 ); + function override_mailchimp_params( $params, $form, $entry, $feed ) { + // do stuff + + return $params; + } + +- Added hook to select whether empty mapped fields should override existing values on Mailchimp; defaults to override. + add_filter('gform_mailchimp_override_empty_fields', '__return_false' ); +- Fixed issue where existing groups were not maintained for users already subscribed. +- Fixed notice messages. +- Fixed fatal error displayed on certain situations. + + +### 3.1 | 2014-11-21 +- Fixed issue where grouping assignment was not working for already subscribed users. +- Fixed issue where a fatal error is displayed in certain situations. +- Fixed issue with upgrade that caused configuration not to be copied over in certain situations. + + +### 3.0 | 2014-11-04 +- Added integration with Add-On Framework. +- Added support for sending selected checkboxes as a concatenated string. +- Updated POT file. +- Updated required version of Gravity Forms to 1.8.17. +- Updated to MailChimp API version 2.0. +- Updated files removing closing php tag at the end. +- Fixed a warning when MailChimp interest groups aren't enabled on the list. + + +### 2.2 | 2013-06-19 +- Updated phone number when set to standard format "(#########)######### - ############" to send in required format of #########-#########-############. + + +### 2.1 | 2013-03-26 +- Added Name (Full) as an option to the field mapping list when the form has a Name field set to Normal or Extended format. + + +### 2.0 | 2013-03-07 +- Fixed PHP warnings when no API key was set. +- Added the *gform_mailchimp_field_value* filter to enable the value to be modified before being sent to the MailChimp API. +- Added entry meta to the list of available field mappings. +- Fixed issue with group conditional logic not displaying all possible operators and value drop down correctly. +- Fixed issue with special character in main group name. +- Fixed issue with group conditional logic with non-selection field types. +- Added new hook *gform_mailchimp_allow_resubscription* which allows disabling support for resubscription. + add_filter('gform_mailchimp_allow_resubscription', '__return_false()'); +- Fixed issue saving group settings in admin when sub groups have the same name. + + +### 1.9 | 2012-11-28 +- Updated Group logic to keep existing groups. +- Added filter to change logic back to overriding groups. + add_filter("gform_mailchimp_keep_existing_groups", "__return_false"); +- Updated to treat members as if they were a new subscribe request when currently set to a status on MailChimp's side of unsubscribed, pending, cleaned. +- Fixed issue with special characters in MailChimp Group names causing issues when creating feed. + + +### 1.8 | 2012-10-24 +- Fixed issue with GetFieldValues() when used with groups; was returning full select when only options were required. +- Fixed notices. +- Fixed group names (commas in names are treated by MailChimp as a delimiter indicating multiple groups). + + +### 1.7 | 2012-07-03 +- Fixed issue with some Mapped Fields not being passed (Entry Date, User IP, Source Url, Form Title). +- Added new conditional logic options (greater than, less than, contains starts with, ends with) and support for other conditional fields. +- Fixed notices. +- Fixed issue when testing if email is already in the list. + + +### 1.6.3 | 2012-03-13 +- Added logging. +- Fixed notices. +- Fixed issue with single quotes on feed edit screen creating javascript errors. + + +### 1.6.2 | 2012-03-01 +- Fixed issue with sack script being initialized with an incorrect admin url. +- Fixed issue that causing conflicts with feeds created by older versions of the plugin. + + +### 1.6.1 | 2012-01-20 +- Fixed issue that caused warnings to be displayed on feeds created by older versions. + + +### 1.6 | 2012-01-05 +- Fixed issue where RG_CURRENT_PAGE constant was not available when GF is deactivated. +- Fixed noticed caused where $api variable not declared. +- Added support for MaiChimp Groups so that subscribers can be assigned to a group when added to a list. +- Added Form Title to the list of fields to be mapped. +- Updated procedure that gets the MailChimp lists so that more than 25 lists are returned (up to 100). +- Added integration with PayPal so that subscribers can be added only when payment is received. + + +### 1.5 | 2011-06-23 +- Updated API Wrapper to 1.3 (mini). +- Removed blank strings from POT file to prevent error messages in Poedit. + + +### 1.4 | 2011-04-25 +- Cleaned up notices. +- Fixed issue when using Opt-in condition on a field with multiple single quote characters in the label. +- Fixed issue when creating a feed using forms with HTML markup in field labels. + + +### 1.3.4 +- Cleaned up notices. + + +### 1.3.3 +- Added "Cancel" button to Edit page and updated "Save" and "Update" button verbiage. + + +### 1.3.2 | 2011-02-06 +- Fixed issue with MailChimp lists being displayed as blank values. Taking into account different data formats returned by the API. + + +### 1.3.1 | 2010-12-15 +- Using new MailChimp PHP API wrapper (v. 1.2.6) when authenticating via an API Key. + + +### 1.3 | 2010-12-15 +- Added support for authentication via MailChimp API Key. + + +### 1.2 | 2010-12-15 +- Fixed issue with automatic upgrade on WP 3.0. + + +### 1.1 +- Adding MailChimp capabilities to admin role upon plugin activation. + + +### 1.0.beta-2 +- Added MailChimp icon. +- Renamed "Contact List" to "MailChimp List". + + +### 1.0.beta-1 +- Changed text on list page when settings haven't been configured. +- Created POT file. + + +### 0.2 | 2010-12-15 +- Map Fields column headers to ?List Fields? and ?Form Fields? and bol. +- Rename button to "Save Feed" for a new feed and "Update Feed" for an existing one. +- Settings page subnavigation to look like "Edit Forms" subnav (i.e. All | Active | Inactive) with no pipe at the end. +- Try adding menu item between Entries and Settings. +- Move "Add Feed" to top right (like posts page) and rename to "Add new". + + +### 0.1 | 2010-12-15 +- Split logic from Feeds Add-On. +- Implemented automatic upgrade. +- Implemented list page checkboxes (for bulk actions). +- Implemented active/inactive icons on list page. diff --git a/class-gf-mailchimp.php b/class-gf-mailchimp.php index fc14238..0fc5856 100755 --- a/class-gf-mailchimp.php +++ b/class-gf-mailchimp.php @@ -8,7 +8,7 @@ GFForms::include_feed_addon_framework(); /** - * Gravity Forms MailChimp Add-On. + * Gravity Forms Mailchimp Add-On. * * @since 1.0 * @package GravityForms @@ -17,6 +17,8 @@ */ class GFMailChimp extends GFFeedAddOn { + const POST_ACTION = 'gravityformsmailchimp_disconnect'; + /** * Contains an instance of this class, if available. * @@ -26,6 +28,15 @@ class GFMailChimp extends GFFeedAddOn { */ private static $_instance = null; + /** + * Enabling background feed processing. + * + * @since 5.1.1 + * + * @var bool + */ + protected $_async_feed_processing = true; + /** * Defines the version of the Mailchimp Add-On. * @@ -87,7 +98,7 @@ class GFMailChimp extends GFFeedAddOn { * @access protected * @var string $_title The title of the Add-On. */ - protected $_title = 'Gravity Forms MailChimp Add-On'; + protected $_title = 'Gravity Forms Mailchimp Add-On'; /** * Defines the short title of the Add-On. @@ -96,7 +107,7 @@ class GFMailChimp extends GFFeedAddOn { * @access protected * @var string $_short_title The short title. */ - protected $_short_title = 'MailChimp'; + protected $_short_title = 'Mailchimp'; /** * Defines if Add-On should use Gravity Forms servers for update data. @@ -144,20 +155,20 @@ class GFMailChimp extends GFFeedAddOn { protected $_capabilities_uninstall = 'gravityforms_mailchimp_uninstall'; /** - * Defines the MailChimp list field tag name. + * Defines the Mailchimp list/audience field tag name. * * @since 3.7 * @access protected - * @var string $merge_var_name The MailChimp list field tag name; used by gform_mailchimp_field_value. + * @var string $merge_var_name The Mailchimp list/audience field tag name; used by gform_mailchimp_field_value. */ protected $merge_var_name = ''; /** - * Defines the MailChimp merge fields used in the current request. + * Defines the Mailchimp merge fields used in the current request. * * @since 4.2.4 * @access protected - * @var array $merge_fields The MailChimp merge fields used in the current request. + * @var array $merge_fields The Mailchimp merge fields used in the current request. */ protected $merge_fields = array(); @@ -202,7 +213,7 @@ public function pre_init() { if ( $this->is_gravityforms_supported() ) { - // Load the MailChimp API library. + // Load the Mailchimp API library. if ( ! class_exists( 'GF_MailChimp_API' ) ) { require_once( 'includes/class-gf-mailchimp-api.php' ); } @@ -225,12 +236,29 @@ public function init() { $this->add_delayed_payment_support( array( - 'option_label' => esc_html__( 'Subscribe user to MailChimp only when payment is received.', 'gravityformsmailchimp' ), + 'option_label' => esc_html__( 'Subscribe user to Mailchimp only when payment is received.', 'gravityformsmailchimp' ), ) ); } + /** + * Add actions for admin_init + * + * @since 4.10 + * + * @return void + */ + public function init_admin() { + parent::init_admin(); + + add_action( 'admin_init', array( $this, 'maybe_update_auth_creds' ) ); + if ( GFForms::is_gravity_page() ) { + add_action( 'admin_init', array( $this, 'warn_for_deprecated_key' ) ); + } + add_action( 'admin_post_' . self::POST_ACTION, array( $this, 'handle_disconnection' ) ); + } + /** * Remove unneeded settings. * @@ -256,14 +284,18 @@ public function uninstall() { * @return array */ public function styles() { + $min = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG || isset( $_GET['gform_debug'] ) ? '' : '.min'; $styles = array( array( - 'handle' => $this->_slug . '_form_settings', - 'src' => $this->get_base_url() . '/css/form_settings.css', + 'handle' => 'gravityformsmailchimp_form_settings', + 'src' => $this->get_base_url() . "/css/form_settings{$min}.css", 'version' => $this->_version, 'enqueue' => array( - array( 'admin_page' => array( 'form_settings' ) ), + array( + 'admin_page' => array( 'plugin_settings', 'form_settings' ), + 'tab' => $this->_slug, + ), ), ), ); @@ -272,9 +304,128 @@ public function styles() { } + /** + * Return the plugin's icon for the plugin/form settings menu. + * + * @since 4.7 + * + * @return string + */ + public function get_menu_icon() { + + return $this->is_gravityforms_supported( '2.5-beta-4' ) ? 'gform-icon--mailchimp' : 'dashicons-admin-generic'; + + } + + // # OAUTH SETTINGS ----------------------------------------------------------------------------------------------- + + /** + * Get the authorization payload data. + * + * Returns the auth POST request if it's present, otherwise attempts to return a recent transient cache. + * + * @since 3.10 + * + * @return array + */ + private function get_oauth_payload() { + $payload = array_filter( + array( + 'auth_payload' => rgpost( 'auth_payload' ), + 'state' => rgpost( 'state' ), + 'auth_error' => rgpost( 'auth_error' ), + ) + ); + if ( count( $payload ) === 2 || isset( $payload['auth_error'] ) ) { + return $payload; + } + $payload = get_transient( "gravityapi_response_{$this->_slug}" ); + + if ( ! is_array( $payload ) ) { + return array(); + } + + delete_transient( "gravityapi_response_{$this->_slug}" ); + + return $payload; + } + + /** + * Update Auth Creds if they have changed. + * + * @since 4.10 + * + * @return void + */ + public function maybe_update_auth_creds() { + $payload = $this->get_oauth_payload(); + + // No payload, bail. + if ( empty( $payload ) ) { + return; + } + + // Auth Error form API - log and bail. + if ( isset( $payload['auth_error'] ) ) { + $this->add_error_notice( __METHOD__, 'error authenticating with the API Server' ); + + return; + } + + $state = $payload['state']; + $auth_payload = json_decode( $payload['auth_payload'], true ); + + // State didn't pass our nonce - log and bail. + if ( $state !== get_transient( "gravityapi_request_{$this->_slug}" ) ) { + $this->add_error_notice( __METHOD__, 'could not verify the state value from the API Server.' ); + + return; + } + + // Incorrect/missing auth data - log and bail. + if ( ! isset( $auth_payload['access_token'] ) || ! isset( $auth_payload['server_prefix'] ) ) { + $this->add_error_notice( __METHOD__, 'missing access_token or server_prefix in API response.' ); + + return; + } + + // Store the auth payload. + $this->update_plugin_settings( $auth_payload ); + } + + /** + * Add an error notice to admin if something goes awry. Also logs error to error_log. + * + * @since 4.10 + * + * @param string $method The method being called. + * @param string $message The message to display. + * + * @return void + */ + private function add_error_notice( $method, $message ) { + add_action( 'admin_notices', function () { + $message = __( 'Could not authenticate with Mailchimp.', 'gravityformsmailchimp' ); + + printf( '

%1$s

', esc_html( $message ) ); + } ); + + $this->log_error( $method . ': ' . $message ); + } + + /** + * Get the authentication state, which was created from a wp nonce. + * + * @since 4.10 + * + * @return string + */ + private function get_authentication_state_action() { + return 'gform_mailchimp_authentication_state'; + } // # PLUGIN SETTINGS ----------------------------------------------------------------------------------------------- @@ -290,19 +441,20 @@ public function plugin_settings_fields() { return array( array( - 'description' => '

' . - sprintf( - esc_html__( 'MailChimp makes it easy to send email newsletters to your customers, manage your subscriber lists, and track campaign performance. Use Gravity Forms to collect customer information and automatically add it to your MailChimp subscriber list. If you don\'t have a MailChimp account, you can %1$ssign up for one here.%2$s', 'gravityformsmailchimp' ), - '', '' - ) - . '

', + // translators: %1 is an opening tag, and %2 is a closing tag. + 'description' => '

' . sprintf( esc_html__( 'Mailchimp makes it easy to send email newsletters to your customers, manage your subscriber audiences, and track campaign performance. Use Gravity Forms to collect customer information and automatically add it to your Mailchimp subscriber audience. If you don\'t have a Mailchimp account, you can %1$ssign up for one here.%2$s', 'gravityformsmailchimp' ), '', '' ) . '

', 'fields' => array( + array( - 'name' => 'apiKey', - 'label' => esc_html__( 'MailChimp API Key', 'gravityformsmailchimp' ), - 'type' => 'text', - 'class' => 'medium', + 'name' => 'connection', + 'type' => 'html', 'feedback_callback' => array( $this, 'initialize_api' ), + 'html' => array( $this, 'render_connection_button' ), + 'callback' => array( $this, 'render_connection_button' ), + ), + array( + 'type' => 'save', + 'class' => 'hidden', ), ), ), @@ -310,8 +462,169 @@ public function plugin_settings_fields() { } + /** + * Render the Connection Button on the Settings Page. + * + * @since 4.10 + * + * @return string + */ + public function render_connection_button() { + $valid = $this->is_valid_connection(); + + if ( ! $valid ) { + $nonce = wp_create_nonce( $this->get_authentication_state_action() ); + $transient_name = 'gravityapi_request_' . $this->_slug; + + if ( get_transient( $transient_name ) ) { + delete_transient( $transient_name ); + } + + set_transient( $transient_name, $nonce, 10 * MINUTE_IN_SECONDS ); + } + + $before = $this->get_before_button_content( $valid ); + $button = $this->get_button_content( $valid ); + $after = $this->get_after_button_content( $valid ); + + if ( version_compare( GFForms::$version, '2.5', '<' ) ) { + echo $before . $button . $after; + + return; + } + + return $before . $button . $after; + } + + /** + * Get the markup to display before the connect button. + * + * @since 4.10 + * + * @param bool $valid Whether the current connection is valid. + * + * @return string + */ + private function get_before_button_content( $valid ) { + $html = ''; + + if ( ! $valid ) { + return ''; + } + + $account = $this->api->account_details(); + $name = isset( $account['account_name'] ) ? $account['account_name'] : false; + $html .= '

'; + + if ( $name ) { + $html .= esc_html__( 'Connected to Mailchimp as: ', 'gravityformsmailchimp' ); + $html .= esc_html( $name ) . '

'; + } else { + $html .= esc_html__( 'Connected to Mailchimp.', 'gravityformsmailchimp' ); + $html .= '

'; + } + + /** + * Allows third-party code to modify the HTML content which appears before the Connect button. + * + * @since 4.10 + * + * @param string $html The current HTML markup. + * @param bool $valid Whether the current API connection is valid (connected and using oAuth). + * + * @return string + */ + return apply_filters( 'gform_mailchimp_before_connect_button', $html, $valid ); + } + + /** + * Get the markup to display the connect button. + * + * @since 4.10 + * + * @param bool $valid Whether the current connection is valid. + * + * @return string + */ + private function get_button_content( $valid ) { + $html = sprintf( + '%2$s', + $valid ? $this->get_disconnect_url() : $this->get_connect_url(), + $valid ? __( 'Disconnect from Mailchimp', 'gravityformsmailchimp' ) : __( 'Connect to Mailchimp', 'gravityformsmailchimp' ), + '_self', + $valid ? 'gform-button--secondary' : 'gform-button--primary' + ); + + /** + * Allows third-party code to modify the Connect button HTML markup. + * + * @since 4.10 + * + * @param string $html The current button HTML markup. + * @param bool $valid Whether the current API connection is valid (connected and using oAuth). + * + * @return string + */ + return apply_filters( 'gform_mailchimp_connect_button', $html, $valid ); + } + + /** + * Get the markup to display after the connect button. + * + * @since 4.10 + * + * @param bool $valid Whether the current connection is valid. + * + * @return string + */ + private function get_after_button_content( $valid ) { + if ( ! $valid ) { + return ''; + } + + $html = '

'; + // translators: %1 is an opening tag, and %2 is a closing tag. + $html .= sprintf( __( 'In order to remove this site from your Mailchimp account, you\'ll need to remove it from your Mailchimp Account. %1$sLearn More.%2$s' ), '', '' ); + $html .= '

'; + + /** + * Allows third-party code to modify the HTML content which appears after the Connect button. + * + * @since 4.10 + * + * @param string $html The current HTML markup. + * @param bool $valid Whether the current API connection is valid (connected and using oAuth). + * + * @return string + */ + return apply_filters( 'gform_mailchimp_after_connect_button', $html, $valid ); + } + + /** + * Get the correct disconnect URL + * + * @since 4.10 + * + * @return string + */ + private function get_disconnect_url() { + return add_query_arg( array( 'action' => self::POST_ACTION ), admin_url( 'admin-post.php' ) ); + } + /** + * Get the correct connect URL + * + * @since 4.10 + * + * @return string + */ + private function get_connect_url() { + $settings_url = urlencode( admin_url( 'admin.php?page=gf_settings&subview=' . $this->_slug ) ); + $connect_url = sprintf( '%1$s/auth/mailchimp', GRAVITY_API_URL ); + $nonce = wp_create_nonce( $this->get_authentication_state_action() ); + return add_query_arg( array( 'redirect_to' => $settings_url, 'state' => $nonce, 'license' => GFCommon::get_key() ), $connect_url ); + } // # FEED SETTINGS ------------------------------------------------------------------------------------------------- @@ -328,7 +641,7 @@ public function feed_settings_fields() { $settings = array( array( - 'title' => esc_html__( 'MailChimp Feed Settings', 'gravityformsmailchimp' ), + 'title' => esc_html__( 'Mailchimp Feed Settings', 'gravityformsmailchimp' ), 'fields' => array( array( 'name' => 'feedName', @@ -344,13 +657,13 @@ public function feed_settings_fields() { ), array( 'name' => 'mailchimpList', - 'label' => esc_html__( 'MailChimp List', 'gravityformsmailchimp' ), + 'label' => esc_html__( 'Mailchimp Audience', 'gravityformsmailchimp' ), 'type' => 'mailchimp_list', 'required' => true, 'tooltip' => sprintf( '
%s
%s', - esc_html__( 'MailChimp List', 'gravityformsmailchimp' ), - esc_html__( 'Select the MailChimp list you would like to add your contacts to.', 'gravityformsmailchimp' ) + esc_html__( 'Mailchimp Audience', 'gravityformsmailchimp' ), + esc_html__( 'Select the Mailchimp audience you would like to add your contacts to.', 'gravityformsmailchimp' ) ), ), ), @@ -366,7 +679,7 @@ public function feed_settings_fields() { 'tooltip' => sprintf( '
%s
%s', esc_html__( 'Map Fields', 'gravityformsmailchimp' ), - esc_html__( 'Associate your MailChimp merge tags to the appropriate Gravity Form fields by selecting the appropriate form field from the list.', 'gravityformsmailchimp' ) + esc_html__( 'Associate your Mailchimp merge tags to the appropriate Gravity Form fields by selecting the appropriate form field from the list.', 'gravityformsmailchimp' ) ), ), array( @@ -377,7 +690,7 @@ public function feed_settings_fields() { 'tooltip' => sprintf( '
%s
%s', esc_html__( 'Groups', 'gravityformsmailchimp' ), - esc_html__( 'When one or more groups are enabled, users will be assigned to the groups in addition to being subscribed to the MailChimp list. When disabled, users will not be assigned to groups.', 'gravityformsmailchimp' ) + esc_html__( 'When one or more groups are enabled, users will be assigned to the groups in addition to being subscribed to the Mailchimp audience. When disabled, users will not be assigned to groups.', 'gravityformsmailchimp' ) ), ), array( @@ -393,7 +706,7 @@ public function feed_settings_fields() { 'tooltip' => sprintf( '
%s
%s', esc_html__( 'Double Opt-In', 'gravityformsmailchimp' ), - esc_html__( 'When the double opt-in option is enabled, MailChimp will send a confirmation email to the user and will only add them to your MailChimp list upon confirmation.', 'gravityformsmailchimp' ) + esc_html__( 'When the double opt-in option is enabled, Mailchimp will send a confirmation email to the user and will only add them to your Mailchimp audience upon confirmation.', 'gravityformsmailchimp' ) ), ), array( @@ -403,14 +716,14 @@ public function feed_settings_fields() { ), ), array( - 'name' => 'tags', - 'type' => 'text', - 'class' => 'medium merge-tag-support mt-position-right mt-hide_all_fields', - 'label' => esc_html__( 'Tags', 'gravityformsmailchimp' ), - 'tooltip' => sprintf( + 'name' => 'tags', + 'type' => 'text', + 'class' => 'medium merge-tag-support mt-position-right mt-hide_all_fields', + 'label' => esc_html__( 'Tags', 'gravityformsmailchimp' ), + 'tooltip' => sprintf( '
%s
%s', esc_html__( 'Tags', 'gravityformsmailchimp' ), - esc_html__( 'Associate tags to your MailChimp contacts with a comma separated list (e.g. new lead, Gravity Forms, web source). Commas within a merge tag value will be created as a single tag.', 'gravityformsmailchimp' ) + esc_html__( 'Associate tags to your Mailchimp contacts with a comma separated list (e.g. new lead, Gravity Forms, web source). Commas within a merge tag value will be created as a single tag.', 'gravityformsmailchimp' ) ), ), array( @@ -426,26 +739,29 @@ public function feed_settings_fields() { 'tooltip' => sprintf( '
%s
%s', esc_html__( 'Conditional Logic', 'gravityformsmailchimp' ), - esc_html__( 'When conditional logic is enabled, form submissions will only be exported to MailChimp when the conditions are met. When disabled all form submissions will be exported.', 'gravityformsmailchimp' ) + esc_html__( 'When conditional logic is enabled, form submissions will only be exported to Mailchimp when the conditions are met. When disabled all form submissions will be exported.', 'gravityformsmailchimp' ) ), ), - array( 'type' => 'save' ), + array( + 'type' => 'save', + 'dependency' => 'mailchimpList', + ), ), ), ); - // Get currently selected list. + // Get currently selected list/audience. $list = $this->get_setting( 'mailchimpList' ); - // If a list is selected, get marketing permissions and add setting. + // If a list/audience is selected, get marketing permissions and add setting. if ( $list ) { try { - // Get MailChimp list, + // Get Mailchimp list/audience, $list = $this->api->get_list( $list ); - // If marketing permissions are enabled for list, add setting. + // If marketing permissions are enabled for list/audience, add setting. if ( rgar( $list, 'marketing_permissions' ) ) { // Prepare setting. @@ -456,7 +772,7 @@ public function feed_settings_fields() { 'tooltip' => sprintf( '
%s
%s', esc_html__( 'Marketing Permissions', 'gravityformsmailchimp' ), - esc_html__( 'When enabled and conditions are met, users will be opted into your MailChimp list marketing permissions. If a user is already subscribed to your list, they will not be opted out of permissions they are already opted into.', 'gravityformsmailchimp' ) + esc_html__( 'When enabled and conditions are met, users will be opted into your Mailchimp audience marketing permissions. If a user is already subscribed to your audience, they will not be opted out of permissions they are already opted into.', 'gravityformsmailchimp' ) ), ); @@ -467,8 +783,8 @@ public function feed_settings_fields() { } catch ( Exception $e ) { - // Log that list could not be retrieved. - $this->log_error( __METHOD__ . '(): Unable to add Marketing Permissions field because list could not be retrieved; ' . $e->getMessage() ); + // Log that list/audience could not be retrieved. + $this->log_error( __METHOD__ . '(): Unable to add Marketing Permissions field because audience could not be retrieved; ' . $e->getMessage() ); } @@ -499,7 +815,7 @@ public function settings_mailchimp_list( $field, $echo = true ) { return $html; } - // Prepare list request parameters. + // Prepare list/audience request parameters. $params = array( 'start' => 0, 'limit' => 100 ); // Filter parameters. @@ -519,52 +835,52 @@ public function settings_mailchimp_list( $field, $echo = true ) { try { - // Log contact lists request parameters. - $this->log_debug( __METHOD__ . '(): Retrieving contact lists; params: ' . print_r( $params, true ) ); + // Log contact lists/audiences request parameters. + $this->log_debug( __METHOD__ . '(): Retrieving contact audiences; params: ' . print_r( $params, true ) ); - // Get lists. + // Get lists/audiences. $lists = $this->api->get_lists( $params ); } catch ( Exception $e ) { - // Log that contact lists could not be obtained. - $this->log_error( __METHOD__ . '(): Could not retrieve MailChimp contact lists; ' . $e->getMessage() ); + // Log that contact lists/audiences could not be obtained. + $this->log_error( __METHOD__ . '(): Could not retrieve Mailchimp contact audiences; ' . $e->getMessage() ); // Display error message. - printf( esc_html__( 'Could not load MailChimp contact lists. %sError: %s', 'gravityformsmailchimp' ), '
', $e->getMessage() ); + printf( esc_html__( 'Could not load Mailchimp contact audiences. %sError: %s', 'gravityformsmailchimp' ), '
', $e->getMessage() ); return; } - // If no lists were found, display error message. + // If no lists/audiences were found, display error message. if ( 0 === $lists['total_items'] ) { - // Log that no lists were found. - $this->log_error( __METHOD__ . '(): Could not load MailChimp contact lists; no lists found.' ); + // Log that no lists/audiences were found. + $this->log_error( __METHOD__ . '(): Could not load Mailchimp contact audiences; no audiences found.' ); // Display error message. - printf( esc_html__( 'Could not load MailChimp contact lists. %sError: %s', 'gravityformsmailchimp' ), '
', esc_html__( 'No lists found.', 'gravityformsmailchimp' ) ); + printf( esc_html__( 'Could not load Mailchimp contact audiences. %sError: %s', 'gravityformsmailchimp' ), '
', esc_html__( 'No audiences found.', 'gravityformsmailchimp' ) ); return; } - // Log number of lists retrieved. - $this->log_debug( __METHOD__ . '(): Number of lists: ' . count( $lists['lists'] ) ); + // Log number of lists/audiences retrieved. + $this->log_debug( __METHOD__ . '(): Number of audiences: ' . count( $lists['lists'] ) ); // Initialize select options. $options = array( array( - 'label' => esc_html__( 'Select a MailChimp List', 'gravityformsmailchimp' ), + 'label' => esc_html__( 'Select a Mailchimp Audience', 'gravityformsmailchimp' ), 'value' => '', ), ); - // Loop through MailChimp lists. + // Loop through Mailchimp lists/audiences. foreach ( $lists['lists'] as $list ) { - // Add list to select options. + // Add list/audience to select options. $options[] = array( 'label' => esc_html( $list['name'] ), 'value' => esc_attr( $list['id'] ), @@ -589,7 +905,7 @@ public function settings_mailchimp_list( $field, $echo = true ) { } /** - * Return an array of MailChimp list fields which can be mapped to the Form fields/entry meta. + * Return an array of Mailchimp list/audience fields which can be mapped to the Form fields/entry meta. * * @since 3.0 * @access public @@ -613,7 +929,7 @@ public function merge_vars_field_map() { return $field_map; } - // Get current list ID. + // Get current list/audience ID. $list_id = $this->get_setting( 'mailchimpList' ); // Get merge fields. @@ -667,6 +983,21 @@ public function can_create_feed() { } + /** + * Allow the feed to be duplicated. + * + * @since 4.7 + * + * @param array|int $id The ID of the feed to be duplicated or the feed object when duplicating a form. + * + * @return bool + */ + public function can_duplicate_feed( $id ) { + + return true; + + } + /** * Configures which columns should be displayed on the feed list page. * @@ -679,42 +1010,42 @@ public function feed_list_columns() { return array( 'feedName' => esc_html__( 'Name', 'gravityformsmailchimp' ), - 'mailchimp_list_name' => esc_html__( 'MailChimp List', 'gravityformsmailchimp' ), + 'mailchimp_list_name' => esc_html__( 'Mailchimp List', 'gravityformsmailchimp' ), ); } /** - * Returns the value to be displayed in the MailChimp List column. + * Returns the value to be displayed in the Mailchimp List/Audience column. * * @since 3.0 * @access public * - * @param array $feed The feed being included in the feed list. + * @param array $feed The feed being included in the feed list/audience. * * @return string */ public function get_column_value_mailchimp_list_name( $feed ) { - // If unable to initialize API, return the list ID. + // If unable to initialize API, return the list/audience ID. if ( ! $this->initialize_api() ) { return rgars( $feed, 'meta/mailchimpList' ); } try { - // Get list. + // Get list/audience. $list = $this->api->get_list( rgars( $feed, 'meta/mailchimpList' ) ); - // Return list name. + // Return list/audience name. return rgar( $list, 'name' ); } catch ( Exception $e ) { // Log error. - $this->log_error( __METHOD__ . '(): Unable to get MailChimp list for feed list; ' . $e->getMessage() ); + $this->log_error( __METHOD__ . '(): Unable to get Mailchimp audience for feed list; ' . $e->getMessage() ); - // Return list ID. + // Return list/audience ID. return rgars( $feed, 'meta/mailchimpList' ); } @@ -740,6 +1071,7 @@ public function settings_interest_categories( $field, $echo = true ) { // If no categories are found, return. if ( empty( $categories ) ) { $this->log_debug( __METHOD__ . '(): No categories found.' ); + return ''; } @@ -819,7 +1151,7 @@ public function interest_category_condition( $setting_name_root ) { $is_enabled = $this->get_setting( $condition_enabled_setting ) == '1'; $container_style = ! $is_enabled ? "style='display:none;'" : ''; - $str = "
" . + $str = "
" . esc_html__( 'Assign to group:', 'gravityformsmailchimp' ) . ' '; $str .= $this->settings_select( @@ -847,7 +1179,7 @@ public function interest_category_condition( $setting_name_root ) { $conditional_style = $decision == 'always' ? "style='display:none;'" : ''; - $str .= '
' . + $str .= '
' . $this->simple_condition( $setting_name_root, $is_enabled ) . '
' . @@ -870,7 +1202,7 @@ public function interest_category_condition( $setting_name_root ) { */ public function settings_marketing_permissions( $field, $echo = true ) { - // Get current list. + // Get current list/audience. $list = $this->get_setting( 'mailchimpList' ); // Get marketing permissions. @@ -879,8 +1211,8 @@ public function settings_marketing_permissions( $field, $echo = true ) { // If permissions are not available, display error message. if ( ! $permissions ) { - $html = esc_html__( 'You must have at least one list subscriber to configure Marketing Permissions.', 'gravityformsmailchimp' ); - $html .= ' ' . gform_tooltip( esc_html__( "Due to limitations with MailChimp's API, we are only able to get available Marketing Permissions when the selected list has at least one subscriber.", 'gravityformsmailchimp' ), '', true ); + $html = esc_html__( 'You must have at least one audience subscriber to configure Marketing Permissions.', 'gravityformsmailchimp' ); + $html .= ' ' . gform_tooltip( esc_html__( "Due to limitations with Mailchimp's API, we are only able to get available Marketing Permissions when the selected audience has at least one subscriber.", 'gravityformsmailchimp' ), '', true ); if ( $echo ) { echo $html; @@ -953,7 +1285,7 @@ public function marketing_permissions_condition( $setting_name_root ) { $container_style = ! $is_enabled ? "style='display:none;'" : ''; $str = sprintf( - '
%s', + '
%s', $setting_name_root, $container_style, $setting_name_root, @@ -961,11 +1293,11 @@ public function marketing_permissions_condition( $setting_name_root ) { ); - $str .= '
' . - $this->simple_condition( $setting_name_root, $is_enabled ) . - '
' . + $str .= '
' . + $this->simple_condition( $setting_name_root, $is_enabled ) . + '
' . - '
'; + '
'; return $str; @@ -1066,7 +1398,7 @@ public function checkbox_input_double_optin( $choice, $attributes, $value, $tool $display = $value ? 'none' : 'block-inline'; // Add warning to checkbox markup. - $markup .= '(' . esc_html__( 'Abusing this may cause your MailChimp account to be suspended.', 'gravityformsmailchimp' ) . ')'; + $markup .= '(' . esc_html__( 'Abusing this may cause your Mailchimp account to be suspended.', 'gravityformsmailchimp' ) . ')'; return $markup; @@ -1079,7 +1411,7 @@ public function checkbox_input_double_optin( $choice, $attributes, $value, $tool // # FEED PROCESSING ----------------------------------------------------------------------------------------------- /** - * Process the feed, subscribe the user to the list. + * Process the feed, subscribe the user to the list/audience. * * @since 3.0 * @access public @@ -1098,6 +1430,7 @@ public function process_feed( $feed, $entry, $form ) { // If unable to initialize API, log error and return. if ( ! $this->initialize_api() ) { $this->add_feed_error( esc_html__( 'Unable to process feed because API could not be initialized.', 'gravityformsmailchimp' ), $feed, $entry, $form ); + return $entry; } @@ -1113,11 +1446,12 @@ public function process_feed( $feed, $entry, $form ) { // If email address is invalid, log error and return. if ( GFCommon::is_invalid_or_empty_email( $email ) ) { $this->add_feed_error( esc_html__( 'A valid Email address must be provided.', 'gravityformsmailchimp' ), $feed, $entry, $form ); + return $entry; } /** - * Prevent empty form fields erasing values already stored in the mapped MailChimp MMERGE fields + * Prevent empty form fields erasing values already stored in the mapped Mailchimp MMERGE fields * when updating an existing subscriber. * * @param bool $override If the merge field should be overridden. @@ -1175,12 +1509,9 @@ public function process_feed( $feed, $entry, $form ) { $field_value_timestamp = strtotime( $field_value ); // Format date. - switch( $date_format ) { + switch ( $date_format ) { case 'DD/MM': - $field_value = date( 'd/m', $field_value_timestamp ); - break; - case 'MM/DD': $field_value = date( 'm/d', $field_value_timestamp ); break; @@ -1205,8 +1536,8 @@ public function process_feed( $feed, $entry, $form ) { try { - // Log that we are checking if user is already subscribed to list. - $this->log_debug( __METHOD__ . "(): Checking to see if $email is already on the list." ); + // Log that we are checking if user is already subscribed to list/audience. + $this->log_debug( __METHOD__ . "(): Checking to see if $email is already on the audience." ); // Get member info. $member = $this->api->get_list_member( $feed['meta']['mailchimpList'], $email ); @@ -1218,7 +1549,7 @@ public function process_feed( $feed, $entry, $form ) { $member_status = $member['status']; // Log member status. - $this->log_debug( __METHOD__ . "(): $email was found on list. Status: $member_status" ); + $this->log_debug( __METHOD__ . "(): $email was found on audience. Status: $member_status" ); } catch ( Exception $e ) { @@ -1233,12 +1564,12 @@ public function process_feed( $feed, $entry, $form ) { } // Log member status. - $this->log_debug( __METHOD__ . "(): $email was not found on list." ); + $this->log_debug( __METHOD__ . "(): $email was not found on audience." ); } /** - * Modify whether a user that currently has a status of unsubscribed on your list is resubscribed. + * Modify whether a user that currently has a status of unsubscribed on your list/audience is resubscribed. * By default, the user is resubscribed. * * @param bool $allow_resubscription If the user should be resubscribed. @@ -1251,18 +1582,19 @@ public function process_feed( $feed, $entry, $form ) { // If member is unsubscribed and resubscription is not allowed, exit. if ( 'unsubscribed' == $member_status && ! $allow_resubscription ) { $this->log_debug( __METHOD__ . '(): User is unsubscribed and resubscription is not allowed.' ); + return; } /** - * Modify whether a user that is already subscribed to your list has their groups replaced when submitting the form a second time. + * Modify whether a user that is already subscribed to your list/audience has their groups replaced when submitting the form a second time. * * @since 1.9 * - * @param bool $keep_existing_interests Should user keep existing interest categories? - * @param array $form The form object. - * @param array $entry The entry object. - * @param array $feed The feed object. + * @param bool $keep_existing_interests Should user keep existing interest categories? + * @param array $form The form object. + * @param array $entry The entry object. + * @param array $feed The feed object. */ $keep_existing_interests = gf_apply_filters( array( 'gform_mailchimp_keep_existing_groups', $form['id'] ), true, $form, $entry, $feed ); @@ -1323,7 +1655,7 @@ public function process_feed( $feed, $entry, $form ) { } // Get tags. - $tags = explode(',', rgars( $feed, 'meta/tags' ) ); + $tags = explode( ',', rgars( $feed, 'meta/tags' ) ); $tags = array_map( 'trim', $tags ); // Prepare tags. @@ -1394,7 +1726,7 @@ public function process_feed( $feed, $entry, $form ) { $subscription['status'] = $subscription['double_optin'] ? 'pending' : $subscription['status']; unset( $subscription['double_optin'] ); - // Extract list ID. + // Extract list/audience ID. $list_id = $subscription['id']; unset( $subscription['id'] ); @@ -1402,17 +1734,39 @@ public function process_feed( $feed, $entry, $form ) { $subscription['email_address'] = $subscription['email']['email']; unset( $subscription['email'] ); + // If member exists, status is pending, and is double opt-in, then update member status to unsubscribed first. + if ( $member && rgar( $member, 'status' ) === 'pending' && rgars( $feed, 'meta/double_optin' ) ) { + try { + // Log that we are patching member status. + $this->log_debug( __METHOD__ . '(): Patching member status for opt-in.' ); + + // Update member status to unsubscribed. + $this->api->update_list_member( $list_id, $subscription['email_address'], array( 'status' => 'unsubscribed' ), 'PATCH' ); + + // Log that the subscription was successfully updated. + $this->log_debug( __METHOD__ . '(): Member status successfully updated.' ); + } catch ( Exception $e ) { + // Log that member status could not be updated. + $this->add_feed_error( sprintf( esc_html__( __METHOD__ . '(): Unable to update member status: %s', 'gravityformsmailchimp' ), $e->getMessage() ), $feed, $entry, $form ); + + // Log field errors. + if ( $e->hasErrors() ) { + $this->log_error( __METHOD__ . '(): Error when attempting to update member status: ' . print_r( $e->getErrors(), true ) ); + } + } + } + /** * Modify the subscription object before it is executed. * * @since 4.1.9 Added existing member object as $member parameter. * * @param array $subscription Subscription arguments. - * @param string $list_id MailChimp list ID. + * @param string $list_id Mailchimp list/audience ID. * @param array $form The form object. * @param array $entry The entry object. * @param array $feed The feed object. - * @param array|false $member The existing member object. (False if member does not currently exist in MailChimp.) + * @param array|false $member The existing member object. (False if member does not currently exist in Mailchimp.) */ $subscription = gf_apply_filters( array( 'gform_mailchimp_subscription', $form['id'] ), $subscription, $list_id, $form, $entry, $feed, $member ); @@ -1460,7 +1814,7 @@ public function process_feed( $feed, $entry, $form ) { // Check condition and add to subscription. $subscription['marketing_permissions'][] = array( - 'marketing_permission_id' => $existing_permission['marketing_permission_id'], + 'marketing_permission_id' => (string) $existing_permission['marketing_permission_id'], 'enabled' => $this->is_marketing_permission_condition_met( $permissions[ $existing_permission['marketing_permission_id'] ], $form, $entry ), ); @@ -1473,7 +1827,7 @@ public function process_feed( $feed, $entry, $form ) { // Add to subscription. $subscription['marketing_permissions'][] = array( - 'marketing_permission_id' => $permission_id, + 'marketing_permission_id' => (string) $permission_id, 'enabled' => $this->is_marketing_permission_condition_met( $permission, $form, $entry ), ); @@ -1646,7 +2000,7 @@ public function get_field_value( $form, $entry, $field_id ) { // Get field value. $field_value = rgar( $entry, $field_id ); - // Reformat standard format phone to match MailChimp format. + // Reformat standard format phone to match Mailchimp format. // Format: NPA-NXX-LINE (404-555-1212) when US/CAN. if ( ! empty( $field_value ) && preg_match( '/^\D?(\d{3})\D?\D?(\d{3})\D?(\d{4})$/', $field_value, $matches ) ) { $field_value = sprintf( '%s-%s-%s', $matches[1], $matches[2], $matches[3] ); @@ -1696,18 +2050,60 @@ public function maybe_override_field_value( $field_value, $form, $entry, $field_ } + // # HELPERS ------------------------------------------------------------------------------------------------------- + /** + * Returns the currently saved plugin settings + * + * @since Unknown + * + * @return array|false + */ + public function get_plugin_settings() { + $settings = get_option( 'gravityformsaddon_' . $this->_slug . '_settings' ); + if ( $this->is_connection_legacy() ) { + $settings['access_token'] = $settings['apiKey']; + $exploded_key = explode( '-', $settings['apiKey'] ); + $settings['server_prefix'] = isset( $exploded_key[1] ) ? $exploded_key[1] : 'us1'; + } - // # HELPERS ------------------------------------------------------------------------------------------------------- + return $settings; + } /** - * Initializes MailChimp API if credentials are valid. + * Determine whether a currently-existing connection to Mailchimp is using the legacy + * API Key paradigm. + * + * @since 4.10 + * + * @return bool + */ + private function is_connection_legacy() { + $settings = get_option( 'gravityformsaddon_' . $this->_slug . '_settings' ); + + return ( ! isset( $settings['access_token'] ) && isset( $settings['apiKey'] ) ); + } + + /** + * Determine if the current connection to Mailchimp is valid (it connects without error and + * uses OAuth instead of an API Key) + * + * @since 4.10 + * + * @return bool + */ + private function is_valid_connection() { + return $this->initialize_api() && ! $this->is_connection_legacy(); + } + + /** + * Initializes Mailchimp API if credentials are valid. * * @since 4.0 - * @access public + * @since 4.10 - Deprecated API Key param. * - * @param string $api_key MailChimp API key. + * @access public * * @uses GFAddOn::get_plugin_setting() * @uses GFAddOn::log_debug() @@ -1716,28 +2112,30 @@ public function maybe_override_field_value( $field_value, $form, $entry, $field_ * * @return bool|null */ - public function initialize_api( $api_key = null ) { + public function initialize_api( $deprecated = null ) { + + if ( ! empty( $deprecated ) ) { + _deprecated_argument( __METHOD__, '4.10' ); + } // If API is already initialized, return true. if ( ! is_null( $this->api ) ) { return true; } - // Get the API key. - if ( rgblank( $api_key ) ) { - $api_key = $this->get_plugin_setting( 'apiKey' ); - } - - // If the API key is blank, do not run a validation check. - if ( rgblank( $api_key ) ) { - return null; - } - // Log validation step. $this->log_debug( __METHOD__ . '(): Validating API Info.' ); - // Setup a new MailChimp object with the API credentials. - $mc = new GF_MailChimp_API( $api_key ); + $this->maybe_update_auth_creds(); + + $settings = $this->get_plugin_settings(); + + if ( ! isset( $settings['access_token'] ) || ! isset( $settings['server_prefix'] ) ) { + return false; + } + + // Setup a new Mailchimp object with the API credentials. + $mc = new GF_MailChimp_API( $settings['access_token'], $settings['server_prefix'] ); try { @@ -1748,14 +2146,14 @@ public function initialize_api( $api_key = null ) { $this->api = $mc; // Log that authentication test passed. - $this->log_debug( __METHOD__ . '(): MailChimp successfully authenticated.' ); + $this->log_debug( __METHOD__ . '(): Mailchimp successfully authenticated.' ); return true; } catch ( Exception $e ) { // Log that authentication test failed. - $this->log_error( __METHOD__ . '(): Unable to authenticate with MailChimp; '. $e->getMessage() ); + $this->log_error( __METHOD__ . '(): Unable to authenticate with Mailchimp; ' . $e->getMessage() ); return false; @@ -1764,12 +2162,12 @@ public function initialize_api( $api_key = null ) { } /** - * Retrieve the interest groups for the list. + * Retrieve the interest groups for the list/audience. * * @since 4.0 * @access public * - * @param string $list_id MailChimp list ID. + * @param string $list_id Mailchimp list/audience ID. * * @return array|bool */ @@ -1780,16 +2178,16 @@ private function get_interest_categories( $list_id = null ) { return false; } - // Get MailChimp list ID. + // Get Mailchimp list/audience ID. if ( rgblank( $list_id ) ) { $list_id = $this->get_setting( 'mailchimpList' ); } - // If MailChimp list ID is not defined, return. + // If Mailchimp list/audience ID is not defined, return. if ( rgblank( $list_id ) ) { - // Log that list ID was not defined. - $this->log_error( __METHOD__ . '(): Could not get MailChimp interest categories because list ID was not defined.' ); + // Log that list/audience ID was not defined. + $this->log_error( __METHOD__ . '(): Could not get Mailchimp interest categories because audience ID was not defined.' ); return false; @@ -1803,7 +2201,7 @@ private function get_interest_categories( $list_id = null ) { } catch ( Exception $e ) { // Log error. - $this->log_error( __METHOD__ . '(): Unable to get interest categories for list "' . $list_id . '"; ' . $e->getMessage() ); + $this->log_error( __METHOD__ . '(): Unable to get interest categories for audience "' . $list_id . '"; ' . $e->getMessage() ); return array(); @@ -1814,12 +2212,12 @@ private function get_interest_categories( $list_id = null ) { } /** - * Get available marketing permissions for a list. + * Get available marketing permissions for a list/audience. * - * @since 4.6 + * @since 4.6 * @access public * - * @param string $list_id MailChimp List ID. + * @param string $list_id Mailchimp List/Audience ID. * * @return array|bool */ @@ -1834,13 +2232,13 @@ private function get_marketing_permissions( $list_id ) { try { - // Get MailChimp list. + // Get Mailchimp list/audience. $list = $this->api->get_list( $list_id ); } catch ( Exception $e ) { - // Log that list could not be retrieved. - $this->log_error( __METHOD__ . '(): Unable to get marketing permissions because list could not be retrieved; ' . $e->getMessage() ); + // Log that list/audience could not be retrieved. + $this->log_error( __METHOD__ . '(): Unable to get marketing permissions because audience could not be retrieved; ' . $e->getMessage() ); return false; @@ -1853,21 +2251,21 @@ private function get_marketing_permissions( $list_id ) { try { - // Get a list member. + // Get a list/audience member. $members = $this->api->get_list_members( $list_id, array( 'count' => 1 ) ); $member = rgar( $members, 'members' ) ? $members['members'][0] : false; } catch ( Exception $e ) { - // Log that list could not be retrieved. - $this->log_error( __METHOD__ . '(): Unable to get marketing permissions because list members could not be retrieved; ' . $e->getMessage() ); + // Log that list/audience could not be retrieved. + $this->log_error( __METHOD__ . '(): Unable to get marketing permissions because audience members could not be retrieved; ' . $e->getMessage() ); return false; } - // If list has no members, create one. + // If list/audience has no members, create one. if ( ! $member ) { try { @@ -1878,7 +2276,7 @@ private function get_marketing_permissions( $list_id ) { 'status' => 'subscribed', ); - // Add member to list. + // Add member to list/audience. $member = $this->api->update_list_member( $list_id, $member_params['email_address'], $member_params ); // Delete member. @@ -1887,7 +2285,7 @@ private function get_marketing_permissions( $list_id ) { } catch ( Exception $e ) { // Log that we could not create test member. - $this->log_error( __METHOD__ . '(): Unable to create test list member to retrieve marketing permissions; ' . $e->getMessage() ); + $this->log_error( __METHOD__ . '(): Unable to create test audience member to retrieve marketing permissions; ' . $e->getMessage() ); return false; @@ -1911,7 +2309,7 @@ private function get_marketing_permissions( $list_id ) { } /** - * Determines if MailChimp list has any defined interest categories. + * Determines if Mailchimp list/audience has any defined interest categories. * * @since 4.0 * @access public @@ -1999,40 +2397,44 @@ public function get_feed_setting_conditions( $feed, $name = 'interestCategory', * @return bool */ public function is_category_condition_met( $category, $form, $entry ) { - - if ( ! $category['enabled'] ) { - + if ( ! rgar( $category, 'enabled' ) ) { $this->log_debug( __METHOD__ . '(): Interest category not enabled. Returning false.' ); return false; + } - } else if ( $category['decision'] == 'always' ) { - + if ( rgar( $category, 'decision' ) == 'always' ) { $this->log_debug( __METHOD__ . '(): Interest category decision is always. Returning true.' ); return true; - } - $field = GFFormsModel::get_field( $form, $category['field'] ); + $category_field = rgar( $category, 'field' ); + $field = GFFormsModel::get_field( $form, $category_field ); if ( ! is_object( $field ) ) { - - $this->log_debug( __METHOD__ . "(): Field #{$category['field']} not found. Returning true." ); + $this->log_debug( __METHOD__ . "(): Field #{$category_field} not found. Returning true." ); return true; + } - } else { - - $field_value = GFFormsModel::get_lead_field_value( $entry, $field ); - $is_value_match = GFFormsModel::is_value_match( $field_value, $category['value'], $category['operator'] ); - - $this->log_debug( __METHOD__ . "(): Add to interest category if field #{$category['field']} value {$category['operator']} '{$category['value']}'. Is value match? " . var_export( $is_value_match, 1 ) ); + // Prepare values for field matching and log output. + $category_value = rgar( $category, 'value' ); + $category_operator = rgar( $category, 'operator' ); + $rule = array_merge( $category, array( 'fieldId' => $field->id ) ); - return $is_value_match; + // Check for the value match. + $is_value_match = GFFormsModel::is_value_match( + GFFormsModel::get_lead_field_value( $entry, $field ), + $category_value, + $category_operator, + $field, + $rule + ); - } + $this->log_debug( __METHOD__ . "(): Add to interest category if field #{$category_field} value {$category_operator} '{$category_value}'. Is value match? " . var_export( $is_value_match, 1 ) ); + return $is_value_match; } @@ -2052,6 +2454,7 @@ public function is_marketing_permission_condition_met( $permission, $form, $entr if ( ! $permission['enabled'] ) { $this->log_debug( __METHOD__ . '(): Marketing Permission not enabled. Returning false.' ); + return false; } @@ -2061,6 +2464,7 @@ public function is_marketing_permission_condition_met( $permission, $form, $entr if ( ! is_object( $field ) ) { $this->log_debug( __METHOD__ . "(): Field #{$permission['field']} not found. Returning true." ); + return true; } else { @@ -2078,9 +2482,9 @@ public function is_marketing_permission_condition_met( $permission, $form, $entr /** * Returns the combined value of the specified Address field. - * Street 2 and Country are the only inputs not required by MailChimp. - * If other inputs are missing MailChimp will not store the field value, we will pass a hyphen when an input is empty. - * MailChimp requires the inputs be delimited by 2 spaces. + * Street 2 and Country are the only inputs not required by Mailchimp. + * If other inputs are missing Mailchimp will not store the field value, we will pass a hyphen when an input is empty. + * Mailchimp requires the inputs be delimited by 2 spaces. * * @since 3.0 * @access public @@ -2123,12 +2527,12 @@ public function get_full_address( $entry, $field_id ) { } /** - * Get MailChimp merge fields for list. + * Get Mailchimp merge fields for list/audience. * * @since 4.2.4 * @access public * - * @param string $list_id List ID to get merge fields for. + * @param string $list_id List/Audience ID to get merge fields for. * * @uses GFMailChimp::initialize_api() * @uses GF_MailChimp_API::get_list_merge_fields() @@ -2137,7 +2541,7 @@ public function get_full_address( $entry, $field_id ) { */ public function get_list_merge_fields( $list_id = '' ) { - // If no list ID was provided or if API cannot be initialized, return. + // If no list/audience ID was provided or if API cannot be initialized, return. if ( rgblank( $list_id ) || ! $this->initialize_api() ) { return array(); } @@ -2155,7 +2559,7 @@ public function get_list_merge_fields( $list_id = '' ) { } catch ( Exception $e ) { // Log error. - $this->log_error( __METHOD__ . '(): Unable to get merge fields for MailChimp list; ' . $e->getMessage() ); + $this->log_error( __METHOD__ . '(): Unable to get merge fields for Mailchimp audience; ' . $e->getMessage() ); $this->merge_fields[ $list_id ] = array(); @@ -2166,12 +2570,12 @@ public function get_list_merge_fields( $list_id = '' ) { } /** - * Get specific MailChimp merge field by tag. + * Get specific Mailchimp merge field by tag. * * @since 4.2.4 * @access public * - * @param string $list_id List ID to get merge fields for. + * @param string $list_id List/Audience ID to get merge fields for. * @param string $tag Merge field tag. * * @uses GFMailChimp::get_list_merge_fields() @@ -2180,7 +2584,7 @@ public function get_list_merge_fields( $list_id = '' ) { */ public function get_list_merge_field( $list_id = '', $tag = '' ) { - // Get the merge fields for list. + // Get the merge fields for list/audience. $merge_fields = $this->get_list_merge_fields( $list_id ); // If no merge fields were provided, return. @@ -2259,23 +2663,24 @@ public function convert_groups_to_categories() { // If API cannot be initialized, exit. if ( ! $this->initialize_api() ) { - $this->log_error( __METHOD__ . '(): Unable to convert MailChimp groups to interest categories because API could not be initialized.' ); + $this->log_error( __METHOD__ . '(): Unable to convert Mailchimp groups to interest categories because API could not be initialized.' ); + return; } // Get plugin settings. $settings = $this->get_plugin_settings(); - // Get MailChimp feeds. + // Get Mailchimp feeds. $feeds = $this->get_feeds(); $list_interest_categories = array(); $interest_category_interests = array(); - // Loop through MailChimp feeds. + // Loop through Mailchimp feeds. foreach ( $feeds as $feed ) { - // If no list ID is set, skip it. + // If no list/audience ID is set, skip it. if ( ! rgars( $feed, 'meta/mailchimpList' ) ) { continue; } @@ -2288,7 +2693,7 @@ public function convert_groups_to_categories() { $list_id = $feed['meta']['mailchimpList']; if ( ! isset( $list_interest_categories[ $list_id ] ) ) { - // Get interest categories for list. + // Get interest categories for list/audience. $list_interest_categories[ $list_id ] = $this->api->get_list_interest_categories( $list_id ); } @@ -2297,7 +2702,7 @@ public function convert_groups_to_categories() { } catch ( Exception $e ) { // Log that we could not get interest categories. - $this->log_error( __METHOD__ . '(): Unable to updated feed #' . $feed['id'] . ' because interest categories could not be retrieved for MailChimp list ' . $feed['meta']['mailchimpList'] ); + $this->log_error( __METHOD__ . '(): Unable to updated feed #' . $feed['id'] . ' because interest categories could not be retrieved for Mailchimp audience ' . $feed['meta']['mailchimpList'] ); continue; @@ -2328,7 +2733,7 @@ public function convert_groups_to_categories() { // Loop through feed meta. foreach ( $feed['meta'] as $key => $value ) { - // If this is not a MailChimp group key, skip it. + // If this is not a Mailchimp group key, skip it. if ( 0 !== strpos( $key, 'mc_group_' ) ) { continue; } @@ -2336,14 +2741,14 @@ public function convert_groups_to_categories() { // Explode meta key. $exploded_key = explode( '_', $key ); - // Get MailChimp group key. + // Get Mailchimp group key. $mc_key = $exploded_key[0] . '_' . $exploded_key[1] . '_' . $exploded_key[2]; unset( $exploded_key[0], $exploded_key[1], $exploded_key[2] ); // Get meta key without group name. $meta_key = implode( '_', $exploded_key ); - // Get settings key for MailChimp group key. + // Get settings key for Mailchimp group key. $settings_key = array_search( $mc_key, $settings ); // Get sanitized group name. @@ -2377,7 +2782,7 @@ public function convert_groups_to_categories() { } /** - * Upgrade versions of MailChimp Add-On before 3.0 to the Add-On Framework. + * Upgrade versions of Mailchimp Add-On before 3.0 to the Add-On Framework. * * @since 4.0 * @access public @@ -2643,7 +3048,7 @@ public function get_old_feeds() { * Retrieve the group setting key. * * @param string $grouping_id The group ID. - * @param string $group_name The group name. + * @param string $group_name The group name. * * @return string */ @@ -2667,4 +3072,53 @@ public function get_group_setting_key( $grouping_id, $group_name ) { return $plugin_settings[ $key ]; } + /** + * Add a warning if the current connection uses the (deprecated) API Key connection method. + * + * @since 4.10 + * + * @return void + */ + public function warn_for_deprecated_key() { + $api_key = $this->get_plugin_setting( 'apiKey' ); + if ( empty( $api_key ) ) { + return; + } + + $initialized = $this->initialize_api(); + + if ( ! $initialized ) { + return; + } + + add_action( + 'admin_notices', + function () { + $settings_url = admin_url( 'admin.php?page=gf_settings&subview=' . $this->_slug ); + + // translators: %1 is an opening tag, and %2 is a closing tag. + $message = sprintf( __( 'It looks like you\'re using an API Key to connect to Mailchimp. Please visit the %1$sMailchimp settings page%2$s in order to connect to the Mailchimp API.', 'gravityformsmailchimp' ), "", '' ); + + printf( '

%1$s

', $message ); + } + ); + + $this->log_error( __METHOD__ . ': user has API Key but has not connected to oAuth.' ); + } + + /** + * Removes the stored API settings when disconnecting. + * + * @since 4.10 + * + * @action admin_post_{self::POST_ACTION} + * + * @return void + */ + public function handle_disconnection() { + delete_option( 'gravityformsaddon_' . $this->_slug . '_settings' ); + $redirect_url = admin_url( 'admin.php?page=gf_settings&subview=' . $this->_slug ); + wp_safe_redirect( $redirect_url ); + } + } diff --git a/css/form_settings.css b/css/form_settings.css index 834de36..3b60650 100644 --- a/css/form_settings.css +++ b/css/form_settings.css @@ -10,8 +10,8 @@ margin-bottom: 5px; } -.gaddon-mailchimp-category .gf_animate_sub_settings, -.gaddon-mailchimp-permission .gf_animate_sub_settings { +.form-table .gaddon-mailchimp-category .gf_animate_sub_settings, +.form-table .gaddon-mailchimp-permission .gf_animate_sub_settings { padding-left: 10px; } @@ -23,7 +23,7 @@ margin-top: 0; } -.gaddon-mailchimp-permission .condition_container { +.form-table .condition_container { margin-bottom: 10px; margin-top: 5px; } @@ -33,6 +33,52 @@ margin-bottom: 5px; } -.gaddon-mailchimp-category { +.form-table .gaddon-mailchimp-category { + padding-bottom: 12px; + +} + +.gform-settings-panel__content .condition_container { + + padding-bottom: 1rem; + +} + +.gform-settings-panel__content .gaddon-mailchimp-permission .condition_container { + + margin-bottom: 1rem; + padding-top: .5rem; + +} + +.gaddon-mailchimp-category .gform-settings-field__conditional-logic .gf_conditional_logic_rules_container, +.gaddon-mailchimp-permission .gform-settings-field__conditional-logic .gf_conditional_logic_rules_container { + align-items: center; + display: flex; + flex-direction: row; } + +.condition_container select { + + width: auto !important; + +} + +.gform-settings-panel__content .condition_container > select { + + line-height: 1.0625rem; + margin-bottom: .5rem; + padding: .5rem 2.4375rem .5rem .8125rem; + +} + + #tab_gravityformsmailchimp #gaddon-setting-row-connection > th { + display: none; + } + + + + html[dir=rtl] .gform-settings-field__conditional-logic .gf_conditional_logic_rules_container select:first-child { + margin-left: 2px; + } diff --git a/css/form_settings.min.css b/css/form_settings.min.css index 1413e5c..f09b732 100644 --- a/css/form_settings.min.css +++ b/css/form_settings.min.css @@ -1 +1 @@ -.gaddon-mailchimp-categoryname{font-weight:700}.gaddon-setting-checkbox{margin:5px 0 0}.gaddon-mailchimp-permission-toggle{margin-bottom:5px}.gaddon-mailchimp-category .gf_animate_sub_settings,.gaddon-mailchimp-permission .gf_animate_sub_settings{padding-left:10px}.gaddon-mailchimp-permission:not( :first-child ){margin-top:5px}.gaddon-mailchimp-permission .gaddon-setting-checkbox:first-child{margin-top:0}.gaddon-mailchimp-permission .condition_container{margin-bottom:10px;margin-top:5px}.gaddon-mailchimp-permission .condition_label{display:inline-block;margin-bottom:5px}.gaddon-mailchimp-category{padding-bottom:12px} \ No newline at end of file +.gaddon-mailchimp-categoryname{font-weight:700}.gaddon-setting-checkbox{margin:5px 0 0}.gaddon-mailchimp-permission-toggle{margin-bottom:5px}.form-table .gaddon-mailchimp-category .gf_animate_sub_settings,.form-table .gaddon-mailchimp-permission .gf_animate_sub_settings{padding-left:10px}.gaddon-mailchimp-permission:not(:first-child){margin-top:5px}.gaddon-mailchimp-permission .gaddon-setting-checkbox:first-child{margin-top:0}.form-table .condition_container{margin-bottom:10px;margin-top:5px}.gaddon-mailchimp-permission .condition_label{display:inline-block;margin-bottom:5px}.form-table .gaddon-mailchimp-category{padding-bottom:12px}.gform-settings-panel__content .condition_container{padding-bottom:1rem}.gform-settings-panel__content .gaddon-mailchimp-permission .condition_container{margin-bottom:1rem;padding-top:.5rem}.gaddon-mailchimp-category .gform-settings-field__conditional-logic .gf_conditional_logic_rules_container,.gaddon-mailchimp-permission .gform-settings-field__conditional-logic .gf_conditional_logic_rules_container{align-items:center;display:flex;flex-direction:row}.condition_container select{width:auto!important}.gform-settings-panel__content .condition_container>select{line-height:1.0625rem;margin-bottom:.5rem;padding:.5rem 2.4375rem .5rem .8125rem}#tab_gravityformsmailchimp #gaddon-setting-row-connection>th{display:none}html[dir=rtl] .gform-settings-field__conditional-logic .gf_conditional_logic_rules_container select:first-child{margin-left:2px} \ No newline at end of file diff --git a/includes/class-gf-mailchimp-api.php b/includes/class-gf-mailchimp-api.php index 22250a7..2e3ce3d 100644 --- a/includes/class-gf-mailchimp-api.php +++ b/includes/class-gf-mailchimp-api.php @@ -1,7 +1,7 @@ api_key = $api_key; - - // Set data center. - $this->set_data_center(); + public function __construct( $access_token, $server_prefix = '' ) { + $this->api_key = $access_token; + if ( ! empty( $server_prefix ) ) { + $this->data_center = $server_prefix; + } } /** @@ -66,12 +65,12 @@ public function account_details() { } /** - * Delete a specific MailChimp list member. + * Delete a specific Mailchimp list/audience member. * * @since 4.6 * @access public * - * @param string $list_id MailChimp list ID. + * @param string $list_id Mailchimp list/audience ID. * @param string $email_address Email address. * * @uses GF_MailChimp_API::process_request() @@ -94,7 +93,7 @@ public function delete_list_member( $list_id, $email_address ) { * @since 4.0 * @access public * - * @param string $list_id MailChimp list ID. + * @param string $list_id Mailchimp list/audience ID. * @param string $category_id Interest category ID. * * @uses GF_MailChimp_API::process_request() @@ -109,12 +108,12 @@ public function get_interest_category_interests( $list_id, $category_id ) { } /** - * Get a specific MailChimp list. + * Get a specific Mailchimp list/audience. * * @since 4.0 * @access public * - * @param string $list_id MailChimp list ID. + * @param string $list_id Mailchimp list/audience ID. * * @uses GF_MailChimp_API::process_request() * @@ -128,12 +127,12 @@ public function get_list( $list_id ) { } /** - * Get all MailChimp lists. + * Get all Mailchimp lists. * * @since 4.0 * @access public * - * @param array $params List request parameters. + * @param array $params List/Audience request parameters. * * @uses GF_MailChimp_API::process_request() * @@ -147,12 +146,12 @@ public function get_lists( $params ) { } /** - * Get all interest categories for a MailChimp list. + * Get all interest categories for a Mailchimp list/audience. * * @since 4.0 * @access public * - * @param string $list_id MailChimp list ID. + * @param string $list_id Mailchimp list/audience ID. * * @uses GF_MailChimp_API::process_request() * @@ -166,12 +165,12 @@ public function get_list_interest_categories( $list_id ) { } /** - * Get a specific MailChimp list member. + * Get a specific Mailchimp list/audience member. * * @since 4.0 * @access public * - * @param string $list_id MailChimp list ID. + * @param string $list_id Mailchimp list/audience ID. * @param string $email_address Email address. * * @uses GF_MailChimp_API::process_request() @@ -189,13 +188,13 @@ public function get_list_member( $list_id, $email_address ) { } /** - * Get MailChimp list members. + * Get Mailchimp list/audience members. * * @since 4.6 * @access public * - * @param string $list_id MailChimp list ID. - * @param array $options Additional settings. + * @param string $list_id Mailchimp list/audience ID. + * @param array $options Additional settings. * * @uses GF_MailChimp_API::process_request() * @@ -209,12 +208,12 @@ public function get_list_members( $list_id, $options = array() ) { } /** - * Get all merge fields for a MailChimp list. + * Get all merge fields for a Mailchimp list/audience. * * @since 4.0 * @access public * - * @param string $list_id MailChimp list ID. + * @param string $list_id Mailchimp list/audience ID. * * @uses GF_MailChimp_API::process_request() * @@ -228,38 +227,44 @@ public function get_list_merge_fields( $list_id ) { } /** - * Add or update a MailChimp list member. + * Add or update a Mailchimp list/audience member. * * @since 4.0 + * @since 5.2 - Add support for request method to allow PATCH requests. * @access public * - * @param string $list_id MailChimp list ID. + * @param string $list_id Mailchimp list/audience ID. * @param string $email_address Email address. - * @param array $subscription Subscription details. + * @param array $subscription Subscription details. + * @param string $method Request method. Defaults to PUT. * * @uses GF_MailChimp_API::process_request() * * @return array * @throws GF_MailChimp_Exception|Exception */ - public function update_list_member( $list_id, $email_address, $subscription ) { + public function update_list_member( $list_id, $email_address, $subscription, $method = 'PUT' ) { + // Make sure that method is either PUT or PATCH. + if ( ! in_array( $method, array( 'PUT', 'PATCH' ) ) ) { + throw Exception( __METHOD__ . '(): Method must be one of PUT or PATCH.' ); + } // Prepare subscriber hash. $subscriber_hash = md5( strtolower( $email_address ) ); - return $this->process_request( 'lists/' . $list_id . '/members/' . $subscriber_hash, $subscription, 'PUT' ); + return $this->process_request( 'lists/' . $list_id . '/members/' . $subscriber_hash, $subscription, $method ); } /** - * Update tags for a MailChimp list member. + * Update tags for a Mailchimp list/audience member. * * @since Unknown * @access public * - * @param string $list_id MailChimp list ID. + * @param string $list_id Mailchimp list/audience ID. * @param string $email_address Email address. - * @param array $tags Member tags. + * @param array $tags Member tags. * * @uses GF_MailChimp_API::process_request() * @@ -276,14 +281,14 @@ public function update_member_tags( $list_id, $email_address, $tags ) { } /** - * Add a note to the MailChimp list member. + * Add a note to the Mailchimp list/audience member. * * @since 4.0.10 * @access public * - * @param string $list_id MailChimp list ID. + * @param string $list_id Mailchimp list/audience ID. * @param string $email_address Email address. - * @param string $note The note to be added to the member. + * @param string $note The note to be added to the member. * * @uses GF_MailChimp_API::process_request() * @@ -300,14 +305,14 @@ public function add_member_note( $list_id, $email_address, $note ) { } /** - * Process MailChimp API request. + * Process Mailchimp API request. * * @since 4.0 * @access private * - * @param string $path Request path. - * @param array $data Request data. - * @param string $method Request method. Defaults to GET. + * @param string $path Request path. + * @param array $data Request data. + * @param string $method Request method. Defaults to GET. * @param string $return_key Array key from response to return. Defaults to null (return full response). * * @throws GF_MailChimp_Exception|Exception If API request returns an error, exception is thrown. @@ -318,23 +323,30 @@ private function process_request( $path = '', $data = array(), $method = 'GET', // If API key is not set, throw exception. if ( rgblank( $this->api_key ) ) { - throw new Exception( 'API key must be defined to process an API request.' ); + throw new Exception( 'Access Token must be defined to process an API request.' ); } // Build base request URL. - $request_url = 'https://' . $this->data_center . '.api.mailchimp.com/3.0/' . $path; + $request_url = 'https://' . $this->get_data_center() . '.api.mailchimp.com/3.0/' . $path; // Add request URL parameters if needed. if ( 'GET' === $method && ! empty( $data ) ) { $request_url = add_query_arg( $data, $request_url ); } + $auth = 'Bearer ' . $this->api_key; + + // Deprecated API Key method detected - use that for auth to prevent breakage. + if ( $this->get_data_center_from_api_key() ) { + $auth = 'Basic ' . base64_encode( ':' . $this->api_key ); + } + // Build base request arguments. $args = array( - 'method' => $method, - 'headers' => array( + 'method' => $method, + 'headers' => array( 'Accept' => 'application/json', - 'Authorization' => 'Basic ' . base64_encode( ':' . $this->api_key ), + 'Authorization' => $auth, 'Content-Type' => 'application/json', ), /** @@ -348,11 +360,12 @@ private function process_request( $path = '', $data = array(), $method = 'GET', /** * Sets the HTTP timeout, in seconds, for the request. * - * @param int 30 The timeout limit, in seconds. Defalts to 30. + * @param int 30 The timeout limit, in seconds. Defaults to 30. + * @param string $request_url The request URL. * * @return int */ - 'timeout' => apply_filters( 'http_request_timeout', 30 ), + 'timeout' => apply_filters( 'http_request_timeout', 30, $request_url ), ); // Add data to arguments if needed. @@ -361,9 +374,9 @@ private function process_request( $path = '', $data = array(), $method = 'GET', } /** - * Filters the MailChimp request arguments. + * Filters the Mailchimp request arguments. * - * @param array $args The request arguments sent to MailChimp. + * @param array $args The request arguments sent to Mailchimp. * @param string $path The request path. * * @return array @@ -426,25 +439,45 @@ private function process_request( $path = '', $data = array(), $method = 'GET', * @since 4.0 * @access private */ - private function set_data_center() { + private function get_data_center() { // If API key is empty, return. if ( empty( $this->api_key ) ) { return; } + if ( ! empty( $this->data_center ) ) { + return $this->data_center; + } + + $data_center = $this->get_data_center_from_api_key(); + + return $data_center ? $data_center : 'us1'; + } + + private function get_data_center_from_api_key() { // Explode API key. $exploded_key = explode( '-', $this->api_key ); // Set data center from API key. - $this->data_center = isset( $exploded_key[1] ) ? $exploded_key[1] : 'us1'; + return isset( $exploded_key[1] ) ? $exploded_key[1] : false; + } + /** + * Get disconnect link. + * + * @since 4.10 + * + * @return string + */ + public function get_disconnect_url() { + return sprintf( 'https://%s.admin.mailchimp.com/account/api/', $this->data_center ); } } /** - * Gravity Forms MailChimp Exception. + * Gravity Forms Mailchimp Exception. * * @since 4.0.3 * @package GravityForms diff --git a/languages/gravityformsmailchimp.pot b/languages/gravityformsmailchimp.pot index 77a24b4..7e74b24 100644 --- a/languages/gravityformsmailchimp.pot +++ b/languages/gravityformsmailchimp.pot @@ -1,236 +1,228 @@ -# Copyright 2009-2019 Rocketgenius, Inc. +# Copyright (C) 2023 Gravity Forms +# This file is distributed under the GPL-2.0+. msgid "" msgstr "" -"Project-Id-Version: Gravity Forms MailChimp Add-On 4.6\n" -"Report-Msgid-Bugs-To: https://www.gravtiyforms.com\n" -"POT-Creation-Date: 2019-03-22 14:18:33+00:00\n" +"Project-Id-Version: Gravity Forms Mailchimp Add-On 5.2.0\n" +"Report-Msgid-Bugs-To: https://gravityforms.com/support\n" +"Last-Translator: Gravity Forms \n" +"Language-Team: Gravity Forms \n" "MIME-Version: 1.0\n" -"Content-Type: text/plain; charset=utf-8\n" +"Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"PO-Revision-Date: 2019-MO-DA HO:MI+ZONE\n" -"Last-Translator: Rocketgenius \n" -"Language-Team: Rocketgenius \n" -"X-Generator: Gravity Forms Build Server\n" -"X-Poedit-KeywordsList: " -"__;_e;_x:1,2c;_ex:1,2c;_n:1,2;_nx:1,2,4c;_n_noop:1,2;_nx_noop:1,2,3c;esc_" -"attr__;esc_html__;esc_attr_e;esc_html_e;esc_attr_x:1,2c;esc_html_x:1,2c;\n" -"Project-Id-Version: gravityformsmailchimp\n" -"Language: en_US\n" -"Plural-Forms: nplurals=2; plural=(n != 1);\n" -"X-Poedit-Basepath: ../\n" -"X-Poedit-Bookmarks: \n" -"X-Poedit-Country: United States\n" -"X-Poedit-SearchPath-0: .\n" -"X-Poedit-SourceCharset: utf-8\n" -"X-Textdomain-Support: yes\n" - -#: class-gf-mailchimp.php:228 -msgid "Subscribe user to MailChimp only when payment is received." -msgstr "" - -#: class-gf-mailchimp.php:295 -msgid "" -"MailChimp makes it easy to send email newsletters to your customers, manage " -"your subscriber lists, and track campaign performance. Use Gravity Forms to " -"collect customer information and automatically add it to your MailChimp " -"subscriber list. If you don't have a MailChimp account, you can %1$ssign up " -"for one here.%2$s" +"POT-Creation-Date: 2023-02-15T17:39:55+00:00\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"X-Generator: WP-CLI 2.7.1\n" +"X-Domain: gravityformsmailchimp\n" + +#. Plugin Name of the plugin +msgid "Gravity Forms Mailchimp Add-On" msgstr "" -#: class-gf-mailchimp.php:302 -msgid "MailChimp API Key" +#. Plugin URI of the plugin +#. Author URI of the plugin +msgid "https://gravityforms.com" msgstr "" -#: class-gf-mailchimp.php:331 -msgid "MailChimp Feed Settings" +#. Description of the plugin +msgid "Integrates Gravity Forms with Mailchimp, allowing form submissions to be automatically sent to your Mailchimp account." msgstr "" -#: class-gf-mailchimp.php:335 class-gf-mailchimp.php:341 -#: class-gf-mailchimp.php:681 +#. Author of the plugin +msgid "Gravity Forms" +msgstr "" + +#: class-gf-mailchimp.php:239 +msgid "Subscribe user to Mailchimp only when payment is received." +msgstr "" + +#: class-gf-mailchimp.php:411 +msgid "Could not authenticate with Mailchimp." +msgstr "" + +#. translators: %1 is an opening tag, and %2 is a closing tag. +#: class-gf-mailchimp.php:445 +msgid "Mailchimp makes it easy to send email newsletters to your customers, manage your subscriber audiences, and track campaign performance. Use Gravity Forms to collect customer information and automatically add it to your Mailchimp subscriber audience. If you don't have a Mailchimp account, you can %1$ssign up for one here.%2$s" +msgstr "" + +#: class-gf-mailchimp.php:520 +msgid "Connected to Mailchimp as: " +msgstr "" + +#: class-gf-mailchimp.php:523 +msgid "Connected to Mailchimp." +msgstr "" + +#: class-gf-mailchimp.php:553 +msgid "Disconnect from Mailchimp" +msgstr "" + +#: class-gf-mailchimp.php:553 +msgid "Connect to Mailchimp" +msgstr "" + +#: class-gf-mailchimp.php:644 +msgid "Mailchimp Feed Settings" +msgstr "" + +#: class-gf-mailchimp.php:648 +#: class-gf-mailchimp.php:654 +#: class-gf-mailchimp.php:1012 msgid "Name" msgstr "" -#: class-gf-mailchimp.php:342 +#: class-gf-mailchimp.php:655 msgid "Enter a feed name to uniquely identify this setup." msgstr "" -#: class-gf-mailchimp.php:347 class-gf-mailchimp.php:352 -#: class-gf-mailchimp.php:682 -msgid "MailChimp List" +#: class-gf-mailchimp.php:660 +#: class-gf-mailchimp.php:665 +msgid "Mailchimp Audience" msgstr "" -#: class-gf-mailchimp.php:353 -msgid "Select the MailChimp list you would like to add your contacts to." +#: class-gf-mailchimp.php:666 +msgid "Select the Mailchimp audience you would like to add your contacts to." msgstr "" -#: class-gf-mailchimp.php:363 class-gf-mailchimp.php:368 +#: class-gf-mailchimp.php:676 +#: class-gf-mailchimp.php:681 msgid "Map Fields" msgstr "" -#: class-gf-mailchimp.php:369 -msgid "" -"Associate your MailChimp merge tags to the appropriate Gravity Form fields " -"by selecting the appropriate form field from the list." +#: class-gf-mailchimp.php:682 +msgid "Associate your Mailchimp merge tags to the appropriate Gravity Form fields by selecting the appropriate form field from the list." msgstr "" -#: class-gf-mailchimp.php:374 class-gf-mailchimp.php:379 +#: class-gf-mailchimp.php:687 +#: class-gf-mailchimp.php:692 msgid "Groups" msgstr "" -#: class-gf-mailchimp.php:380 -msgid "" -"When one or more groups are enabled, users will be assigned to the groups " -"in addition to being subscribed to the MailChimp list. When disabled, users " -"will not be assigned to groups." +#: class-gf-mailchimp.php:693 +msgid "When one or more groups are enabled, users will be assigned to the groups in addition to being subscribed to the Mailchimp audience. When disabled, users will not be assigned to groups." msgstr "" -#: class-gf-mailchimp.php:385 +#: class-gf-mailchimp.php:698 msgid "Options" msgstr "" -#: class-gf-mailchimp.php:390 class-gf-mailchimp.php:395 +#: class-gf-mailchimp.php:703 +#: class-gf-mailchimp.php:708 msgid "Double Opt-In" msgstr "" -#: class-gf-mailchimp.php:396 -msgid "" -"When the double opt-in option is enabled, MailChimp will send a " -"confirmation email to the user and will only add them to your MailChimp " -"list upon confirmation." +#: class-gf-mailchimp.php:709 +msgid "When the double opt-in option is enabled, Mailchimp will send a confirmation email to the user and will only add them to your Mailchimp audience upon confirmation." msgstr "" -#: class-gf-mailchimp.php:401 +#: class-gf-mailchimp.php:714 msgid "Mark subscriber as VIP" msgstr "" -#: class-gf-mailchimp.php:409 class-gf-mailchimp.php:412 +#: class-gf-mailchimp.php:722 +#: class-gf-mailchimp.php:725 msgid "Tags" msgstr "" -#: class-gf-mailchimp.php:413 -msgid "" -"Associate tags to your MailChimp contacts with a comma separated list (e.g. " -"new lead, Gravity Forms, web source). Commas within a merge tag value will " -"be created as a single tag." +#: class-gf-mailchimp.php:726 +msgid "Associate tags to your Mailchimp contacts with a comma separated list (e.g. new lead, Gravity Forms, web source). Commas within a merge tag value will be created as a single tag." msgstr "" -#: class-gf-mailchimp.php:420 +#: class-gf-mailchimp.php:733 msgid "Note" msgstr "" -#: class-gf-mailchimp.php:424 class-gf-mailchimp.php:428 +#: class-gf-mailchimp.php:737 +#: class-gf-mailchimp.php:741 msgid "Conditional Logic" msgstr "" -#: class-gf-mailchimp.php:429 -msgid "" -"When conditional logic is enabled, form submissions will only be exported " -"to MailChimp when the conditions are met. When disabled all form " -"submissions will be exported." +#: class-gf-mailchimp.php:742 +msgid "When conditional logic is enabled, form submissions will only be exported to Mailchimp when the conditions are met. When disabled all form submissions will be exported." msgstr "" -#: class-gf-mailchimp.php:454 class-gf-mailchimp.php:458 +#: class-gf-mailchimp.php:770 +#: class-gf-mailchimp.php:774 msgid "Marketing Permissions" msgstr "" -#: class-gf-mailchimp.php:459 -msgid "" -"When enabled and conditions are met, users will be opted into your " -"MailChimp list marketing permissions. If a user is already subscribed to " -"your list, they will not be opted out of permissions they are already opted " -"into." +#: class-gf-mailchimp.php:775 +msgid "When enabled and conditions are met, users will be opted into your Mailchimp audience marketing permissions. If a user is already subscribed to your audience, they will not be opted out of permissions they are already opted into." msgstr "" -#: class-gf-mailchimp.php:534 class-gf-mailchimp.php:547 -msgid "Could not load MailChimp contact lists. %sError: %s" +#: class-gf-mailchimp.php:850 +#: class-gf-mailchimp.php:863 +msgid "Could not load Mailchimp contact audiences. %sError: %s" msgstr "" -#: class-gf-mailchimp.php:547 -msgid "No lists found." +#: class-gf-mailchimp.php:863 +msgid "No audiences found." msgstr "" -#: class-gf-mailchimp.php:559 -msgid "Select a MailChimp List" +#: class-gf-mailchimp.php:875 +msgid "Select a Mailchimp Audience" msgstr "" -#: class-gf-mailchimp.php:605 +#: class-gf-mailchimp.php:921 msgid "Email Address" msgstr "" -#: class-gf-mailchimp.php:823 +#: class-gf-mailchimp.php:1013 +msgid "Mailchimp List" +msgstr "" + +#: class-gf-mailchimp.php:1155 msgid "Assign to group:" msgstr "" -#: class-gf-mailchimp.php:832 +#: class-gf-mailchimp.php:1164 msgid "Always" msgstr "" -#: class-gf-mailchimp.php:836 +#: class-gf-mailchimp.php:1168 msgid "If" msgstr "" -#: class-gf-mailchimp.php:882 -msgid "" -"You must have at least one list subscriber to configure Marketing " -"Permissions." +#: class-gf-mailchimp.php:1214 +msgid "You must have at least one audience subscriber to configure Marketing Permissions." msgstr "" -#: class-gf-mailchimp.php:883 -msgid "" -"Due to limitations with MailChimp's API, we are only able to get available " -"Marketing Permissions when the selected list has at least one subscriber." +#: class-gf-mailchimp.php:1215 +msgid "Due to limitations with Mailchimp's API, we are only able to get available Marketing Permissions when the selected audience has at least one subscriber." msgstr "" -#: class-gf-mailchimp.php:960 +#: class-gf-mailchimp.php:1292 msgid "Enable permission if:" msgstr "" -#: class-gf-mailchimp.php:1069 -msgid "Abusing this may cause your MailChimp account to be suspended." +#: class-gf-mailchimp.php:1401 +msgid "Abusing this may cause your Mailchimp account to be suspended." msgstr "" -#: class-gf-mailchimp.php:1100 +#: class-gf-mailchimp.php:1432 msgid "Unable to process feed because API could not be initialized." msgstr "" -#: class-gf-mailchimp.php:1115 +#: class-gf-mailchimp.php:1448 msgid "A valid Email address must be provided." msgstr "" -#: class-gf-mailchimp.php:1229 +#: class-gf-mailchimp.php:1560 msgid "Unable to check if email address is already used by a member: %s" msgstr "" -#: class-gf-mailchimp.php:1506 +#: class-gf-mailchimp.php:1860 msgid "Unable to add/update subscriber: %s" msgstr "" -#: class-gf-mailchimp.php:1531 +#: class-gf-mailchimp.php:1885 msgid "Unable to add/update subscriber tags: %s" msgstr "" -#: class-gf-mailchimp.php:1549 +#: class-gf-mailchimp.php:1903 msgid "Unable to add note to subscriber: %s" msgstr "" -#. Plugin Name of the plugin/theme -msgid "Gravity Forms MailChimp Add-On" -msgstr "" - -#. Plugin URI of the plugin/theme -msgid "https://www.gravityforms.com" -msgstr "" - -#. Description of the plugin/theme -msgid "" -"Integrates Gravity Forms with MailChimp, allowing form submissions to be " -"automatically sent to your MailChimp account" +#. translators: %1 is an opening tag, and %2 is a closing tag. +#: class-gf-mailchimp.php:3100 +msgid "It looks like you're using an API Key to connect to Mailchimp. Please visit the %1$sMailchimp settings page%2$s in order to connect to the Mailchimp API." msgstr "" - -#. Author of the plugin/theme -msgid "rocketgenius" -msgstr "" - -#. Author URI of the plugin/theme -msgid "https://www.rocketgenius.com" -msgstr "" \ No newline at end of file diff --git a/mailchimp.php b/mailchimp.php index a3f7271..c5df8ef 100644 --- a/mailchimp.php +++ b/mailchimp.php @@ -6,18 +6,18 @@ } /** -Plugin Name: Gravity Forms MailChimp Add-On -Plugin URI: https://www.gravityforms.com -Description: Integrates Gravity Forms with MailChimp, allowing form submissions to be automatically sent to your MailChimp account -Version: 4.6 -Author: rocketgenius -Author URI: https://www.rocketgenius.com +Plugin Name: Gravity Forms Mailchimp Add-On +Plugin URI: https://gravityforms.com +Description: Integrates Gravity Forms with Mailchimp, allowing form submissions to be automatically sent to your Mailchimp account. +Version: 5.2.0 +Author: Gravity Forms +Author URI: https://gravityforms.com License: GPL-2.0+ Text Domain: gravityformsmailchimp Domain Path: /languages ------------------------------------------------------------------------ -Copyright 2009 rocketgenius +Copyright 2009-2023 Rocketgenius This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -34,7 +34,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA **/ -define( 'GF_MAILCHIMP_VERSION', '4.6' ); +define( 'GF_MAILCHIMP_VERSION', '5.2.0' ); // If Gravity Forms is loaded, bootstrap the Mailchimp Add-On. add_action( 'gform_loaded', array( 'GF_MailChimp_Bootstrap', 'load' ), 5 );