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
' . - 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( '%1$s