Easy Forms for MailChimp - Version 6.3.10

Version Description

Download this release

Release Info

Developer yikesitskevin
Plugin Icon 128x128 Easy Forms for MailChimp
Version 6.3.10
Comparing to
See all releases

Code changes from version 6.3.9.1 to 6.3.10

admin/partials/ajax/class.ajax.php CHANGED
@@ -79,7 +79,11 @@
79
  $interest_groupings = yikes_get_mc_api_manager()->get_list_handler()->get_interest_categories( $list_id );
80
  if ( is_wp_error( $interest_groupings ) ) {
81
  $error_logging = new Yikes_Inc_Easy_Mailchimp_Error_Logging();
82
- $error_logging->maybe_write_to_log( $interest_groupings['error'], __( "Get Interest Groups" , 'yikes-inc-easy-mailchimp-extender' ), "class.ajax.php" );
 
 
 
 
83
  $interest_groupings = array();
84
  }
85
 
@@ -142,9 +146,12 @@
142
 
143
  // Check for an error. If error, log it and return error
144
  if ( is_wp_error( $merge_field ) ) {
145
- $error = isset( $merge_field['error'] ) ? $merge_field['error'] : __( 'API request failed. Unknown error.', 'yikes-inc-easy-mailchimp-extender' );
146
  $error_logging = new Yikes_Inc_Easy_Mailchimp_Error_Logging();
147
- $error_logging->maybe_write_to_log( $error, __( "Updating merge field" , 'yikes-inc-easy-mailchimp-extender' ), "class.ajax.php" );
 
 
 
 
148
  wp_send_json_error( array(
149
  'message' => __( 'Could not update the field label: API request failed.', 'yikes-inc-easy-mailchimp-extender' ),
150
  'developer-info' => $error
79
  $interest_groupings = yikes_get_mc_api_manager()->get_list_handler()->get_interest_categories( $list_id );
80
  if ( is_wp_error( $interest_groupings ) ) {
81
  $error_logging = new Yikes_Inc_Easy_Mailchimp_Error_Logging();
82
+ $error_logging->maybe_write_to_log(
83
+ $interest_groupings->get_error_code(),
84
+ __( "Get Interest Groups" , 'yikes-inc-easy-mailchimp-extender' ),
85
+ "class.ajax.php"
86
+ );
87
  $interest_groupings = array();
88
  }
89
 
146
 
147
  // Check for an error. If error, log it and return error
148
  if ( is_wp_error( $merge_field ) ) {
 
149
  $error_logging = new Yikes_Inc_Easy_Mailchimp_Error_Logging();
150
+ $error_logging->maybe_write_to_log(
151
+ $merge_field->get_error_code(),
152
+ __( "Updating merge field" , 'yikes-inc-easy-mailchimp-extender' ),
153
+ "class.ajax.php"
154
+ );
155
  wp_send_json_error( array(
156
  'message' => __( 'Could not update the field label: API request failed.', 'yikes-inc-easy-mailchimp-extender' ),
157
  'developer-info' => $error
public/js/form-submission-helpers.js CHANGED
@@ -40,17 +40,18 @@ jQuery( document ).ready( function() {
40
  /**
41
  * Show/Hide zip-address field based on the chosen country.
42
  *
43
- * U.S. & G.B.: show zip
44
- * All other countries: do not show zip
45
- *
46
  * @param object | clicked_element | A reference to the clicked element - the country dropdown (JavaScript's `this`)
47
  * @param string | country_value | The value of the country dropdown
48
  */
49
  function yikes_mc_toggle_zip_field_visibility( clicked_element, country_value ) {
50
- if( country_value !== 'US' && country_value !== 'GB' ) {
51
- jQuery( clicked_element ).parents( '.yikes-mailchimp-container' ).find( jQuery( 'label[data-attr-name="zip-input"]' ) ).fadeOut();
52
- } else {
 
 
53
  jQuery( clicked_element ).parents( '.yikes-mailchimp-container' ).find( jQuery( 'label[data-attr-name="zip-input"]' ) ).fadeIn();
 
 
54
  }
55
  }
56
 
40
  /**
41
  * Show/Hide zip-address field based on the chosen country.
42
  *
 
 
 
43
  * @param object | clicked_element | A reference to the clicked element - the country dropdown (JavaScript's `this`)
44
  * @param string | country_value | The value of the country dropdown
45
  */
46
  function yikes_mc_toggle_zip_field_visibility( clicked_element, country_value ) {
47
+
48
+ // form_submission_helpers.countries_with_zip is a filterable array, passed through via the wp_localize_script function
49
+ var countries_with_zip_code_field = form_submission_helpers.countries_with_zip;
50
+
51
+ if ( typeof( countries_with_zip_code_field[ country_value ] ) !== 'undefined' ) {
52
  jQuery( clicked_element ).parents( '.yikes-mailchimp-container' ).find( jQuery( 'label[data-attr-name="zip-input"]' ) ).fadeIn();
53
+ } else {
54
+ jQuery( clicked_element ).parents( '.yikes-mailchimp-container' ).find( jQuery( 'label[data-attr-name="zip-input"]' ) ).fadeOut();
55
  }
56
  }
57
 
public/js/form-submission-helpers.min.js CHANGED
@@ -1 +1 @@
1
- function yikes_mc_toggle_zip_field_visibility(a,b){"US"!==b&&"GB"!==b?jQuery(a).parents(".yikes-mailchimp-container").find(jQuery('label[data-attr-name="zip-input"]')).fadeOut():jQuery(a).parents(".yikes-mailchimp-container").find(jQuery('label[data-attr-name="zip-input"]')).fadeIn()}function yikes_mc_toggle_state_field_visibility(a,b){var c=yikes_mc_does_country_have_states(a,b);c===!0?jQuery(a).parents(".yikes-mailchimp-container").find(jQuery('label[data-attr-name="state-dropdown"]')).fadeIn():jQuery(a).parents(".yikes-mailchimp-container").find(jQuery('label[data-attr-name="state-dropdown"]')).fadeOut()}function yikes_mc_toggle_state_fields_dropdown(a,b){jQuery(a).parents(".yikes-mailchimp-container").find(jQuery('label[data-attr-name="state-dropdown"]')).children("select").children("option").each(function(){jQuery(this).data("country")===b?jQuery(this).show():jQuery(this).hide()})}function yikes_mc_does_country_have_states(a,b){var c=!1;return jQuery(a).parents(".yikes-mailchimp-container").find(jQuery('label[data-attr-name="state-dropdown"]')).children("select").children("option").each(function(){if(jQuery(this).data("country")===b)return c=!0,!1}),c}jQuery(document).ready(function(){jQuery('select[data-country="true"]').change(function(){var a=jQuery(this).val();yikes_mc_toggle_state_fields_dropdown(this,a),yikes_mc_toggle_zip_field_visibility(this,a),yikes_mc_toggle_state_field_visibility(this,a)}),jQuery('select[data-country="true"]').trigger("change"),jQuery("body").on("click",".send-update-email",function(){var a={action:"easy_forms_send_email",user_email:jQuery(this).attr("data-user-email"),list_id:jQuery(this).attr("data-list-id"),form_id:jQuery(this).attr("data-form-id")};return jQuery(this).parent("p").fadeTo("fast",.75).append('<img src="'+form_submission_helpers.preloader_url+'" class="update-email-preloader" />'),jQuery.post(form_submission_helpers.ajax_url,a,function(a){a.success?jQuery(".yikes-easy-mc-error-message").removeClass("yikes-easy-mc-error-message").addClass("yikes-easy-mc-success-message").html(a.data.response_text):jQuery(".yikes-easy-mc-error-message").fadeTo("fast",1).html(a.data.response_text)}),!1})});
1
+ function yikes_mc_toggle_zip_field_visibility(a,b){var c=form_submission_helpers.countries_with_zip;"undefined"!=typeof c[b]?jQuery(a).parents(".yikes-mailchimp-container").find(jQuery('label[data-attr-name="zip-input"]')).fadeIn():jQuery(a).parents(".yikes-mailchimp-container").find(jQuery('label[data-attr-name="zip-input"]')).fadeOut()}function yikes_mc_toggle_state_field_visibility(a,b){var c=yikes_mc_does_country_have_states(a,b);c===!0?jQuery(a).parents(".yikes-mailchimp-container").find(jQuery('label[data-attr-name="state-dropdown"]')).fadeIn():jQuery(a).parents(".yikes-mailchimp-container").find(jQuery('label[data-attr-name="state-dropdown"]')).fadeOut()}function yikes_mc_toggle_state_fields_dropdown(a,b){jQuery(a).parents(".yikes-mailchimp-container").find(jQuery('label[data-attr-name="state-dropdown"]')).children("select").children("option").each(function(){jQuery(this).data("country")===b?jQuery(this).show():jQuery(this).hide()})}function yikes_mc_does_country_have_states(a,b){var c=!1;return jQuery(a).parents(".yikes-mailchimp-container").find(jQuery('label[data-attr-name="state-dropdown"]')).children("select").children("option").each(function(){if(jQuery(this).data("country")===b)return c=!0,!1}),c}jQuery(document).ready(function(){jQuery('select[data-country="true"]').change(function(){var a=jQuery(this).val();yikes_mc_toggle_state_fields_dropdown(this,a),yikes_mc_toggle_zip_field_visibility(this,a),yikes_mc_toggle_state_field_visibility(this,a)}),jQuery('select[data-country="true"]').trigger("change"),jQuery("body").on("click",".send-update-email",function(){var a={action:"easy_forms_send_email",user_email:jQuery(this).attr("data-user-email"),list_id:jQuery(this).attr("data-list-id"),form_id:jQuery(this).attr("data-form-id")};return jQuery(this).parent("p").fadeTo("fast",.75).append('<img src="'+form_submission_helpers.preloader_url+'" class="update-email-preloader" />'),jQuery.post(form_submission_helpers.ajax_url,a,function(a){a.success?jQuery(".yikes-easy-mc-error-message").removeClass("yikes-easy-mc-error-message").addClass("yikes-easy-mc-success-message").html(a.data.response_text):jQuery(".yikes-easy-mc-error-message").fadeTo("fast",1).html(a.data.response_text)}),!1})});
public/partials/shortcodes/process_form_shortcode.php CHANGED
@@ -286,6 +286,28 @@ function process_mailchimp_shortcode( $atts ) {
286
  // custom action hook to enqueue scripts & styles wherever the shortcode is used
287
  do_action( 'yikes-mailchimp-shortcode-enqueue-scripts-styles', $form_id );
288
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
289
  // object buffer
290
  ob_start();
291
 
@@ -343,7 +365,7 @@ function process_mailchimp_shortcode( $atts ) {
343
  if( ( ! empty( $atts['ajax'] ) && $atts['ajax'] == 1 ) || $form_data['submission_settings']['ajax'] == 1 ) {
344
  // enqueue our ajax script
345
  $min = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
346
- wp_enqueue_script( 'yikes-easy-mc-ajax' , YIKES_MC_URL . "public/js/yikes-mc-ajax-forms{$min}.js" , array( 'jquery' ) , YIKES_MC_VERSION, false );
347
  wp_localize_script( 'yikes-easy-mc-ajax', 'yikes_mailchimp_ajax', array(
348
  'ajax_url' => esc_url( admin_url( 'admin-ajax.php' ) ),
349
  'page_data' => $page_data,
@@ -355,10 +377,11 @@ function process_mailchimp_shortcode( $atts ) {
355
  }
356
 
357
  // Generic JavaScript functions for interacting with the form
358
- wp_enqueue_script( 'form-submission-helpers', YIKES_MC_URL . 'public/js/form-submission-helpers.min.js' , array( 'jquery' ), 'all' );
359
  wp_localize_script( 'form-submission-helpers', 'form_submission_helpers', array(
360
  'ajax_url' => esc_url( admin_url( 'admin-ajax.php' ) ),
361
- 'preloader_url' => apply_filters( 'yikes-mailchimp-preloader', esc_url_raw( admin_url( 'images/wpspin_light.gif' ) ) )
 
362
  ) );
363
 
364
  /*
@@ -716,7 +739,21 @@ function process_mailchimp_shortcode( $atts ) {
716
  <?php } ?>
717
 
718
  <select <?php echo implode( ' ' , $field_array ); ?>>
719
- <?php include( YIKES_MC_PATH . 'public/partials/shortcodes/templates/state-and-province-dropdown.php' ); ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
720
  </select>
721
 
722
  </label>
@@ -727,7 +764,7 @@ function process_mailchimp_shortcode( $atts ) {
727
  case 'zip':
728
 
729
  ?>
730
- <label for="<?php echo esc_attr( $field['merge'] ); ?>" <?php echo implode( ' ' , $label_array ); ?> data-attr-name="zip-input"<?php if( ! in_array( $default_country, array( 'US', 'GB' ) ) ) { ?> style="display: none;"<?php } ?>>
731
 
732
  <?php if( ! isset( $field['hide-label'] ) ) { ?>
733
  <span class="<?php echo esc_attr( $field['merge'] ) . '-label'; ?>">
286
  // custom action hook to enqueue scripts & styles wherever the shortcode is used
287
  do_action( 'yikes-mailchimp-shortcode-enqueue-scripts-styles', $form_id );
288
 
289
+
290
+ /**** Set up any filter'able content (that needs to be filtered before the rest of the logic kicks off) ****/
291
+
292
+ /**
293
+ * yikes-mailchimp-countries-with-zip
294
+ *
295
+ * Filter which countries show the zip field
296
+ *
297
+ * @param array | An array of country codes that the zip field will appear for - default: US, GB, CA
298
+ * Note: please return the array with the country code as the KEY! This allows for optimal searching.
299
+ * @param int | $form_id
300
+ */
301
+ $countries_with_zip_code_field = apply_filters( 'yikes-mailchimp-countries-with-zip',
302
+ array( 'US' => 'US', 'GB' => 'GB', 'CA' => 'CA',
303
+ 'IE' => 'IE', 'CN' => 'CN', 'IN' => 'IN',
304
+ 'AU' => 'AU', 'BR' => 'BR', 'MX' => 'MX',
305
+ 'IT' => 'IT', 'NZ' => 'NZ', 'JP' => 'JP',
306
+ 'FR' => 'FR', 'GR' => 'GR', 'DE' => 'DE',
307
+ 'NL' => 'NL', 'PT' => 'PT', 'ES' => 'ES'
308
+ ), $form_id
309
+ );
310
+
311
  // object buffer
312
  ob_start();
313
 
365
  if( ( ! empty( $atts['ajax'] ) && $atts['ajax'] == 1 ) || $form_data['submission_settings']['ajax'] == 1 ) {
366
  // enqueue our ajax script
367
  $min = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
368
+ wp_enqueue_script( 'yikes-easy-mc-ajax' , YIKES_MC_URL . "public/js/yikes-mc-ajax-forms{$min}.js" , array( 'jquery' ), YIKES_MC_VERSION, false );
369
  wp_localize_script( 'yikes-easy-mc-ajax', 'yikes_mailchimp_ajax', array(
370
  'ajax_url' => esc_url( admin_url( 'admin-ajax.php' ) ),
371
  'page_data' => $page_data,
377
  }
378
 
379
  // Generic JavaScript functions for interacting with the form
380
+ wp_enqueue_script( 'form-submission-helpers', YIKES_MC_URL . 'public/js/form-submission-helpers.min.js' , array( 'jquery' ), YIKES_MC_VERSION, false );
381
  wp_localize_script( 'form-submission-helpers', 'form_submission_helpers', array(
382
  'ajax_url' => esc_url( admin_url( 'admin-ajax.php' ) ),
383
+ 'preloader_url' => apply_filters( 'yikes-mailchimp-preloader', esc_url_raw( admin_url( 'images/wpspin_light.gif' ) ) ),
384
+ 'countries_with_zip' => $countries_with_zip_code_field
385
  ) );
386
 
387
  /*
739
  <?php } ?>
740
 
741
  <select <?php echo implode( ' ' , $field_array ); ?>>
742
+ <?php
743
+ $state_and_province_list = file_get_contents( YIKES_MC_PATH . 'public/partials/shortcodes/templates/state-and-province-dropdown.php' );
744
+ /**
745
+ * 'yikes-mailchimp-state-province-list'
746
+ *
747
+ * Filter the HTML options for the states dropdown
748
+ *
749
+ * @param string | $state_and_province_list | HTML string of state/province options
750
+ * @param int | $form_id | The form ID
751
+ *
752
+ * @return string | $state_and_province_list | Filtered HTML string of state/province options
753
+ */
754
+ echo apply_filters( 'yikes-mailchimp-state-province-list', $state_and_province_list, $form_id );
755
+
756
+ ?>
757
  </select>
758
 
759
  </label>
764
  case 'zip':
765
 
766
  ?>
767
+ <label for="<?php echo esc_attr( $field['merge'] ); ?>" <?php echo implode( ' ' , $label_array ); ?> data-attr-name="zip-input"<?php if ( ! isset( $countries_with_zip_code_field[ $default_country ] ) ) { ?> style="display: none;"<?php } ?>>
768
 
769
  <?php if( ! isset( $field['hide-label'] ) ) { ?>
770
  <span class="<?php echo esc_attr( $field['merge'] ) . '-label'; ?>">
readme.txt CHANGED
@@ -4,7 +4,7 @@ Donate link: https://yikesplugins.com/?utm_source=wp_plugin_repo&utm_medium=dona
4
  Tags: MailChimp, MailChimp forms, MailChimp lists, opt-in forms, sign up form, MailChimp, email, forms, mailing lists, marketing, newsletter, sign up
5
  Requires at least: 4.0
6
  Tested up to: 4.7.3
7
- Stable tag: 6.3.9.1
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -226,6 +226,9 @@ Below you'll find a complete list of the hooks and filters available in Easy For
226
  * `yikes-mailchimp-default-zip-code` - Filter to set the default zip code value. Default: `''` - @params $default_zip_code_value, $form_id
227
  * Version 6.3.6:
228
  * `yikes-mailchimp-excluded-redirect-post-types` - Filter which post types will *not* be included in the dropdown of pages that you can redirect to. Some post types will never need to be redirected to, and for convenience (e.g. a smaller and easier to navigate dropdown) these can be added to the excluded post types array. Default: `array( 'attachment' , 'revision' , 'nav_menu_item', 'shop_order', 'shop_order_refund', 'custom_css', 'customize_changeset' );` - @params: $excluded_post_types (the default array)
 
 
 
229
 
230
  **Actions**
231
 
@@ -247,6 +250,11 @@ Below you'll find a complete list of the hooks and filters available in Easy For
247
 
248
  == Changelog ==
249
 
 
 
 
 
 
250
  = Easy Forms for MailChimp 6.3.9.1 - March 14th, 2017 =
251
  * Added a new option for AJAX submissions with redirect set: open in new window/tab. (Note: some browsers may detect the redirect as a popup and block it by default)
252
  * Refactored the way the redirect logic worked
4
  Tags: MailChimp, MailChimp forms, MailChimp lists, opt-in forms, sign up form, MailChimp, email, forms, mailing lists, marketing, newsletter, sign up
5
  Requires at least: 4.0
6
  Tested up to: 4.7.3
7
+ Stable tag: 6.3.10
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
226
  * `yikes-mailchimp-default-zip-code` - Filter to set the default zip code value. Default: `''` - @params $default_zip_code_value, $form_id
227
  * Version 6.3.6:
228
  * `yikes-mailchimp-excluded-redirect-post-types` - Filter which post types will *not* be included in the dropdown of pages that you can redirect to. Some post types will never need to be redirected to, and for convenience (e.g. a smaller and easier to navigate dropdown) these can be added to the excluded post types array. Default: `array( 'attachment' , 'revision' , 'nav_menu_item', 'shop_order', 'shop_order_refund', 'custom_css', 'customize_changeset' );` - @params: $excluded_post_types (the default array)
229
+ * Version 6.3.10:
230
+ * `yikes-mailchimp-countries-with-zip` - Control which countries the zip field displays for. If the chosen country is not in this array, the zip field will fade out. @params: $countries_with_zip, $form_id
231
+ * `yikes-mailchimp-state-province-list` - Add or remove options from the states dropdown list. Default: All U.S. States and Canadian Provinces - @params: $state_and_province_list, $form_id
232
 
233
  **Actions**
234
 
250
 
251
  == Changelog ==
252
 
253
+ = Easy Forms for MailChimp 6.3.10 - March 21st, 2017 =
254
+ * Added a filter to customize the options in the states' dropdown. You can now add your own states/provinces, or remove the default ones. Use `yikes-mailchimp-state-province-list`
255
+ * Added a filter to customize the behavior of the zip code field. There are now around 20 different countries that the zip code field will be displayed for. Use the filter `yikes-mailchimp-countries-with-zip` to add/remove.
256
+ * Fixed an error handling bug that occurred when interest groups were empty for certain integrations
257
+
258
  = Easy Forms for MailChimp 6.3.9.1 - March 14th, 2017 =
259
  * Added a new option for AJAX submissions with redirect set: open in new window/tab. (Note: some browsers may detect the redirect as a popup and block it by default)
260
  * Refactored the way the redirect logic worked
yikes-inc-easy-mailchimp-extender.php CHANGED
@@ -3,7 +3,7 @@
3
  * Plugin Name: Easy Forms for MailChimp
4
  * Plugin URI: https://yikesplugins.com/plugin/easy-forms-for-mailchimp/
5
  * Description: The ultimate MailChimp WordPress plugin. Easily build <strong>unlimited forms for your MailChimp lists</strong>, add them to your site and track subscriber activity. To get started, go to the settings page and enter your <a href="https://yikesplugins.com/support/knowledge-base/finding-your-mailchimp-api-key/" target="_blank">MailChimp API key</a>.
6
- * Version: 6.3.9.1
7
  * Author: YIKES, Inc.
8
  * Author URI: https://www.yikesplugins.com/
9
  * License: GPL-3.0+
@@ -42,7 +42,7 @@ if ( ! defined( 'WPINC' ) ) {
42
  * @since 6.1.3
43
  */
44
  if ( ! defined( 'YIKES_MC_VERSION' ) ) {
45
- define( 'YIKES_MC_VERSION' , '6.3.9.1' );
46
  }
47
 
48
  /**
3
  * Plugin Name: Easy Forms for MailChimp
4
  * Plugin URI: https://yikesplugins.com/plugin/easy-forms-for-mailchimp/
5
  * Description: The ultimate MailChimp WordPress plugin. Easily build <strong>unlimited forms for your MailChimp lists</strong>, add them to your site and track subscriber activity. To get started, go to the settings page and enter your <a href="https://yikesplugins.com/support/knowledge-base/finding-your-mailchimp-api-key/" target="_blank">MailChimp API key</a>.
6
+ * Version: 6.3.10
7
  * Author: YIKES, Inc.
8
  * Author URI: https://www.yikesplugins.com/
9
  * License: GPL-3.0+
42
  * @since 6.1.3
43
  */
44
  if ( ! defined( 'YIKES_MC_VERSION' ) ) {
45
+ define( 'YIKES_MC_VERSION' , '6.3.10' );
46
  }
47
 
48
  /**