MailChimp List Subscribe Form - Version 1.2.6

Version Description

Fixes major bug with "Settings" link on Plugins screen.

Download this release

Release Info

Developer crowdfavorite
Plugin Icon wp plugin MailChimp List Subscribe Form
Version 1.2.6
Comparing to
See all releases

Code changes from version 1.2.5 to 1.2.6

Files changed (2) hide show
  1. mailchimp.php +27 -13
  2. readme.txt +9 -1
mailchimp.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: MailChimp
4
  Plugin URI: http://www.mailchimp.com/plugins/mailchimp-wordpress-plugin/
5
  Description: The MailChimp plugin allows you to quickly and easily add a signup form for your MailChimp list.
6
- Version: 1.2.5
7
  Author: MailChimp and Crowd Favorite
8
  Author URI: http://mailchimp.com/api/
9
  */
@@ -25,10 +25,10 @@ Author URI: http://mailchimp.com/api/
25
  */
26
 
27
  // Version constant for easy CSS refreshes
28
- define('MCSF_VER', '1.2.5');
29
 
30
  // What's our permission (capability) threshold
31
- define('MCSF_CAP_THRESHOLD', 'edit_plugins');
32
 
33
  // Define our location constants, both MCSF_DIR and MCSF_URL
34
  mailchimpSF_where_am_i();
@@ -63,12 +63,20 @@ function mailchimpSF_plugin_init() {
63
  }
64
  add_action( 'init', 'mailchimpSF_plugin_init' );
65
 
 
 
 
 
 
 
 
66
  function mailchimpSD_plugin_action_links($links) {
67
- $settings_link = '<a href="'. admin_url('options-general.php?page=mailchimpSF_options').'">'.__('Settings', 'mailchimp_i18n' ).'</a>';
 
68
  array_unshift($links, $settings_link);
69
  return $links;
70
  }
71
- add_filter('plugin_action_links', 'mailchimpSD_plugin_action_links', 10, 1);
72
 
73
  /**
74
  * Loads the appropriate JS and CSS resources depending on
@@ -352,16 +360,15 @@ add_action('admin_init', 'mailchimpSF_upgrade');
352
  function mailchimpSF_needs_upgrade() {
353
  $igs = get_option('mc_interest_groups');
354
 
355
- /* True if:
356
- * The option is set in the database AND
357
- * The option is empty (no interest groups) OR the option is an array and the first element has an 'id' element in it
358
- * False otherwise
359
- */
360
- if ($igs !== false && (empty($igs) || (is_array($igs) && isset($igs[0]['id']))) ) {
361
- return false;
362
  }
363
  else {
364
- return true;
365
  }
366
  }
367
 
@@ -375,6 +382,10 @@ function mailchimpSF_do_upgrade() {
375
  delete_option('mc_password');
376
  $api = new mailchimpSF_MCAPI(get_option('mc_apikey'));
377
  $igs = $api->listInterestGroupings(get_option('mc_list_id'));
 
 
 
 
378
  update_option('mc_interest_groups', $igs);
379
  }
380
 
@@ -1186,6 +1197,9 @@ function mailchimpSF_signup_submit() {
1186
  // Head back to the beginning of the merge vars array
1187
  reset($mv);
1188
 
 
 
 
1189
  foreach ($igs as $ig) {
1190
  if (get_option('mc_show_interest_groups_'.$ig['id']) == 'on') {
1191
  $groupings = array();
3
  Plugin Name: MailChimp
4
  Plugin URI: http://www.mailchimp.com/plugins/mailchimp-wordpress-plugin/
5
  Description: The MailChimp plugin allows you to quickly and easily add a signup form for your MailChimp list.
6
+ Version: 1.2.6
7
  Author: MailChimp and Crowd Favorite
8
  Author URI: http://mailchimp.com/api/
9
  */
25
  */
26
 
27
  // Version constant for easy CSS refreshes
28
+ define('MCSF_VER', '1.2.6');
29
 
30
  // What's our permission (capability) threshold
31
+ define('MCSF_CAP_THRESHOLD', 'manage_options');
32
 
33
  // Define our location constants, both MCSF_DIR and MCSF_URL
34
  mailchimpSF_where_am_i();
63
  }
64
  add_action( 'init', 'mailchimpSF_plugin_init' );
65
 
66
+
67
+ /**
68
+ * Add the settings link to the MailChimp plugin row
69
+ *
70
+ * @param array $links - Links for the plugin
71
+ * @return array - Links
72
+ */
73
  function mailchimpSD_plugin_action_links($links) {
74
+ $settings_page = add_query_arg(array('page' => 'mailchimpSF_options'), admin_url('options-general.php'));
75
+ $settings_link = '<a href="'.esc_url($settings_page).'">'.__('Settings', 'mailchimp_i18n' ).'</a>';
76
  array_unshift($links, $settings_link);
77
  return $links;
78
  }
79
+ add_filter('plugin_action_links_'.plugin_basename(__FILE__), 'mailchimpSD_plugin_action_links', 10, 1);
80
 
81
  /**
82
  * Loads the appropriate JS and CSS resources depending on
360
  function mailchimpSF_needs_upgrade() {
361
  $igs = get_option('mc_interest_groups');
362
 
363
+ if ($igs !== false // we have an option
364
+ && (
365
+ empty($igs) || // it can be an empty array (no interest groups)
366
+ (is_array($igs) && isset($igs[0]['id'])) // OR it should be a populated array that's well-formed
367
+ )) {
368
+ return false; // no need to upgrade
 
369
  }
370
  else {
371
+ return true; // yeah, let's do it
372
  }
373
  }
374
 
382
  delete_option('mc_password');
383
  $api = new mailchimpSF_MCAPI(get_option('mc_apikey'));
384
  $igs = $api->listInterestGroupings(get_option('mc_list_id'));
385
+
386
+ // If we don't have any interest groups store an empty array, not (bool) false
387
+ $igs = !$igs ? array() : $igs;
388
+
389
  update_option('mc_interest_groups', $igs);
390
  }
391
 
1197
  // Head back to the beginning of the merge vars array
1198
  reset($mv);
1199
 
1200
+ // Ensure we have an array
1201
+ $igs = !is_array($igs) ? array() : $igs;
1202
+
1203
  foreach ($igs as $ig) {
1204
  if (get_option('mc_show_interest_groups_'.$ig['id']) == 'on') {
1205
  $groupings = array();
readme.txt CHANGED
@@ -3,7 +3,7 @@ Contributors: mc_jesse, crowdfavorite
3
  Tags: mailchimp, email, newsletter, signup, marketing, plugin, widget
4
  Requires at least: 2.8
5
  Tested up to: 3.2.1
6
- Stable tag: 1.2.5
7
 
8
  == Description ==
9
 
@@ -117,11 +117,19 @@ Maybe! Look in the /po/ directory in our plugin package and see if your language
117
 
118
  == Upgrade Notice ==
119
 
 
 
 
120
  = 1.2.5 =
121
  Added support for multiple interest groups, field formatting based on type and date picker.
122
 
123
  == Changelog ==
124
 
 
 
 
 
 
125
  = 1.2.5 =
126
  * Field formatting based on type
127
  * Support for multiple interest groups (a data upgrade procedure must be run by visiting the WordPress dashboard)
3
  Tags: mailchimp, email, newsletter, signup, marketing, plugin, widget
4
  Requires at least: 2.8
5
  Tested up to: 3.2.1
6
+ Stable tag: 1.2.6
7
 
8
  == Description ==
9
 
117
 
118
  == Upgrade Notice ==
119
 
120
+ = 1.2.6 =
121
+ Fixes major bug with "Settings" link on Plugins screen.
122
+
123
  = 1.2.5 =
124
  Added support for multiple interest groups, field formatting based on type and date picker.
125
 
126
  == Changelog ==
127
 
128
+ = 1.2.6 =
129
+ * Fixed bug with "Settings" link appearing on all plugins (props Jason Lane)
130
+ * Resolved issue with unnecessary calls to the MailChimp API during upgrade check
131
+ * Resolved PHP warning when there weren't any interest groups
132
+
133
  = 1.2.5 =
134
  * Field formatting based on type
135
  * Support for multiple interest groups (a data upgrade procedure must be run by visiting the WordPress dashboard)