MailChimp for WordPress - Version 4.1.3

Version Description

Download this release

Release Info

Developer DvanKooten
Plugin Icon 128x128 MailChimp for WordPress
Version 4.1.3
Comparing to
See all releases

Code changes from version 4.1.2 to 4.1.3

CHANGELOG.md CHANGED
@@ -1,6 +1,14 @@
1
  Changelog
2
  =========
3
 
 
 
 
 
 
 
 
 
4
  #### 4.1.2 - May 8, 2017
5
 
6
  **Fixes**
1
  Changelog
2
  =========
3
 
4
+ #### 4.1.3 - May 24, 2017
5
+
6
+ **Improvements**
7
+
8
+ - Randomise time of cron event that renews MailChimp lists.
9
+ - Always try to show MailChimp list info when API key is given.
10
+
11
+
12
  #### 4.1.2 - May 8, 2017
13
 
14
  **Fixes**
includes/admin/class-admin-ajax.php CHANGED
@@ -27,14 +27,13 @@ class MC4WP_Admin_Ajax {
27
  /**
28
  * Empty lists cache & fetch lists again.
29
  */
30
- public function refresh_mailchimp_lists() {
31
  if( ! $this->tools->is_user_authorized() ) {
32
  wp_send_json(false);
33
  }
34
 
35
  $mailchimp = new MC4WP_MailChimp();
36
- $lists = $mailchimp->fetch_lists();
37
- $success = ! empty( $lists );
38
  wp_send_json( $success );
39
  }
40
 
27
  /**
28
  * Empty lists cache & fetch lists again.
29
  */
30
+ public function refresh_mailchimp_lists() {
31
  if( ! $this->tools->is_user_authorized() ) {
32
  wp_send_json(false);
33
  }
34
 
35
  $mailchimp = new MC4WP_MailChimp();
36
+ $success = $mailchimp->fetch_lists();
 
37
  wp_send_json( $success );
38
  }
39
 
includes/admin/class-admin.php CHANGED
@@ -297,7 +297,7 @@ class MC4WP_Admin {
297
  array(
298
  'mailchimp' => array(
299
  'api_connected' => ! empty( $opts['api_key'] ),
300
- 'lists' => $this->mailchimp->get_lists()
301
  ),
302
  'countries' => MC4WP_Tools::get_countries(),
303
  'i18n' => array(
@@ -422,7 +422,7 @@ class MC4WP_Admin {
422
  }
423
  }
424
 
425
- $lists = $this->mailchimp->get_lists();
426
  $obfuscated_api_key = mc4wp_obfuscate_string( $opts['api_key'] );
427
  require MC4WP_PLUGIN_DIR . 'includes/views/general-settings.php';
428
  }
297
  array(
298
  'mailchimp' => array(
299
  'api_connected' => ! empty( $opts['api_key'] ),
300
+ 'lists' => $this->mailchimp->get_cached_lists()
301
  ),
302
  'countries' => MC4WP_Tools::get_countries(),
303
  'i18n' => array(
422
  }
423
  }
424
 
425
+ $lists = $this->mailchimp->get_cached_lists();
426
  $obfuscated_api_key = mc4wp_obfuscate_string( $opts['api_key'] );
427
  require MC4WP_PLUGIN_DIR . 'includes/views/general-settings.php';
428
  }
includes/admin/migrations/4.1.3-reschedule-event.php ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ defined( 'ABSPATH' ) or exit;
4
+
5
+ wp_clear_scheduled_hook( 'mc4wp_refresh_mailchimp_lists' );
6
+
7
+ $time_string = sprintf("tomorrow %d:%d%d am", rand(1,6), rand(0,5), rand(0, 9) );
8
+ wp_schedule_event( strtotime( $time_string ), 'daily', 'mc4wp_refresh_mailchimp_lists' );
9
+
includes/class-mailchimp.php CHANGED
@@ -157,11 +157,10 @@ class MC4WP_MailChimp {
157
  */
158
  public function empty_cache() {
159
  global $wpdb;
160
- $wpdb->query("DELETE FROM {$wpdb->options} WHERE option_name LIKE 'mc4wp_mailchimp_list_%'");
161
 
 
 
162
  delete_transient( 'mc4wp_list_counts' );
163
-
164
- /* deprecated */
165
  }
166
 
167
  /**
@@ -172,7 +171,17 @@ class MC4WP_MailChimp {
172
  */
173
  public function get_cached_lists() {
174
  return $this->get_lists( false );
175
- }
 
 
 
 
 
 
 
 
 
 
176
 
177
  /**
178
  * Get MailChimp lists, from cache or remote API.
@@ -277,7 +286,9 @@ class MC4WP_MailChimp {
277
  }
278
 
279
  /**
280
- * Fetch list ID's + lists from MailChimp.
 
 
281
  */
282
  public function fetch_lists() {
283
  // try to increase time limit as this can take a while
@@ -288,9 +299,11 @@ class MC4WP_MailChimp {
288
  shuffle( $list_ids );
289
 
290
  // fetch individual list details
291
- foreach ( $list_ids as $list_id ) {
292
  $list = $this->fetch_list( $list_id );
293
- }
 
 
294
  }
295
 
296
  /**
157
  */
158
  public function empty_cache() {
159
  global $wpdb;
 
160
 
161
+ delete_option( 'mc4wp_mailchimp_list_ids' );
162
+ $wpdb->query( "DELETE FROM {$wpdb->options} WHERE option_name LIKE 'mc4wp_mailchimp_list_%'" );
163
  delete_transient( 'mc4wp_list_counts' );
 
 
164
  }
165
 
166
  /**
171
  */
172
  public function get_cached_lists() {
173
  return $this->get_lists( false );
174
+ }
175
+
176
+ /**
177
+ * Get a specific MailChimp list from local DB.
178
+ *
179
+ * @param string $list_id
180
+ * @return MC4WP_MailChimp_List
181
+ */
182
+ public function get_cached_list( $list_id ) {
183
+ return $this->get_list( $list_id, false );
184
+ }
185
 
186
  /**
187
  * Get MailChimp lists, from cache or remote API.
286
  }
287
 
288
  /**
289
+ * Fetch list ID's + lists from MailChimp.
290
+ *
291
+ * @return bool
292
  */
293
  public function fetch_lists() {
294
  // try to increase time limit as this can take a while
299
  shuffle( $list_ids );
300
 
301
  // fetch individual list details
302
+ foreach ( $list_ids as $list_id ) {
303
  $list = $this->fetch_list( $list_id );
304
+ }
305
+
306
+ return ! empty( $list_ids );
307
  }
308
 
309
  /**
includes/views/general-settings.php CHANGED
@@ -75,7 +75,7 @@ defined( 'ABSPATH' ) or exit;
75
  */
76
  do_action( 'mc4wp_admin_after_general_settings' );
77
 
78
- if( $connected ) {
79
  echo '<hr />';
80
  include dirname( __FILE__ ) . '/parts/lists-overview.php';
81
  }
75
  */
76
  do_action( 'mc4wp_admin_after_general_settings' );
77
 
78
+ if( ! empty( $opts['api_key'] ) ) {
79
  echo '<hr />';
80
  include dirname( __FILE__ ) . '/parts/lists-overview.php';
81
  }
mailchimp-for-wp.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: MailChimp for WordPress
4
  Plugin URI: https://mc4wp.com/#utm_source=wp-plugin&utm_medium=mailchimp-for-wp&utm_campaign=plugins-page
5
  Description: MailChimp for WordPress by ibericode. Adds various highly effective sign-up methods to your site.
6
- Version: 4.1.2
7
  Author: ibericode
8
  Author URI: https://ibericode.com/
9
  Text Domain: mailchimp-for-wp
@@ -25,7 +25,7 @@ GNU General Public License for more details.
25
 
26
  You should have received a copy of the GNU General Public License
27
  along with this program. If not, see <http://www.gnu.org/licenses/>.
28
- */
29
 
30
  // Prevent direct file access
31
  defined( 'ABSPATH' ) or exit;
@@ -47,7 +47,7 @@ function _mc4wp_load_plugin() {
47
  }
48
 
49
  // bootstrap the core plugin
50
- define( 'MC4WP_VERSION', '4.1.2' );
51
  define( 'MC4WP_PLUGIN_DIR', dirname( __FILE__ ) . '/' );
52
  define( 'MC4WP_PLUGIN_URL', plugins_url( '/' , __FILE__ ) );
53
  define( 'MC4WP_PLUGIN_FILE', __FILE__ );
@@ -77,7 +77,7 @@ function _mc4wp_load_plugin() {
77
  // bootstrapping of core integrations
78
  _mc4wp_bootstrap_integrations();
79
 
80
- // Doing cron? Load Usage Tracking class.
81
  if( defined( 'DOING_CRON' ) && DOING_CRON ) {
82
  MC4WP_Usage_Tracking::instance()->add_hooks();
83
  }
@@ -85,26 +85,26 @@ function _mc4wp_load_plugin() {
85
  // Initialize admin section of plugin
86
  if( is_admin() ) {
87
 
88
- $admin_tools = new MC4WP_Admin_Tools();
89
 
90
- if( defined( 'DOING_AJAX' ) && DOING_AJAX ) {
91
- $ajax = new MC4WP_Admin_Ajax( $admin_tools );
92
- $ajax->add_hooks();
93
- } else {
94
- $messages = new MC4WP_Admin_Messages();
95
- $mc4wp['admin.messages'] = $messages;
96
 
97
- $mailchimp = new MC4WP_MailChimp();
98
 
99
- $admin = new MC4WP_Admin( $admin_tools, $messages, $mailchimp );
100
- $admin->add_hooks();
101
 
102
- $forms_admin = new MC4WP_Forms_Admin( $messages, $mailchimp );
103
- $forms_admin->add_hooks();
104
 
105
- $integrations_admin = new MC4WP_Integration_Admin( $mc4wp['integrations'], $messages, $mailchimp );
106
- $integrations_admin->add_hooks();
107
- }
108
  }
109
 
110
  return true;
@@ -112,7 +112,7 @@ function _mc4wp_load_plugin() {
112
 
113
  // bootstrap custom integrations
114
  function _mc4wp_bootstrap_integrations() {
115
- require_once MC4WP_PLUGIN_DIR . 'integrations/bootstrap.php';
116
  }
117
 
118
  add_action( 'plugins_loaded', '_mc4wp_load_plugin', 8 );
@@ -124,7 +124,8 @@ add_action( 'plugins_loaded', '_mc4wp_load_plugin', 8 );
124
  * @since 3.0
125
  */
126
  function _mc4wp_on_plugin_activation() {
127
- wp_schedule_event( strtotime('tomorrow 3 am'), 'daily', 'mc4wp_refresh_mailchimp_lists' );
 
128
  }
129
 
130
  /**
3
  Plugin Name: MailChimp for WordPress
4
  Plugin URI: https://mc4wp.com/#utm_source=wp-plugin&utm_medium=mailchimp-for-wp&utm_campaign=plugins-page
5
  Description: MailChimp for WordPress by ibericode. Adds various highly effective sign-up methods to your site.
6
+ Version: 4.1.3
7
  Author: ibericode
8
  Author URI: https://ibericode.com/
9
  Text Domain: mailchimp-for-wp
25
 
26
  You should have received a copy of the GNU General Public License
27
  along with this program. If not, see <http://www.gnu.org/licenses/>.
28
+ */
29
 
30
  // Prevent direct file access
31
  defined( 'ABSPATH' ) or exit;
47
  }
48
 
49
  // bootstrap the core plugin
50
+ define( 'MC4WP_VERSION', '4.1.3' );
51
  define( 'MC4WP_PLUGIN_DIR', dirname( __FILE__ ) . '/' );
52
  define( 'MC4WP_PLUGIN_URL', plugins_url( '/' , __FILE__ ) );
53
  define( 'MC4WP_PLUGIN_FILE', __FILE__ );
77
  // bootstrapping of core integrations
78
  _mc4wp_bootstrap_integrations();
79
 
80
+ // Doing cron? Load Usage Tracking class.
81
  if( defined( 'DOING_CRON' ) && DOING_CRON ) {
82
  MC4WP_Usage_Tracking::instance()->add_hooks();
83
  }
85
  // Initialize admin section of plugin
86
  if( is_admin() ) {
87
 
88
+ $admin_tools = new MC4WP_Admin_Tools();
89
 
90
+ if( defined( 'DOING_AJAX' ) && DOING_AJAX ) {
91
+ $ajax = new MC4WP_Admin_Ajax( $admin_tools );
92
+ $ajax->add_hooks();
93
+ } else {
94
+ $messages = new MC4WP_Admin_Messages();
95
+ $mc4wp['admin.messages'] = $messages;
96
 
97
+ $mailchimp = new MC4WP_MailChimp();
98
 
99
+ $admin = new MC4WP_Admin( $admin_tools, $messages, $mailchimp );
100
+ $admin->add_hooks();
101
 
102
+ $forms_admin = new MC4WP_Forms_Admin( $messages, $mailchimp );
103
+ $forms_admin->add_hooks();
104
 
105
+ $integrations_admin = new MC4WP_Integration_Admin( $mc4wp['integrations'], $messages, $mailchimp );
106
+ $integrations_admin->add_hooks();
107
+ }
108
  }
109
 
110
  return true;
112
 
113
  // bootstrap custom integrations
114
  function _mc4wp_bootstrap_integrations() {
115
+ require_once MC4WP_PLUGIN_DIR . 'integrations/bootstrap.php';
116
  }
117
 
118
  add_action( 'plugins_loaded', '_mc4wp_load_plugin', 8 );
124
  * @since 3.0
125
  */
126
  function _mc4wp_on_plugin_activation() {
127
+ $time_string = sprintf("tomorrow %d:%d%d am", rand(1,6), rand(0,5), rand(0, 9) );
128
+ wp_schedule_event( strtotime( $time_string ), 'daily', 'mc4wp_refresh_mailchimp_lists' );
129
  }
130
 
131
  /**
readme.txt CHANGED
@@ -3,8 +3,8 @@ Contributors: Ibericode, DvanKooten, hchouhan, lapzor
3
  Donate link: https://mc4wp.com/#utm_source=wp-plugin-repo&utm_medium=mailchimp-for-wp&utm_campaign=donate-link
4
  Tags: mailchimp, mc4wp, email, marketing, newsletter, subscribe, widget, mc4wp, contact form 7, woocommerce, buddypress, ibericode, mailchimp forms, mailchimp integrations
5
  Requires at least: 4.1
6
- Tested up to: 4.7.4
7
- Stable tag: 4.1.2
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -194,6 +194,14 @@ MailChimp for WordPress comes with many filter & action hooks which allow you to
194
  == Changelog ==
195
 
196
 
 
 
 
 
 
 
 
 
197
  #### 4.1.2 - May 8, 2017
198
 
199
  **Fixes**
3
  Donate link: https://mc4wp.com/#utm_source=wp-plugin-repo&utm_medium=mailchimp-for-wp&utm_campaign=donate-link
4
  Tags: mailchimp, mc4wp, email, marketing, newsletter, subscribe, widget, mc4wp, contact form 7, woocommerce, buddypress, ibericode, mailchimp forms, mailchimp integrations
5
  Requires at least: 4.1
6
+ Tested up to: 4.8
7
+ Stable tag: 4.1.3
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
194
  == Changelog ==
195
 
196
 
197
+ #### 4.1.3 - May 24, 2017
198
+
199
+ **Improvements**
200
+
201
+ - Randomise time of cron event that renews MailChimp lists.
202
+ - Always try to show MailChimp list info when API key is given.
203
+
204
+
205
  #### 4.1.2 - May 8, 2017
206
 
207
  **Fixes**
vendor/autoload_52.php CHANGED
@@ -4,4 +4,4 @@
4
 
5
  require_once dirname(__FILE__) . '/composer'.'/autoload_real_52.php';
6
 
7
- return ComposerAutoloaderInit5bf7af865abd357743e770c4549a200a::getLoader();
4
 
5
  require_once dirname(__FILE__) . '/composer'.'/autoload_real_52.php';
6
 
7
+ return ComposerAutoloaderInit4dc707105fc640cf229f5c568acd354f::getLoader();
vendor/composer/autoload_real_52.php CHANGED
@@ -2,7 +2,7 @@
2
 
3
  // autoload_real_52.php generated by xrstf/composer-php52
4
 
5
- class ComposerAutoloaderInit5bf7af865abd357743e770c4549a200a {
6
  private static $loader;
7
 
8
  public static function loadClassLoader($class) {
@@ -19,9 +19,9 @@ class ComposerAutoloaderInit5bf7af865abd357743e770c4549a200a {
19
  return self::$loader;
20
  }
21
 
22
- spl_autoload_register(array('ComposerAutoloaderInit5bf7af865abd357743e770c4549a200a', 'loadClassLoader'), true /*, true */);
23
  self::$loader = $loader = new xrstf_Composer52_ClassLoader();
24
- spl_autoload_unregister(array('ComposerAutoloaderInit5bf7af865abd357743e770c4549a200a', 'loadClassLoader'));
25
 
26
  $vendorDir = dirname(dirname(__FILE__));
27
  $baseDir = dirname($vendorDir);
2
 
3
  // autoload_real_52.php generated by xrstf/composer-php52
4
 
5
+ class ComposerAutoloaderInit4dc707105fc640cf229f5c568acd354f {
6
  private static $loader;
7
 
8
  public static function loadClassLoader($class) {
19
  return self::$loader;
20
  }
21
 
22
+ spl_autoload_register(array('ComposerAutoloaderInit4dc707105fc640cf229f5c568acd354f', 'loadClassLoader'), true /*, true */);
23
  self::$loader = $loader = new xrstf_Composer52_ClassLoader();
24
+ spl_autoload_unregister(array('ComposerAutoloaderInit4dc707105fc640cf229f5c568acd354f', 'loadClassLoader'));
25
 
26
  $vendorDir = dirname(dirname(__FILE__));
27
  $baseDir = dirname($vendorDir);