Version Description
Download this release
Release Info
Developer | anderly |
Plugin | WooCommerce MailChimp |
Version | 2.1.2 |
Comparing to | |
See all releases |
Code changes from version 2.1.1 to 2.1.2
includes/class-ss-wc-mailchimp-compatibility.php
CHANGED
@@ -233,19 +233,18 @@ final class SS_WC_MailChimp_Compatibility {
|
|
233 |
// If WooCommerce doesn't exist, assume WooCommerce not active
|
234 |
$return = false;
|
235 |
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
if( ! function_exists('wp_create_nonce') ) {
|
241 |
-
require_once ABSPATH . WPINC . '/pluggable.php';
|
242 |
-
}
|
243 |
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
|
|
|
|
|
249 |
$return = false;
|
250 |
|
251 |
$button = function_exists('is_network_admin') && is_network_admin() ? '<strong><a href="#woocommerce">' : '<strong><a href="'. wp_nonce_url( admin_url( 'plugins.php?action=activate&plugin=woocommerce/woocommerce.php' ), 'activate-plugin_woocommerce/woocommerce.php') . '" class="button button-large">';
|
233 |
// If WooCommerce doesn't exist, assume WooCommerce not active
|
234 |
$return = false;
|
235 |
|
236 |
+
// Required for multisite
|
237 |
+
if ( ! function_exists('wp_create_nonce') ) {
|
238 |
+
require_once ABSPATH . WPINC . '/pluggable.php';
|
239 |
+
}
|
|
|
|
|
|
|
240 |
|
241 |
+
// Otherwise, throws an error on activation & deactivation "Use of undefined constant LOGGED_IN_COOKIE"
|
242 |
+
if ( is_multisite() ) {
|
243 |
+
wp_cookie_constants();
|
244 |
+
}
|
245 |
|
246 |
+
switch ( $wc_status ) {
|
247 |
+
case 'inactive':
|
248 |
$return = false;
|
249 |
|
250 |
$button = function_exists('is_network_admin') && is_network_admin() ? '<strong><a href="#woocommerce">' : '<strong><a href="'. wp_nonce_url( admin_url( 'plugins.php?action=activate&plugin=woocommerce/woocommerce.php' ), 'activate-plugin_woocommerce/woocommerce.php') . '" class="button button-large">';
|
includes/class-ss-wc-mailchimp-plugin.php
CHANGED
@@ -1,4 +1,9 @@
|
|
1 |
-
<?php
|
|
|
|
|
|
|
|
|
|
|
2 |
|
3 |
/**
|
4 |
* WooCommerce MailChimp plugin main class
|
@@ -7,42 +12,49 @@ final class SS_WC_MailChimp_Plugin {
|
|
7 |
|
8 |
/**
|
9 |
* Plugin version
|
|
|
10 |
* @var string
|
11 |
*/
|
12 |
-
private static $version = '2.1.
|
13 |
|
14 |
/**
|
15 |
* Plugin singleton instance
|
|
|
16 |
* @var SS_WC_MailChimp_Plugin
|
17 |
*/
|
18 |
private static $instance;
|
19 |
|
20 |
/**
|
21 |
* Plugin namespace
|
|
|
22 |
* @var string
|
23 |
*/
|
24 |
private $namespace = 'ss_wc_mailchimp';
|
25 |
|
26 |
/**
|
27 |
* Plugin settings
|
|
|
28 |
* @var array
|
29 |
*/
|
30 |
private $settings;
|
31 |
|
32 |
/**
|
33 |
* Plugin MailChimp helper instance
|
|
|
34 |
* @var SS_WC_MailChimp
|
35 |
*/
|
36 |
private $mailchimp;
|
37 |
|
38 |
/**
|
39 |
* Plugin compatibility checker
|
40 |
-
*
|
|
|
41 |
*/
|
42 |
public $compatibility;
|
43 |
|
44 |
/**
|
45 |
* Returns the plugin version
|
|
|
46 |
* @return string
|
47 |
*/
|
48 |
public static function version() {
|
@@ -58,7 +70,7 @@ final class SS_WC_MailChimp_Plugin {
|
|
58 |
|
59 |
if ( empty( self::$instance ) && ! ( self::$instance instanceof SS_WC_MailChimp_Plugin ) ) {
|
60 |
|
61 |
-
self::$instance = new SS_WC_MailChimp_Plugin;
|
62 |
self::$instance->define_constants();
|
63 |
|
64 |
self::$instance->save_settings();
|
@@ -67,14 +79,12 @@ final class SS_WC_MailChimp_Plugin {
|
|
67 |
self::$instance->mailchimp();
|
68 |
self::$instance->handler = SS_WC_MailChimp_Handler::get_instance();
|
69 |
self::$instance->compatibility = SS_WC_MailChimp_Compatibility::get_instance();
|
70 |
-
self::$instance->admin_notices = new SS_WC_MailChimp_Admin_Notices;
|
71 |
self::$instance->load_plugin_textdomain();
|
72 |
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
do_action( 'ss_wc_mailchimp_loaded' );
|
77 |
-
//}
|
78 |
|
79 |
}
|
80 |
|
@@ -84,7 +94,8 @@ final class SS_WC_MailChimp_Plugin {
|
|
84 |
|
85 |
/**
|
86 |
* Gets the plugin db settings
|
87 |
-
*
|
|
|
88 |
* @return array The plugin db settings
|
89 |
*/
|
90 |
public function settings( $refresh = false ) {
|
@@ -114,25 +125,26 @@ final class SS_WC_MailChimp_Plugin {
|
|
114 |
}
|
115 |
|
116 |
/**
|
117 |
-
*
|
|
|
118 |
* @return string MailChimp API Key
|
119 |
*/
|
120 |
public function api_key() {
|
121 |
-
return $this->settings[
|
122 |
}
|
123 |
|
124 |
/**
|
125 |
-
*
|
126 |
*
|
127 |
* @access public
|
128 |
* @return boolean
|
129 |
*/
|
130 |
public function is_enabled() {
|
131 |
-
return 'yes' === $this->settings[
|
132 |
}
|
133 |
|
134 |
/**
|
135 |
-
*
|
136 |
*
|
137 |
* @access public
|
138 |
* @return boolean
|
@@ -147,96 +159,97 @@ final class SS_WC_MailChimp_Plugin {
|
|
147 |
}
|
148 |
|
149 |
/**
|
150 |
-
*
|
|
|
151 |
* @return string
|
152 |
*/
|
153 |
public function occurs() {
|
154 |
-
return $this->settings[
|
155 |
}
|
156 |
|
157 |
/**
|
158 |
-
*
|
159 |
*
|
160 |
* @access public
|
161 |
* @return string MailChimp list ID
|
162 |
*/
|
163 |
public function get_list() {
|
164 |
-
return $this->settings[
|
165 |
}
|
166 |
|
167 |
/**
|
168 |
-
*
|
169 |
*
|
170 |
* @access public
|
171 |
* @return boolean
|
172 |
*/
|
173 |
public function double_opt_in() {
|
174 |
-
return 'yes' === $this->settings[
|
175 |
}
|
176 |
|
177 |
/**
|
178 |
-
*
|
179 |
*
|
180 |
* @access public
|
181 |
* @return boolean
|
182 |
*/
|
183 |
public function display_opt_in() {
|
184 |
-
return 'yes' === $this->settings[
|
185 |
}
|
186 |
|
187 |
/**
|
188 |
-
*
|
189 |
*
|
190 |
* @access public
|
191 |
* @return string
|
192 |
*/
|
193 |
public function opt_in_label() {
|
194 |
-
return $this->settings[
|
195 |
}
|
196 |
|
197 |
/**
|
198 |
-
*
|
199 |
*
|
200 |
* @access public
|
201 |
* @return string
|
202 |
*/
|
203 |
public function opt_in_checkbox_default_status() {
|
204 |
-
return $this->settings[
|
205 |
}
|
206 |
|
207 |
/**
|
208 |
-
*
|
209 |
*
|
210 |
* @access public
|
211 |
* @return string
|
212 |
*/
|
213 |
public function opt_in_checkbox_display_location() {
|
214 |
-
return $this->settings[
|
215 |
}
|
216 |
|
217 |
/**
|
218 |
-
*
|
219 |
*
|
220 |
* @access public
|
221 |
* @return array
|
222 |
*/
|
223 |
public function interest_groups() {
|
224 |
-
return $this->settings[
|
225 |
}
|
226 |
|
227 |
/**
|
228 |
-
*
|
229 |
*
|
230 |
* @access public
|
231 |
* @return boolean
|
232 |
*/
|
233 |
public function has_api_key() {
|
234 |
$api_key = $this->api_key();
|
235 |
-
return !empty( $api_key );
|
236 |
}
|
237 |
|
238 |
/**
|
239 |
-
*
|
240 |
*
|
241 |
* @access public
|
242 |
* @return boolean
|
@@ -246,17 +259,18 @@ final class SS_WC_MailChimp_Plugin {
|
|
246 |
}
|
247 |
|
248 |
/**
|
249 |
-
*
|
250 |
*
|
251 |
* @access public
|
252 |
* @return boolean
|
253 |
*/
|
254 |
public function debug_enabled() {
|
255 |
-
return 'yes' === $this->settings[
|
256 |
}
|
257 |
|
258 |
/**
|
259 |
* Saves the settings back to the DB
|
|
|
260 |
* @return void
|
261 |
*/
|
262 |
public function save_settings() {
|
@@ -271,8 +285,9 @@ final class SS_WC_MailChimp_Plugin {
|
|
271 |
|
272 |
/**
|
273 |
* Gets the MailChimp Helper
|
274 |
-
*
|
275 |
-
* @param
|
|
|
276 |
* @return SS_WC_MailChimp MailChimp Helper class
|
277 |
*/
|
278 |
public function mailchimp( $api_key = null, $debug = false ) {
|
@@ -282,7 +297,7 @@ final class SS_WC_MailChimp_Plugin {
|
|
282 |
if ( empty( $this->mailchimp ) || ! is_null( $api_key ) ) {
|
283 |
|
284 |
$api_key = $api_key ? $api_key : $settings['api_key'];
|
285 |
-
$debug = $debug
|
286 |
|
287 |
require_once( SS_WC_MAILCHIMP_DIR . 'includes/class-ss-wc-mailchimp.php' );
|
288 |
$this->mailchimp = new SS_WC_MailChimp( $api_key, $debug );
|
@@ -299,13 +314,13 @@ final class SS_WC_MailChimp_Plugin {
|
|
299 |
*/
|
300 |
private function define_constants() {
|
301 |
|
302 |
-
// Minimum supported version of WordPress
|
303 |
$this->define( 'SS_WC_MAILCHIMP_MIN_WP_VERSION', '3.5.1' );
|
304 |
|
305 |
-
// Minimum supported version of WooCommerce
|
306 |
$this->define( 'SS_WC_MAILCHIMP_MIN_WC_VERSION', '2.2.0' );
|
307 |
|
308 |
-
// Minimum supported version of PHP
|
309 |
$this->define( 'SS_WC_MAILCHIMP_MIN_PHP_VERSION', '5.4.0' );
|
310 |
|
311 |
// Plugin version.
|
@@ -315,7 +330,7 @@ final class SS_WC_MailChimp_Plugin {
|
|
315 |
$this->define( 'SS_WC_MAILCHIMP_DIR', plugin_dir_path( SS_WC_MAILCHIMP_FILE ) );
|
316 |
|
317 |
// Plugin Folder URL.
|
318 |
-
$this->define('SS_WC_MAILCHIMP_URL', plugin_dir_url( SS_WC_MAILCHIMP_FILE ) );
|
319 |
|
320 |
$settings_url = admin_url( 'admin.php?page=wc-settings&tab=mailchimp' );
|
321 |
|
@@ -326,8 +341,9 @@ final class SS_WC_MailChimp_Plugin {
|
|
326 |
/**
|
327 |
* Define constant if not already set.
|
328 |
*
|
329 |
-
* @param string
|
330 |
-
* @param string|bool $value
|
|
|
331 |
*/
|
332 |
private function define( $name, $value ) {
|
333 |
if ( ! defined( $name ) ) {
|
@@ -337,6 +353,8 @@ final class SS_WC_MailChimp_Plugin {
|
|
337 |
|
338 |
/**
|
339 |
* Include required core plugin files
|
|
|
|
|
340 |
*/
|
341 |
public function includes() {
|
342 |
|
@@ -358,6 +376,8 @@ final class SS_WC_MailChimp_Plugin {
|
|
358 |
|
359 |
/**
|
360 |
* Add plugin hooks
|
|
|
|
|
361 |
*/
|
362 |
private function add_hooks() {
|
363 |
|
@@ -365,14 +385,14 @@ final class SS_WC_MailChimp_Plugin {
|
|
365 |
register_activation_hook( SS_WC_MAILCHIMP_FILE, array( __CLASS__, 'activate' ) );
|
366 |
register_deactivation_hook( SS_WC_MAILCHIMP_FILE, array( __CLASS__, 'deactivate' ) );
|
367 |
|
368 |
-
// Add the "Settings" links on the Plugins administration screen
|
369 |
if ( is_admin() ) {
|
370 |
|
371 |
add_filter( 'plugin_action_links_' . plugin_basename( SS_WC_MAILCHIMP_FILE ), array( $this, 'action_links' ) );
|
372 |
|
373 |
add_filter( 'woocommerce_get_settings_pages', array( $this, 'add_mailchimp_settings' ) );
|
374 |
|
375 |
-
add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_scripts') );
|
376 |
|
377 |
}
|
378 |
|
@@ -386,6 +406,8 @@ final class SS_WC_MailChimp_Plugin {
|
|
386 |
* Locales found in:
|
387 |
* - WP_LANG_DIR/plugins/woocommerce-mailchimp/woocommerce-mailchimp-{lang}_{country}.mo
|
388 |
* - WP_CONTENT_DIR/plugins/woocommerce-mailchimp/languages/woocommerce-mailchimp-{lang}_{country}.mo
|
|
|
|
|
389 |
*/
|
390 |
public function load_plugin_textdomain() {
|
391 |
|
@@ -393,7 +415,7 @@ final class SS_WC_MailChimp_Plugin {
|
|
393 |
$woocommerce_mailchimp_lang_dir = dirname( plugin_basename( SS_WC_MAILCHIMP_FILE ) ) . '/languages/';
|
394 |
|
395 |
// Traditional WordPress plugin locale filter.
|
396 |
-
// get locale in {lang}_{country} format (e.g. en_US)
|
397 |
$locale = apply_filters( 'plugin_locale', get_locale(), 'woocommerce-mailchimp' );
|
398 |
|
399 |
$mofile = sprintf( '%1$s-%2$s.mo', 'woocommerce-mailchimp', $locale );
|
@@ -424,8 +446,8 @@ final class SS_WC_MailChimp_Plugin {
|
|
424 |
/**
|
425 |
* Add Settings link to plugins list
|
426 |
*
|
427 |
-
* @param array $links Plugin links
|
428 |
-
* @return array
|
429 |
*/
|
430 |
public function action_links( $links ) {
|
431 |
$plugin_links = array(
|
@@ -438,6 +460,9 @@ final class SS_WC_MailChimp_Plugin {
|
|
438 |
|
439 |
/**
|
440 |
* Add the MailChimp settings tab to WooCommerce
|
|
|
|
|
|
|
441 |
*/
|
442 |
function add_mailchimp_settings( $settings ) {
|
443 |
|
@@ -452,18 +477,18 @@ final class SS_WC_MailChimp_Plugin {
|
|
452 |
} //end function add_mailchimp_settings
|
453 |
|
454 |
/**
|
455 |
-
|
456 |
-
|
457 |
-
|
458 |
-
|
459 |
-
|
460 |
-
|
461 |
|
462 |
-
|
463 |
wp_register_script( 'woocommerce-mailchimp-admin', SS_WC_MAILCHIMP_URL . 'assets/js/woocommerce-mailchimp-admin.js', array( 'jquery' ), self::version() );
|
464 |
wp_register_style( 'woocommerce-mailchimp', SS_WC_MAILCHIMP_URL . 'assets/css/style.css', array(), self::version() );
|
465 |
|
466 |
-
// Localize javascript messages
|
467 |
$translation_array = array(
|
468 |
'connecting_to_mailchimp' => __( 'Connecting to MailChimp', 'woocommerce-mailchimp' ),
|
469 |
'error_loading_account' => __( 'Error. Please check your api key.', 'woocommerce-mailchimp' ),
|
@@ -473,16 +498,17 @@ final class SS_WC_MailChimp_Plugin {
|
|
473 |
);
|
474 |
wp_localize_script( 'woocommerce-mailchimp-admin', 'SS_WC_MailChimp_Messages', $translation_array );
|
475 |
|
476 |
-
// Scripts
|
477 |
wp_enqueue_script( 'woocommerce-mailchimp-admin' );
|
478 |
|
479 |
-
// Styles
|
480 |
wp_enqueue_style( 'woocommerce-mailchimp' );
|
481 |
|
482 |
} //end function enqueue_scripts
|
483 |
|
484 |
/**
|
485 |
* Handles running plugin upgrades if necessary
|
|
|
486 |
* @return void
|
487 |
*/
|
488 |
public static function update() {
|
@@ -498,7 +524,7 @@ final class SS_WC_MailChimp_Plugin {
|
|
498 |
*
|
499 |
* @access public
|
500 |
* @static
|
501 |
-
* @param mixed $network_wide
|
502 |
* @return void
|
503 |
*/
|
504 |
public static function activate( $network_wide = false ) {
|
@@ -512,17 +538,18 @@ final class SS_WC_MailChimp_Plugin {
|
|
512 |
*
|
513 |
* @access public
|
514 |
* @static
|
515 |
-
* @param mixed $network_wide
|
516 |
* @return void
|
517 |
*/
|
518 |
public static function deactivate( $network_wide ) {
|
519 |
|
520 |
-
// Placeholder
|
521 |
|
522 |
} //end function deactivate
|
523 |
|
524 |
/**
|
525 |
* Check whether WooCommerce MailChimp is network activated
|
|
|
526 |
* @since 1.0
|
527 |
* @return bool
|
528 |
*/
|
@@ -532,7 +559,8 @@ final class SS_WC_MailChimp_Plugin {
|
|
532 |
|
533 |
/**
|
534 |
* Returns namespace prefixed value
|
535 |
-
*
|
|
|
536 |
* @return string
|
537 |
*/
|
538 |
private function namespace_prefixed( $suffix ) {
|
@@ -541,4 +569,4 @@ final class SS_WC_MailChimp_Plugin {
|
|
541 |
|
542 |
} // end function namespace_prefixed
|
543 |
|
544 |
-
} //end final class SS_WC_MailChimp_Plugin
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Main Plugin Class
|
4 |
+
*
|
5 |
+
* @package WooCommerce MailChimp
|
6 |
+
*/
|
7 |
|
8 |
/**
|
9 |
* WooCommerce MailChimp plugin main class
|
12 |
|
13 |
/**
|
14 |
* Plugin version
|
15 |
+
*
|
16 |
* @var string
|
17 |
*/
|
18 |
+
private static $version = '2.1.2';
|
19 |
|
20 |
/**
|
21 |
* Plugin singleton instance
|
22 |
+
*
|
23 |
* @var SS_WC_MailChimp_Plugin
|
24 |
*/
|
25 |
private static $instance;
|
26 |
|
27 |
/**
|
28 |
* Plugin namespace
|
29 |
+
*
|
30 |
* @var string
|
31 |
*/
|
32 |
private $namespace = 'ss_wc_mailchimp';
|
33 |
|
34 |
/**
|
35 |
* Plugin settings
|
36 |
+
*
|
37 |
* @var array
|
38 |
*/
|
39 |
private $settings;
|
40 |
|
41 |
/**
|
42 |
* Plugin MailChimp helper instance
|
43 |
+
*
|
44 |
* @var SS_WC_MailChimp
|
45 |
*/
|
46 |
private $mailchimp;
|
47 |
|
48 |
/**
|
49 |
* Plugin compatibility checker
|
50 |
+
*
|
51 |
+
* @var SS_WC_MailChimp_Compatibility
|
52 |
*/
|
53 |
public $compatibility;
|
54 |
|
55 |
/**
|
56 |
* Returns the plugin version
|
57 |
+
*
|
58 |
* @return string
|
59 |
*/
|
60 |
public static function version() {
|
70 |
|
71 |
if ( empty( self::$instance ) && ! ( self::$instance instanceof SS_WC_MailChimp_Plugin ) ) {
|
72 |
|
73 |
+
self::$instance = new SS_WC_MailChimp_Plugin();
|
74 |
self::$instance->define_constants();
|
75 |
|
76 |
self::$instance->save_settings();
|
79 |
self::$instance->mailchimp();
|
80 |
self::$instance->handler = SS_WC_MailChimp_Handler::get_instance();
|
81 |
self::$instance->compatibility = SS_WC_MailChimp_Compatibility::get_instance();
|
82 |
+
self::$instance->admin_notices = new SS_WC_MailChimp_Admin_Notices();
|
83 |
self::$instance->load_plugin_textdomain();
|
84 |
|
85 |
+
self::update();
|
86 |
+
self::$instance->add_hooks();
|
87 |
+
do_action( 'ss_wc_mailchimp_loaded' );
|
|
|
|
|
88 |
|
89 |
}
|
90 |
|
94 |
|
95 |
/**
|
96 |
* Gets the plugin db settings
|
97 |
+
*
|
98 |
+
* @param boolean $refresh refresh the settings from DB.
|
99 |
* @return array The plugin db settings
|
100 |
*/
|
101 |
public function settings( $refresh = false ) {
|
125 |
}
|
126 |
|
127 |
/**
|
128 |
+
* Returns the api key.
|
129 |
+
*
|
130 |
* @return string MailChimp API Key
|
131 |
*/
|
132 |
public function api_key() {
|
133 |
+
return $this->settings['api_key'];
|
134 |
}
|
135 |
|
136 |
/**
|
137 |
+
* Whether or not the plugin functionality is enabled.
|
138 |
*
|
139 |
* @access public
|
140 |
* @return boolean
|
141 |
*/
|
142 |
public function is_enabled() {
|
143 |
+
return 'yes' === $this->settings['enabled'];
|
144 |
}
|
145 |
|
146 |
/**
|
147 |
+
* Whether or not a main list has been selected.
|
148 |
*
|
149 |
* @access public
|
150 |
* @return boolean
|
159 |
}
|
160 |
|
161 |
/**
|
162 |
+
* When the subscription should be triggered.
|
163 |
+
*
|
164 |
* @return string
|
165 |
*/
|
166 |
public function occurs() {
|
167 |
+
return $this->settings['occurs'];
|
168 |
}
|
169 |
|
170 |
/**
|
171 |
+
* Returns the selected list.
|
172 |
*
|
173 |
* @access public
|
174 |
* @return string MailChimp list ID
|
175 |
*/
|
176 |
public function get_list() {
|
177 |
+
return $this->settings['list'];
|
178 |
}
|
179 |
|
180 |
/**
|
181 |
+
* Whether or not double opt-in is selected.
|
182 |
*
|
183 |
* @access public
|
184 |
* @return boolean
|
185 |
*/
|
186 |
public function double_opt_in() {
|
187 |
+
return 'yes' === $this->settings['double_opt_in'];
|
188 |
}
|
189 |
|
190 |
/**
|
191 |
+
* Whether or not to display opt-in checkbox to user.
|
192 |
*
|
193 |
* @access public
|
194 |
* @return boolean
|
195 |
*/
|
196 |
public function display_opt_in() {
|
197 |
+
return 'yes' === $this->settings['display_opt_in'];
|
198 |
}
|
199 |
|
200 |
/**
|
201 |
+
* Opt-in label.
|
202 |
*
|
203 |
* @access public
|
204 |
* @return string
|
205 |
*/
|
206 |
public function opt_in_label() {
|
207 |
+
return $this->settings['opt_in_label'];
|
208 |
}
|
209 |
|
210 |
/**
|
211 |
+
* Opt-in checkbox default status.
|
212 |
*
|
213 |
* @access public
|
214 |
* @return string
|
215 |
*/
|
216 |
public function opt_in_checkbox_default_status() {
|
217 |
+
return $this->settings['opt_in_checkbox_default_status'];
|
218 |
}
|
219 |
|
220 |
/**
|
221 |
+
* Opt-in checkbox display location.
|
222 |
*
|
223 |
* @access public
|
224 |
* @return string
|
225 |
*/
|
226 |
public function opt_in_checkbox_display_location() {
|
227 |
+
return $this->settings['opt_in_checkbox_display_location'];
|
228 |
}
|
229 |
|
230 |
/**
|
231 |
+
* Returns selected MailChimp interest groups.
|
232 |
*
|
233 |
* @access public
|
234 |
* @return array
|
235 |
*/
|
236 |
public function interest_groups() {
|
237 |
+
return $this->settings['interest_groups'];
|
238 |
}
|
239 |
|
240 |
/**
|
241 |
+
* Whether or not an api key has been set.
|
242 |
*
|
243 |
* @access public
|
244 |
* @return boolean
|
245 |
*/
|
246 |
public function has_api_key() {
|
247 |
$api_key = $this->api_key();
|
248 |
+
return ! empty( $api_key );
|
249 |
}
|
250 |
|
251 |
/**
|
252 |
+
* Whether or not the configuration is valid.
|
253 |
*
|
254 |
* @access public
|
255 |
* @return boolean
|
259 |
}
|
260 |
|
261 |
/**
|
262 |
+
* Whether or not debug is enabled.
|
263 |
*
|
264 |
* @access public
|
265 |
* @return boolean
|
266 |
*/
|
267 |
public function debug_enabled() {
|
268 |
+
return 'yes' === $this->settings['debug'];
|
269 |
}
|
270 |
|
271 |
/**
|
272 |
* Saves the settings back to the DB
|
273 |
+
*
|
274 |
* @return void
|
275 |
*/
|
276 |
public function save_settings() {
|
285 |
|
286 |
/**
|
287 |
* Gets the MailChimp Helper
|
288 |
+
*
|
289 |
+
* @param string $api_key MailChimp API Key.
|
290 |
+
* @param boolean $debug Debug mode enabled/disabled.
|
291 |
* @return SS_WC_MailChimp MailChimp Helper class
|
292 |
*/
|
293 |
public function mailchimp( $api_key = null, $debug = false ) {
|
297 |
if ( empty( $this->mailchimp ) || ! is_null( $api_key ) ) {
|
298 |
|
299 |
$api_key = $api_key ? $api_key : $settings['api_key'];
|
300 |
+
$debug = $debug ? $debug : $settings['debug'];
|
301 |
|
302 |
require_once( SS_WC_MAILCHIMP_DIR . 'includes/class-ss-wc-mailchimp.php' );
|
303 |
$this->mailchimp = new SS_WC_MailChimp( $api_key, $debug );
|
314 |
*/
|
315 |
private function define_constants() {
|
316 |
|
317 |
+
// Minimum supported version of WordPress.
|
318 |
$this->define( 'SS_WC_MAILCHIMP_MIN_WP_VERSION', '3.5.1' );
|
319 |
|
320 |
+
// Minimum supported version of WooCommerce.
|
321 |
$this->define( 'SS_WC_MAILCHIMP_MIN_WC_VERSION', '2.2.0' );
|
322 |
|
323 |
+
// Minimum supported version of PHP.
|
324 |
$this->define( 'SS_WC_MAILCHIMP_MIN_PHP_VERSION', '5.4.0' );
|
325 |
|
326 |
// Plugin version.
|
330 |
$this->define( 'SS_WC_MAILCHIMP_DIR', plugin_dir_path( SS_WC_MAILCHIMP_FILE ) );
|
331 |
|
332 |
// Plugin Folder URL.
|
333 |
+
$this->define( 'SS_WC_MAILCHIMP_URL', plugin_dir_url( SS_WC_MAILCHIMP_FILE ) );
|
334 |
|
335 |
$settings_url = admin_url( 'admin.php?page=wc-settings&tab=mailchimp' );
|
336 |
|
341 |
/**
|
342 |
* Define constant if not already set.
|
343 |
*
|
344 |
+
* @param string $name Constant name.
|
345 |
+
* @param string|bool $value Constant value.
|
346 |
+
* @return void
|
347 |
*/
|
348 |
private function define( $name, $value ) {
|
349 |
if ( ! defined( $name ) ) {
|
353 |
|
354 |
/**
|
355 |
* Include required core plugin files
|
356 |
+
*
|
357 |
+
* @return void
|
358 |
*/
|
359 |
public function includes() {
|
360 |
|
376 |
|
377 |
/**
|
378 |
* Add plugin hooks
|
379 |
+
*
|
380 |
+
* @return void
|
381 |
*/
|
382 |
private function add_hooks() {
|
383 |
|
385 |
register_activation_hook( SS_WC_MAILCHIMP_FILE, array( __CLASS__, 'activate' ) );
|
386 |
register_deactivation_hook( SS_WC_MAILCHIMP_FILE, array( __CLASS__, 'deactivate' ) );
|
387 |
|
388 |
+
// Add the "Settings" links on the Plugins administration screen.
|
389 |
if ( is_admin() ) {
|
390 |
|
391 |
add_filter( 'plugin_action_links_' . plugin_basename( SS_WC_MAILCHIMP_FILE ), array( $this, 'action_links' ) );
|
392 |
|
393 |
add_filter( 'woocommerce_get_settings_pages', array( $this, 'add_mailchimp_settings' ) );
|
394 |
|
395 |
+
add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_scripts' ) );
|
396 |
|
397 |
}
|
398 |
|
406 |
* Locales found in:
|
407 |
* - WP_LANG_DIR/plugins/woocommerce-mailchimp/woocommerce-mailchimp-{lang}_{country}.mo
|
408 |
* - WP_CONTENT_DIR/plugins/woocommerce-mailchimp/languages/woocommerce-mailchimp-{lang}_{country}.mo
|
409 |
+
*
|
410 |
+
* @return void
|
411 |
*/
|
412 |
public function load_plugin_textdomain() {
|
413 |
|
415 |
$woocommerce_mailchimp_lang_dir = dirname( plugin_basename( SS_WC_MAILCHIMP_FILE ) ) . '/languages/';
|
416 |
|
417 |
// Traditional WordPress plugin locale filter.
|
418 |
+
// get locale in {lang}_{country} format (e.g. en_US).
|
419 |
$locale = apply_filters( 'plugin_locale', get_locale(), 'woocommerce-mailchimp' );
|
420 |
|
421 |
$mofile = sprintf( '%1$s-%2$s.mo', 'woocommerce-mailchimp', $locale );
|
446 |
/**
|
447 |
* Add Settings link to plugins list
|
448 |
*
|
449 |
+
* @param array $links Plugin links.
|
450 |
+
* @return array Modified plugin links
|
451 |
*/
|
452 |
public function action_links( $links ) {
|
453 |
$plugin_links = array(
|
460 |
|
461 |
/**
|
462 |
* Add the MailChimp settings tab to WooCommerce
|
463 |
+
*
|
464 |
+
* @param array $settings MailChimp settings.
|
465 |
+
* @return array Settings.
|
466 |
*/
|
467 |
function add_mailchimp_settings( $settings ) {
|
468 |
|
477 |
} //end function add_mailchimp_settings
|
478 |
|
479 |
/**
|
480 |
+
* Load scripts required for admin
|
481 |
+
*
|
482 |
+
* @access public
|
483 |
+
* @return void
|
484 |
+
*/
|
485 |
+
public function enqueue_scripts() {
|
486 |
|
487 |
+
// Plugin scripts and styles.
|
488 |
wp_register_script( 'woocommerce-mailchimp-admin', SS_WC_MAILCHIMP_URL . 'assets/js/woocommerce-mailchimp-admin.js', array( 'jquery' ), self::version() );
|
489 |
wp_register_style( 'woocommerce-mailchimp', SS_WC_MAILCHIMP_URL . 'assets/css/style.css', array(), self::version() );
|
490 |
|
491 |
+
// Localize javascript messages.
|
492 |
$translation_array = array(
|
493 |
'connecting_to_mailchimp' => __( 'Connecting to MailChimp', 'woocommerce-mailchimp' ),
|
494 |
'error_loading_account' => __( 'Error. Please check your api key.', 'woocommerce-mailchimp' ),
|
498 |
);
|
499 |
wp_localize_script( 'woocommerce-mailchimp-admin', 'SS_WC_MailChimp_Messages', $translation_array );
|
500 |
|
501 |
+
// Scripts.
|
502 |
wp_enqueue_script( 'woocommerce-mailchimp-admin' );
|
503 |
|
504 |
+
// Styles.
|
505 |
wp_enqueue_style( 'woocommerce-mailchimp' );
|
506 |
|
507 |
} //end function enqueue_scripts
|
508 |
|
509 |
/**
|
510 |
* Handles running plugin upgrades if necessary
|
511 |
+
*
|
512 |
* @return void
|
513 |
*/
|
514 |
public static function update() {
|
524 |
*
|
525 |
* @access public
|
526 |
* @static
|
527 |
+
* @param mixed $network_wide Network activate.
|
528 |
* @return void
|
529 |
*/
|
530 |
public static function activate( $network_wide = false ) {
|
538 |
*
|
539 |
* @access public
|
540 |
* @static
|
541 |
+
* @param mixed $network_wide Network activate.
|
542 |
* @return void
|
543 |
*/
|
544 |
public static function deactivate( $network_wide ) {
|
545 |
|
546 |
+
// Placeholder.
|
547 |
|
548 |
} //end function deactivate
|
549 |
|
550 |
/**
|
551 |
* Check whether WooCommerce MailChimp is network activated
|
552 |
+
*
|
553 |
* @since 1.0
|
554 |
* @return bool
|
555 |
*/
|
559 |
|
560 |
/**
|
561 |
* Returns namespace prefixed value
|
562 |
+
*
|
563 |
+
* @param string $suffix The suffix to prefix.
|
564 |
* @return string
|
565 |
*/
|
566 |
private function namespace_prefixed( $suffix ) {
|
569 |
|
570 |
} // end function namespace_prefixed
|
571 |
|
572 |
+
} //end final class SS_WC_MailChimp_Plugin
|
includes/class-ss-wc-settings-mailchimp.php
CHANGED
@@ -45,7 +45,7 @@ if ( ! class_exists( 'SS_WC_Settings_MailChimp' ) ) {
|
|
45 |
$this->namespace = 'ss_wc_' . $this->id;
|
46 |
$this->label = __( 'MailChimp', 'woocommerce-mailchimp' );
|
47 |
$this->init();
|
48 |
-
|
49 |
$this->register_hooks();
|
50 |
|
51 |
} //end function __construct
|
@@ -205,7 +205,7 @@ if ( ! class_exists( 'SS_WC_Settings_MailChimp' ) ) {
|
|
205 |
public function init() {
|
206 |
|
207 |
$this->api_key = $this->get_option( 'api_key' );
|
208 |
-
|
209 |
$this->enabled = $this->get_option( 'enabled' );
|
210 |
|
211 |
}
|
@@ -268,7 +268,7 @@ if ( ! class_exists( 'SS_WC_Settings_MailChimp' ) ) {
|
|
268 |
|
269 |
$this->wc_enqueue_js("
|
270 |
(function($){
|
271 |
-
|
272 |
$(document).ready(function() {
|
273 |
SS_WC_MailChimp.init();
|
274 |
});
|
@@ -297,7 +297,7 @@ if ( ! class_exists( 'SS_WC_Settings_MailChimp' ) ) {
|
|
297 |
$sswcmc = SSWCMC();
|
298 |
// Trigger reload of plugin settings
|
299 |
$settings = $sswcmc->settings( true );
|
300 |
-
|
301 |
}
|
302 |
|
303 |
/**
|
@@ -369,7 +369,7 @@ if ( ! class_exists( 'SS_WC_Settings_MailChimp' ) ) {
|
|
369 |
'default' => '',
|
370 |
'options' => $interest_groups,
|
371 |
'class' => 'wc-enhanced-select',
|
372 |
-
'custom_attributes' => array(
|
373 |
'placeholder' => __( 'Select interest groups...', 'woocommerce-mailchimp' ),
|
374 |
),
|
375 |
'css' => 'min-width: 350px;',
|
@@ -392,7 +392,7 @@ if ( ! class_exists( 'SS_WC_Settings_MailChimp' ) ) {
|
|
392 |
),
|
393 |
'desc_tip' => true,
|
394 |
);
|
395 |
-
|
396 |
$settings[] = array(
|
397 |
'id' => $this->namespace_prefixed( 'double_opt_in' ),
|
398 |
'title' => __( 'Double Opt-In', 'woocommerce-mailchimp' ),
|
@@ -596,10 +596,10 @@ if ( ! class_exists( 'SS_WC_Settings_MailChimp' ) ) {
|
|
596 |
'' => __( 'Select a list...', 'woocommerce-mailchimp' ),
|
597 |
);
|
598 |
}
|
599 |
-
$mailchimp_lists =
|
600 |
|
601 |
return $mailchimp_lists;
|
602 |
-
|
603 |
}
|
604 |
|
605 |
/**
|
@@ -626,7 +626,7 @@ if ( ! class_exists( 'SS_WC_Settings_MailChimp' ) ) {
|
|
626 |
}
|
627 |
|
628 |
return $interest_groups;
|
629 |
-
|
630 |
}
|
631 |
|
632 |
/**
|
@@ -648,7 +648,7 @@ if ( ! class_exists( 'SS_WC_Settings_MailChimp' ) ) {
|
|
648 |
sprintf( __( 'Unable to load lists from MailChimp: (%s) %s. ', 'woocommerce-mailchimp' ), $this->mailchimp()->get_error_code(), $this->mailchimp()->get_error_message() ) .
|
649 |
sprintf( __( 'Please check your Settings %ssettings%s.', 'woocommerce-mailchimp' ), '<a href="' . WOOCOMMERCE_MAILCHIMP_SETTINGS_URL .'">', '</a>' )
|
650 |
);
|
651 |
-
} //end function mailchimp_api_error_msg
|
652 |
|
653 |
/**
|
654 |
* Helper log function for debugging
|
@@ -702,4 +702,4 @@ if ( ! class_exists( 'SS_WC_Settings_MailChimp' ) ) {
|
|
702 |
|
703 |
return SS_WC_Settings_MailChimp::get_instance();
|
704 |
|
705 |
-
} //end if ( ! class_exists( 'SS_WC_Settings_MailChimp' ) )
|
45 |
$this->namespace = 'ss_wc_' . $this->id;
|
46 |
$this->label = __( 'MailChimp', 'woocommerce-mailchimp' );
|
47 |
$this->init();
|
48 |
+
|
49 |
$this->register_hooks();
|
50 |
|
51 |
} //end function __construct
|
205 |
public function init() {
|
206 |
|
207 |
$this->api_key = $this->get_option( 'api_key' );
|
208 |
+
|
209 |
$this->enabled = $this->get_option( 'enabled' );
|
210 |
|
211 |
}
|
268 |
|
269 |
$this->wc_enqueue_js("
|
270 |
(function($){
|
271 |
+
|
272 |
$(document).ready(function() {
|
273 |
SS_WC_MailChimp.init();
|
274 |
});
|
297 |
$sswcmc = SSWCMC();
|
298 |
// Trigger reload of plugin settings
|
299 |
$settings = $sswcmc->settings( true );
|
300 |
+
|
301 |
}
|
302 |
|
303 |
/**
|
369 |
'default' => '',
|
370 |
'options' => $interest_groups,
|
371 |
'class' => 'wc-enhanced-select',
|
372 |
+
'custom_attributes' => array(
|
373 |
'placeholder' => __( 'Select interest groups...', 'woocommerce-mailchimp' ),
|
374 |
),
|
375 |
'css' => 'min-width: 350px;',
|
392 |
),
|
393 |
'desc_tip' => true,
|
394 |
);
|
395 |
+
|
396 |
$settings[] = array(
|
397 |
'id' => $this->namespace_prefixed( 'double_opt_in' ),
|
398 |
'title' => __( 'Double Opt-In', 'woocommerce-mailchimp' ),
|
596 |
'' => __( 'Select a list...', 'woocommerce-mailchimp' ),
|
597 |
);
|
598 |
}
|
599 |
+
$mailchimp_lists = $default + $mailchimp_lists;
|
600 |
|
601 |
return $mailchimp_lists;
|
602 |
+
|
603 |
}
|
604 |
|
605 |
/**
|
626 |
}
|
627 |
|
628 |
return $interest_groups;
|
629 |
+
|
630 |
}
|
631 |
|
632 |
/**
|
648 |
sprintf( __( 'Unable to load lists from MailChimp: (%s) %s. ', 'woocommerce-mailchimp' ), $this->mailchimp()->get_error_code(), $this->mailchimp()->get_error_message() ) .
|
649 |
sprintf( __( 'Please check your Settings %ssettings%s.', 'woocommerce-mailchimp' ), '<a href="' . WOOCOMMERCE_MAILCHIMP_SETTINGS_URL .'">', '</a>' )
|
650 |
);
|
651 |
+
} //end function mailchimp_api_error_msg
|
652 |
|
653 |
/**
|
654 |
* Helper log function for debugging
|
702 |
|
703 |
return SS_WC_Settings_MailChimp::get_instance();
|
704 |
|
705 |
+
} //end if ( ! class_exists( 'SS_WC_Settings_MailChimp' ) )
|
readme.txt
CHANGED
@@ -3,8 +3,8 @@ Contributors: saintsystems, anderly
|
|
3 |
Donate link: http://ssms.us/hVdk
|
4 |
Tags: woocommerce, mailchimp
|
5 |
Requires at least: 3.5.1
|
6 |
-
Tested up to: 4.8
|
7 |
-
Stable tag: 2.1.
|
8 |
License: GPLv3
|
9 |
|
10 |
Simple and flexible MailChimp integration for WooCommerce.
|
@@ -113,6 +113,9 @@ Also, if you enjoy using the software [we'd love it if you could give us a revie
|
|
113 |
|
114 |
== Changelog ==
|
115 |
|
|
|
|
|
|
|
116 |
#### 2.1.1 - July 24, 2017
|
117 |
- Fix settings default for older PHP versions.
|
118 |
|
3 |
Donate link: http://ssms.us/hVdk
|
4 |
Tags: woocommerce, mailchimp
|
5 |
Requires at least: 3.5.1
|
6 |
+
Tested up to: 4.8.1
|
7 |
+
Stable tag: 2.1.2
|
8 |
License: GPLv3
|
9 |
|
10 |
Simple and flexible MailChimp integration for WooCommerce.
|
113 |
|
114 |
== Changelog ==
|
115 |
|
116 |
+
#### 2.1.2 - August 25, 2017
|
117 |
+
- Fix retrieval of mailchimp lists with numeric ids.
|
118 |
+
|
119 |
#### 2.1.1 - July 24, 2017
|
120 |
- Fix settings default for older PHP versions.
|
121 |
|
woocommerce-mailchimp.php
CHANGED
@@ -5,7 +5,7 @@
|
|
5 |
* Description: WooCommerce MailChimp provides simple MailChimp integration for WooCommerce.
|
6 |
* Author: Saint Systems
|
7 |
* Author URI: https://www.saintsystems.com
|
8 |
-
* Version: 2.1.
|
9 |
* Text Domain: woocommerce-mailchimp
|
10 |
* Domain Path: languages
|
11 |
*
|
5 |
* Description: WooCommerce MailChimp provides simple MailChimp integration for WooCommerce.
|
6 |
* Author: Saint Systems
|
7 |
* Author URI: https://www.saintsystems.com
|
8 |
+
* Version: 2.1.2
|
9 |
* Text Domain: woocommerce-mailchimp
|
10 |
* Domain Path: languages
|
11 |
*
|