diff --git a/change_log.txt b/change_log.txt index 6ff2cc3..05b0639 100644 --- a/change_log.txt +++ b/change_log.txt @@ -1,265 +1,276 @@ ------------------------------------------------------------------------------------------------------------------- -Version 4.2 - - 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. - ------------------------------------------------------------------------------------------------------------------- -Version 4.1 - - 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. - ------------------------------------------------------------------------------------------------------------------- -Version 4.0 - - 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. - ------------------------------------------------------------------------------------------------------------------- -Version 3.7.5 - - Fixed strings for translations - ------------------------------------------------------------------------------------------------------------------- -Version 3.7.4 - - Fixed an issue with multi-input fields available for use with groups logic not including the inputs (i.e. Name and Address). - ------------------------------------------------------------------------------------------------------------------- -Version 3.7.3 - - Updated the MailChimp API to support the WP_PROXY_HOST and WP_PROXY_PORT constants when configuring the cURL options. - ------------------------------------------------------------------------------------------------------------------- -Version 3.7.2 - - Fixed an issue which was preventing feed processing aborting early if there is an issue with the MailChimp API. - ------------------------------------------------------------------------------------------------------------------- -Version 3.7.1 - - 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. - ------------------------------------------------------------------------------------------------------------------- -Version 3.7 - - 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. - ------------------------------------------------------------------------------------------------------------------- -Version 3.6 - - 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. - ------------------------------------------------------------------------------------------------------------------- -Version 3.5 - - 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. - ------------------------------------------------------------------------------------------------------------------- -Version 3.4 - - 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. - ------------------------------------------------------------------------------------------------------------------- -Version 3.3 - - 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. - ------------------------------------------------------------------------------------------------------------------- -Version 3.2 - - Added hook to allow args to be changed before sending submission to MailChimp. +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. + - 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. - ------------------------------------------------------------------------------------------------------------------- -Version 3.1 - - 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 - ------------------------------------------------------------------------------------------------------------------- -Version 3.0 - - 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. - ------------------------------------------------------------------------------------------------------------------- -Version 2.2 - - Updated phone number when set to standard format "(###)### - ####" to send in required format of ###-###-#### - ------------------------------------------------------------------------------------------------------------------- -Version 2.1 - - Added Name (Full) as an option to the field mapping list when the form has a Name field set to Normal or Extended format - ------------------------------------------------------------------------------------------------------------------- -Version 2.0 - - 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 + - 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 + - Fixed issue saving group settings in admin when sub groups have the same name ------------------------------------------------------------------------------------------------------------------- -Version 1.9 - - Updated Group logic to keep existing groups. - - Added filter to change logic back to overriding groups + +# 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. - ------------------------------------------------------------------------------------------------------------------- -Version 1.8 - - 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) - ------------------------------------------------------------------------------------------------------------------- -Version 1.7 - - 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 - ------------------------------------------------------------------------------------------------------------------- -Version 1.6.3 - - Added logging - - Fixed notices - - Fixed issue with single quotes on feed edit screen creating javascript errors - ------------------------------------------------------------------------------------------------------------------- -Version 1.6.2 - - 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 - ------------------------------------------------------------------------------------------------------------------- -Version 1.6.1 - - Fixed issue that caused warnings to be displayed on feeds created by older versions. - ------------------------------------------------------------------------------------------------------------------- -Version 1.6 - - 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 - ------------------------------------------------------------------------------------------------------------------- -Version 1.5 - - Updated API Wrapper to 1.3 (mini) - - Removed blank strings from POT file to prevent error messages in Poedit - ------------------------------------------------------------------------------------------------------------------- -Version 1.4 - - 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 - ------------------------------------------------------------------------------------------------------------------- -Version 1.3.4 - - Cleaned up notices - ------------------------------------------------------------------------------------------------------------------- -Version 1.3.3 - - Added "Cancel" button to Edit page and updated "Save" and "Update" button verbiage - ------------------------------------------------------------------------------------------------------------------- -Version 1.3.2 - - Fixed issue with MailChimp lists being displayed as blank values. Taking into account different data formats returned by the API - ------------------------------------------------------------------------------------------------------------------- -Version 1.3.1 - - Using new MailChimp PHP API wrapper (v. 1.2.6) when authenticating via an API Key - ------------------------------------------------------------------------------------------------------------------- -Version 1.3 - - Added support for authentication via MailChimp API Key - ------------------------------------------------------------------------------------------------------------------- -Version 1.2 - - Fixed issue with automatic upgrade on WP 3.0 - ------------------------------------------------------------------------------------------------------------------- -Version 1.1 - - Adding MailChimp capabilities to admin role upon plugin activation - ------------------------------------------------------------------------------------------------------------------- -Version 1.0.beta-2 - - Added MailChimp icon - - Renamed "Contact List" to "MailChimp List" - ------------------------------------------------------------------------------------------------------------------- -Version 1.0.beta-1 - - Changed text on list page when settings haven't been configured - - Created POT file - ------------------------------------------------------------------------------------------------------------------- -Version 0.2 - - 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" - ------------------------------------------------------------------------------------------------------------------- -Version 0.1 - - Split logic from Feeds Add-On - - Implemented automatic upgrade - - Implemented list page checkboxes (for bulk actions) - - Implemented active/inactive icons on list page - ------------------------------------------------------------------------------------------------------------------- + - 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 7455610..bfca2fe 100644 --- a/class-gf-mailchimp.php +++ b/class-gf-mailchimp.php @@ -1,5 +1,10 @@ is_gravityforms_supported() ) { - // Load the Mailgun API library. + // Load the MailChimp API library. if ( ! class_exists( 'GF_MailChimp_API' ) ) { require_once( 'includes/class-gf-mailchimp-api.php' ); } @@ -248,7 +262,9 @@ public function styles() { 'handle' => $this->_slug . '_form_settings', 'src' => $this->get_base_url() . '/css/form_settings.css', 'version' => $this->_version, - 'enqueue' => array( 'admin_page' => array( 'form_settings' ) ), + 'enqueue' => array( + array( 'admin_page' => array( 'form_settings' ) ), + ), ), ); @@ -547,19 +563,8 @@ public function merge_vars_field_map() { // Get current list ID. $list_id = $this->get_setting( 'mailchimpList' ); - try { - - // Get merge fields. - $merge_fields = $this->api->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() ); - - return $field_map; - - } + // Get merge fields. + $merge_fields = $this->get_list_merge_fields( $list_id ); // If merge fields exist, add to field map. if ( ! empty( $merge_fields['merge_fields'] ) ) { @@ -985,6 +990,38 @@ public function process_feed( $feed, $entry, $form ) { continue; } + // Get merge field. + $merge_field = $this->get_list_merge_field( $feed['meta']['mailchimpList'], $name ); + + // Format date field. + if ( ! empty( $field_value ) && ! empty( $merge_field ) && in_array( $merge_field['type'], array( 'date', 'birthday' ) ) ) { + + // Get date format. + $date_format = $merge_field['options']['date_format']; + + // Convert field value to timestamp. + $field_value_timestamp = strtotime( $field_value ); + + // Format date. + 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; + + case 'DD/MM/YYYY': + case 'MM/DD/YYYY': + $field_value = date( 'm/d/Y', $field_value_timestamp ); + break; + + } + + } + $merge_vars[ $name ] = $field_value; } @@ -1045,9 +1082,6 @@ public function process_feed( $feed, $entry, $form ) { return; } - // Initialize interests array. - $interests = $member_found ? $member['interests'] : array(); - /** * Modify whether a user that is already subscribed to your list has their groups replaced when submitting the form a second time. * @@ -1063,8 +1097,8 @@ public function process_feed( $feed, $entry, $form ) { // Initialize interests to keep array. $interests_to_keep = array(); - // Get existing interests. - $existing_interests = rgar( $member, 'interests' ); + // Initialize interests array. + $interests = $existing_interests = rgar( $member, 'interests', array() ); // If member was found, has existing interests and we are not keeping existing interest categories, remove them. if ( $member_found && $existing_interests ) { @@ -1116,8 +1150,8 @@ public function process_feed( $feed, $entry, $form ) { } - // If member status is not defined, set to subscribed. - $member_status = isset( $member_status ) ? $member_status : 'subscribed'; + // If member status is not defined or is anything other than pending, set to subscribed. + $member_status = isset( $member_status ) && $member_status === 'pending' ? $member_status : 'subscribed'; // Prepare subscription arguments. $subscription = array( @@ -1264,7 +1298,7 @@ public function process_feed( $feed, $entry, $form ) { * @uses GFMailChimp::get_full_address() * @uses GFMailChimp::maybe_override_field_value() * - * @return array + * @return array|string */ public function get_field_value( $form, $entry, $field_id ) { @@ -1676,6 +1710,88 @@ public function get_full_address( $entry, $field_id ) { } + /** + * Get MailChimp merge fields for list. + * + * @since 4.2.4 + * @access public + * + * @param string $list_id List ID to get merge fields for. + * + * @uses GFMailChimp::initialize_api() + * @uses GF_MailChimp_API::get_list_merge_fields() + * + * @return array + */ + public function get_list_merge_fields( $list_id = '' ) { + + // If no list ID was provided or if API cannot be initialized, return. + if ( rgblank( $list_id ) || ! $this->initialize_api() ) { + return array(); + } + + // If merge fields have already been retrieved, return. + if ( isset( $this->merge_fields[ $list_id ] ) ) { + return $this->merge_fields[ $list_id ]; + } + + try { + + // Get merge fields. + $this->merge_fields[ $list_id ] = $this->api->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->merge_fields[ $list_id ] = array(); + + } + + return $this->merge_fields[ $list_id ]; + + } + + /** + * 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 $tag Merge field tag. + * + * @uses GFMailChimp::get_list_merge_fields() + * + * @return array + */ + public function get_list_merge_field( $list_id = '', $tag = '' ) { + + // Get the merge fields for list. + $merge_fields = $this->get_list_merge_fields( $list_id ); + + // If no merge fields were provided, return. + if ( empty( $merge_fields ) || ! isset( $merge_fields['merge_fields'] ) ) { + return; + } + + // Loop through merge fields. + foreach ( $merge_fields['merge_fields'] as $merge_field ) { + + // If this is not the merge field we are looking for, skip. + if ( $tag !== $merge_field['tag'] ) { + continue; + } + + return $merge_field; + + } + + return array(); + + } + diff --git a/includes/class-gf-mailchimp-api.php b/includes/class-gf-mailchimp-api.php index 0dbbbb7..51ec780 100644 --- a/includes/class-gf-mailchimp-api.php +++ b/includes/class-gf-mailchimp-api.php @@ -234,7 +234,7 @@ public function add_member_note( $list_id, $email_address, $note ) { * @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 Exception if API request returns an error, exception is thrown. + * @throws GF_MailChimp_Exception If API request returns an error, exception is thrown. * * @return array */ @@ -261,7 +261,21 @@ private function process_request( $path = '', $data = array(), $method = 'GET', 'Authorization' => 'Basic ' . base64_encode( ':' . $this->api_key ), 'Content-Type' => 'application/json', ), + /** + * Filters if SSL verification should occur. + * + * @param bool false If the SSL certificate should be verified. Defalts to false. + * + * @return bool + */ 'sslverify' => apply_filters( 'https_local_ssl_verify', false ), + /** + * Sets the HTTP timeout, in seconds, for the request. + * + * @param int 30 The timeout limit, in seconds. Defalts to 30. + * + * @return int + */ 'timeout' => apply_filters( 'http_request_timeout', 30 ), ); @@ -270,7 +284,14 @@ private function process_request( $path = '', $data = array(), $method = 'GET', $args['body'] = json_encode( $data ); } - // Filter request arguments. + /** + * Filters the MailChimp request arguments. + * + * @param array $args The request arguments sent to MailChimp. + * @param string $path The request path. + * + * @return array + */ $args = apply_filters( 'gform_mailchimp_request_args', $args, $path ); // Get request response. diff --git a/languages/gravityformsmailchimp-ca.mo b/languages/gravityformsmailchimp-ca.mo index 7f977eb..6d7a0b0 100644 Binary files a/languages/gravityformsmailchimp-ca.mo and b/languages/gravityformsmailchimp-ca.mo differ diff --git a/languages/gravityformsmailchimp-da_DK.mo b/languages/gravityformsmailchimp-da_DK.mo index e3d627a..89f587e 100644 Binary files a/languages/gravityformsmailchimp-da_DK.mo and b/languages/gravityformsmailchimp-da_DK.mo differ diff --git a/languages/gravityformsmailchimp-de_DE.mo b/languages/gravityformsmailchimp-de_DE.mo index ca67c5a..87783b7 100644 Binary files a/languages/gravityformsmailchimp-de_DE.mo and b/languages/gravityformsmailchimp-de_DE.mo differ diff --git a/languages/gravityformsmailchimp-de_DE_formal.mo b/languages/gravityformsmailchimp-de_DE_formal.mo new file mode 100644 index 0000000..78217da Binary files /dev/null and b/languages/gravityformsmailchimp-de_DE_formal.mo differ diff --git a/languages/gravityformsmailchimp-en.mo b/languages/gravityformsmailchimp-en.mo index 583ba57..8c9e8a7 100644 Binary files a/languages/gravityformsmailchimp-en.mo and b/languages/gravityformsmailchimp-en.mo differ diff --git a/languages/gravityformsmailchimp-en_AU.mo b/languages/gravityformsmailchimp-en_AU.mo index 6fe31ab..87987ad 100644 Binary files a/languages/gravityformsmailchimp-en_AU.mo and b/languages/gravityformsmailchimp-en_AU.mo differ diff --git a/languages/gravityformsmailchimp-en_GB.mo b/languages/gravityformsmailchimp-en_GB.mo index bee2e90..89a9204 100644 Binary files a/languages/gravityformsmailchimp-en_GB.mo and b/languages/gravityformsmailchimp-en_GB.mo differ diff --git a/languages/gravityformsmailchimp-es_ES.mo b/languages/gravityformsmailchimp-es_ES.mo index e91da44..0b54130 100644 Binary files a/languages/gravityformsmailchimp-es_ES.mo and b/languages/gravityformsmailchimp-es_ES.mo differ diff --git a/languages/gravityformsmailchimp-fi.mo b/languages/gravityformsmailchimp-fi.mo index f9aba1e..9f1b567 100644 Binary files a/languages/gravityformsmailchimp-fi.mo and b/languages/gravityformsmailchimp-fi.mo differ diff --git a/languages/gravityformsmailchimp-fr_CA.mo b/languages/gravityformsmailchimp-fr_CA.mo new file mode 100644 index 0000000..40327c6 Binary files /dev/null and b/languages/gravityformsmailchimp-fr_CA.mo differ diff --git a/languages/gravityformsmailchimp-fr_FR.mo b/languages/gravityformsmailchimp-fr_FR.mo index b4ce9f1..52e9f33 100644 Binary files a/languages/gravityformsmailchimp-fr_FR.mo and b/languages/gravityformsmailchimp-fr_FR.mo differ diff --git a/languages/gravityformsmailchimp-it_IT.mo b/languages/gravityformsmailchimp-it_IT.mo index 5fb2e05..3c486d5 100644 Binary files a/languages/gravityformsmailchimp-it_IT.mo and b/languages/gravityformsmailchimp-it_IT.mo differ diff --git a/languages/gravityformsmailchimp-nb_NO.mo b/languages/gravityformsmailchimp-nb_NO.mo index efcc437..35c0d20 100644 Binary files a/languages/gravityformsmailchimp-nb_NO.mo and b/languages/gravityformsmailchimp-nb_NO.mo differ diff --git a/languages/gravityformsmailchimp-nl_NL.mo b/languages/gravityformsmailchimp-nl_NL.mo index 816ef88..af1e9c1 100644 Binary files a/languages/gravityformsmailchimp-nl_NL.mo and b/languages/gravityformsmailchimp-nl_NL.mo differ diff --git a/languages/gravityformsmailchimp-pt_BR.mo b/languages/gravityformsmailchimp-pt_BR.mo index 4d78692..3fb7587 100644 Binary files a/languages/gravityformsmailchimp-pt_BR.mo and b/languages/gravityformsmailchimp-pt_BR.mo differ diff --git a/languages/gravityformsmailchimp-pt_PT.mo b/languages/gravityformsmailchimp-pt_PT.mo index 5cdcde0..cc651db 100644 Binary files a/languages/gravityformsmailchimp-pt_PT.mo and b/languages/gravityformsmailchimp-pt_PT.mo differ diff --git a/languages/gravityformsmailchimp-ru_RU.mo b/languages/gravityformsmailchimp-ru_RU.mo index c35829f..0201ceb 100644 Binary files a/languages/gravityformsmailchimp-ru_RU.mo and b/languages/gravityformsmailchimp-ru_RU.mo differ diff --git a/languages/gravityformsmailchimp-zh_CN.mo b/languages/gravityformsmailchimp-zh_CN.mo index 512454c..5a4e5f2 100644 Binary files a/languages/gravityformsmailchimp-zh_CN.mo and b/languages/gravityformsmailchimp-zh_CN.mo differ diff --git a/languages/gravityformsmailchimp.pot b/languages/gravityformsmailchimp.pot index e111658..280f538 100644 --- a/languages/gravityformsmailchimp.pot +++ b/languages/gravityformsmailchimp.pot @@ -1,13 +1,13 @@ -# Copyright 2009-2017 Rocketgenius, Inc. +# Copyright 2009-2018 Rocketgenius, Inc. msgid "" msgstr "" -"Project-Id-Version: Gravity Forms MailChimp Add-On 4.2\n" +"Project-Id-Version: Gravity Forms MailChimp Add-On 4.3\n" "Report-Msgid-Bugs-To: http://www.gravtiyhelp.com\n" -"POT-Creation-Date: 2017-04-03 19:18:35+00:00\n" +"POT-Creation-Date: 2018-04-10 16:38:34+00:00\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=utf-8\n" "Content-Transfer-Encoding: 8bit\n" -"PO-Revision-Date: 2017-MO-DA HO:MI+ZONE\n" +"PO-Revision-Date: 2018-MO-DA HO:MI+ZONE\n" "Last-Translator: Rocketgenius \n" "Language-Team: Rocketgenius \n" "X-Generator: Gravity Forms Build Server\n" @@ -24,11 +24,11 @@ msgstr "" "X-Poedit-SourceCharset: utf-8\n" "X-Textdomain-Support: yes\n" -#: class-gf-mailchimp.php:214 +#: class-gf-mailchimp.php:228 msgid "Subscribe user to MailChimp only when payment is received." msgstr "" -#: class-gf-mailchimp.php:279 +#: 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 " @@ -37,136 +37,136 @@ msgid "" "for one here.%2$s" msgstr "" -#: class-gf-mailchimp.php:286 +#: class-gf-mailchimp.php:302 msgid "MailChimp API Key" msgstr "" -#: class-gf-mailchimp.php:315 +#: class-gf-mailchimp.php:331 msgid "MailChimp Feed Settings" msgstr "" -#: class-gf-mailchimp.php:319 class-gf-mailchimp.php:325 -#: class-gf-mailchimp.php:623 +#: class-gf-mailchimp.php:335 class-gf-mailchimp.php:341 +#: class-gf-mailchimp.php:628 msgid "Name" msgstr "" -#: class-gf-mailchimp.php:326 +#: class-gf-mailchimp.php:342 msgid "Enter a feed name to uniquely identify this setup." msgstr "" -#: class-gf-mailchimp.php:331 class-gf-mailchimp.php:336 -#: class-gf-mailchimp.php:624 +#: class-gf-mailchimp.php:347 class-gf-mailchimp.php:352 +#: class-gf-mailchimp.php:629 msgid "MailChimp List" msgstr "" -#: class-gf-mailchimp.php:337 +#: class-gf-mailchimp.php:353 msgid "Select the MailChimp list you would like to add your contacts to." msgstr "" -#: class-gf-mailchimp.php:347 class-gf-mailchimp.php:352 +#: class-gf-mailchimp.php:363 class-gf-mailchimp.php:368 msgid "Map Fields" msgstr "" -#: class-gf-mailchimp.php:353 +#: 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." msgstr "" -#: class-gf-mailchimp.php:358 class-gf-mailchimp.php:363 +#: class-gf-mailchimp.php:374 class-gf-mailchimp.php:379 msgid "Groups" msgstr "" -#: class-gf-mailchimp.php:364 +#: 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." msgstr "" -#: class-gf-mailchimp.php:369 +#: class-gf-mailchimp.php:385 msgid "Options" msgstr "" -#: class-gf-mailchimp.php:374 class-gf-mailchimp.php:379 +#: class-gf-mailchimp.php:390 class-gf-mailchimp.php:395 msgid "Double Opt-In" msgstr "" -#: class-gf-mailchimp.php:380 +#: 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." msgstr "" -#: class-gf-mailchimp.php:385 +#: class-gf-mailchimp.php:401 msgid "Mark subscriber as VIP" msgstr "" -#: class-gf-mailchimp.php:393 +#: class-gf-mailchimp.php:409 msgid "Note" msgstr "" -#: class-gf-mailchimp.php:397 class-gf-mailchimp.php:401 +#: class-gf-mailchimp.php:413 class-gf-mailchimp.php:417 msgid "Conditional Logic" msgstr "" -#: class-gf-mailchimp.php:402 +#: class-gf-mailchimp.php:418 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:465 class-gf-mailchimp.php:478 +#: class-gf-mailchimp.php:481 class-gf-mailchimp.php:494 msgid "Could not load MailChimp contact lists. %sError: %s" msgstr "" -#: class-gf-mailchimp.php:478 +#: class-gf-mailchimp.php:494 msgid "No lists found." msgstr "" -#: class-gf-mailchimp.php:490 +#: class-gf-mailchimp.php:506 msgid "Select a MailChimp List" msgstr "" -#: class-gf-mailchimp.php:536 +#: class-gf-mailchimp.php:552 msgid "Email Address" msgstr "" -#: class-gf-mailchimp.php:765 +#: class-gf-mailchimp.php:770 msgid "Assign to group:" msgstr "" -#: class-gf-mailchimp.php:774 +#: class-gf-mailchimp.php:779 msgid "Always" msgstr "" -#: class-gf-mailchimp.php:778 +#: class-gf-mailchimp.php:783 msgid "If" msgstr "" -#: class-gf-mailchimp.php:892 +#: class-gf-mailchimp.php:897 msgid "Abusing this may cause your MailChimp account to be suspended." msgstr "" -#: class-gf-mailchimp.php:923 +#: class-gf-mailchimp.php:928 msgid "Unable to process feed because API could not be initialized." msgstr "" -#: class-gf-mailchimp.php:938 +#: class-gf-mailchimp.php:943 msgid "A valid Email address must be provided." msgstr "" -#: class-gf-mailchimp.php:1020 +#: class-gf-mailchimp.php:1057 msgid "Unable to check if email address is already used by a member: %s" msgstr "" -#: class-gf-mailchimp.php:1217 +#: class-gf-mailchimp.php:1251 msgid "Unable to add/update subscriber: %s" msgstr "" -#: class-gf-mailchimp.php:1242 +#: class-gf-mailchimp.php:1276 msgid "Unable to add note to subscriber: %s" msgstr "" @@ -175,7 +175,7 @@ msgid "Gravity Forms MailChimp Add-On" msgstr "" #. Plugin URI of the plugin/theme -msgid "http://www.gravityforms.com" +msgid "https://www.gravityforms.com" msgstr "" #. Description of the plugin/theme @@ -189,5 +189,5 @@ msgid "rocketgenius" msgstr "" #. Author URI of the plugin/theme -msgid "http://www.rocketgenius.com" +msgid "https://www.rocketgenius.com" msgstr "" \ No newline at end of file diff --git a/mailchimp.php b/mailchimp.php index e91d62a..807729a 100644 --- a/mailchimp.php +++ b/mailchimp.php @@ -1,11 +1,18 @@